﻿var iMaxMonthCount = 60;
var iMaxYearsCount = 5;
var iMaxMettingCount = 30;

var iDistSoftwareCount = 5000;
var iSoftwareCount = 1000;

function getElement(oID)
{
	return(document.getElementById(oID));
}

function Asc(strChar) {
	var strTmp=new String(strChar);
	return(strTmp.charCodeAt(0));
}

function Chr(intCode) {
	return(String.fromCharCode(intCode));
}

function Mid(strSource,intStart,intCount) {
	return(strSource.substr(intStart-1,intCount));
}

function Left(strSource,intCount) {
	return(strSource.substr(0,intCount));
}

function Right(strSource,intCount) {
	return(source.substr(source.length-count,count));
}

function CheckDataMatching(cString,iType)
{
    var i,j,cTemplateData;
    if(iType == null)
    {
        iType = 0;
    }
    if(iType == 0)
    {
        cTemplateData = "0123456789";
    }
    if (cString.length == 0)
        return 0
    
    for (i=0;i<cString.length;i++)
    {
        j=cTemplateData.indexOf(cString.charAt(i));
        if (j==-1)
        {
            return 0;
        }
    }
    return 1;
}

function AjaxRequestFunc(Op,Para,returnFunc)
{
	if(Para != "")
	{
		Para = "&" + Para;	
	}
	zAjax_LoadPage("../Common/Func_ajax.aspx","op="+Op+Para,"",1,1,0,2,returnFunc);
}

function getCheckboxValue(iID)
{
	var oCheck = document.getElementsByName(iID);
	var cR = "";
	for(var i=0;i<oCheck.length;i++)
	{
		if(oCheck[i].checked)
		{
			if(isNull(cR))
			{
				cR = oCheck[i].value;
			}
			else
			{
				cR = cR + "," + oCheck[i].value;
			}
		}
	}
	
	return(cR);
}

function isNull(objID,iT)
{
	if(typeof(objID) != "undefined")
	{
		if(iT == 1)
		{
			var oB = document.getElementById(objID);
			if(oB)
			{
				if(oB.value == "" || oB.value == null)
				{
					return(true);
				}
			}
		}
		else
		{
			if(objID == null)
			{
				return(true);
			}
			
			if(typeof(objID) == "object")
			{
				return(false);
			}
			else
			{
				if(objID == "" || objID == "undefined")
				{
					return(true);
				}
				else
				{
					return(false);
				}
			}
		}
	}
	else
	{
		return(true);
	}
	
	return(false);	
}

function Replace(strSource,strFind,strToStr) {
	strSource=new String(strSource);
	strFind=new String(strFind);
    var strEndValue,intFindStart,intFindEnd,strTmpFront,strTmpEnd;
    strEndValue=strSource;
    intFindEnd=0;
    while (true){
		intFindStart=strEndValue.indexOf(strFind,0);
		if (intFindStart!=-1) {
			intFindEnd=intFindStart+strFind.length;
			strTmpFront=strEndValue.substr(0,intFindStart);
			strTmpEnd=strEndValue.substr(intFindEnd);
			strEndValue=strTmpFront+strToStr+strTmpEnd;
		} else {
			break;
		}
	}
    return(strEndValue);
}

function lTrim(strSource) {
	return(strSource.replace(/^\s*/,""));
}

function rTrim(strSource) {
	return(strSource.replace(/\s*$/,""));
}

function Trim(strSource) {
	return(strSource.replace(/\s*$/,"").replace(/^\s*/,""));
}

function lCase(strSource) {
	strSource=new String(strSource);
	strSource=strSource.toLowerCase(strSource);
	return(strSource);
}

function uCase(strSource) {
	strSource=new String(strSource);
	strSource=strSource.toUpperCase(strSource);
	return(strSource);
}

function Random(intLow,intUp) {
	var intTmp;
	if (intUp<intLow) {
		intTmp=intUp;
		intUp=intLow;
		intLow=intTmp;
	}
	return(parseInt(parseInt(intUp-intLow+1)*Math.random()+intLow));
}

function preloadImagesList() {
	var d=document;
	if(d.images) {
		if(!d.MM_p) {
			d.MM_p=new Array();
		}
		var i,j=d.MM_p.length,a=preloadimageslist.arguments;
		for(i=0; i<a.length; i++) {
			if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function IsNumber(sData)
{
	var re= /^\d+$/g;
	re.lastIndex = 0;
	if(!re.test(sData))
	{
		return false;
	}
	else
	{
		return true;
	}
	return false;
}

function getQueryValue(strName) {
	var reg=new RegExp("(^|&)"+ strName +"=([^&]*)(&|$)");
	var r=window.location.search.substr(1).match(reg);
	if (r!=null) return unescape(r[2]);
	return "";
}

function openUrlInNewWindowWithPara(strUrl,intWidth,intHeight,strShowScroll) {
	if (strShowScroll==null) {
		strShowScroll="yes";
	}
	newwin=window.open("","","width="+intWidth+",height="+intHeight+",top=20,left=20,scrollbars="+strShowScroll);
	newwin.location.href=strUrl;
}

function IsEmail(sData)
{
	var re= /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/g;
	re.lastIndex = 0
	if(!re.test(sData))
	{
		return false;
	}
	else
	{
		return true;
	}
	return true;
}

function validateCharLen(sData,ilen,clew)
{
	if (sData.length > ilen)
	{
		alert(readResource(132,iLang)+clew+ readResource(133,iLang)+ilen+ readResource(134,iLang));
		//##alert("输入的"+clew+"不能大于"+ilen+"字符,请重新输入");
		return(false);
	}
	return(true);
}

//FormName:表单名
//strSource:检查的字符串,
//iNull:是否允许为空(0:不允许,1:允许;)
//iLen最大长度
function CheckInputString(FormName,strSource,iNull,iLen)
{
	var sArrString = new Array();
	sArrString[0] = "&";
	sArrString[1] = "+";
	var sString = "\"&\",\"+\"";
	var iError = 0;
	if (iNull != 1)
	{
		if(strSource == "")
		{
			iError = 1;	
		}	
	}
	
	if(iError == 0)
	{
		if(strSource != "")
		{
			//检查输入是否是空格
			if(Trim(strSource) == "")
			{
				iError = 2;	
			}
			
			//检查是否需要判断检查字符长度
			if(iError == 0)
			{
				if(iLen != 0)
				{
					if(!validateCharLen(strSource,iLen,FormName))
					{
						iError = 3;	
					}
				}		
			}
		}
	}
	
	if(iError == 0)
	{
		for (var i=0; i<sArrString.length; i++)
		{
			if(strSource.indexOf(sArrString[i]) != -1)
			{
				iError = 4;	
				break;	
			}
		}
	}
	
	switch(iError)
	{
		case 0:
			return(true);
			break;
		case 1:
			alert(FormName + "不能为空");
			break;
		case 2:
			alert(FormName + "不能为空格");
			break;	
		case 3:
			break;
		case 4:
			alert(FormName + "不能含有 " + sString + " 字符")
			break;
	}
	return(false);
}

//替换特殊字符
function ReplaceJaxEspecialString(strSource)
{
	//替换"&"
	if (strSource != "")
	{
		strSource = Replace(strSource,"&","$20200$");
		strSource = Replace(strSource,"+","$20201$");	
	}
	//替换"+"
	//替换"="
	//替换"%"
	return(strSource)
}


/* IE 7 激活Falsh控件*/
function writeflashhtml(arg)
{
	var parm = []
	var _default_version = "6,0,29,0";
	var _default_quality = "high";
	var _default_align = "middle";
	var _default_menu = "false";

	for(i = 0; i < arguments.length; i ++)
	{
		parm[i] = arguments[i].split(' ').join('').split('=')
		for (var j = parm[i].length-1; j > 1; j --)
		{
			parm[i][j-1]+="="+parm[i].pop();
		}
		switch (parm[i][0])
		{
			case '_version' : var _version = parm[i][1] ; break ; 
			case '_swf' : var _swf = parm[i][1] ; break ; 
			case '_base' : var _base = parm[i][1] ; break ; 
			case '_quality' : var _quality = parm[i][1] ; break ; 
			case '_loop' : var _loop = parm[i][1] ; break ; 
			case '_bgcolor' : var _bgcolor = parm[i][1] ; break ; 
			case '_wmode' : var _wmode = parm[i][1] ; break ; 
			case '_play' : var _play = parm[i][1] ; break ; 
			case '_menu' : var _menu = parm[i][1] ; break ; 
			case '_scale' : var _scale = parm[i][1] ; break ; 
			case '_salign' : var _salign = parm[i][1] ; break ; 
			case '_height' : var _height = parm[i][1] ; break ; 
			case '_width' : var _width = parm[i][1] ; break ; 
			case '_hspace' : var _hspace = parm[i][1] ; break ; 
			case '_vspace' : var _vspace = parm[i][1] ; break ; 
			case '_align' : var _align = parm[i][1] ; break ; 
			case '_class' : var _class = parm[i][1] ; break ; 
			case '_id' : var _id = parm[i][1] ; break ; 
			case '_name' : var _name = parm[i][1] ; break ; 
			case '_style' : var _style = parm[i][1] ; break ; 
			case '_declare' : var _declare = parm[i][1] ; break ; 
			case '_flashvars' : var _flashvars = parm[i][1] ; break ; 
			default :;
		}
	}

	var thtml = ""
	thtml += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=" + ((_version)?_version:_default_version) + "'"
	if(_width) thtml += " width='" + _width + "'"
	if(_height) thtml += " height='" + _height + "'"
	if(_hspace) thtml += " hspace='" + _hspace + "'"
	if(_vspace) thtml += " vspace='" + _vspace + "'"
	if(_align) thtml += " align='" + _align + "'"
	else thtml += " align='" + _default_align + "'"
	if(_class) thtml += " class='" + _class + "'"
	if(_id) thtml += " id='" + _id + "'"
	if(_name) thtml += " name='" + _name + "'"
	if(_style) thtml += " style='" + _style + "'"
	if(_declare) thtml += " " + _declare
	thtml += ">"
	if(_swf) thtml += "<param name='movie' value='" + _swf + "'>"
	if(_quality) thtml += "<param name='quality' value='" + _quality + "'>" 
	else thtml += "<param name='quality' value ='" + _default_quality + "'>"
	if(_loop) thtml += "<param name='loop' value='" + _loop + "'>"
	if(_bgcolor) thtml += "<param name='bgcolor' value='" + _bgcolor + "'>"
	if(_play) thtml += "<param name='play' value='" + _play + "'>"
	if(_menu) thtml += "<param name='menu' value='" + _menu + "'>"
	else thtml += "<param name='menu' value='" + _default_menu + "'>"
	if(_scale) thtml += "<param name='scale' value='" + _scale + "'>"
	if(_salign) thtml += "<param name='salign' value='" + _salign + "'>"
	if(_wmode) thtml += "<param name='wmode' value='" + _wmode + "'>"
	if(_base) thtml += "<param name='base' value='" + _base + "'>"
	if(_flashvars) thtml += "<param name='flashvars' value='" + _flashvars + "'>"
	thtml += "<embed pluginspage='https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0'"
	if(_width) thtml += " width='" + _width + "'"
	if(_height) thtml += " height='" + _height + "'"
	if(_hspace) thtml += " hspace='" + _hspace + "'"
	if(_vspace) thtml += " vspace='" + _vspace + "'"
	if(_align) thtml += " align='" + _align + "'"
	else thtml += " align='" + _default_align + "'"
	if(_class) thtml += " class='" + _class + "'"
	if(_id) thtml += " id='" + _id + "'"
	if(_name) thtml += " name='" + _name + "'"
	if(_style) thtml += " style='" + _style + "'"
	thtml += " type='application/x-shockwave-flash'"
	if(_declare) thtml += " " + _declare 
	if(_swf) thtml += " src='" + _swf + "'"
	if(_quality) thtml += " quality='" + _quality + "'"
	else thtml += " quality='" + _default_quality + "'"
	if(_loop) thtml += " loop='" + _loop + "'"
	if(_bgcolor) thtml += " bgcolor='" + _bgcolor + "'"
	if(_play) thtml += " play='" + _play + "'"
	if(_menu) thtml += " menu='" + _menu + "'"
	else thtml += " menu='" + _default_menu + "'"
	if(_scale) thtml += " scale='" + _scale + "'"
	if(_salign) thtml += " salign='" + _salign + "'"
	if(_wmode) thtml += " wmode='" + _wmode + "'"
	if(_base) thtml += " base='" + _base + "'"
	if(_flashvars) thtml += " flashvars='" + _flashvars + "'"
	thtml += "></embed>"
	thtml += "</object>"
	return thtml;
}


var Win_Waite = function ()
{
	var TB = document.createElement("TABLE");
	TB.style.backgroundColor = "#f1f1f1";
	//间距
	var TR = TB.insertRow(-1);
	var TD = TR.insertCell(-1);
	TD.style.width = "80";
	TD.innerHTML = "&nbsp;";
	TD.rowSpan = "5";
	TD = TR.insertCell(-1);
	TD.style.height = "30";
	TD = TR.insertCell(-1);
	TD.innerHTML = "&nbsp;";
	TD.rowSpan = "5";
	TD.style.width = "80";

	TR = TB.insertRow(-1);
	TD = TR.insertCell(-1);
	oText = document.createTextNode("Connecting to GEG server, please wait...");
	TD.appendChild(oText);	
        	
	//间距
	TR = TB.insertRow(-1);
	TD = TR.insertCell(-1);
	TD.style.height = "30";
        	
	 //间距
	TR = TB.insertRow(-1);
	TD = TR.insertCell(-1);
	TD.style.height = "20";

	return (TB);
}

function ShowTimezoneOffset()
{
	var dNow = new Date();
	var iOffset = dNow.getTimezoneOffset();
	iOffset = iOffset / 60;

	var sText = "<br><br>The current local time is ";
	var oDiv = document.getElementById("divTZOff");
	if (iOffset < 0)
	{
		sText += iOffset;
		sText += " hours before GMT";
	}
	else if (iOffset == 0)
	{
		sText += "GMT";
	}
	else
	{
		sText += iOffset;
		sText += " hours after GMT";
	}

	oDiv.innerHTML=sText;
	return;
}

	var openUserWin = function(iUpg)
	{
		var TB = document.createElement("TABLE");
		//TB.style.backgroundColor = "#ffffff";
		TB.border = 0;
		
		var TR = TB.insertRow(-1);
		var TD = TR.insertCell(-1);
		var iTDWidth = 570;
		TD.style.width = iTDWidth;
		//TD.style.textAlign = "justify";
		TD.style.wordWrap = "break-word";
		TD.style.paddingLeft = 20;
		TD.style.paddingTop = 20;
		TD.style.paddingRight = 20;
		if(iUpg == 1)
		{
			oText = document.createTextNode(readResource(114,iLang));
			TD.appendChild(oText);	
		}
		else
		{
			oText = document.createTextNode(readResource(102,iLang));
			TD.appendChild(oText);	
			
			TR = TB.insertRow(-1);
			TD = TR.insertCell(-1);
			TD.style.width = iTDWidth;
			TD.style.paddingLeft = 20;
			TD.style.paddingRight = 20;
			//TD.style.textAlign = "justify";
			TD.style.wordWrap = "break-word";
			oText = document.createTextNode(readResource(103,iLang));
			TD.appendChild(oText);
			
			/*TR = TB.insertRow(-1);
			TD = TR.insertCell(-1);
			TD.style.width = iTDWidth;
			TD.style.paddingLeft = 20;
			TD.style.paddingRight = 20;
			//TD.style.textAlign = "justify";
			TD.style.wordWrap = "break-word";
			oText = document.createTextNode(readResource(119,iLang));
			TD.appendChild(oText);*/
		}
		TR = TB.insertRow(-1);
		TD = TR.insertCell(-1);
		TD.style.height = "10";
		
		TR = TB.insertRow(-1);
		TD = TR.insertCell(-1);
		TD.align = "center";
		var oFormImg = document.createElement("img");
		oFormImg.className = "hand";
		oFormImg.src = redImgResource("securitycontrol.gif",iLang); 
		oFormImg.setAttribute('onclick',document.all ? function(){
		openUserWin_submit();
		} :'openUserWin_submit()');
		TD.appendChild(oFormImg);
		
		oText = document.createTextNode(" ");
		TD.appendChild(oText);
		
		oFormImg = document.createElement("img");
		oFormImg.className = "hand";
		oFormImg.src = redImgResource("controlBack.gif",iLang); 
		oFormImg.setAttribute('onclick',document.all ? function(){
		openCompleteWin_submit();
		} :'openCompleteWin_submit()');
		TD.appendChild(oFormImg);
		
		//间距
		TR = TB.insertRow(-1);
		TD = TR.insertCell(-1);
		TD.style.height = "20";

		return (TB);
	}
	
	function openUserWin_submit()
	{
		if(isIE)
		{
			location.href="../OCXLib/GaaihoSEdit.msi";
		}
		else
		{
			location.href="../OCXLib/NPGaaihoSEdit.msi";
		}
	}
	
	function openCompleteWin_submit()
	{
		closeWin();
	}
