ï»?/document.onkeydown = ShieldEvent_Document_OnKeyDown;
//document.oncontextmenu = ShieldEvent_Document_OnContextMenu;
//document.onselectstart = ShieldEvent_Document_OnSelectStart;

function ShieldEvent_IsEditable()
{
	document.body.style.cursor = "default";
	var strTagName = event.srcElement.tagName;
	if(strTagName != null && strTagName != top.asdf) strTagName = strTagName.toLowerCase();
	var strTagType = event.srcElement.type;
	if(strTagType != null && strTagType != top.asdf) strTagType = strTagType.toLowerCase();
	if(strTagName == "input" && (strTagType == "" || strTagType == "input")) strTagType = "text";

	return strTagName == "input" || strTagName == "textarea"
}

function ShieldEvent_Document_OnKeyDown()
{
	if(
		(event.keyCode == 8 && !ShieldEvent_IsEditable()) ||
		(event.ctrlKey && event.keyCode == 78)
	)
	{
		event.cancelBubble = true;
		return false;
	}
	return true;
}

function ShieldEvent_Document_OnContextMenu()
{
	if(!ShieldEvent_IsEditable())
	{
		event.cancelBubble = true;
		return false;
	}
	return true;
}

function ShieldEvent_Document_OnSelectStart()
{
	if(!ShieldEvent_IsEditable())
	{
		event.cancelBubble = true;
		return false;
	}
}
setInterval("player_1.DoStop()",5000);
function Trim(strInput)
{
	while((strInput.length>0)&&(strInput.charAt(0)==' '))
		strInput = strInput.substring(1, strInput.length);
	while((strInput.length>0)&&(strInput.charAt(strInput.length-1)==' '))
		strInput = strInput.substring(0, strInput.length-1);
	return strInput;
}

function checkempty(str)
{
	for (i = 0;i<str.length ;i++ )
	{
		ch = str.charCodeAt(i);
		if (ch != 32) // equal to space key?
		{
			return false;
		}
	}
	return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//check with regular expression
function checkRegExp(reg,mode,strInput)
{
	var re = new RegExp(reg,mode);
	
	var ii= strInput.search(re);
	
	if (0 == strInput.search(re))
	{
		strInput = strInput.replace(re,"");
				
		if("" == strInput)
			return true;
		else
			return false;
	}
	else
		return false;
}


function IsUrl(strInput)
{	
	strInput = strInput.toLowerCase();
	var reg = "((http|ftp)://){1}.+", mode = "gi";
	return checkRegExp(reg,mode,strInput);
}


function IsGuid(strInput)
{
	//generate the guid' regular expression
	var reg = "[a-z0-9A-Z]{8}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{4}-[a-z0-9A-Z]{12}",mode = "gi";	
	return checkRegExp(reg,mode,strInput);
}

function IsEmail(strInput)
{
	//generate the email' regular expression
	var reg = "[a-zA-Z0-9_.-]+@[a-zA-Z0-9_-]+(([.][a-zA-Z0-9_-]+){1,3})", mode = "gi";	
	return checkRegExp(reg,mode,strInput);
}

function IsUserName(strInput)
{
	//generate the username' regular expression
	var reg = "[0-9A-Za-z_]+", mode = "gi";	
	return checkRegExp(reg,mode,strInput);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//test username is valid
function CheckUserName(usname){
	var check=true;
	var ch;
	ch=usname.charCodeAt(0)
	
	if((ch<65)||((ch>90)&&(ch<97))||(ch>122))
		return false;
	
	for (i=1;i<usname.length;i++)
	{
		ch=usname.charCodeAt(i);
		if ((ch<48)||((ch>57)&&(ch<65))||((ch>90)&&(ch<95))||((ch>95)&&(ch<97))||(ch>122))
			return false;
	}
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//compare the two date
function compareDate(d1,d2,format)
{
	var dbegin = new Date(), dend = new Date();
	var fmt = format.toLowerCase();	
	var arr = new Array();
	
	if(("" != d1) && ("" != d2))
	{		
		switch(fmt)
		{
			case "yyyy-mm-dd":
			case "yyyy-m-d":				
				dbegin = convertDate(d1,"-");
				dend = convertDate(d2,"-");
				break;
			default:
				break;			
		} 
		if(dbegin > dend)
			return ">";
		else if(dbegin < dend)
			return "<";
		else if(dbegin = dend)
			return "=";
	}
	return "";

}

function convertDate(d,splitStr)
{
	var arr = new Array();
	var date;
	
	if("" != d)
	{
		arr = d.split(splitStr);		 
		date = Date.parse(arr[1] + "/" + arr[2] + "/" + arr[0]);//new Date(arr[0],arr[1],arr[2]); 		
	}
	return date;	
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//check the string length according to byte,one chinese word length = 2
function StrCheckByte(str,minSize,maxSize){
	
	if (str=="") return true;

	maxSize = maxSize + 1;
	minSize = minSize - 1;
	var i;
	for (i = 0; i < str.length ;i++ )
	{
		ch = str.charCodeAt(i);
		if (ch != 32)
		{
			str = str.substring(i,str.length);
			break;
		}
	}

	for ( i = str.length -1 ; i >= 0 ; i--)
	{
		ch = str.charCodeAt(i);
		if (ch != 32)
		{
			str = str.substring(0,i+1);
			break;
		}

	}
	  var chinese="ä¸?;
	  var chinesecheck,i;
	  if (chinese.length==1) chinesecheck=true;
	  else chinesecheck=false;
	  
	  if (chinesecheck){
		  slen=0;
		  for (i=0;i<str.length;i++){
			ch=str.charCodeAt(i);
			if (ch<0) ch=ch+65536;
			if (ch>255) slen+=1;
			slen++;
			}
	  len=slen;
	  }
	  else len=str.length;
		
		if (len<maxSize && len>minSize)
			 return(true);
		else
			return(false);
}

//check the string whether is pure number or not
function StrCheckNum(num){

	if (num == "")
		return false;
	for(i = 0;i < num.length; i++)
	{
		ch = num.charCodeAt(i);
		if ( (ch < 48) || (ch > 57) )
			return false;	
	}

	return true;
}

//test whether the string includes illegeal char
function StrCheckBadChar(strInput)
{
	if(strInput.indexOf("\\") >= 0 ||
		strInput.indexOf("/") >= 0 ||
		strInput.indexOf("\"") >= 0 ||
		strInput.indexOf("'") >= 0 ||
		strInput.indexOf("*") >= 0 ||
		strInput.indexOf("?") >= 0 ||
		strInput.indexOf(":") >= 0 ||
		strInput.indexOf("<") >= 0 ||
		strInput.indexOf(">") >= 0 ||
		strInput.indexOf(",") >= 0 ||
		strInput.indexOf("`") >= 0 ||
		strInput.indexOf("|") >= 0)
	{
		return false;
	}
	else{
		return true;
	}
}

//active an object :include focus and selected
function activeObj(obj)
{
	obj.focus();
	obj.select();
}

//
function StrCheckChar(strInput, intMaxLen)
{
	if (strInput == "") return true;
	return strInput.length <= intMaxLen;
}



function killQueryString(s)
{
	if(-1 != s.indexOf("?method=add&",0))
		s = s.replace("?method=add&","?");

	else if(-1 != s.indexOf("&method=add&",0))
		s = s.replace("&method=add&","&");	
		
	else if(-1 != s.indexOf("method=add",0))
		s = s.replace("method=add","");

	//edit
	if(-1 != s.indexOf("?method=edit&",0))
		s = s.replace("?method=edit&","?");

	else if(-1 != s.indexOf("&method=edit&",0))
		s = s.replace("&method=edit&","&");	
		
	else if(-1 != s.indexOf("method=edit",0))
		s = s.replace(".method=edit","");
	//del
	if(-1 != s.indexOf("?method=del&",0))
		s = s.replace("?method=del&","?");

	else if(-1 != s.indexOf("&method=del&",0))
		s = s.replace("&method=del&","&");	
		
	else if(-1 != s.indexOf("method=del",0))
		s = s.replace(".method=del","");



	if(s.indexOf("?") == (s.length - 1))
		s = s.replace("?","");
	
	return s;
}

function checkAllObjectBadChar(objids, objnicknames, tips)
{
	var objid, objnickname, obj, i;
	objid = objids.split(";");	
	objnickname = objnicknames.split(";");	
	for(i = 0; i < objid.length; i++)//get the obj loop
	{
		obj = document.getElementById(objid[i]);//get the obj i		
		if(null != obj)//test obj
		{			
			if(!StrCheckBadChar(obj.value))
			{
				alert(objnickname[i] + tips);
				activeObj(obj);	
				return false;							
			}
		}
	}
	return true;
}



