function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function onSearchEnter( evt, frm ) {
  var keyCode = null;

  if( evt.which ) {
  keyCode = evt.which;
  } else if( evt.keyCode ) {
  keyCode = evt.keyCode;
  }
  if( 13 == keyCode ) {
  goToSearch();
  return false;
  }
  return true;
}

function goToSearch()
{
  var seoSearch = document.getElementById('zoom_query').value;
  while (seoSearch.indexOf(' ') >= 0) seoSearch = seoSearch.replace(' ', '-');
  allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-"
  while (seoSearch.indexOf('--') >= 0) seoSearch = seoSearch.replace('--', '-');
  var i=0;
  while (i < seoSearch.length)
  {
    currentChar = seoSearch.substr(i, 1);
    if (allowedChars.indexOf(currentChar) == -1)
    {
    while (seoSearch.indexOf(currentChar) >= 0) seoSearch = seoSearch.replace(currentChar, '');
    }
    else i++;
  }
  window.location='/search/' + seoSearch + '.html'
}

function clearBox(textboxId)
{
	if (document.getElementById(textboxId).value == "search") document.getElementById(textboxId).value = "";
}

function populateBox(textboxId)
{
	if (document.getElementById(textboxId).value == "") document.getElementById(textboxId).value = "search";
}

function updateCountry(countryClientID)
{
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	showHideStateFields(countryClientID)
	validateCustom(document.getElementById(stateDdlClientID));
	validateCustom(document.getElementById(provinceDdlClientID));
	validateCustom(document.getElementById(stateTxtClientID));
	if (c == "USA" || c == "United Arab Emirates" || c == "Antigua and Barbuda" || c == "Bahamas" || c == "Kirbati" || c == "Malta" || c == "Netherlands Antilles" || c == "Seychelles" || c == "Solomon Islands" || c == "St. Kitts and Nevis" || c == "Tonga" || c == "Tuvalu" || c == "Uzbekistan" || c == "Jamaica" || c == "Hong Kong" || c == "Japan" || c == "Afghanistan" || c == "Albania" || c == "American Samoa" || c == "Anguilla" || c == "Antarctica" || c == "Barbados" || c == "Bhutan" || c == "Bouvet Island" || c == "Brazil" || c == "British Indian Ocean Territory" || c == "Cambodia" || c == "Canada" || c == "Cayman Island" || c == "Christmas Island" || c == "Cocos (Keeling) Islands" || c == "Colombia" || c == "Cook Islands" || c == "Cote D'ivoire" || c == "Dominica" || c == "Egypt" || c == "El Salvador" || c == "European Monetary Union" || c == "Faroe Islands" || c == "France, Metropolitan" || c == "Grenada" || c == "Guadeloupe" || c == "Guam" || c == "Guyana" || c == "Heard and Mc Donald Islands" || c == "Honduras" || c == "Iraq" || c == "Italy" || c == "Korea" || c == "Korea, Democratic People's Rep" || c == "Lao People's Democratic Republic" || c == "Lebanon" || c == "Libyan Arab Jamahiriya" || c == "Macau" || c == "Micronesia, Federated States of" || c == "Montserrat" || c == "Nigeria" || c == "Palestinian Authority" || c == "Panama" || c == "Papua New Guinea" || c == "Philippines" || c == "Serbia" || c == "Somalia" || c == "South Georgia and the Sandwich Isles" || c == "Spain" || c == "St. Helena" || c == "Svalbard and Jan Mayen Islands" || c == "Thailand" || c == "Tokelau" || c == "Turks and Caicos Islands" || c == "United States Minor Outlying I" || c == "Venezuela" || c == "Virgin Islands (British)" || c == "Wallis and Futuna Islands" || c == "Yugoslavia" || c == "Oman" || c == "Australia" || c == "Marshall Islands" || c == "Mexico" || c == "Norfolk Island" || c == "Northern Mariana Islands" || c == "Palau" || c == "Samoa" || c == "Virgin Islands (U.S.)")
	{
	    document.getElementById("rowStateProvince").style.display = isIE ? "block" : "table-row";
	}
	else
	{
	    document.getElementById("rowStateProvince").style.display = "none";
		document.getElementById(stateTxtClientID).value = "Validate";
	}
}

function showHideStateFields(countryClientID)
{
	c = document.getElementById(countryClientID).value;
	if (c == "USA")
	{
		document.getElementById(stateDdlClientID).style.display = "inline";
		document.getElementById(stateDdlClientID).selectedIndex = 0;
		document.getElementById(stateTxtClientID).style.display = "none";
		document.getElementById(stateTxtClientID).value = "Validate";
		document.getElementById(provinceDdlClientID).style.display = "none";
		document.getElementById(provinceDdlClientID).selectedIndex = 1;
	}
	else if (c == "Canada")
	{
		document.getElementById(stateDdlClientID).style.display = "none";
		document.getElementById(stateDdlClientID).selectedIndex = 1;
		document.getElementById(stateTxtClientID).style.display = "none";
		document.getElementById(stateTxtClientID).value = "Validate";
		document.getElementById(provinceDdlClientID).style.display = "inline";
		document.getElementById(provinceDdlClientID).value = "";
	}
	else
	{
		document.getElementById(stateDdlClientID).style.display = "none";
		document.getElementById(stateDdlClientID).selectedIndex = 1;
		document.getElementById(stateTxtClientID).style.display = "inline";
		document.getElementById(stateTxtClientID).value = "";
		document.getElementById(provinceDdlClientID).style.display = "none";
		document.getElementById(provinceDdlClientID).selectedIndex = 0;
	}
}

function loadStateFieldStatus()
{
	 if (typeof(countryDdlClientID) != "undefined" && typeof(stateDdlClientID) != "undefined" && typeof(provinceDdlClientID) != "undefined")
	 {
		showHideStateFields(countryDdlClientID);
	 }
}

function validateState(sender, args)
{
    var selectedCountry = document.getElementById(countryDdlClientID).value;
	if (typeof(selectedCountry) != 'undefined')
	{
	    if (selectedCountry == "USA")
	    {
	        if (args.Value.length > 0) args.IsValid = true;
	        else args.IsValid = false;
	    }
	    else args.IsValid = true;
	}
	else
	{
        if (args.Value.length > 0) args.IsValid = true;
        else args.IsValid = false;
    }
} 

function validateProvince(sender, args)
{
	var selectedCountry = document.getElementById(countryDdlClientID).value;
	if (typeof(selectedCountry) != 'undefined')
	{
	    if (selectedCountry == "Canada")
	    {
	        if (args.Value.length > 0) args.IsValid = true;
	        else args.IsValid = false;
	    }
	    else args.IsValid = true;
	}
	else
	{
        if (args.Value.length > 0) args.IsValid = true;
        else args.IsValid = false;
    }
} 

function validateCustom(targetedControl)
{
	if (typeof(targetedControl.Validators) != "undefined") {
		vals = targetedControl.Validators;
	} 
	var i;
	for (i = 0; i < vals.length; i++) {
		ValidatorValidate(vals[i], null, null);
	}
	ValidatorUpdateIsValid(); 
}
var _gaq = _gaq || []; 
_gaq.push(['_setAccount', 'UA-1626336-1']); 
_gaq.push(['_trackPageview']); 

(function() { 
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); 
})(); 

window.onload=loadStateFieldStatus;
