
/*
-- ------ Common ------ --
unionNets.com
2010
*/
function netsCommon(){}
//-- ------ #Parameters ------ --
netsCommon.prototype.sName="tmpCommon";

netsCommon.prototype.sCCodeURL="../../../Component/Nets/netsJscript/netsCheckCode0.php?TID=";

netsCommon.prototype.sysRoot="";
netsCommon.prototype.sysHome="";
netsCommon.prototype.sysPage="";

netsCommon.prototype.sysFavoriteURL="";
netsCommon.prototype.sysComplaintsURL="";

netsCommon.prototype.sysForm="phpForm1";
netsCommon.prototype.sysMainID="mainID";
netsCommon.prototype.sysActionTypeF="ActionTypeF";
netsCommon.prototype.sysActionWithOut="ActionWithOut";
netsCommon.prototype.sysMessage="topMessage";

netsCommon.prototype.sysNormal_Multiple="Normal_Multiple";
netsCommon.prototype.sysNormal_MultipleByTxt="Normal_MultipleByTxt";
netsCommon.prototype.sysNormal_MultipleByTxt_Columns="Normal_MultipleByTxt_Columns";

netsCommon.prototype.sysHidden="DHidden";
netsCommon.prototype.sysPx="px";
netsCommon.prototype.sysSPLIT1=",";
netsCommon.prototype.sysSPLIT2=";";
netsCommon.prototype.sysSPLIT3="|";
netsCommon.prototype.sysSPLIT4="\r\n";
netsCommon.prototype.sysSPLIT5="|||";
netsCommon.prototype.sysSPLIT6="<!---RTB.SPLIT1--->";
netsCommon.prototype.sysSPLIT7="<!---RTB.SPLIT2--->\r\n";
netsCommon.prototype.sysSPLIT8="<br />";
netsCommon.prototype.sysSPLIT14="/*-- ------ ###NETS### ------ #SPLIT1 ------ ###NETS### ------ --*/";
netsCommon.prototype.sysSPLIT15="-A-";

netsCommon.prototype.sysError_Ajax="<div style='text-align:center; margin:24px auto 24px auto;'>没有可以载入的数据，请与<a href='http://www.unionNets.com' target='_blank' class='FRed1 Link3'>平台开发商</a>联系；<br />或通过查看<a href='{Nets.Response}' target='_blank' class='FRed1 Link3'>响应内容</a>得到更多信息。</div>";
netsCommon.prototype.sysLoading_Ajax="<div>数据正在载入中...</div>";
netsCommon.prototype.sysChooseHiddenButton="<div style='text-align:center;'><a href='#' class='Link1 FGreen1' onclick='hiddenChoose();'>关闭弹窗</a>";

//-- ------ #Methods ------ --
//-- #Common --
netsCommon.prototype.Favorite=function(pURL,pName){
	if(pURL==""){
		pURL=location.href;
		pName=document.title;
	}
	try{
		window.external.addFavorite(pURL,pName);
	}catch(Except){
		window.sidebar.addPanel(pName,pURL,"");
	}
	return 0;
}
netsCommon.prototype.SetHome=function(pURL,pObject){
	if(pURL==""){
		pURL=location.href;
	}
	pObject.style.behavior="url(#default#homepage)";
	pObject.setHomePage(pURL);
}
netsCommon.prototype.OnClipboard=function(pSTR){
	window.clipboardData.setData("Text",pSTR);
	alert("已复制到剪切板");
}
netsCommon.prototype.OnPrint=function(){
	window.print();
}
netsCommon.prototype.Favorite_S=function(pREQUEST,pName,pURL){
	//-- #Parameter --
	//#Require
	var tmpREQUEST=this.sysFavoriteURL;
	if(pREQUEST!=""){
		tmpREQUEST=pREQUEST;
	}
	//#Name
	var tmpName=document.title;
	if(pName!=""){
		tmpName=pName;
	}
	tmpName=this.encodeURL(tmpName,1);
	//#URL
	var tmpFavoriteURL=document.URL;
	if(pURL!=""){
		tmpFavoriteURL=pURL;
	}
	tmpFavoriteURL=this.encodeURL(tmpFavoriteURL,1);
	//-- #Make --
	var tmpURL=tmpREQUEST+"?ActionType=AddFavorite&AddFavorite_NAME="+tmpName+"&AddFavorite_URL="+tmpFavoriteURL;
	window.open(tmpURL,'_blank');
}
netsCommon.prototype.Complaints_S=function(pREQUEST,pName,pType){
	//-- #Parameter --
	//#Require
	var tmpREQUEST=this.sysComplaintsURL;
	if(pREQUEST!=""){
		tmpREQUEST=pREQUEST;
	}
	//#Name
	var tmpName=document.title;
	if(pName!=""){
		tmpName=pName;
	}
	tmpName=this.encodeURL(tmpName,1);
	//-- #Make --
	var tmpURL=tmpREQUEST+"?DType="+pType+this.sysSPLIT1+tmpName;
	window.open(tmpURL,'_blank');
}
netsCommon.prototype.goBack=function(pPageNum){
	history.go(pPageNum);
}
netsCommon.prototype.goRefresh=function(){
	location.reload();
}
//-- #Get element X and Y --
netsCommon.prototype.getElementX=function(pElement,pTag){
	var tmpINT=0;
	var tmpElement=pElement;
	
	while(tmpElement.tagName!=pTag){
		tmpINT+=tmpElement.offsetLeft;
		tmpElement=tmpElement.parentNode;
	}
	
	return tmpINT;
}
netsCommon.prototype.getElementY=function(pElement,pTag){
	var tmpINT=0;
	var tmpElement=pElement;
	tmpINT=tmpElement.offsetHeight;
	
	while(tmpElement.tagName!=pTag){
		tmpINT+=tmpElement.offsetTop;
		tmpElement=tmpElement.parentNode;
	}
	
	return tmpINT;
}
//-- #URL --
netsCommon.prototype.encodeURL=function(pSTR,pType){
	if(pType==1){
		pSTR+="";
		pSTR=pSTR.replace(/\,/g,"%NETSSPLIT1");
	}
	pSTR=encodeURI(pSTR);
	return pSTR;
}
netsCommon.prototype.decodeURL=function(pSTR,pType){
	pSTR=decodeURI(pSTR);
	if(pType==1){
		pSTR+="";
		pSTR=pSTR.replace(/\%NETSSPLIT1/g,",");
	}
	return pSTR;
}
//-- #XML --
netsCommon.prototype.analyzeXML=function(pCONTENT){
	var tmpXML=new Object();
	try{
		var tmpXML=new ActiveXObject("Microsoft.XMLDOM");
		tmpXML.async="false";
		tmpXML.loadXML(pCONTENT);
	}catch(Except){
		try{
			var tmpParser=new DOMParser();
			var tmpXML=tmpParser.parseFromString(pCONTENT,"text/xml");
		}catch(Except){}
	}
	
	return tmpXML;
}
//-- #Control action --
netsCommon.prototype.setInitialValue=function(pType,pValue,pElement){
	var tmpElement=pElement;
	if(pType==0){
		//Focus
		if(tmpElement.value==pValue){
			tmpElement.value="";
		}
		tmpElement.style.color="#000000";
	}else{
		//Blue
		if(tmpElement.value=="" || tmpElement.value==pValue){
			tmpElement.style.color="#CCCCCC";
			tmpElement.value=pValue;
		}
	}
}
//-- #Choose all --
netsCommon.prototype.chooseAllBox=function(){
	var tmpElement1=document.getElementById(this.sysForm);
	var IsCheck=document.getElementById("checkedAll").checked;
	
	Coun0=0;
	while(document.getElementById("checkedBox"+Coun0)!=undefined){
		document.getElementById("checkedBox"+Coun0).checked=IsCheck;
		Coun0++;
	}
}
//-- #Refresh CCode --
netsCommon.prototype.refreshCCode=function(pControlName){
	if(pControlName==""){
		pControlName="CCodeIframe";
	}
	document.getElementById(pControlName).src=this.sCCodeURL+Math.random()+'&Name='+pControlName;
}
//-- #Set action type --
netsCommon.prototype.setActionType=function(pActionType,pFormActionType,pPage,pExtends){
	if(pPage==""){
		pPage=this.sysPage;
	}
	document.getElementById(this.sysForm).action=pPage+"?ActionType="+pActionType+"&"+this.sysActionTypeF+"="+pFormActionType+"&"+pExtends;
	document.getElementById(this.sysActionTypeF).value=pFormActionType;
}
//-- #Set action with out --
netsCommon.prototype.setActionWithOut=function(pType){
	document.getElementById(this.sysActionWithOut).value=pType;
}
//-- #Confirm do --
netsCommon.prototype.confirmDo=function(pMessage){
	if(confirm(pMessage)){
		document.getElementById(this.sysActionWithOut).value="1";
	}else{
		document.getElementById(this.sysActionWithOut).value="2";
	}
	return 0;
}
//-- #Hidden element by tag --
netsCommon.prototype.hiddenAllElement=function(pTag,pType){
	var tmpElementAR=document.getElementsByTagName(pTag);
	var Coun0=0;
	
	while(tmpElementAR.length>Coun0){
		if(pType==0){
			tmpElementAR[Coun0].style.visibility="hidden";
		}else{
			tmpElementAR[Coun0].style.visibility="visible";
		}
		Coun0++;
	}
	
	return 0;
}
//-- #Decimal --
netsCommon.prototype.changeTwoDecimal_f=function(x){
	var f_x = parseFloat(x);
	if (isNaN(f_x)){
		alert('function:changeTwoDecimal->parameter error');
		return false;
	}
	var f_x = Math.round(x*100)/100;
	var s_x = f_x.toString();
	var pos_decimal = s_x.indexOf('.');
	if (pos_decimal < 0){
		pos_decimal = s_x.length;
		s_x += '.';
	}
	while (s_x.length <= pos_decimal + 2){
		s_x += '0';
	}
	return s_x;
}
//-- #Date --
netsCommon.prototype.formatDate=function(pValue){
	var tmpDate=new Date();
	var tmpAR0=pValue.split(" ");
	var tmpAR1=new Array(2009,1,1);
	var tmpAR2=new Array(0,0,0);
	if(tmpAR0.length<1){
		return tmpDate;
	}
	tmpAR1=tmpAR0[0].split("-");
	if(tmpAR1.length!=3){
		return tmpDate;
	}
	if(tmpAR0.length>1){
		tmpAR2=tmpAR0[1].split(":");
	}
	
	tmpDate=new Date(tmpAR1[0],tmpAR1[1],tmpAR1[2],tmpAR2[0],tmpAR2[1],tmpAR2[2]);
	return tmpDate;
}
//-- ------ #Instanct ------ --
var tmpCommon=new netsCommon();


//-- ------ #Time ------ --
var sysTimeIndex=0;
var sysTimeHandle=0;
function doTime(){
	netsTime_callback();
	sysTimeIndex++;
	sysTimeHandle=setTimeout("doTime()",10);
}
function netsTime_callback(){
}

//-- ------ #Other class ------ --
String.prototype.getBytes = function() {    
    var cArr = this.match(/[^\x00-\xff]/ig);    
    return this.length + (cArr == null ? 0 : cArr.length);    
}


