<?php

if(! defined('OT_ROOT')) {
	exit('Access Denied');
}

class JS{
	public static function Diy($str){
		echo('<script language="javascript" type="text/javascript">'. $str .'</script>');
	}

	public static function DiyEnd($str){
		die('<script language="javascript" type="text/javascript">'. $str .'</script>');
	}


	public static function Href($str){
		echo('
		<script language="javascript" type="text/javascript">
		document.location.href="'. $str .'";
		</script>
		');
	}

	public static function HrefEnd($str){
		die('
		<script language="javascript" type="text/javascript">
		document.location.href="'. $str .'";
		</script>
		');
	}

	public static function HrefTimeout($str,$sec){
		echo('
		<script language="javascript" type="text/javascript">
		setTimeout("document.location.href=\''. $str .'\';",'. ($sec*1000) .');
		</script>
		');
	}

	public static function HrefTimeoutEnd($str,$sec){
		die('
		<script language="javascript" type="text/javascript">
		setTimeout("document.location.href=\''. $str .'\';",'. ($sec*1000) .');
		</script>
		');
	}


	public static function Write($str, $addiStr=''){
		echo('
		<script language="javascript" type="text/javascript">
		document.write("'. $str .'");'. $addiStr .'
		</script>
		');
	}

	public static function WriteEnd($str, $addiStr=''){
		die('
		<script language="javascript" type="text/javascript">
		document.write("'. $str .'");'. $addiStr .'
		</script>
		');
	}


	public static function Alert($str, $addiStr=''){
		echo('
		<script language="javascript" type="text/javascript">
		alert("'. $str .'");'. $addiStr .'
		</script>
		');
	}

	public static function AlertEnd($str, $addiStr=''){
		die('
		<script language="javascript" type="text/javascript">
		alert("'. self::AlertFilter($str) .'");'. $addiStr .'
		</script>
		');
	}

	public static function AlertClose($str){
		echo('
		<script language="javascript" type="text/javascript">
		alert("'. self::AlertFilter($str) .'");window.close();
		</script>
		');
	}

	public static function AlertCloseEnd($str){
		die('
		<script language="javascript" type="text/javascript">
		alert("'. self::AlertFilter($str) .'");window.close();
		</script>
		');
	}


	public static function AlertBack($str){
		echo('
		<script language="javascript" type="text/javascript">
		alert("'. self::AlertFilter($str) .'");history.back();
		</script>
		');
	}

	public static function AlertBackEnd($str){
		die('
		<script language="javascript" type="text/javascript">
		alert("'. self::AlertFilter($str) .'");history.back();
		</script>
		');
	}


	public static function AlertHref($str,$url){
		echo('
		<script language="javascript" type="text/javascript">
		alert("'. self::AlertFilter($str) .'");document.location.href="'. $url .'";
		</script>
		');
	}

	public static function AlertHrefEnd($str,$url){
		die('
		<script language="javascript" type="text/javascript">
		alert("'. self::AlertFilter($str) .'");document.location.href="'. $url .'";
		</script>
		');
	}


	public static function ModeDeal($mode,$jud,$value='',$href=''){
		if ($mode=='jud'){
			return $jud;

		}elseif ($mode=='show'){
			die($value);

		}elseif ($mode=='get'){
			return $value;

		}elseif ($mode=='alert'){
			self::AlertEnd($value);

		}elseif ($mode=='alertBack'){
			self::AlertBackEnd($value);

		}elseif ($mode=='alertClose'){
			self::AlertCloseEnd($value);

		}elseif ($mode=='alertHref'){
			self::AlertHrefEnd($value,$href);

		}elseif ($mode=='alertStr'){
			die('alert("'. $value .'");');

		}elseif ($mode=='alertBackStr'){
			die('alert("'. $value .'");history.back();');

		}elseif ($mode=='alertHrefStr'){
			die('alert("'. $value .'");document.location.href="'. $href .'";');

		}
	}

	public static function AlertFilter($str){
		return str_replace(array("\n",'"'), array('\n','“'), $str);
	}

}

?>