﻿
function showHide(idToShow, idToHide) {	hideElement(idToHide); showElement(idToShow); }
function showElement(idToShow){ $(idToShow).style.display = 'inline'; }
function hideElement(idToHide){ $(idToHide).style.display = 'none'; }

// this function will prevent multiple form submissions...
// - it should be in the onsubmit event for every form tag
// - ex.  onsubmit="return checkandsubmit()"
var requestSubmitted = false;
function checkandsubmit() { if (requestSubmitted) return false; requestSubmitted = true; return true; }
function checkandsubmitWaitpage(){ showWaitpage(); checkandsubmit(); }
function showWaitpage(){ showHide("pnlWaitScreen", "pnlAllContent"); resetProgress(); runProgress(); }

function trim (str) {
  return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function popUp(url) 
{
   sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
   self.name = "mainWin";
}

function LanguageRedirect(strCulture)
{
   if (strCulture != "")
   {
		redirectTo = location.protocol + "//" + location.host + location.pathname + "?Culture=" + strCulture;
		window.location = redirectTo;
   }
}

function GetFullId(strPartialId, strTagName)
{
	var strId; var aColl = document.getElementsByTagName(strTagName);
	for (i=0; i < aColl.length; i++) {
      strId = aColl[i].id;
      if (strId.indexOf(strPartialId) > -1) {break;}
      else {strId = "";}
   }
   return strId;
}

function GetSelectTagFullId(strPartialId){ return GetFullId(strPartialId, "SELECT"); }
function GetSpanTagFullId(strPartialId){ return GetFullId(strPartialId, "SPAN"); }
function GetInputTagFullId(strPartialId){	return GetFullId(strPartialId, "INPUT"); }

function SelectValueFromList(ddlPartialId, strValue)
{
	var ddlFullId = GetSelectTagFullId(ddlPartialId);
	var list = $(ddlFullId);
	list.value = strValue;
}

function GetStateOptionsStatic(ddlPartialId, country) {
	var list = $(GetSelectTagFullId(ddlPartialId));
	list.options.length = 0;
	list.options[list.options.length] = new Option('-- No Selection --','0',true,true);
	switch (country)
	{
		case 'USA':
			list.options[list.options.length] = new Option('Alabama','AL'); list.options[list.options.length] = new Option('Alaska','AK');
			list.options[list.options.length] = new Option('Arizona','AZ'); list.options[list.options.length] = new Option('Arkansas','AR');
			list.options[list.options.length] = new Option('California','CA'); list.options[list.options.length] = new Option('Colorado','CO');
			list.options[list.options.length] = new Option('Connecticut','CT'); list.options[list.options.length] = new Option('Delaware','DE');
			list.options[list.options.length] = new Option('Florida','FL'); list.options[list.options.length] = new Option('Georgia','GA');
			list.options[list.options.length] = new Option('Guam','GU'); list.options[list.options.length] = new Option('Hawaii','HI');
			list.options[list.options.length] = new Option('Idaho','ID'); list.options[list.options.length] = new Option('Illinois','IL');
			list.options[list.options.length] = new Option('Indiana','IN'); list.options[list.options.length] = new Option('Iowa','IA');
			list.options[list.options.length] = new Option('Kansas','KS'); list.options[list.options.length] = new Option('Kentucky','KY');
			list.options[list.options.length] = new Option('Louisiana','LA'); list.options[list.options.length] = new Option('Maine','ME');
			list.options[list.options.length] = new Option('Maryland','MD'); list.options[list.options.length] = new Option('Massachusetts','MA');
			list.options[list.options.length] = new Option('Michigan','MI'); list.options[list.options.length] = new Option('Minnesota','MN');
			list.options[list.options.length] = new Option('Mississippi','MS'); list.options[list.options.length] = new Option('Missouri','MO');
			list.options[list.options.length] = new Option('Montana','MT'); list.options[list.options.length] = new Option('Nebraska','NE');
			list.options[list.options.length] = new Option('Nevada','NV'); list.options[list.options.length] = new Option('New Hampshire','NH');
			list.options[list.options.length] = new Option('New Jersey','NJ'); list.options[list.options.length] = new Option('New Mexico','NM');
			list.options[list.options.length] = new Option('New York','NY'); list.options[list.options.length] = new Option('North Carolina','NC');
			list.options[list.options.length] = new Option('North Dakota','ND'); list.options[list.options.length] = new Option('Ohio','OH');
			list.options[list.options.length] = new Option('Oklahoma','OK'); list.options[list.options.length] = new Option('Oregon','OR');
			list.options[list.options.length] = new Option('Pennsylvania','PA'); list.options[list.options.length] = new Option('Puerto Rico','PR');
			list.options[list.options.length] = new Option('Rhode Island','RI'); list.options[list.options.length] = new Option('South Carolina','SC');
			list.options[list.options.length] = new Option('South Dakota','SD'); list.options[list.options.length] = new Option('Tennessee','TN');
			list.options[list.options.length] = new Option('Texas','TX'); list.options[list.options.length] = new Option('Utah','UT');
			list.options[list.options.length] = new Option('Vermont','VT'); list.options[list.options.length] = new Option('Virgin Islands','VI');
			list.options[list.options.length] = new Option('Virginia','VA'); list.options[list.options.length] = new Option('Washington','WA');
			list.options[list.options.length] = new Option('Washington DC','DC'); list.options[list.options.length] = new Option('West Virginia','WV');
			list.options[list.options.length] = new Option('Wisconsin','WI'); list.options[list.options.length] = new Option('Wyoming','WY');
			new Effect.Appear('pnlStateProvince', {duration:0.3});
			break;
		case 'CAN':
			list.options[list.options.length] = new Option('Alberta','AB'); list.options[list.options.length] = new Option('British Columbia','BC');
			list.options[list.options.length] = new Option('Manitoba','MB'); list.options[list.options.length] = new Option('New Brunswick','NB');
			list.options[list.options.length] = new Option('Newfoundland','NF'); list.options[list.options.length] = new Option('Northwest Territories','NT');
			list.options[list.options.length] = new Option('Nova Scotia','NS'); list.options[list.options.length] = new Option('Nunavut','NU');
			list.options[list.options.length] = new Option('Ontario','ON'); list.options[list.options.length] = new Option('Prince Edward Island','PE');
			list.options[list.options.length] = new Option('Quebec','QC'); list.options[list.options.length] = new Option('Saskatchewan','SK');
			list.options[list.options.length] = new Option('Yukon','YK');
			new Effect.Appear('pnlStateProvince', {duration:0.3});
			break;
		default:
			new Effect.Fade('pnlStateProvince', {duration:0.3});
	}
}
