<?php
/*
+-----------------------------------------------------------------------------+
| $Id: bwjs.class.php 2009-08-18 08:10:45Z Bleakwind $
| Run Javascript use PHP
| Copyright (c) 2003-2010 Bleakwind (www.weaverdream.com)
| http://www.weaverdream.com/
| Release under the GNU Lesser General Public License Version 3 (LGPLv3):
|   http://www.gnu.org/licenses/lgpl.html
+-----------------------------------------------------------------------------+
*/

class bwjs
{

    function bwjs()
    {
        return;
    }

    function back($step = -1)
    {
        $msg = "history.go(".$step.");";
        bwjs::write($msg);
        exit;
    }

    function alert($msg)
    {
        $msg = "alert(\"".$msg."\");";
        bwjs::write($msg);
    }

    function write($msg)
    {
        echo "<script language=\"javascript\">\n";
        echo $msg."\n";
        echo "</script>\n";
    }

    function reload()
    {
        $msg = "location.reload();";
        bwjs::write($msg);
        exit;
    }

    function reload_opener()
    {
        $msg = "if (opener){opener.location.reload();}";
        bwjs::write($msg);
    }

    function goto($url)
    {
        $msg = "location.href = '$url';";
        bwjs::write($msg);
        exit;
    }

     function close()
     {
         $msg = "window.close()";
         bwjs::write($msg);
         exit;

     }

    function submit($frm)
    {
        $msg = $frm.".submit();";
        bwjs::write($msg);
    }
}
?>