//Reformat phone number to be (xxx) xxx-xxxx format if entered in xxxxxxxxxx or xxx-xxx-xxxx format
function parsePhone (custPhone){
   var tmpPhone

   if (custPhone == ""){
	tmpPhone = "NA"
	} else {
	if (custPhone.value.length == 10){
	     tmpPhone = "("+custPhone.value.substr(0,3)+") "+custPhone.value.substr(3,3)+"-"+custPhone.value.substr(6,4)
	     } else {
	     if (custPhone.value.length == 12){
		  tmpPhone = "("+custPhone.value.substr(0,3)+") "+custPhone.value.substr(4,3)+"-"+custPhone.value.substr(8,4)
		  } else {
		  tmpPhone = custPhone.value
		  }
	     }
	}
   custPhone.value = tmpPhone

}

//Store List Pop-Up
function OpenStoreList(){
	var queryString = document.getElementById("txtCity").value+", "+getSelected(this.Form1['ddStates:ddStates'].options);
	var windowString = "StoreFinder.aspx?CS=";
	if (queryString != ""){
		windowString = windowString + queryString;
	}
	window.open(windowString,'ProductPopup','width=485,height=320,left=0,top=0');
}

function getSelected(opt) {
    var selected = "";
    var index = 0;
    for (var intLoop = 0; intLoop<opt.length; intLoop++){
        if (opt[intLoop].selected){
        selected = opt[intLoop].value;
        }
    }
    return selected;
}