function windowOpenCQAR(url)
{
	var w = "792";
	var h = 528;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var args = 'status=yes, resizable=yes, scrollbars=yes,height='+h+',width='+w+',top='+wint+',left='+winl	
	var win = window.open( url, 0, args );
	if (win)
	{
		win.focus();
	}
	else
	{
		alert("Error#1: Unable to focus window.");
	}
}

function windowOpenOLS(url)
{
	windowprops = "height=600,width=800,location=yes,scrollbars=yes,menubar=yes,toolbar=yes,resizable=yes";
	window.open(url, "Popup", windowprops);
}

function isInteger (s)
{
	var i;
	if (isEmpty(s))
		if (isInteger.arguments.length == 1) return false;
		else return (isInteger.arguments[1] == true);
	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}
	return true;
}

function isDigit (c)
{
	return ((c >= '0') && (c <= '9'))
}

function isEmpty(s)
{
	return ((s == null) || (s.length == 0))
}

function ValidateAndSendBanner(form)
{
	var url = 'http://www.progressiveagent.com/redirect/qtstartbanner.aspx?drv=bnr';
	var agentCode = getDriveCode();
	var prodCode;
	url = AppendUrlParameter(url, 'agt_cd', agentCode);
	
	var product = form.Product;
	if (product)
	{
		if(product.value == '')
		{
			alert('Please select a choice from the drop-down.');
			product.focus();
			return false;
		}
		else
		{
			if(product.value.indexOf('-') > -1) {
				prodCode = product.value.split('-');			
			
				url = AppendUrlParameter(url, 'prod_cd', prodCode[0]);	
				url = AppendUrlParameter(url, 'veh_typ', prodCode[1]);	
			}
			else {
				url = AppendUrlParameter(url, 'prod_cd', product.value);
			}
		}
	}
	var zip = form.ZIP;
	if (zip)
	{
		if((zip.value.length != 5) || (!isInteger(zip.value)))
		{
			alert("Zip code must be 5 digits long (No non numeric characters allowed).");
			zip.focus();
			zip.select();
			return false;
		}
		else
		{
			url = AppendUrlParameter(url, 'zip_cd', zip.value);
		}
	}
	window.open(url);
	return false;
}

document.onkeydown=function(e){
	if (!e) var e = window.event;
	var code=e.keyCode ? e.keyCode:e.which;
	if(code==13)
	{
	
	
		if(e.srcElement.name == 'drvzip5fld')
		{
			validateAndSend();
			return false;
		}
		
	}
}

function AppendUrlParameter(url, parameterName, parameterValue)
{
	if (parameterValue != '')
	{
		var connector = '?';
		if (url.indexOf(connector) != -1)
		{
			connector = '&';
			if (url.lastIndexOf(connector) == url.Length - 1)
			{
				connector = '';
			}
		}
		url += connector + parameterName + '=' + parameterValue;
	}
	return url;
}




