// Ask for confirmation when user clicks on 'Cancel Subscription'.
function cancelConfirmed () {
	var yes = false;
	//if (cccglobal <= 0) {
		yes = confirm("Are you sure you want to cancel this subscription?");
		cccglobal = cccglobal + 1;
	//} else {
		//alert ("Your request was submitted, please wait.");
	//}
	return yes;
}	

function IsNumeric (sText) {
	var ValidChars = "0123456789.";
	var IsNumber = true;
	var Char;
	
	for (i=0; i<sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}

function validateZip () {
	var z = document.forms[0].zc.value;
	if (z.indexOf("-") > 0) 
	{
		var zParams = z.split("-");
		z = zParams[0];
	}
	
	var s = document.forms[0].state.value;
	if ( IsNumeric(z) ) {
		if (s == 'AK' && (z < 99501 || z > 99950))	return false;
		if (s == 'AL' && (z < 35004 || z > 36925)) return false;
		if (s == 'AR' && (z < 71601 || z > 72959)) {
			if (s == 'AR' && (z < 75502 || z > 75502))
				return false;
			else
				return true;
		}
		if (s == 'AZ' && (z < 85001 || z > 86556))	return false;		
		if (s == 'CA' && (z < 90001 || z > 96162)) return false;
		if (s == 'CO' && (z < 80001 || z > 81658)) return false;
		if (s == 'CT' && (z < 06001 || z > 06389)) {
			if (s == 'CT' && (z < 06401 || z > 06928))
				return false;
			else
				return true;
		}
		if (s == 'DC' && (z < 20001 || z > 20039)) {
			if (s == 'DC' && (z < 20042 || z > 20599)) {
				if (s == 'DC' && (z < 20799 || z > 20799))
					return false;
				else
					return true;
			} else {
				return true;
			}
		}
		if (s == 'DE' && (z < 19701 || z > 19980)) return false;
		if (s == 'FL' && (z < 32004 || z > 34997)) return false;
		if (s == 'GA' && (z < 30001 || z > 31999)) {
			if (s == 'GA' && (z < 39832 || z > 39901))
				return false;
			else
				return true;
		}
		if (s == 'HI' && (z < 96701 || z > 96898)) return false;
		if (s == 'IA' && (z < 50001 || z > 52809)) {
			if (s == 'IA' && (z < 68119 || z > 68120))
				return false;
			else
				return true;
		}
		if (s == 'ID' && (z < 83201 || z > 83888)) return false;
		if (s == 'IL' && (z < 60001 || z > 62999)) return false;
		if (s == 'IN' && (z < 46001 || z > 47997)) return false;
		if (s == 'KS' && (z < 66002 || z > 67954)) return false;
		if (s == 'KY' && (z < 40003 || z > 42788)) return false;
		if (s == 'LA' && (z < 70001 || z > 71232)) {
			if (s == 'LA' && (z < 71234 || z > 71497))
				return false;
			else
				return true;
		}
		if (s == 'MA' && (z < 01001 || z > 02791)) {
			if (s == 'MA' && (z < 05501 || z > 05544))
				return false;
			else
				return true;
		}
		if (s == 'MD' && (z < 20331 || z > 20331)) {
			if (s == 'MD' && (z < 20335 || z > 20797)) {
				if (s == 'MD' && (z < 20812 || z > 21930))
					return false;
				else
					return true;
			} else {
				return true;
			}
		}
		if (s == 'ME' && (z < 03901 || z > 04992)) return false;
		if (s == 'MI' && (z < 48001 || z > 49971)) return false;
		if (s == 'MN' && (z < 55001 || z > 56763)) return false;
		if (s == 'MO' && (z < 63001 || z > 65899)) return false;
		if (s == 'MS' && (z < 38601 || z > 39776)) {
			if (s == 'MS' && (z < 71233 || z > 71233)) 
				return false;
			else
				return true;
		}
		if (s == 'MT' && (z < 59001 || z > 59937)) return false;
		if (s == 'NC' && (z < 27006 || z > 28909)) return false;
		if (s == 'ND' && (z < 58001 || z > 58856)) return false;
		if (s == 'NE' && (z < 68001 || z > 68118)) {
			if (s == 'NE' && (z < 68122 || z > 69367))
				return false;
			else
				return true;
		}
		if (s == 'NH' && (z < 03031 || z > 03897)) return false;
		if (s == 'NJ' && (z < 07001 || z > 08989)) return false;
		if (s == 'NM' && (z < 87001 || z > 88441)) return false;
		if (s == 'NV' && (z < 88901 || z > 89883)) return false;
		if (s == 'NY' && (z < 06390 || z > 06390)) {
			if ( s == 'NY' && (z < 10001 || z > 14975))
				return false;
			else
				return true;
		}
		if (s == 'OH' && (z < 43001 || z > 45999)) return false;
		if (s == 'OK' && (z < 73001 || z > 73199)) {
			if (s == 'OK' && (z < 73401 || z > 74966))
				return false;
			else
				return true;
		}
		if (s == 'OR' && (z < 97001 || z > 97920)) return false;
		if(s == 'PA' && (z < 15001 || z > 19640)) return false;
		if (s == 'PR' && (z < 00600 || z > 00999)) return false;
		if (s == 'RI' && (z < 02801 || z > 02940)) return false;
		if (s == 'SC' && (z < 29001 || z > 29948)) return false;
		if (s == 'SD' && (z < 57001 || z > 57799)) return false;
		if (s == 'TN' && (z < 37010 || z > 38589)) return false;
		if (s == 'TX' && (z < 73301 || z > 73301)) {
			if (s == 'TX' && (z < 75001 || z > 75501)) {
				if (s == 'TX' && (z < 75503 || z > 79999)) {
					if (s == 'TX' && (z < 88510 || z > 88589))
						return false;
					else
						return true;
				} else
					return true;
			} else
				return true;
		}
		if (s == 'UT' && (z < 84001 || z > 84791)) return false;
		/*if (s == 'VA' && (z < 20040 || z > 20041)) {
			if (s == 'VA' && (z < 20040 || z > 20172)) {
				if (s == 'VA' && (z < 20042 || z > 20042)) {
					if (s == 'VA' && (z < 22001 || z > 24658))
						return false;
					else
						return true;
				} else
					return true;
			} else
				return true;
		} ANTHONY SIMPLIFIED TO BELOW VALIDATION*/  
		
		if (s == 'VA' && (z < 20101 || z > 24658)) return false;
		
		if (s == 'VT' && (z < 05001 || z > 05495)) {
			if (s == 'VT' && (z < 05601 || z > 05907))
				return false;
			else
				return true;
		}
		if (s == 'WA' && (z < 98001 || z > 99403)) return false;
		if (s == 'WI' && (z < 53001 || z > 54990)) return false;
		if (s == 'WV' && (z < 24701 || z > 26886)) return false;
		if (s == 'WY' && (z < 82001 || z > 83128)) return false;
    
		return true;
	} else if ((s=='AA')||(s=='AB')||(s=='AE')||(s=='AP')||(s=='AS')||(s=='BC')||(s=='FM')||(s=='FO')||(s=='GU')||(s=='LB')||(s=='MB')||(s=='MH')||(s=='MP')||(s=='NB')||(s=='NF')||(s=='NS')||(s=='NT')||(s=='ON')||(s=='PE')||(s=='PW')||(s=='QC')||(s=='SK')||(s=='VI')||(s=='YT')) {
		return true;
	} else {
		return false;
	}
}

function addPlusToZip() {
	if (document.forms[0].zcplus.value != "") {
		var zcd = document.forms[0].zc.value;
		zcd = zcd + "-" + document.forms[0].zcplus.value;
		document.forms[0].zc.value = zcd;
	}
}

function get2Digits (v) {
	if (v < 10) {
		return ("0"+v);
	}
	return v;
}

// Get a ficticious email address
function getEmail (pubcode) {
	var now = new Date();
	var year = now.getFullYear();
	var month = now.getMonth();
	var date = now.getDate();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	
	month = get2Digits(month+1);
	//alert ("Month: "+month);
	date = get2Digits(date);
	//alert ("Date: "+date);	
	hours = get2Digits(hours);
	//alert ("Hours: "+hours);
	minutes = get2Digits(minutes);
	//alert ("Minutes: "+minutes);	
	seconds = get2Digits(seconds);
	//alert ("Seconds: "+seconds);
	
	return (year+month+date+"-"+hours+minutes+seconds+"@"+pubcode+".com");
}		

// checks to see if atleast one element is selected in given array
function arValidator (name,ar) {
	//alert ("In the rbValidator: "+ar);
	var i=0;
	var isOk = false;
	while (i < ar.length) {
		if (ar[i].checked)	{
			//alert ("Found Checked");
			isOk = true;
			break;
		}
		i = i + 1;
	}
	//alert ("Out of While in rbValidator");
	if (!isOk) {
		alert (name + " is required.");
	}
	return isOk;
}

// checks to see if value provides is not null or empty
function svValidator (name, val) {
	//alert ("Val: "+val);
	if (val == "" || val == null || val == "(Select state)") {
		alert (name + " is required.");
		return false;
	}
	return true;
}

// controls the enable/disable of the textbox associated with radiobuttons array
function enableTB (ctrlname, action) {
	var i = 0;
	//alert ("Action: "+action);
	while (i < document.forms[0].elements.length) {
		//alert (document.forms[0].elements[i].name);
		if (document.forms[0].elements[i].name == ctrlname) {
			document.forms[0].elements[i].disabled = action;
			//alert (document.forms[0].elements[i].disabled);
			break;
		}
		i = i + 1;
	}
}

// Flip-Flop 'None of the above' option
function ffNOA (ctrl) {
	var i = 0;
	//alert ("length: "+ctrl.length);
	//alert ("Checked?: "+ctrl[ctrl.length-1].checked);
	if (ctrl[ctrl.length-1].checked) {
		for (i=0; i<ctrl.length-1; i++) {
			ctrl[i].checked = false;
		}
	}
	
	// check to see if other was clicked before selecting 'noa', if yes then pass a code back so that its disabled
}

// Flip-Flop 'None of the above' option
function ffNOA1 (ctrl) {
	var i = 0;
	//alert ("length: "+ctrl.length);
	//alert ("Checked?: "+ctrl[ctrl.length-1].checked);
	if (ctrl[ctrl.length-1].checked || ctrl[ctrl.length-2].checked) {
		for (i=0; i<ctrl.length-2; i++) {
			ctrl[i].checked = false;
			if (ctrl[ctrl.length-2].checked) {
				ctrl[ctrl.length-1].checked = false;
			}
			if (ctrl[ctrl.length-1].checked) {
				ctrl[ctrl.length-2].checked = false;
			}
		}
	}
	
	// check to see if other was clicked before selecting 'noa', if yes then pass a code back so that its disabled
}
		
// Validates if textbox corresponding to radiobutton or checkbox or combobox is empty or not even after user selecting that option
function isEmpty (ctrl) {
	//alert ("name: "+ctrl.name);
	//alert("value: "+ctrl.value);
	//alert("status: "+ctrl.disabled);
	if ((!ctrl.disabled) && (ctrl.value == "")) {
		//alert("status: "+ctrl.disabled);
		return true;
	}
	return false;
}

// controls the enable/disable of the textbox associated with drop down box
function ddlCtrlTB (ctrltochange, callerctrl, valuetocheck, valuetochangeto) {
//	alert ("In the ddlCtrlTB");
	var i = 0;
//	alert ("CtrlToChange: "+ctrltochange+"<BR>CallerCtrl: "+callerctrl+"<BR>ValueToCheck: "+valuetocheck+"<BR>ValueToChangeTo: "+valuetochangeto);
	while (i < document.forms[0].elements.length) {
		if (document.forms[0].elements[i].name == callerctrl) {
			//alert ("Found: "+document.forms[0].elements[i].name);
			//alert ("Its value is: "+document.forms[0].elements[i].value);
			if (document.forms[0].elements[i].value == valuetocheck) {
				document.forms[0].elements[ctrltochange].disabled = valuetochangeto;
				//alert ("Changed to: "+document.forms[0].elements[ctrltochange].disabled);
				break;
			} else {
				document.forms[0].elements[ctrltochange].disabled = !valuetochangeto;
				//alert("Changed To: "+document.forms[0].elements[ctrltochange].disabled);
				break;
			}
		}
		i = i + 1;
	}
}

// controls the enable/disable of the textbox associated with checkbox array
function disableTB (ctrlname) {
	var i = 0;
	//alert (ctrlname);
	//alert (document.forms[0].elements[0].name);
	//alert (document.forms[0].elements[0].value);
	while (i < document.forms[0].elements.length) {
		//alert(document.forms[0].elements[i].name);
		if (document.forms[0].elements[i].name == ctrlname) {
			document.forms[0].elements[i].disabled = document.forms[0].elements[i].disabled ^ true;
			//alert (document.elements[i].disabled);
		}
		i = i + 1;
	}
}
// controls the enable/disable of the textbox associated with checkbox array
function ToggleTB(obj,ctrlname)
 {
	var i = 0;
	while (i < document.forms[0].elements.length) {
		if (document.forms[0].elements[i].name == ctrlname) {
			
			if (obj.checked)
				document.forms[0].elements[i].disabled = false;
			else
				document.forms[0].elements[i].disabled = true;
		}
		i = i + 1;
	}
}

// creates a string output seperated by , for array of checkbox
function setCB (cba) {
	var i = 0;
	var tv = "";
	while (i < cba.length) {
		if (cba[i].checked) {
			tv += cba[i].value + ",";
		}
		i = i + 1;
	}
	tv = tv.substring(0, tv.length-1);
	//alert ("tv: "+tv);
	return tv;
}

// reads all the query string values passed
function getQS () {
	var pos = 0;
	var key = "";
	var val = "";
	var aqs = new Array();
	var qs = window.location.search.substring(1);
	//alert ("qs: "+qs);
	var vps = qs.split('&');
	//alert ("# of Parameters: "+vps.length);
	for (var i=0; i<vps.length; i++) {
		pos = vps[i].indexOf('=');
		if (pos > 0) {
			key = vps[i].substring(0,pos);
			//alert ("Key: "+ key);
			val = vps[i].substring(pos+1);
			//alert ("Val: " + val);
			aqs[key] = val;
		}
	}
	return aqs;
}

// if no country is passed this method will populate the country combo-box with all the country names
function fillAllTheCountries() {
	var sElement = document.getElementById("country");
	var countries = new Array 
		("(New Subscription - Select Country)", "ALBANIA", "ALGERIA", "AMERICAN SAMOA", "ANDORRA", "ANGOLA", "ANTARCTICA", "ANTIGUA", 
			"ARGENTINA", "ARMENIA", "ARUBA", "ASCENSION", "AUSTRALIA", "AUSTRIA", "AZERBAIJAN", "BAHAMAS", "BAHRAIN", "BANGLADESH", 
			"BARBADOS", "BELARUS", "BELGIUM", "BELIZE", "BENIN", "BERMUDA", "BHUTAN", "BOLIVIA", "BOTSWANA", "BOZNIA-HERZEGOVINA", 
			"BRAZIL", "BRITISH VIRGIN ISLANDS", "BRITISH WEST INDIES", "BRUNEI", "BULGARIA", "BURKINA FASO", "BURMA", "BURUNDI", "CAMBODIA", 
			"CAMEROON", "CANADA", "CANARY ISLANDS", "CAPE VERDE ISLANDS", "CAYMAN ISLANDS", "CENTRAL AFRICAN REPUBLIC", "CHAD", 
			"CHANNEL ISLANDS", "CHATHAM ISLAND", "CHILE", "CHINA", "CHRISTMAS ISLAND", "CIS", "COCOS ISLANDS", "COLOMBIA", "COMOROS", 
			"CONGO", "COOK ISLANDS", "COSTA RICA", "CROATIA", "CUBA", "CURACO", "CYPRUS", "CZECH REPUBLIC", "DENMARK", "DIEGO GARCIA", 
			"DJIBOUTI", "DOMINICA", "DOMINICIAN REPUBLIC", "EASTER ISLAND", "ECUADOR", "EGYPT", "EL SALVADOR", "EQUATORIAL GUINEA", 
			"ERITREA", "ESTONIA", "ETHIOPIA", "FAEROE ISLANDS", "FALKLAND ISLANDS", "FIJI", "FINLAND", "FRANCE", "FRENCH ANTILLES", 
			"FRENCH GUIANA", "FRENCH POLYNESIA", "FSM", "GABON", "GAMBIA", "GEORGIA", "GERMANY", "GHANA", "GIBRALTAR", "GINEA-BISSAU", 
			"GREECE", "GREENLAND", "GRENADA", "GRENADIN ISLANDS", "GUADELOUPE", "GUANTANAMO BAY", "GUATEMALA", "GUINEA", "GUYANA", 
			"HAITI", "HONDURAS", "HONG KONG-SAR", "HUNGARY", "ICELAND", "INDIA", "INDONESIA", "IRAN", "IRAQ", "IRELAND, REPUBLIC OF","ISLE OF MAN", "ISRAEL", "ITALY", 
			"IVORY COAST", "JAMAICA", "JAPAN", "JORDAN", "KAZAKHSTAN", "KENYA", "KIRIBATI", "KUWAIT", "KYRGYSTAN", "LAOS", "LATVIA", "LEBANON", 
			"LESOTHO", "LIBERIA", "LIBYA", "LIECHTENSTEIN", "LITHUANIA", "LUXEMBOURG", "MACAO", "MACEDONIA", "MADAGASCAR", "MALAWI", 
			"MALAYSIA", "MALDIVES REPUBLIC", "MALI", "MALTA", "MARSHALL ISLANDS", "MARTINIQUE", "MAURITANIA", "MAURITIUS", "MAYOTTE", 
			"MEXICO", "MIDWAY ISLANDS", "MIQUELON", "MOLDOVA", "MONACO", "MONGOLIA", "MONTSERRAT", "MOROCCO", "MOZAMBIQUE", "NAMIBIA", 
			"NAURU", "NEPAL", "NETHERLANDS", "NETHERLANDS ANTILLES", "NEVIS", "NEW CALCEDONIA", "NEW GUINEA", "NEW ZEALAND", "NICARAGUA", 
			"NIGER", "NIGERIA", "NIUE", "NORFOLK ISLAND", "NORTH KOREA", "NORWAY", "OMAN", "PAKISTAN", "PALAU", "PANAMA", "PAPAU NEW GUINEA", 
			"PARAGUAY", "PERU", "PHILIPPINES", "POLAND", "PORTUGAL", "PRINCIPE", "QATAR", "REPUBLIC OF MACEDONIA", 
			"REUNION ISLANDS", "ROMANIA", "RUSSIAN FEDERATION", "RWANDA", "SAIPAN", "SAN MARINO", "SAO TOME", "SAUDI ARABIA", "SENEGAL REPUBLIC", "SERBIA", 
			"SEYCHELLES", "SIERRA LEONE", "SINGAPORE", "SLOVAKIA", "SLOVENIA", "SOLOMON ISLANDS", "SOMALIA", "SOUTH AFRICA", "SOUTH KOREA", 
			"SPAIN", "SRI LANKA", "ST HELENA", "ST KITTS", "ST LUCIA", "ST PIERRE", "ST VINCENT", "SUDAN", "SURINAME", "SWAZILAND", "SWEDEN", 
			"SWITZERLAND", "SYRIA", "TAHITI", "TAIWAN ROC", "TAJIKISTAN", "TANZANIA", "THAILAND", "TIBET", "TOGO", "TONGA", "TRINIDAD & TOBAGO", 
			"TUNISIA", "TURKEY", "TURKMENISTAN", "TURKS & CAICOS ISLANDS", "TUVALU", "UGANDA", "UKRAINE", "UNITED ARAB EMIRATES", 
			"UNITED KINGDOM", "URUGUAY", "UZBEKISTAN", "VANUATU", "VATICAN CITY", "VENEZUELA", "VIETNAM", "WAKE ISLAND", 
			"WALLIS & FUTUNA ISLANDS", "WESTERN SOMOA", "YEMEN", "YUGOSLAVIA", "ZAIRE", "ZAMBIA", "ZIMBABWE");
		
	for (var i=0; i < countries.length; i++) {
		if (i==0) {
			document.forms[0].ctry.options[i] = new Option(countries[i],'',false,false);
		} else {
		document.forms[0].ctry.options[i] = new Option(countries[i],countries[i],false,false);
		}
	}
}
// if no country is passed this method will populate the country combo-box with all the country names
function fillEuroCountries() {
	var sElement = document.getElementById("country");
	var countries = new Array 
		("(New Subscription - Select Country)", "AUSTRIA", "BELGIUM", "BOZNIA-HERZEGOVINA", "CROATIA", "CYPRUS", "CZECH REPUBLIC", "DENMARK", "ESTONIA", "FINLAND", "FRANCE", 
"GERMANY", "GREECE", "HUNGARY", "ICELAND","IRELAND, REPUBLIC OF", "ITALY", "LATVIA", "LITHUANIA", "LUXEMBOURG", "MACEDONIA", "MALTA", 
"NETHERLANDS", "NORWAY", "POLAND", "PORTUGAL", "ROMANIA", "RUSSIAN FEDERATION", "SLOVAKIA","SLOVENIA", "SPAIN", "SWEDEN", 
"SWITZERLAND", "UKRAINE", "UNITED KINGDOM");
		
	for (var i=0; i < countries.length; i++) {
		if (i==0) {
			document.forms[0].ctry.options[i] = new Option(countries[i],'',false,false);
		} else {
			document.forms[0].ctry.options[i] = new Option(countries[i],countries[i],false,false);
		}
	}
}
// fills combo box with passed country	
function fillEuroCountry() {
	var qs = new Array();
	qs = getQS();
		
	if (qs['countryname'] == undefined) {
		fillEuroCountries();
	} else {
		if (qs['countryname'] != "") {
			//alert ("In If");
			//sElement.options.add(oElement);
			var cn = qs['countryname'];
			var cna = cn.split("+");
			cn = "";
			for (i=0; i<cna.length-1; i++) {
				cn += cna[i] + " ";
			}
			cn += cna[cna.length-1];
			document.forms[0].ctry.options[0] = new Option(cn,cn,false,false);
			//alert ("Country: "+cn);
		} else {
			//alert ("In Else");
			fillEuroCountries();
		}
	}
}


// fills combo box with passed country	
function fillCountry() {
	var qs = new Array();
	qs = getQS();
	//var oElement = document.createElement("option");
	//var sElement = document.getElementById("country");
		//alert ("countrypay: "+document.forms[0].ctry);	
		
	if (qs['countryname'] == undefined) {
		fillAllTheCountries();
	} else {
		if (qs['countryname'] != "") {
			//alert ("In If");
			//sElement.options.add(oElement);
			var cn = qs['countryname'];
			var cna = cn.split("+");
			cn = "";
			for (i=0; i<cna.length-1; i++) {
				cn += cna[i] + " ";
			}
			cn += cna[cna.length-1];
			document.forms[0].ctry.options[0] = new Option(cn,cn,false,false);
			//alert ("Country: "+cn);
		} else {
			//alert ("In Else");
			fillAllTheCountries();
		}
	}
}


function getSubscriberAndEmailID(){
	var sURL = window.document.URL.toString();
	var sidValue = "";
	var eidValue = "";	
	var ctrk_eidValue = "";		
	var ctrk_bidValue = "";			
	
	if (sURL.indexOf("?") > 0) {
		var arrParams = sURL.split("?");
			
		var arrURLParams = arrParams[1].split("&");
		
		var arrParamNames = new Array(arrURLParams.length);
		var arrParamValues = new Array(arrURLParams.length);
		
		var i = 0;
		for (i=0;i<arrURLParams.length;i++) {
			var sParam =  arrURLParams[i].split("=");
			arrParamNames[i] = sParam[0];
			if (sParam[1] != "")
				arrParamValues[i] = unescape(sParam[1]);
			else
				arrParamValues[i] = "No Value";
		}
		
		for (i=0;i<arrURLParams.length;i++) {
			if(arrParamNames[i] == "subID"){
				sidValue = arrParamValues[i];
				document.frmsub.user_SUBSCRIBERID.value = sidValue;
				//alert("sid:"+document.frmsub.user_SUBSCRIBERID.value);
			}else if(arrParamNames[i] == "eID"){
				eidValue = arrParamValues[i];
				document.frmsub.ei.value = eidValue;
				//alert("eid:"+document.frmsub.ei.value);				
			}else if(arrParamNames[i] == "ctrk_eid"){
				ctrk_eidValue = arrParamValues[i];
				if( !(ctrk_eidValue == null) && !(ctrk_eidValue.length == 0) && !(ctrk_eidValue == 'No Value')){
					document.frmsub.ctrk_eid.value = ctrk_eidValue;
				}
				//alert("eid:"+document.frmsub.ctrk_eid.value);				
			}else if(arrParamNames[i] == "ctrk_bid"){
				ctrk_bidValue = arrParamValues[i];
				if( !(ctrk_bidValue == null) && !(ctrk_bidValue.length == 0) && !(ctrk_bidValue == 'No Value')){
					document.frmsub.ctrk_bid.value = ctrk_bidValue;
				}
				//alert("ctrk_bid:"+document.frmsub.ctrk_bid.value);				
			}
		}
	}
	checkForZip();
}

function checkForZip() {
    var zip = document.forms[0].zc.value;
    if (zip.length > 6) {
        /*
        //var izc = document.getElementById("zc");
        //izc.value = zip.substring(0,4);
        document.forms[0].zc.value = zip.substring(0,5);
        //var izcp = document.getElementById("zcplus");
        //izcp.value = zip.substring(6,zip.length);
        if (document.forms[0].zcplus) {
        document.forms[0].zcplus.value = zip.substring(6,zip.length);
        }
        */
        if (document.forms[0].zcplus) {
            document.forms[0].zc.value = zip.substring(0, 5);
            document.forms[0].zcplus.value = zip.substring(6, zip.length);
        }
    }
}
	
	
function setPromo() {
	var qs = getQS();
	
	if (qs['promoCode'] != "" && qs['promoCode'] != undefined) {
		document.frmsub.user_DEMO39.value = qs['promoCode'];
	}
}	

function getDemo7() {
	var qs = getQS();
	
	if (qs['demo7'] == "b" || qs['demo7'] == "B") {
		return true;
	}else{
		return false;	
	}
}

function setPromoOne(){
  var qs = getQS();	
  var promoValue = (qs['promoCode']);
  if (promoValue != '' && promoValue != undefined)
  {
	  document.getElementById('DEMO39').value = promoValue;
	  
  }	
}


function setPromoTwo(){
  var qs = getQS();	
  var promoValue = (qs['promoCode']);
  if (promoValue != '' && promoValue != undefined)
  {
	  removeAllOptions(document.getElementById('DEMO39'));
	  addOption(document.getElementById('DEMO39'), promoValue, promoValue);
  }	
}

function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}

function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}


function checkKeyPressForInteger(oEvent){

		var keyCode;
		
		if(window.event) {
			// for IE, e.keyCode or window.event.keyCode can be used
			keyCode = oEvent.keyCode; 
		}
		else if(oEvent.which)
		{	// for Netscape and Mozilla
			keyCode = oEvent.which;
		}
		
				
		//Minus is allowed only as first char
		if (keyCode == 45){
			oEvent.returnValue = false;
			return false;
		}

		//only 0..9,-,backspace and non-keycode chars(del, arrows, ...)
		if((keyCode < 48 || keyCode > 57) && (keyCode != 45) && (keyCode != 8) && (keyCode != 0)) {
			oEvent.returnValue = false;
			return false;
		}
}