/***************************************************************\
 * 软件所有权归 奥兴网络[A.S.™]，如有需要欢迎与联系我们！
 * 网址：http://www.AsnSoft.net
 * 邮箱：admin@asnsoft.net		
 * AsnSoft Copyright © 2008 - 2010
 *-------------------------------------------------------------*
 * 名称： AS.js core	奥兴JS插件核心驱动
 * 版本： 1.2.4
\***************************************************************/
var AS = AS || $ || window.jQuery || jQuery; 

if(!AS)alert("请先加载jQuery");


/************************	public function ************************/
function unset(){for(var i = 0;i< arguments.length ; i++){arguments[i] = null;}if(AS.browser.msie){CollectGarbage();}}function clear(){CollectGarbage();setTimeout(CollectGarbage, 10);}if(AS.browser.msie){clear();}
AS.getPath = function(){
	var _as = '';
	if(!AS.browser.msie){
		_as = "/";
	}else{
		var _jss = AS("script");
		for(var c = 0 ; c < _jss.length ; c++){
			var $src = AS(_jss.eq(c)).attr("src");
			if($src && $src.indexOf("AS.js") >=0 ){
					_as = $src;	
				break;
			}
		}
		_as = _as.replace("AS.js","");
		unset(_jss);
	}
	return _as;
}


/**
 * 字符比对函数
**/
AS.match = function(_str,_match){
	var _reg = '';
	switch(_match){
		case "number":
			_reg = /\d+/ig;
		break;
		case "date":
			_reg = /^(\d{4})(\/)(\d{2})\2(\d{2})$/;
		break;
	}
	return _reg.test(_str);
}
var root = (AS.getPath()).replace("plugs/","");

function empty($var){
	if($var == null)return true;
	switch(typeof($var)){
		case "undefined":
			return true;
		break;
		case "string":
			if($var == "0" || $var == "" || $var.length <= 0){
				return  true;
			}else{
				return false;
			}
		break
		case "number":
			if($var == 0){
				return true;
			}else{
				return false;
			}
		break;
		case "array":
			if($var.length == 0){
				return true;
			}else{
				return false;
			}
		break;
	}
}

AS.browser	=	function(){
   var ua = navigator.userAgent.toLowerCase();
   if(ua.indexOf("msie") >= 0){
   		return "IE"+ua.match(/msie ([\d.]+)/)[1];
   }else if(ua.indexOf("firefox") >= 0){
   		 return "FF" + ua.match(/firefox\/([\d.]+)/)[1]	;
   }else if(ua.indexOf("chrome") >= 0){
   		 return "CH" + ua.match(/chrome\/([\d.]+)/)[1];
   }else if(ua.indexOf("opera") >= 0){
   		 return "OP" + ua.match(/opera.([\d.]+)/)[1];
   }
}

AS.echo	=	function($str){
	if(AS("#debug").is("pre")){
		var	$txt	=	AS("#debug").html();
		AS("#debug").html($str + '<br/>' + $txt);
	}else{
		AS(document.body).append('<pre id="debug" style="width:400px;border:3px solid #AAA;background:#FFF;position:fixed;_position:absolute;z-index:2010;right:0px;top:33px;padding:5px;height:150px;overflow:scroll;">'+$str+'</pre>');
	}
}
var $_GET	=	null;
AS.GET	=	function($key){
	if($_GET !== null && typeof($_GET[$key]) !== "undefined"){
		return $_GET[$key];
	}else if($_GET == null){
		$_GET	=	new Array();
		var $str	=	location.search.substr(1);
		var $tmp	=	$str.split("&");
		for(var $i in $tmp){
			var $s	=	$tmp[$i].split("=");
			$_GET[$s[0]] = $s[1];
			$s	= null;
		}
		if(typeof($_GET[$key]) === "undefined"){
			return null;
		}else{
			return $_GET[$key];
		}
	}else{
		return null;
	}
}

AS.postJSON	=	function($url,$data,$fn,$sync){
	AS.ajax({
		async	:	$sync	,
		url		:	$url	,
		cache	:	false	,
		data	:	$data	,
		dataType:	'json'	,
		type	:	'POST'	,
		success	:	$fn
	});
}

var root = (AS.getPath()).replace("/Public/","");

function urlencode($str){
	return encodeURI($str);
}
