jQuery.parseQuery=function(A,B){var C=(typeof A==="string"?A:window.location.search),E={f:function(F){return unescape(F).replace(/\+/g," ")}},B=(typeof A==="object"&&typeof B==="undefined")?A:B,E=jQuery.extend({},E,B),D={};jQuery.each(C.match(/^\??(.*)$/)[1].split("&"),function(F,G){G=G.split("=");G[1]=E.f(G[1]);D[G[0]]=D[G[0]]?((D[G[0]] instanceof Array)?(D[G[0]].push(G[1]),D[G[0]]):[D[G[0]],G[1]]):G[1]});return D};

function chkV(obj) {
	for(var i=0; i<obj.length; i++) {
		if(obj[i].selected){
			if(obj[i].value == 'FAIR' || obj[i].value == 'POOR'){ 
			document.getElementById("pom").style.display = 'block';
			}else{
			document.getElementById("pom").style.display = 'none';
			}
		 }
	}       
}
    
function chkYN(obj) {
	isInternalClick = true;
	for(var i=0; i<obj.length; i++) {
		if(obj[i].selected){
			if(obj[i].value == 'YES'){ 
			    _showPrompt = false; 
				window.location = 'http://www.nycmortgage.com/lateMortgage.php'; //'http://www.neighborhoodassistance.com/indexlm.php?PPCID=1';
			}
		 }
	}       
}
		
function validate() {
	var f=document.frmm; //form name	
	_showPrompt = false; 
}

var _promptMessage = "Want to see rates without filling out a form? Click 'OK'.";
var	QueryString = $.parseQuery(); 
var _redirectURL = 'http://www.nycmortgage.com/mortgageResults.php?imm_cid='+QueryString.imm_cid+'&imm_mid='+QueryString.imm_mid+'&propertyStateCode='+QueryString.propertyStateCode+'&typeOfLoan='+QueryString.typeOfLoan;
var _redirect = false;
_showPrompt = true;
//get our QueryString & pass in the imm_cid & imm_mid

		
function onExit()
{	
	if(_showPrompt && confirmRedirect() && !_redirect)
		_redirect = true;
}

function confirmRedirect()
{
	if(confirm(_promptMessage))
		return true;
	else
		return false;
}

function redirectTo()
{
	if(_redirect)
	{
		_redirect = false;
		window.onbeforeunload = null;
		window.location = _redirectURL;
	}			
}

function makeSwitch(item,change){
	item.src=change;
}

$(document).ready(function () {			
	window.onbeforeunload = onExit;
	$("a").mousedown(function (){ _showPrompt = false; });
    $("input").mousedown(function (){  _showPrompt = false; });
	setInterval(redirectTo,100);
});	