var whitespace = " \t\n\r";
var defaultEmptyOK = true;
var MAX_INT = 2147483647;
var INT_SUBFIX_MSG = " could not be empty and must be an integer value (greater than 0 and less than " + MAX_INT + ").";
var timeToRefresh = "10";//in seconds

function leadingZero(val){
	return (val<10)?"0"+val:val;
}
function focusOldPassword() {
	var oldPassword = document.getElementById(lookupIdByTagId("oldPasswordChange"));
	if (oldPassword !== null){
		oldPassword.focus();
	}
}										

function popWin(url,width,height,windowName,scrollbar,content){
	var x=(screen.width)?(screen.width-width)/2:100;
	var y=(screen.height)?(screen.height-height)/2:100;

	var features="width="+width+"px,height="+height+"px, top="+y+"px, left="+x+"px";
		features+=(scrollbar)?",scrollbars=yes":"";
	if (!windowName){
		windowName="untitled";
	}
	var popWindow=window.open(url, windowName, features);

	if (content!==""){
		popWindow.document.write(content);
	}
	if (document.layers){
		window.moveTo(x, y);
	}
	popWindow.focus();
}

function checkForm(frm, arr_ctrl) {

	var count= arr_ctrl.length ;
	var i=0  ;
	for(i=0; i< count; i++) {
		func= trim( arr_ctrl[i][0] ) ;
		if( eval( func ) ) { //==
			alert( arr_ctrl[i][1] ) ;
			if( arr_ctrl[i][2] !== "" )
				eval( "frm."  + arr_ctrl[i][2] ).focus() ;
			return false ; //== Error
		}
	}
	return true ; //== OK
}

function isEmail(s){
	var result = false;
	if (s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/) != -1)
		result =  true ;
	if (s.search(/^\w+((-\w+)|(\.\w+))*(\.|-)\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]{2,4}$/) != -1)
		
		result =  true ;
	return result ;
}

function isNotEmail(str)
{
	var listEmail = str.split(";");
	var j;
	for(j = 0; j < listEmail.length; j++)
	{
		var strEmail = listEmail[j];
		if(!isBlank(trim(strEmail)))
			if(isEmail(strEmail) == false) return true;
	}
	return false;
}

function trimEmail(str)
{
	var listEmail = str.split(";");
	var j;
	var strRet = "";
	for(j = 0; j < listEmail.length; j++)
	{
		var strEmail = listEmail[j];
		if(!isBlank(trim(strEmail)))
		{
			strRet += trim(strEmail);
			strRet += ";";
		}
	}
	strRet = strRet.substr(0,strRet.length-1);
	return strRet;
}

function trim(str) {
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function isNegative(str) {
	if( isNaN(str) || str <= 0 )
		return true ;
	return false ;
}

function isBlank(str) {
	if( str == "" )
		return true ;
	return false ;
}

function isNickname(str){
	if((str.indexOf("!")!=-1) ||
		(str.indexOf("`")!=-1) ||
		(str.indexOf("~")!=-1) ||
		(str.indexOf("#")!=-1) ||
		(str.indexOf("$")!=-1) ||
		(str.indexOf("%")!=-1) ||
		(str.indexOf("^")!=-1) ||
		(str.indexOf("&")!=-1) ||
		(str.indexOf("*")!=-1) ||
		(str.indexOf("(")!=-1) ||
		(str.indexOf(")")!=-1)) 
		
		return false;
	return true;
}

function isDate(date,type){
	if (!(type==0||type==1||type==2)) {alert("Please specify date type in check form function!"); return false;}
	var day, month, year;
	var dateText=new Array("null","january","february","march","april","may","june","july","august","september","october","november","december");
	var thisdate=trim(date);

	//validate basic format
	var dateType=new Array();
	dateType[0]=/^\d{1,2}(\-|\/|\.|\s)\d{1,2}(\-|\/|\.|\s)\d+$/;	//date format dd mm yyyy
	dateType[1]=/^\d{1,2}(\-|\/|\.|\s)\d{1,2}(\-|\/|\.|\s)\d+$/;	//date format mm dd yyyy
	dateType[2]=/^\d{1,2}(\-|\/|\.|\s)\w{3,9}(\-|\/|\.|\s)\d+$/;	//date format dd mmmm yyyy
	if (thisdate.search(dateType[type])==-1) return false;

	var seperator=(thisdate.indexOf("-")!=-1)?"-":(thisdate.indexOf("/")!=-1)?"/":(thisdate.indexOf(".")!=-1)?".":(thisdate.indexOf(" ")!=-1)?" ":"";
	if (seperator=="") return false;	//no seperator

	var dateParam=thisdate.split(seperator);
	if (dateParam.length!=3) return false;	//use difference seperator

	//day month year from date string
	day=dateParam[0];
	year=dateParam[2];
	switch (type){
		case 0:
			month=dateParam[1];
		break;
		case 1:
			day=dateParam[1];
			month=dateParam[0];
		break;
		case 2:
			month=inArray(dateParam[1].toLowerCase(),dateText);
		break;
	}
	if (!month) return false;
	if (!senseDate(day,month,year)) return false;
	return true;
}


function inArray(itemToCheck,targetArray){
	var i=-1; var result=false;
	if (!isArray(targetArray)) return false;
	while ((i<targetArray.length-1)&&(!result)){
		i++;
		result=(targetArray[i].indexOf(itemToCheck)!=-1)?true:false;
	}
	if (result) return i;
	return false;
}

function isArray(obj){
	if (obj.constructor.toString().indexOf("Array")==-1)
		return false;
	return true;
}

function senseDate(day,month,year){
	if ((day<1)||(day>31)) return false;
	if ((month<1)||(month>12)) return false;
	if (year<1) return false;
	if ((month==2)&&(day>29)) return false;
	if (((month==4)||(month==6)||(month==9)||(month==11))&&(day>30)) return false;
	if ((month==2)&&(day==29)){
		var div4=year%4;
        var div100=year%100;
        var div400=year%400;
		if (div4!=0) return false;
		if ((div100==0)&&(div400!=0)) return false;
	}
	return true;
}

function jumppage(urlvar){
	window.location.href = urlvar;
}

function compareDate(date1,date2,type){
	var dateInput=(type==1)?1:0;
	var dateType=new Array();
	dateType[0]=/^\d{1,2}(\-|\/|\.|\s)\d{1,2}(\-|\/|\.|\s)\d+$/;	//date format dd mm yyyy
	dateType[1]=/^\d{1,2}(\-|\/|\.|\s)\d{1,2}(\-|\/|\.|\s)\d+$/;	//date format mm dd yyyy
	if (date1.search(dateType[dateInput])==-1||date2.search(dateType[dateInput])==-1) return 0;
	var seperator1=(date1.indexOf("-")!=-1)?"-":(date1.indexOf("/")!=-1)?"/":(date1.indexOf(".")!=-1)?".":(date1.indexOf(" ")!=-1)?" ":"";
	var seperator2=(date2.indexOf("-")!=-1)?"-":(date2.indexOf("/")!=-1)?"/":(date2.indexOf(".")!=-1)?".":(date2.indexOf(" ")!=-1)?" ":"";
	if (seperator1==""||seperator2=="") return 0;
	var dateArr1=date1.split(seperator1);
	var dateArr2=date2.split(seperator2);
	if (dateArr1.length!=3||dateArr2.length!=3) return 0;
	if (dateInput==1){
		var dateobj1=new Date(dateArr1[2], dateArr1[0], dateArr1[1]);
		var dateobj2=new Date(dateArr2[2], dateArr2[0], dateArr2[1]);
	}else{
		var dateobj1=new Date(dateArr1[2], dateArr1[1], dateArr1[0]);
		var dateobj2=new Date(dateArr2[2], dateArr2[1], dateArr2[0]);
	}
	if (dateobj1>dateobj2){
		return 1;
	}else if (dateobj1<dateobj2){
		return 2;
	}else{
		return 3;
	}
}

function autoRefresh(){
	if (timeToRefresh == 1){
		submitAction("refresh");
	}else{
		timeToRefresh -= 1
	}
	setTimeout("autoRefresh()",1000)
}

function submitAction(command, index){
	document.main.command.value = command;
	if(arguments.length==2){
		document.main.currentIndex.value = index;
	}
	document.main.submit();
}

function changeTab(tabName){
	document.main.action = tabName;
	document.main.submit();
}

function open_calendar(frm_name,frm_field,func)
{
	if(!func)
		func=""
	var url="calendar/calendar.htm#"+frm_name+"="+frm_field +"="+func
	popWin(url,300,250,"calendar","no","")
}

/**
 Toggle all check boxes in form, whose name starts with namePattern
 ie: if namePattern="chkCert" then chkCert0, chkCert1 and chkCert2 will be affected
*/
function checkAll(form, namePattern, checked){
	elements = form.elements;
	for(i=0; i<elements.length; i++){

		if(elements[i].type != "checkbox") continue;

		if(elements[i].name.search(namePattern)!=-1){
			elements[i].checked = checked;
		}
	}
}


function isEmpty(s){
	return ((s == null) || (s.length == 0));
}

function isExistWhiteSpace(s){
	if (isEmpty(s)) return false;
	// Search through string's characters one by one
	// until we find a whitespace character.
	// When we do, return false; if we don't, return true.
	for (i = 0; i < s.length; i++){
		// Check that current character is whitespace.
		var c = s.charAt(i);
		if (whitespace.indexOf(c) != -1) return true;
	}
	// All characters are not whitespace.
	return false;
}

function isWhitespace (s){
	var i;
	// Is s empty?
	if (isEmpty(s)) return true;
	// Search through string's characters one by one
	// until we find a non-whitespace character.
	// When we do, return false; if we don't, return true.
	for (i = 0; i < s.length; i++){
		// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}
	// All characters are whitespace.
	return true;
}

function cutSpaces(str){
	var newStr = '';
	str = trim(str);
	var strTemp = ' ';
	for (i = 0; i < str.length; i++){
		// Check that current character is whitespace.
		var c = str.charAt(i);
		if (whitespace.indexOf(c) != -1){
			strTemp += c;
		} else {
			if(strTemp.length >= 2){
				strTemp = ' ';
				newStr += strTemp;
			}
			newStr += c;
		}
	}
	return newStr;
}

function isDigit (c){
	  return ((c >= "0") && (c <= "9"));
}

function isAlpha (c){
	  return ((c.toLowerCase() >= "a") && (c.toLowerCase() <= "z"));
}

function isInteger (s){
	var i;
	if (isEmpty(s))
	   if (isInteger.arguments.length == 1) return defaultEmptyOK;
	   else return (isInteger.arguments[1] == true);
	// Search through string's characters one by one
	// until we find a non-numeric character.
	// When we do, return false; if we don't, return true.
	for (i = 0; i < s.length; i++){
		// Check that current character is number.
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	// All characters are numbers.
	return true;
}

function warnEmpty (theField, errMsg){
	theField.focus();
	alert(errMsg);
	return false;
}


function checkField (theField, errMsg, emptyOK){
	if (checkField.arguments.length == 2) emptyOK = defaultEmptyOK;

	if ((emptyOK == true) && (isEmpty(theField.value))) return true;
	//not allow empty
	if (isWhitespace(theField.value)){
	   return warnEmpty (theField, errMsg);
    }
	else return true;
}

function checkNumberField (theField, errMsg, emptyOK){
	if (checkIntegerField.arguments.length == 2) emptyOK = defaultEmptyOK;

	if ((emptyOK == true) && (isEmpty(theField.value))) return true;
	//not allow empty
	if (isWhitespace(theField.value) || !isInteger(theField.value)){
	   return warnEmpty (theField, errMsg);
    }
	else return true;
}

function checkIntegerField (theField, errMsg, emptyOK){
	if (checkIntegerField.arguments.length == 2) emptyOK = defaultEmptyOK;

	if ((emptyOK == true) && (isEmpty(theField.value))) return true;
	//not allow empty
	if (isWhitespace(theField.value) || !isInteger(theField.value) || theField.value > MAX_INT || parseInt(theField.value) <= 0){
	   return warnEmpty (theField, errMsg + INT_SUBFIX_MSG);
    }
	else return true;
}

function isNotPhone(strPhone){
	strPhone = trim(strPhone);
	var result = true;
	
	if (strPhone.length == 12)
	{
		if (isValidatePhone(strPhone))
		{
 		  result = false;
 		 } 
 		 
	}
	else if (strPhone.length == 10)
	{
		if(isInteger(strPhone))
		{
			result = false;
		}
	}
	
		return result;
	
}
/*function Check(str)
{
	var i,strCert=trim(str);
	var str1='\';
	
	for(i=0; i < strCert.length; i++)
	{
		if (strCert[i]== '\')
			return false;

	}
	return true;

}*/

function isValidateAddr(str)
{
	var strAddr = trim(str);
	var i,j,pos;
	for(i = 0; i < strAddr.length; i++)
	{
		strAddr = strAddr.toUpperCase(str[i]);
	}

	for(i = 0; i < strAddr.length; i++)
	{
		pos = strAddr.indexOf("PO",i);
		if (pos > -1)
		{
		    if (!isAlpha(strAddr.charAt(pos-1)) && !isDigit(strAddr.charAt(pos-1)) && !isAlpha(strAddr.charAt(pos+2)) && !isDigit(strAddr.charAt(pos+2)))
			 return  true;
		}

		pos = strAddr.indexOf("POB",i);
		if (pos > -1)
		{
		    if (!isAlpha(strAddr.charAt(pos-1)) && !isDigit(strAddr.charAt(pos-1)) && !isAlpha(strAddr.charAt(pos+3)) && !isDigit(strAddr.charAt(pos+3)))
			 return  true;
		}

		pos = strAddr.indexOf("BOX",i);
		if (pos > -1)
		{
		    if (!isAlpha(strAddr.charAt(pos-1)) && !isDigit(strAddr.charAt(pos-1)) && !isAlpha(strAddr.charAt(pos+3)) && !isDigit(strAddr.charAt(pos+3)))
			 return  true;
		}
		
		pos = strAddr.indexOf("CASILLA",i);
		if (pos > -1)
		{
		    if (!isAlpha(strAddr.charAt(pos-1)) && !isDigit(strAddr.charAt(pos-1)) && !isAlpha(strAddr.charAt(pos+7)) && !isDigit(strAddr.charAt(pos+7)))
			 return  true;
		}
	}
        return false ;
}

function isValidateAddrForMerchantBilling(str)
{
	var strAddr = trim(str);
	var i,j,pos;
	for(i = 0; i < strAddr.length; i++)
	{
		strAddr = strAddr.toUpperCase(str[i]);
	}

	/*for(i = 0; i < strAddr.length; i++)
	{
		pos = strAddr.indexOf("PO",i);
		if (pos > -1)
		{
		    if (!isAlpha(strAddr.charAt(pos-1)) && !isDigit(strAddr.charAt(pos-1)) && !isAlpha(strAddr.charAt(pos+2)) && !isDigit(strAddr.charAt(pos+2)))
			 return  true;
		}

		pos = strAddr.indexOf("POB",i);
		if (pos > -1)
		{
		    if (!isAlpha(strAddr.charAt(pos-1)) && !isDigit(strAddr.charAt(pos-1)) && !isAlpha(strAddr.charAt(pos+3)) && !isDigit(strAddr.charAt(pos+3)))
			 return  true;
		}

		pos = strAddr.indexOf("BOX",i);
		if (pos > -1)
		{
		    if (!isAlpha(strAddr.charAt(pos-1)) && !isDigit(strAddr.charAt(pos-1)) && !isAlpha(strAddr.charAt(pos+3)) && !isDigit(strAddr.charAt(pos+3)))
			 return  true;
		}
		
		pos = strAddr.indexOf("CASILLA",i);
		if (pos > -1)
		{
		    if (!isAlpha(strAddr.charAt(pos-1)) && !isDigit(strAddr.charAt(pos-1)) && !isAlpha(strAddr.charAt(pos+7)) && !isDigit(strAddr.charAt(pos+7)))
			 return  true;
		}
	}
        return false ;*/
}
/* validate phone format like 123-456-7890 */
function isValidatePhone(str)
{
	var strPhone = trim(str);
	var result = false;
	var s1 = strPhone.substring(0,3);//123
	
	var s2 = strPhone.substring(3,4);//-
	//alert(s2);
	var s3 = strPhone.substring(4,7);//456
	//alert(s3);	
	var s4 = strPhone.substring(7,8);//-
	//alert(s4);
	var s5 = strPhone.substring(8,12);//7894
	//alert(s5);
	if(isInteger(s1) && isInteger(s3) && isInteger(s5) && s2=="-" && s4=="-")
	{
	    result =  true;
	 }
	
	 return result;
    
}

function isEqual(aStr,bStr) {

	var a = "" + aStr;
	var b = "" + bStr;

    for (var k = 0; k < a.length; k++) {

    	var c1 = a.substring(k, k+1);
		var c2 = b.substring(k, k+1);

        if (c1!=c2) return false;
    }

	for (var h = 0; h < b.length; h++) {

    	var c1 = a.substring(h, h+1);
		var c2 = b.substring(h, h+1);

        if (c1!=c2) return false;
    }

    return true;
}
     
function isEasyPwd(s){
	if (isEmpty(s)) return false;
	var len = s.length;
	var temp = 0;
	for (i = 0; i < s.length; i++){
		var c = s.charAt(i);
		if (isInteger(c))
		{
			temp = temp + 1;
		}
	}
	if (len>=4 && temp>=1 && temp < len)
	{
	 	return true;
	}
	else
	{
		return false;
	}
}

function isAlphaA_F (c){
	  return ((c.toLowerCase() >= "a") && (c.toLowerCase() <= "f"));
}

function checkNumberLetters(s){
				
	for(var i=0; i<s.length; i++){
		c = s.charAt(i);					
		if(!isDigit(c)){
			if(!isAlphaA_F(c)){
				return false;
			}
		}
	}
	return true;
}

function checkZipCode(s){
	if (isEmpty(s)) return false;
	var len = s.length;
	
	var temp = 0;
	if (len==5)
	{
		var result4 = false;
		var result5 = false;
		for (i = 0; i < s.length; i++)
		{

			var c = s.charAt(i);
			if (c==0)
			{
				temp = temp + 1;
			}
			
		}
		if (temp!=5)
		{
	 		result4 = true;
		}
		if (isInteger(s))
		{
			result5 = true;
		}
		if (result4==true && result5==true)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else if (len==10)
	{
		var s1 = s.substring(0,5);
		var s2 = s.charAt(s.indexOf("-"));
		var s3 = s.substring(6);
		
		var temp1 = 0;
		var result1 = false;
		var result2 = false;
		var result3 = false;
		for (i = 0; i < s1.length; i++)
		{
			
			var c = s1.charAt(i);
			if (c==0)
			{
				temp1 = temp1 + 1;
			}
		}
		if (temp1!=5)
		{
	 		result1 = true;
		}
		
		var temp2 = 0;
		for (i = 0; i < s3.length; i++)
		{
			
			var c = s3.charAt(i);
			if (c==0)
			{
				temp2 = temp2 + 1;
			}
		}
		if (temp2!=4)
		{
	 		result2 = true;
		}
		if(isInteger(s1) && isInteger(s3) && s2=="-" )
		{
			result3 = true;
		}
		if (result1==true && result2==true && result3==true)
		{
			return true;
		}
		else 
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}
   

function checkIP(s){

	var lists = s.split(".");
	var j;
	var strRet = "";
	if (lists.length != 4)
		return false;
	for(j = 0; j < lists.length; j++)
	{
		var partIP = lists[j];
		if(!isInteger(partIP)||partIP <0 || partIP >255)
			return false;
	}
	return true;
	
}


     function checkFax(s){
	if (isEmpty(s)) return false;
	var len = s.length;
	var temp = 0;
	for (i = 0; i < s.length; i++){
		// Check that current character is whitespace.
		var c = s.charAt(i);
		if (c=="." || !isInteger(c))
		{
			temp = temp + 1;
		}
	}
	if (temp!=0)
	{
	 	return false;
	}
	else
	{
		return true;
	}
}

function inputKey(e) {
	var key;
	if(window.event) {
		key =e.keyCode;	
	}
	else {
		key =e.which;
	}
	//number : 0--9
	if (48 <= key  && key <= 57) {
		return true;
	}
	//a--z
	if (97 <= key  && key <= 122) {
		return true;
	}
	//@ ,A -- Z
	if (64 <= key  && key <= 90) {
		return true;
	}
	//space ,_ 
	if(key==32 || key ==95 || key ==8 || key==42 ||
		key ==45 || key ==46 || key ==127) {
		return true;
	}
	//left,right,up,down
	if(key==28 || key ==29 || key ==30 || key ==31) {
		return true;
	}
	return false;
}

function checkDomainName(s){
	if (isEmpty(s)) return false;
	var temp = 0;
	var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw');

var mai = s;
var val = true;

var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
	
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
	  	 //alert("Your domain extension "+ext+" is not correct");
	  	 temp = 1;
		 return temp;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {
		 	  	// alert("Domain name should not begin are end with '-'");
		 	  	temp=2;
			      return temp;
		 	 }
		  }
		else	{
		  	// alert("Your domain name should not have special characters");
		  	temp=3;
			 return temp;
		  }
		}
	}
}
else
{
 //alert("Your Domain name is too short/long");
 temp=4;
 return temp;
}	

return temp;
}



function checkFaxRegister(s){
	if (isEmpty(s)) return false;
	var len = s.length;
	var temp = 0;
	
	for (i = 0; i < s.length; i++){
		// Check that current character is whitespace.
		var c = s.charAt(i);
		if (c==".")
		{
			temp = temp + 1;
		}
		if (c!="0" && c!="1" && c!="2" && c!="3" && c!="4" && c!="5" && c!="6" && c!="7" && c!="8" && c!="9" && c!="-")
		{
			temp = temp + 1
		}
		
	}
	
	if (temp!=0)
	{
	 	return false;
	}
	else
	{
		return true;
	}
}

function verifyVarchar(s)
{
	return 0;
	var temp=0;
	for(var j=0; j<s.length; j++)
		{
		  var dh = s.charAt(j);

		  var hh = dh.charCodeAt(0);
			//alert(dh + ":" + hh);
		  if((hh > 31 && hh<59) || (hh > 58 && hh<91) || (hh > 90 && hh<127) || hh==169  || hh==13 || hh==10 || hh==8220 || hh==8221 || hh==8482 || hh==8217 || hh==147 || hh==148 || hh==146 || (hh>159 && hh<256))
		  {
			 /*if((j==0 || j==s.length-1) && hh == 45)	
		  	 {

		 	  	temp=1;
			      return temp;
		 	 }*/
		 	 temp = 0;
		  }
		else	{

		  	temp=1;
			 return temp;
		  }
		}
	return temp;
}

// author : Christopher Vy
//function textCounter(field, remainField, maxlimit) {
function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);// if too long...trim it!
	// otherwise, update 'characters left' counter
	}
	//else {
	//	var remainLength = maxlimit - field.value.length;
	//	remainField.innerHTML = "The number of character remains : " + remainLength;
	//}
}


function clearForm(formIdent) 
{ 
  var form, elements, i, elm; 
  form = document.getElementById 
    ? document.getElementById(formIdent) 
    : document.forms[formIdent]; 

	if (document.getElementsByTagName)
	{
		elements = form.getElementsByTagName('input');
		for( i=0, elm; elm=elements.item(i++); )
		{
			if (elm.getAttribute('type') == "text")
			{
				elm.value = '';
			}
		}
		elements = form.getElementsByTagName('textarea');
		for( i=0, elm; elm=elements.item(i++); )
		{
			elm.value = '';
		}
	}

	// Actually looking through more elements here
	// but the result is the same.
	else
	{
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text" || elm.type == "textarea")
			{
				elm.value ='';
			}
		}
	}
}

function setCombo(arrCombo){
	for (var i=0; i < arrCombo.length; i++){
		var hiddenId = arrCombo[i].id + "SelectedIndex";
		var comboValue = document.getElementById(hiddenId);
		
		if (comboValue.value != ""){
			arrCombo[i].value = comboValue.value;
		}
	}
}

var arrComboBoxes = new Array();
function addComboArr(objCombo){
	var arrLength = arrComboBoxes.length;
	arrComboBoxes[arrLength] = objCombo;
}

function correctComboText_FocusTextBox(){
	var element;
	var elements;
	var hiddenField;
	var alreadyFocus = false;
	for(var i = 0; i < document.forms.length ; i++){
		elements = document.forms[i].elements;
		for( var j = 0; j < elements.length ; j++){
			element = elements[j];
			if(element.type == "select-one"){
				hiddenField = document.getElementById(element.id + "SelectedIndex");
				if((hiddenField != null)&&(hiddenField.value != "")){
					element.value = hiddenField.value;
				}
			}else {					
				if(element.type == "text"){						
					if(!alreadyFocus){
						alreadyFocus = true;
						if(element.disabled!=true)
						{
						element.focus();
						}
					}													
				}
			}			
		}
	}
}

	