/*cookies:begin-----------------------------------------------------------*/
function setCookie(name,value,expires,path,domain,secure){		
	document.cookie = name + "=" + escape (value) + 
		((expires) ? "; expires=" + expires.toGMTString() : "") + 
		((path) ? "; path=" + path : "") + 
		((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); 
} 
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr));
} 
function getCookie(name){
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen){
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break;  
	} 
	return null; 
} 

function RefreshCookie(cName,cValue,nNumber,cStyle){
	var dNowDate = new Date();
	setCookie(cName,cValue,DateAdd(dNowDate,nNumber,cStyle));
}


/*cookies:over-----------------------------------------------------------*/

/*datetime:begin-----------------------------------------------------------*/

function  cDateAdd(strInterval,NumDay,cDate)  {  
	return dateAdd(stringToDate(cDate),NumDay,strInterval)
}

function  dateAdd(strInterval,NumDay,dtDate)  {  
	var dtTmp = new Date(dtDate);
	if  (isNaN(dtTmp))  dtTmp  = new Date();
	switch  (strInterval){
	case "s":return new Date(Date.parse(dtTmp) + (1000 * NumDay));  
	case "n":return new Date(Date.parse(dtTmp) + (60000 * NumDay));  
	case "h":return new Date(Date.parse(dtTmp) + (3600000 * NumDay));
	case "d":return new Date(Date.parse(dtTmp) + (86400000 * NumDay)); 
	case "w":return new Date(Date.parse(dtTmp) + ((86400000 * 7) * NumDay)); 
	case "m":return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + NumDay, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());  
	case "y":return new Date((dtTmp.getFullYear() + NumDay), dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());  
    }
}

function getDateTimeString(cDate,cType,chn){
	var cDateTime,dNowDate
	
	dNowDate = cDate
	if (dNowDate == null || dNowDate == ""){ dNowDate = new Date();}
	if (dNowDate.toString().indexOf("-")>0){var aDate = dNowDate.split("-");dNowDate = new Date(aDate[0],aDate[1]-1,aDate[2]);}
	var Week = dNowDate.getDay();
	var Year= dNowDate.getYear();
	var Mon = dNowDate.getMonth()+1;
	var Day= dNowDate.getDate();
	var Hour = dNowDate.getHours();
	var Min = dNowDate.getMinutes();
	var Sec = dNowDate.getSeconds();

	Year = (Year > 200) ? Year : 1900 + Year;
	
	if (chn) {Mon = ((Mon < 10) ? "Äê0" : "Äê" ) + Mon;}else {Mon = ((Mon < 10) ? "-0" : "-" ) + Mon;}
	
	if (chn) {Day = ((Day < 10) ? "ÔÂ0" : "ÔÂ" ) + Day;}else {Day = ((Day < 10) ? "-0" : "-" ) + Day;}

	cDateTime = Year + Mon + Day
	if (chn) {cDateTime = cDateTime + "ÈÕ"}
	
	if (cType == "t"){
		Hour = ((Hour < 10) ? "0" : "" ) + Hour;
		
		if (chn) {Min = ((Min < 10) ? ':0' : ':') + Min;}
		else {Min = ((Min < 10) ? 'Ê±0' : 'Ê±') + Min;}
		
		if (chn) {Sec = ((Sec < 10) ? '·Ö0' : '·Ö') + Sec;}
		else {Sec = ((Sec < 10) ? ':0' : ':') + Sec;}
		
		cDateTime = DateTime + Hour + Min + Sec
		if (chn) {cDateTime = cDateTime + "Ãë"}
	}
	return cDateTime
}


function getNowTime(chn,w,s) {
	var DateTime
	var dNowDate = new Date();
	var Week = dNowDate.getDay();
	var Year= dNowDate.getYear();
	var Mon = dNowDate.getMonth() + 1;
	var Day= dNowDate.getDate();
	var Hour = dNowDate.getHours();
	var Min = dNowDate.getMinutes();
	var Sec = dNowDate.getSeconds();

	Year = (Year > 200) ? Year : 1900 + Year;
	
	if (chn){
		Year = Year + "Äê"
		Mon = ((Mon < 10) ? "0" : "" ) + Mon + "ÔÂ";
		Day = ((Day < 10) ? "0" : "" ) + Day + "ÈÕ";
	}else{
		Mon = ((Mon < 10) ? "-0" : "-" ) + Mon;
		Day = ((Day < 10) ? "-0" : "-" ) + Day;
	}

	DateTime = Year + Mon + Day 

	if (w){
		switch (Week){
			case 0:Week = " ÐÇÆÚÈÕ";break;
			case 1:Week = " ÐÇÆÚÒ»";break;
			case 2:Week = " ÐÇÆÚ¶þ";break;
			case 3:Week = " ÐÇÆÚÈý";break;
			case 4:Week = " ÐÇÆÚËÄ";break;
			case 5:Week = " ÐÇÆÚÎå";break;
			case 6:Week = " ÐÇÆÚÁù";break;
		}
		DateTime = DateTime + Week
	}
	if (s){
		Hour = ((Hour < 10) ? " 0" : " " ) + Hour;
		Min = ((Min < 10) ? ':0' : ':') + Min;
		Sec = ((Sec < 10) ? ':0' : ':') + Sec;
		DateTime = DateTime + Hour + Min + Sec
	}
	return DateTime
}

function isDateString(cDate){
	var iaMonthDays = [31,28,31,30,31,30,31,31,30,31,30,31]
	var iaDate = new Array(3)
	var year, month, day
//	if (arguments.length != 1) return false
	iaDate = cDate.toString().split("-")
	if (iaDate.length != 3) return false;
	if (iaDate[0].length <= 2 || iaDate[1].length == 0 || iaDate[2].length == 0) return false;
	if (iaDate[0].length > 4 || iaDate[1].length > 2 || iaDate[2].length > 2) return false;
	if (isNaN(iaDate[0])||isNaN(iaDate[1])||isNaN(iaDate[2])) return false;

	year = parseFloat(iaDate[0])
	month = parseFloat(iaDate[1])
	day=parseFloat(iaDate[2])

	if (isNaN(year)||isNaN(month)||isNaN(day)) return false
	if (year < 1900 || year > 2100) return false
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) iaMonthDays[1]=29;
	if (month < 1 || month > 12) return false
	if (day < 1 || day > iaMonthDays[month - 1]) return false
	
	return true
}

function isDateTime(cTime){
	var iaTime = new Array(2);
	if (cTime==null) return false;
	iaTime = cTime.toString().split(" ");
	
	if (!isDateString(iaTime[0])) return false;
	if (iaTime.length==2){
		if (!isTimeString(iaTime[1])) return false;
	}
	return true;
}

function isTimeString(cTime){
	var iaTime = new Array(3)
	var hour, minu, sec
	
	iaTime = cTime.toString().split(":")
	if (iaTime.length<2 ||iaTime.length>3) return false;
	if (iaTime.length==2)iaTime[2]="00";
	if (parseFloat(iaTime[0]) < 0 || parseFloat(iaTime[0])>=24) return false;
	if (parseFloat(iaTime[1]) < 0 || parseFloat(iaTime[1])>=60) return false;
	if (parseFloat(iaTime[2]) < 0 || parseFloat(iaTime[2])>=60) return false;
	
	return true
}

function dateToString(dDate,blTime){
//	var nWeek = dDate.getDay();
	var nYear= dDate.getYear();
	var nMon = dDate.getMonth() + 1;
	var nDay= dDate.getDate();
	var nHour = dDate.getHours();
	var nMin = dDate.getMinutes();
	var nSec = dDate.getSeconds();
	
	var cDate = nYear + "-" + nMon + "-" + nDay
	if (blTime){
		cDate = cDate + " " + nHour + ":" + nMin + ":" + nSec
	}
	return cDate
}

function stringToDate(sDate,bIgnore){
	var bValidDate,date1,time1,year,month,day,hour,minu,sec;
	var iaDate,iaTime;

	if (bIgnore) bValidDate = true;
	else bValidDate = isDateTime(sDate);
	
	if (bValidDate){
		sDate = sDate.replace(".","-")
		sDate = sDate.replace("/","-")
		if (sDate.indexOf(" ") > 0){
			date1 = sDate.toString().split(" ");
			iaDate = date1[0].split("-");
			iaTime = date1[1].split(":");
		}else{
			iaDate = sDate.toString().split("-");
		}
		if (iaDate.length==3){
			year = parseInt(iaDate[0],10);
			month = parseInt(iaDate[1],10) - 1;
			day = parseInt(iaDate[2],10);
		}
//		document.write(year,month,day,hour,minu,sec)

		if (iaTime==null){
			iaDate = new Date(year,month,day)
		}else{
			if (iaTime.length>=2){
				hour = parseInt(iaTime[0],10);
				minu = parseInt(iaTime[1],10);
				if (iaTime.length==3)
					sec = parseInt(iaTime[2],10);
				else
					sec = "00"
			}
			iaDate = new Date(year,month,day,hour,minu,sec)
		}
		return (iaDate)
	}else{
		return (new Date())
	}
}
/*datetime:over-----------------------------------------------------------*/

//orther functions;

function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}

//·µ»ØÒ»¸ö×Ö·ûÔÚ×Ö·û´®ÖÐ³öÏÖµÄ¸öÊý
function CharCount(strFind,strTilde) {
	var i = 0;
	var j = 0;
	if (strFind.length>0 && strTilde.length>0){
		do{
			i = strFind.indexOf(strTilde,i);
			if (i >= 0) {i++;j++}
		}
		while(i>=0)
	}
	return j;
}
	
function checkLength(txt){
	var x = txt.length;
	var y = 0;
	for (var i=0;i<x;i++) {
		if (txt.charCodeAt(i) < 0 || txt.charCodeAt(i) > 255){
			y = y + 2;
		}else{
			y = y + 1;
		}
	}
	return y;
}

function checkWords(txt){
	if(txt.length == 0){
		alert("ÇëÊäÈëÄãµÄÃû×Ö¡£");
		return false;
	}else{
		testword = "~!@#$%^&*()+\[]{}'<> ,./?" + '"'
		for(i=0;i<testword.length;i++){
			if(txt.indexOf(testword.substring(i,i+1))>=0){
				alert("Ãû×Ö²»ÄÜº¬ÓÐÌØÊâµÄ×Ö·û,°üÀ¨~!@#$%^&*()+\[]{}<>,./?¼°µ¥Ë«ÒýºÅ,¿Õ¸ñ.");
				return false;
				break;
			}
		}
	}
	return true;
}

function display(cObj){
	cObj = eval(cObj)
	if (cObj.style.display=='none'){
		cObj.style.display='';
	}else{
		cObj.style.display='none';
	}
}


//ÔÚ´øÓÐÖ¸¶¨·Ö¸ô·ûºÅµÄ×Ö·û´®ÖÐ²éÕÒÄ¿±ê×Ö·û´®ÊÇ·ñ´æÔÚ
function findString(AllStr,TotalStr,Tilde){
	var SubStr = "";
	var i = 0;
	do{
		SubStr = getSubString(AllStr,Tilde,++i);
		if (SubStr == TotalStr){return 1;break;}
	}
	while (SubStr.length > 0)
	return 0;
}

function getSubString(FindStr,FindTilde,i) {
	var ReturnStr = "";
	var size1 = 0;
	var j;

	if (i <= 0 ) i = 1;
	for (j = 1 ; j <= i ; j++ )	{
		if (size1 >= 0){
			if (j > 2) size1++;	//µÚÒ»¡¢¶þ´Î²éÕÒµÄ¶¼ÊÇµÚÒ»¸ö·Ö¸ô·û
			size1 = FindStr.indexOf(FindTilde,size1);
		}
	}
	if (FindStr.length > 0 && FindTilde.length > 0){
		if (i == 1)	{
			if (size1 > 0)
				ReturnStr = FindStr.substring(0,size1);
			else
				ReturnStr = FindStr;
		}else{
			if (size1 >= 0){
				var size2 = FindStr.indexOf(FindTilde,++size1);
				if (size2 > 0)
					ReturnStr = FindStr.substring(size1,size2);
				else
					ReturnStr = FindStr.substring(size1,FindStr.length);
			}
		}
	}
	return ReturnStr
}

function getNum(cNum,blIsDec){
	if (isNumber(cNum,blIsDec)){
		if (blIsDec)
			return parseFloat(cNum);
		else
			return parseInt(cNum);
	}else{
		return 0;
	}
	

}

function isEmail (s){
        // Writen by david, we can delete the before code
        if (s.length > 100){
                window.alert("EmailµØÖ·³¤¶È²»ÄÜ³¬¹ý100Î»!");
                return(false);
        }

         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|cn|net|com|gov|mil|org|edu|int)$"
         var re = new RegExp(regu);
         if (s.search(re) != -1) {
               return(true);
         } else {
 //              window.alert ("ÇëÊäÈëÓÐÐ§µÄE-mailµØÖ· £¡ÀýÈç£ºtest@abc.com")
               return(false);
         }
}

function isNumber(cValue,blIsDec){
	//flags:define cValue : true:cValue is decimal; false:cValue is integer;
	var x = cValue.length;
	if (x == 0) return false;
	for (var i=0;i<x;i++)
		if (cValue.charCodeAt(i) < 48 || cValue.charCodeAt(i) > 57){
//			alert(cValue.charCodeAt(i))
			if (!(cValue.charCodeAt(i)==43 && i==0))
				if (!(blIsDec && cValue.charCodeAt(i)==46))
					return false;
		}
	return true;
}


function listSelect(objName,objValue){
	var objOptVal;
	for (var i=0;i<objName.options.length;i++){
		objOptVal = objName.options[i];
		if (objOptVal.value.toLowerCase() == objValue.toLowerCase()){
			objName.selectedIndex = i;
			return i;
		}
	}
	return 0
}

function moneyTypeSign(cType){
	if (cType=="RMB"||cType=="CNY"||cType=="Ôª"||cType=="ÈËÃñ±Ò"||cType=="") return "£¤";
	if (cType=="NTD"||cType=="ÐÂÌ¨±Ò") return "NTD";
	if (cType=="USD"||cType=="ÃÀÔª") return "$";
	if (cType=="HKD"||cType=="¸Û±Ò") return "HKD";
	if (cType=="EUR"||cType=="Å·Ôª") return "€";
	if (cType=="JPY"||cType=="ÈÕÔª") return "JPY";
	if (cType=="WON"||cType=="KRW"||cType=="º«Ôª") return "W";
	if (cType=="AUD"||cType=="°ÄÔª") return "$";
	return cMoneyType
}

function moneyTypeOption(cSelectType){
	document.write('<option>Ôª</option>');
	document.write('<option value="ÃÀÔª" ',cSelectType=='ÃÀÔª'||cSelectType=='USD' ? ' selected ' : '','>ÃÀÔª</option>');
	document.write('<option value="¸Û±Ò" ',cSelectType=='¸Û±Ò'||cSelectType=='HKD' ? ' selected ' : '','>¸Û±Ò</option>');
	document.write('<option value="ÐÂÌ¨±Ò" ',cSelectType=='ÐÂÌ¨±Ò'||cSelectType=='NTD' ? ' selected ' : '','>ÐÂÌ¨±Ò</option>');
	document.write('<option value="Å·Ôª" ',cSelectType=='Å·Ôª'||cSelectType=='EUR' ? ' selected ' : '','>Å·Ôª</option>');
	document.write('<option value="ÈÕÔª" ',cSelectType=='ÈÕÔª'||cSelectType=='JPY' ? ' selected ' : '','>ÈÕÔª</option>');
	document.write('<option value="º«Ôª" ',cSelectType=='º«Ôª'||cSelectType=='WON'||cSelectType=='KRW' ? ' selected ' : '','>º«Ôª</option>');
	document.write('<option value="°ÄÔª" ',cSelectType=='°ÄÔª'||cSelectType=='AUD' ? ' selected ' : '','>°ÄÔª</option>');
	document.write('<option value="ÆäËü" ',cSelectType=='ÆäËü' ? ' selected ' : '','>ÆäËü</option>');	
}


function radioCheck(obj,objValue) {
	for (var i=0;i<obj.length;i++) {
		if (obj[i].value.toLowerCase() == objValue.toLowerCase()){
			obj[i].checked = true;
			return i;
		}
	}
	return -1
}
