//Region Startfunction populateStates(countrylistId, statelistid, selectedState, labelregion){	var objstate= document.getElementById(statelistid);	var objregionlabel = document.getElementById(labelregion);	var objcountry = document.getElementById(countrylistId);	objstate.options.length = 1;	var statelist = g_statelist;	 	var countryId = objcountry[objcountry.selectedIndex].value;	var countryCode = countryId.split("_")[1];	countryId = countryId.split("_")[0];		var counter = 0;	var states = new Array();		for ( i=0; i < statelist.length; i++ )	{		if ( statelist[i].refID == countryId)		{		    //copy matching states into an array		    states[counter] = { optText:statelist[i].title, optValue:statelist[i].id };		    counter++;		}	}			var postalCode = document.getElementById("PostalCode");	var postcodeDiv = document.getElementById("postCodeDiv");		// sort the states array	if(countryCode != "JP")	{        states.sort(sortAsc);        if(postcodeDiv)            postcodeDiv.style.display="inline";    }    else    {        if(postcodeDiv)            postcodeDiv.style.display="none";        if(postalCode)            postalCode.value = "11111";    }    // copy sorted options from array to states dropdown    for (var j=0; j<states.length; j++)     {        var optObj = document.createElement('option');        optObj.text = states[j].optText;        optObj.value = states[j].optValue + "_" + states[j].optText;        objstate.options.add(optObj);                if(states[j].optValue == selectedState)            optObj.selected = true;    }	if(counter > 0)	{		 	objstate.style.display='';	 	if(null != objregionlabel)	 		objregionlabel.style.display = '';	    var regionBox = $get("supxRegionB");	 	if(__supxFlow && regionBox){	 	    Sys.UI.DomElement.removeCssClass(regionBox, "hide");	 	}	}		else	{		    objregionlabel.style.display = 'none';		objstate.style.display='none';		var regionBox = $get("supxRegionB");	 	if(__supxFlow && regionBox){	 	    Sys.UI.DomElement.addCssClass(regionBox, "hide");	 	}	}}// sort function - ascending (case-insensitive)function sortAsc(r1, r2) {    var v1 = r1.optText.toLowerCase();    var v2 = r2.optText.toLowerCase();    if (v1 > v2) return(1);    if (v1 < v2) return(-1);    return(0);}function validateRegion(id, valObj) {	var country = document.getElementById('Country');	var region = document.getElementById(id);		if ((region.options != null ) && (region.options.length > 1) && 	    country[country.selectedIndex].value.split("_")[1] != 'US' && 	    country[country.selectedIndex].value.split("_")[1] != 'UK')	{		if (region.value == "" || region.value == " ") 		{			//alert("Please Select a State/Province/Territory");			updateErrLists(id, {id:id, msg:valObj.body, head:valObj.head, style:'signupinputError'}, false);			return false;		} 	}	updateErrLists(id, {style: 'signupinput'}, true);	return true;}function validateCity(id, valObj) {	var city = document.getElementById(id);		if (city.value == "" || city.value == " ") 		{			updateErrLists(id, {id:id, msg:valObj.body, head:valObj.head, style:'signupinputError'}, false);			return false;		} 	updateErrLists(id, {style: 'signupinput'}, true);	return true;}function displayPostalCodeSample(countryListId, postalCodeEleId) {    var objcountry = document.getElementById(countryListId);	var countryCode =objcountry[objcountry.selectedIndex].value.split("_")[1];	var objPostalCode = document.getElementById(postalCodeEleId);	var sampleText = GetClientString("Example") + ": ";	if(countryCode=="AU" || countryCode=="NO" || countryCode=="DK") 	{	    sampleText = sampleText + " 0123";	}	else if(countryCode=="FR" || countryCode=="DE" || countryCode=="IT" || countryCode=="ES" || 		countryCode=="MX")     {		sampleText = sampleText + " 01234";	}	else if(countryCode=="AT" || countryCode=="BE" || countryCode=="CH") 	{		sampleText = sampleText + " 1234";	}	else if(countryCode=="SE" || countryCode=="FI") 	{		sampleText = sampleText + "012 34";	}	else if(countryCode=="IN" || countryCode=="RU") 	{		sampleText = sampleText + "123456";	}	else if(countryCode=="BR") 	{		sampleText = sampleText + "01234-567";	}	else if(countryCode=="NL") 	{		sampleText = sampleText + "1111ww";	}	else if(countryCode=="PL") 	{		sampleText = sampleText + "12345 / 12-345";	}	else if(countryCode=="PT") 	{		sampleText = sampleText + "1234 / 1234-567";	}	else if(countryCode=="TR") 	{		sampleText = sampleText + "12345";	}	else if(countryCode == "UK") //TFS #37594: Validate UK postal code.	{	    sampleText = sampleText + "SO32 4NG";	}		if(sampleText != GetClientString("Example") + ": ")	{	    //{hint: "", head: "", style: ""}        SetHint(objPostalCode, {id:objPostalCode.id, hint:sampleText, head:"", style: ""});        showHint(objPostalCode);	}	else	{	    SetHint(objPostalCode, {id:objPostalCode.id, hint:"", head:"", style: ""});	    hideHint();	}}function PostalCodeMessageFocus(countryListId, postalCodeEleId){    var countrySelected = document.getElementById(countryListId);	var postalCodeCell = document.getElementById(postalCodeEleId);	var countryCode = countrySelected[countrySelected.selectedIndex].value.split("_")[1];      //TFS #37594: Validate UK postal code  	if( countryCode!="US" && countryCode!="CA" && countryCode!="AU" && 	    countryCode!="FR" && countryCode!="DE" && countryCode!="IT" && countryCode!="ES" && 	    countryCode!="AT" && countryCode!="MX" && countryCode!="SE" && countryCode!="JP" && 	    countryCode!="NL" && countryCode!="SE" && countryCode!="CH" && countryCode!="KR" && 	    countryCode!="NO" && countryCode!="DK" && countryCode!="FI")	{		SetHint(postalCodeCell, {id:postalCodeCell.id, hint:GetClientString('International_SignupPleaseEnterPostalCodeErro2'), head:"", style: ""});        showHint(postalCodeCell);    }	else	{	    SetHint(postalCodeCell, {id:postalCodeCell.id, hint:"", head:"", style: ""});        hideHint();	}}String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };function validatePostalCode(id, valObj) {	var country = document.getElementById('Country');	var postalCode = document.getElementById('PostalCode');	var countryZipCodeKey = "";	var isValid = true;	var countryCode = country.value.split('_')[1];	countryZipCodeKey = getCountryZipCodeKey(countryCode)	if(countryZipCodeKey!="") 	{		var items = countryZipCodeKey.split(":")				//Strip space from SE postal code		if (items[0] == "SE" && postalCode.value.indexOf(" " ) >= 0)		{				var temp = postalCode.value;			postalCode.value = temp.replace(/\s/g,"");		}				if (countryCode == "NL" || countryCode == "PL" || countryCode == "TR" || countryCode == "PT" || countryCode == "UK") 		{		    var countryPostalCode = postalCode.value.trim();		    //UK allows whitespace in postal code.		    if(countryCode != "UK")		{		        countryPostalCode = countryPostalCode.replace(" ","");		    }		    			if (countryPostalCode=="") 			{				//{id:ele.id, msg:msg, head:head}				updateErrLists(postalCode.id, {id:postalCode.id, msg:GetClientString('PostalCodeErrorMessage'), head:valObj.head, style:'signupinputError'}, false);				return false;			}			else			{							var postalRegEx =  "";//new RegExp(/^\d{4}\w{2}$/i);				if (countryCode == "NL") 					postalRegEx =  new RegExp(/^\d{4}( )?\w{2}$/);				if (countryCode == "PL") 					postalRegEx =  new RegExp(/^\d{2}(-)?\d{3}$/);				if (countryCode == "TR") 					postalRegEx =  new RegExp(/^\d{5}$/);				if (countryCode == "PT") 					postalRegEx =  new RegExp(/^\d{4}(-\d{3})?$/);				if (countryCode == "UK")  //TFS #37594: Validate UK postal code				    postalRegEx = new RegExp(/^[A-Za-z0-9 -_]{2,9}$/);								if(postalRegEx.test(countryPostalCode)) 				{				    updateErrLists(postalCode.id, {style: 'signupinput'}, true);					return true;				}				else 				{				    updateErrLists(postalCode.id, {id:postalCode.id, msg:GetClientString('ZipCodeErrorMessage'), head:valObj.head, style: 'signupinputError'}, false);					displayPostalCodeSample(country.id, postalCode.id);					return false;				}			}		}		if(items[1]=="1") 		{			if(postalCode.value.trim()=="") 			{			    updateErrLists(postalCode.id, {id:postalCode.id, msg:GetClientString('PostalCodeErrorMessage'), head:valObj.head, style: 'signupinputError'}, false);				return false;			}			else if(!isNumeric(postalCode.value.trim())) 			{				if(items[0] != "US" && items[0] != "UK" && items[0] != "JP" && items[0] != "CA" && items[0] != "KR" &&					items[0] != "NL" && items[0] != "SE") 				{					updateErrLists(postalCode.id, {id:postalCode.id, msg:GetClientString('LoginErrorMessage23'), head:valObj.head, style: 'signupinput'}, false);					return false;				}			}			else 			{				isValid = isValidPostalCode(items[0],postalCode.value.trim());			}		}		else 		{			isValid = isValidPostalCode(items[0],postalCode.value.trim());		}				if (!isValid) 		{		    updateErrLists(postalCode.id, {id:postalCode.id, msg:GetClientString('LoginErrorMessage18'), head:valObj.head, style: 'signupinputError'}, false);			return false;		}	}	if(isValid == true)	    updateErrLists(postalCode.id, {style: 'signupinput'}, true);	return isValid;}function isValidPostalCode(countryCode, postalCodeValue) {	if(countryCode=="AU" || countryCode=="NO" || countryCode=="DK") 	{		if(postalCodeValue.length != 4) 			return false;	}	else if(countryCode=="FR" || countryCode=="DE" || countryCode=="IT" || countryCode=="ES" || 		countryCode=="MX" || countryCode=="FI" || countryCode=="SE" ) 	{		if(postalCodeValue.length != 5) 			return false;	}	else if (countryCode=="IN" || countryCode=="CA" || countryCode=="RU") 	{		if(postalCodeValue.length != 6) 			return false;	}	else if(countryCode=="AT" || countryCode=="BE" || countryCode=="CH") 	{		if(postalCodeValue.length == 4) 		{			if(postalCodeValue.charAt(0)=="0") 				return false;		}		else 			return false;	}	else if(countryCode=="BR")	{				if(postalCodeValue.length > 9) 			return false;	}	else if (countryCode=="NL") 	{		if (postalCodeValue.length <= 6) 		{			if (postalCodeValue.charAt(0)=="0") 			{				return false;			}		} 	}	return true;}function getCountryZipCodeKey(countryCode) {	// Key - "US:0" (CountryCode:IsZipCodeRequired)	var countryCheckList = new Array("AU:1","AT:1","BE:1","CA:1","FR:1",					                  "DE:1","IT:1","JP:1","KR:1","ES:1",					                  "NL:1","CH:0","UK:1", "US:1", 					                  "MX:1","SE:1","NO:1","DK:1",					                  "FI:1", "IN:1", "BR:0","RU:1","PL:1","TR:1","PT:1");	var items;					  	for(var i=0; i<countryCheckList.length; i++) 	{		items = countryCheckList[i].split(":");		if(countryCode==items[0])			return countryCheckList[i].toString();	}	return "";}function isNumeric(s) { 	var validChars = "0123456789"; 	var c;	for (i = 0; i < s.length; i++) 	{		c = s.charAt(i);		if (validChars.indexOf(c) == -1) 			return false;	}	return true;}//Region End