function loadResponsePage() {
	var queryString = window.location.search.substring(1);
	val = getParameterValue(queryString, "val");
	document.getElementById('drLocZipTxt').value = val;	
	if(!val || val==''){
		val = "30097";
		document.getElementById('drLocZipTxt').value = "";
	}
	//document.getElementById('drLocZipTxt').value = val;
	getECPResults(val);
	
}

function loadIFrm() 
{
	
	val = document.getElementById('drLocZipTxt').value;
	getECPResults(val);
}

function getECPResults(val)
{
	//check if valid zip
	if( isValidZip(val) ) postalCode = val;

	var url1 = document.URL;
	var url2 = url1.replace('http://','');
	var url3 = url2.replace('https://','');

	var url4 = new Array();
	var url4 = url3.split('/');

	var url5 = url4[0];
	var cDom = url5;

	var url ="http://get.cibavision.com/index.shtml?brandSite=Y&brandSiteURL="+cDom+"&country=USA&bic=Y&flex=O2OPTIX OR NIGHTDAY&postalCd="+postalCode;
	document.getElementById('drLocatorFrame').src = url;
	document.getElementById('drLocatorFrame').style.display="block";
}

function isValidZip(val)
{
  return (/^\d{5}([- ]?\d{4})?$/.test(val));
}

function loadLocatorPage() {
	//alert('Hi');
	var val = document.getElementById('drLocZip').value;
	if(!isNaN(val))
		location.href="/doctor-locator/index.shtml?val="+val;
	else
		alert('Enter a valid zip code');
}

function loadLocatorPage_1() {
	var val = document.getElementById('drLocZip_1').value;
	if(!isNaN(val))
		location.href="/doctor-locator/index.shtml?val="+val;
	else
		alert('Enter a valid zip code');
}
function loadLocatorPage_vis() {
	try 
	{ 
		pageTracker._trackEvent("Free_Trial_Generic","FT_Confirmation","FT_Confirmation_Find_An_ECP");
	} 
	catch(err) {}
	var val = document.getElementById('drLocZip_1').value;
	if(!isNaN(val))
		window.parent.location.href="http://www.airoptix.com/doctor-locator/index.shtml?val="+val;
	else
		alert('Enter a valid zip code');
}
function loadLocatorPage_frm() {
	var val = document.getElementById('drLocZipTxt').value;
	if(!isNaN(val))
		location.href="/doctor-locator/index.shtml?val="+val;
	else
		alert('Enter a valid zip code');
}

//function gives the parameter value from the query string, takes query string and parameter name as parameters
function getParameterValue(queryString,parameterName){
	var paramName = parameterName + "=";
	var begin;
	var end;
	if(queryString.length > 0){
		begin = queryString.indexOf(paramName);
		if(begin != -1){
			begin = begin + paramName.length;
			end = queryString.indexOf("&",begin);
			if(end == -1)
				end = queryString.length;
			return queryString.substring(begin,end);
		}
	}
	return null;
}