	// function used for country dropdown list
		function gourl(s)
	{	var d = s.options[s.selectedIndex].value
		window.top.location.href = d
		s.selectedIndex=0
	}

//scrubber function
function replaceAmpersands(inputString, fromString, toString) {
	fromString = '&amp;';
	toString = '&';
// Goes through the inputString and replaces every occurrence of fromString with toString
var temp = inputString;
if (fromString == "") {return inputString;}
if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
	while (temp.indexOf(fromString) != -1) {
		var toTheLeft = temp.substring(0, temp.indexOf(fromString));
		var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
		temp = toTheLeft + toString + toTheRight;
		}
		} else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
			var midStrings = new Array("~", "`", "_", "^", "#");
			var midStringLen = 1;
			var midString = "";
			// Find a string that doesn't exist in the inputString to be used
			// as an "inbetween" string
			while (midString == "") {
				for (var i=0; i < midStrings.length; i++) {
						var tempMidString = "";
						for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
						if (fromString.indexOf(tempMidString) == -1) {
							midString = tempMidString;
							i = midStrings.length + 1;
						}
					}
			}   // Keep on going until we build an "inbetween" string that doesn't exist
			// Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
			while (temp.indexOf(fromString) != -1) {
			var toTheLeft = temp.substring(0, temp.indexOf(fromString));
			var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
temp = toTheLeft + midString + toTheRight;
	}
			// Next, replace the "inbetween" string with the "toString"
	while (temp.indexOf(midString) != -1) {
				var toTheLeft = temp.substring(0, temp.indexOf(midString));
				var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
	temp = toTheLeft + toString + toTheRight;
		}
	}   // Ends the check to see if the string being replaced is part of the replacement string or not
		return temp;   // Send the updated string back to the user
		}   

function scrublogin() {
$newurl = replaceAmpersands(loginform.powurl.value);
loginform.powurl.value = ($newurl);
loginform.submit();
}

function switchlanguage(s)
{
	var d = s.options[s.selectedIndex].value
		window.top.location.href = d
		s.selectedIndex=0
}



function filled(field) {
      if (field.value == "" || field.value == null) {;
         return false;
      } else {
         return true;
      }
}
function cansubmitsearch(form) {
 var translationform = document.forms['translationform'];
 var max=50;
      if (!filled(form.term) ) {
         alert(translationform.searcherrorterm.value);
         form.term.focus();
         return false;
      } else if (form.term.value.length <= 1)
      {
		  alert(translationform.searcherrorchar.value);
		   form.term.focus();
         return false;
      } else if (form.term.value.length > max) {
alert(translationform.searcherrorlength.value);
return false;
 }
	  
      return true;
	  
   }

function launchwtbpartner(url) {
document.upcData.action=url;
document.upcData.submit()
}

function filled(field) {
      if (field.value == "" || field.value == null) {;
         return false;
      } else {
         return true;
      }
}

function limitmessage(form) {
var max=400;
if (form.message.value.length > max) {
alert(form.emailerrorlimit.value);
return false;
   } else {
   return true;
   }
   }
function isEmailAddr(str)
{
	var validFormat = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,3})+$/;
	if (validFormat.test(str)){
return (true)
} 


}

function verifyFaxFormat(f) {
                    var n = f;
                    // Accepted formats invlude xxx-xxx-xxxx or xxxxxxxxxx (x must be a digit)
                    var acceptedFormat = /^\d{10}$|^\d{3}-\d{3}-\d{4}$/;
                    if (n.match(acceptedFormat) != null) {
                        return true;
                    } 
                    return false;
                }
                
                
                
 function canSubmitemail(form) {
  var translationform = document.forms['translationform'];
  var max=400;
      if (!filled(form.toemailaddress) ) {
         alert(translationform.emailerrorto.value);
         form.toemailaddress.focus();
         return false;
      }
      if (!filled(form.contactemailaddress)) {
      	alert(translationform.emailerrorcontact.value);
      	form.contactemailaddress.focus();
      	return false;
      }
      
	 if (form.message.value.length > max) {
		alert(translationform.emailerrorlimit.value);
		return false;
   	 } 
      
      if(!isEmailAddr(form.toemailaddress.value)) {
         alert(translationform.emailerrorto.value);
         form.toemailaddress.focus();
         return false;
      } 
      if(!isEmailAddr(form.contactemailaddress.value)) {
      	alert(translationform.emailerrorcontact.value);
      	form.contactemailaddress.focus();
      	return false;
      } 

      return true;
   }
   
   function canSubmitfax(form) {
    var translationform = document.forms['translationform'];
    if (!filled(form.toname) ) {
       alert(translationform.faxerrorto.value);
       form.toname.focus();
       return false;
    }

    if (!filled(form.fromname) ) {
       alert(translationform.faxerrorfrom.value);
       form.fromname.focus();
       return false;
    }

	if(!verifyFaxFormat(form.faxnumber.value)) {
        alert(translationform.faxerrornumberformat.value);
         form.faxnumber.focus();
         return false;
    } 
	return true;

   }

function replacestring(inputString, fromString, toString) {
// Goes through the inputString and replaces every occurrence of fromString with toString
var temp = inputString;
if (fromString == "") {return inputString;}
if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
	while (temp.indexOf(fromString) != -1) {
		var toTheLeft = temp.substring(0, temp.indexOf(fromString));
		var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
		temp = toTheLeft + toString + toTheRight;
		}
		} else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
			var midStrings = new Array("~", "`", "_", "^", "#");
			var midStringLen = 1;
			var midString = "";
			// Find a string that doesn't exist in the inputString to be used
			// as an "inbetween" string
			while (midString == "") {
				for (var i=0; i < midStrings.length; i++) {
						var tempMidString = "";
						for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
						if (fromString.indexOf(tempMidString) == -1) {
							midString = tempMidString;
							i = midStrings.length + 1;
						}
					}
			}   // Keep on going until we build an "inbetween" string that doesn't exist
			// Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
			while (temp.indexOf(fromString) != -1) {
			var toTheLeft = temp.substring(0, temp.indexOf(fromString));
			var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
temp = toTheLeft + midString + toTheRight;
	}
			// Next, replace the "inbetween" string with the "toString"
	while (temp.indexOf(midString) != -1) {
				var toTheLeft = temp.substring(0, temp.indexOf(midString));
				var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
	temp = toTheLeft + toString + toTheRight;
		}
	}   // Ends the check to see if the string being replaced is part of the replacement string or not
		return temp;   // Send the updated string back to the user
		}   

function launchscrubbedlink(url) {
	var	newurl = replacestring(url, "(AMPPOWX)", "&");
	//window.alert(newurl);
	window.top.location.href = newurl;
}

function closeWindow() {
	window.opener = "Something";
	self.close();
}
