	/**********************scripts for Application 6 ***********************
	/ used to hide show text boxes to medication, traffic, etc.. questions   */
	
	function DisplayControl(decisionControl,displayControl)
	{
		if (decisionControl.checked=true) displayControl.style.display='';
	}
	
	function UnDisplayControl(decisionControl,displayControl)
	{
		if (decisionControl.checked==true) displayControl.style.display='none';
	}
	

	function homeowner()
	{
		if(document.forms[0].LoanTypeDropDownList.selectedIndex == 1)
		{
			document.getElementById('HiddenQuestions2').style.display='none';
				
		}
		else
		{
			document.getElementById('HiddenQuestions2').style.display='';
				
		}
	}
/************************** scripts from the Defualt9.aspx page******************/

/*function Resize()
{
	var nameValString = document.location.search;
	var fullURL=document.location.href;
	var ampPos =  nameValString.indexOf('&amp;');
	var secondPair  = nameValString.substring(ampPos+1);
	var twoValues = firstPair.substring(firstPair.indexOf('=')+1);
	var firstPair  = nameValString.substring(0,ampPos);
	document.getElementById('qry').innerHTML='Full URL String: ' + fullURL;
	document.getElementById('nvUrl').innerHTML='Name Value Pairs: ' + nameValString;
	document.getElementById('first').innerHTML='The first name/value pair: ' + firstPair;
	document.getElementById('second').innerHTML='The second name/value pair: ' + secondPair;
   	twoValues += ' ';
	twoValues += secondPair.substring(secondPair.indexOf('=')+1);
	document.getElementById('values').innerHTML='Our passed values: ' + twoValues;
	alert('qry' + 'nvUrl' + 'first' + 'second');


	

}
*/
//this.moveTo(0,0);
//this.resizeTo(screen.availWidth,screen.availHeight);
var exit=true;
function exitwindow(url)
{
	//var url = 'http://www.policymatch.com/policypop.htm';
	var win = 'toolbar=yes,directories=0,menubar=yes,scrollbars=yes,location=yes,width=480 ,height=400,resizable=yes';
	if (exit)
	open(url,'windowname',win); 
		if (exit)
		{
			var popunder=new Array()
			popunder[0]="pop2.aspx"
			var width = '550';
			var height = '453';

			var p = 'scrollbars=yes,resizable=yes,toolbar=yes,' +
			'menubar=yes,status=yes,location=yes,left=85,top=20,height=' + 
			height + ',width=' + width;
			var one_time=1
		}
}

function get_cookie(Name) 
{
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search)
		if (offset != -1) 
		{ 
			offset += search.length
			end = document.cookie.indexOf(";", offset); 
			if (end == -1) 
			{
				end = document.cookie.length;
			}
		returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}
					
function loadornot()
{
	if (get_cookie('popunder')=='')
	{
		load_pop_power()
		document.cookie="popunder=yes"
	}
}
					
function load_pop_power()
{
	win2=window.open(popunder[Math.floor(Math.random()*(popunder.length))],"bw",p)
	win2.blur()
	window.focus()
	if (one_time==0)
	{
		load_pop_power()
	}
	else
	{
		loadornot()
	}
}
			
function AutoTab(original,destination)
{
	if(original.getAttribute && original.value.length == original.getAttribute("maxlength"))
	{
		destination.focus();
	}
}

function MortgageQuote()
{
	var hiddenRow = document.getElementById("HiddenQuestions");
	var checkBox = document.getElementById("MortgageQuoteCheckBox");
	
	if(checkBox.checked==false)
	{
		checkBox.checked=true;
		hiddenRow.style.display='';
	}
	else
	{
		checkBox.checked=false;
		hiddenRow.style.display='none';
	}
}		
function popwindow(URL,windowName, properties) 
{
	popupWin = window.open(URL, windowName, properties);
	window.top.name = 'opener';
}


function popRBCSource(URL,windowName, properties) 
{
	var qs = new Querystring();
	var source = qs.get("source","none");
	if(source == "none")
	{
		URL += "&promotioncode=206-1";
	}
	else
	{
		URL += "&promotioncode=" + source;
	}

	popupWin = window.open(URL, windowName, properties);
	window.top.name = 'opener';
}
				
/*function AutoTab(startControl,endControl)
{
	if (startControl.value.length==startControl.maxLength)
	endControl.focus();
}
*/
function attention(OBJ) 
{
	OBJ.style.background = '#C9D5D8';
}

function background(OBJ) 
{
	OBJ.style.background = '';
}


/* This block of code is used to parse the QueryString and then Prepop a window based on a specific source */
function Querystring()
{
// get the query string, ignore the ? at the front.
	var querystring=location.search.substring(1,location.search.length);

// parse out name/value pairs separated via &
	var args = querystring.split('&');

// split out each name = value pair
	for (var i=0;i<args.length;i++)
	{
		var pair = args[i].split('=');

		// Fix broken unescaping
		temp = unescape(pair[0]).split('+');
		temp0 = temp.join(' ');
		
		temp = unescape(pair[1]).split('+');
		temp1 = temp.join(' ');
		
		this[temp0]=temp1;
	}

	this.get=Querystring_get;
}

// add the get member
function Querystring_get(strKey,strDefault)
{
	var value=this[strKey];
	if (value==null)
	{
		value=strDefault;
	}
	
	return value;
}

function prepop(URL,windowName, properties) 
{
	var qs = new Querystring();
	
	var source = qs.get("source","none");
	if(source.substring(0,4) == "220-" || source.substring(0,3) == "84-" || source.substring(0,4) == "118-")
	{
		popupWin = window.open(URL, windowName, properties);
		popupWin.moveTo(200,200);
	}
	else
	{
		// alert("Don't do anything for this source");
	}
}

// Not currently Used...  
function prepop10(URL,windowName, properties) 
{
	var qs = new Querystring();
	
	var source = qs.get("source","none");
	if(source.substring(0,4) == "122-" || source.substring(0,4) == "126-" || source.substring(0,4) == "288-")
	{
		popupWin = window.open(URL, windowName, properties);
		popupWin.moveTo(200,200);
	} 
	else
	{
		// alert("Don't do anything for this source");
	}
}

// This is the actual window pop function
function timedpop(URL,windowName, properties) 
{
	var qs = new Querystring();
	
	var source = qs.get("source","none");
	if(source == "220-1")
	{
		popupWin = window.open(URL, windowName, properties);
		setTimeout('popupWin.close()', 5000); 
	}
	else
	{
		// alert("Don't do anything for this source");
	}

}
			
/*************************************************************************/

function Hide() 
{
	LinkRow.style.display='none';
	Mortgage.style.display='none';
	Purple1.style.display='none';
	Purple2.style.display='none';

}

function Hide10() 
{
	if(document.getElementById('MortgageCheckbox')!= null)
	{
		checkbox = document.getElementById('MortgageCheckbox');
		checkbox.style.display='none';
	}
}


/******************************************************************************/
/* on mouse over show a new table with information on what to do*/
/* added by Rick march 3 ----------------------------------------------------*/
  function mouseOver() {
    var notes = document.body.all["TheAnswer"], left, top;
    if ((event.clientY + 20 + notes.offsetHeight) >  document.body.offsetHeight) {
      left = event.x + 40;
      top = document.body.offsetHeight - notes.offsetHeight + document.body.scrollTop - 10;
    } else {
      left = event.x;
      top = event.y + 20;   
    }
    notes.style.posTop = top;
    notes.style.posLeft = left;
    notes.style.visibility = "visible"; 
  }
  
  function mouseOut() {
    var notes = document.body.all["TheAnswer"];  
    notes.style.visibility = "hidden";
  }

/* Decision for Termfinder QuoteAmlny show and hide 10 & 20 Year datagrids*/
function TabDisplay(image1,image2)
{
	var one = document.getElementById(image1);
	var two = document.getElementById(image2);
	var row20 = document.getElementById('Quote20Row');
	var row10 = document.getElementById('Quote10Row');
	if(row20.style.display='none')
	{
		row20.style.display=''
		row10.style.display='none';
		one.src = "images/Tf/20YrTabSelected.gif";
		two.src = "images/Tf/10YrTab.gif";	
	}	
	else
	{
		row20.style.display=''
		row10.style.display='none';
		one.src = "images/TF/20YrTabSelected.gif";
		two.src = "images/Tf/10YrTab.gif";	
	}	
}
function TabUnDisplay(image1,image2)
{
	var one = document.getElementById(image1);
	var two = document.getElementById(image2);
	var row20 = document.getElementById('Quote20Row');
	var row10 = document.getElementById('Quote10Row');
	if(row10.style.display='none')
	{
		row20.style.display='none'
		row10.style.display=''
		one.src = "images/TF/20YrTab.gif";
		two.src = "images/TF/10YrTabSelected.gif";	
	}
	else
	{
		row20.style.display='none'
		row10.style.display=''
		one.src = "images/Tf/20YrTab.gif";
		two.src = "images/TF/10YrTabSelected.gif";	
	}
}
/*-------------------------------------------------------------------------			
function UnDisplayControls(decisionControl,displayControl)
{
	if (decisionControl.style.display=='none';) displayControl.style.display='';
}
*/





/* Change Row Background Color When Moused over or clicked*/
function HighlightRow(ID, clsn) {
	if (document.getElementById(ID).className != 'clicked')
	 {
	 document.getElementById(ID).className = clsn;
	 }	
} 

function SetFocus( ctrlId)
{
	var ctrl = document.getElementById(ctrlId);
	if(ctrl != null)
	{
		ctrl.focus();
	}
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) 
{
	newWindow=window.open(URLtoOpen, windowName, windowFeatures);
}


function PopAuto()
{
	var zip = document.getElementById('zip').value;
	pop = window.open('AutoQuoteResults.aspx?Zip=' + zip,'Pop','toolbar=no,menubar=no,scrollbars=yes,location=no,width=700,height=400,resizable=yes').blur();
	window.focus();
}

function FormatPhone(ctrl)
//Adds dashes to a Phone field if the field is in correct format
{
	var val = ctrl.value;
	
	var replaceExpr = /\W/g	
	val = val.replace(replaceExpr,'');
	replaceExpr = /_/g
	val = val.replace(replaceExpr,'');	
	
	var phone = '';
	if(val.length > 3)
	{
		phone = val.substr(0,3) + '-';
	}
	if(val.length > 6)
	{
		phone += val.substr(3,3)+ '-'+val.substr(6);
	}
	else
	{
		phone += val.substr(3);
	}
	if(phone.length > 1)
	{
		ctrl.value = phone;
	}
	

}

function ShowHide(toShow, toHide)
{
	/*
		used with a button 'onclick' event.
		toShow - array with the IDs of the elements to be shown
		toHide - array with the IDs of the elements to be hidden
		
	*/
	if (document.getElementById(toShow) != null)
	{
		Display(document.getElementById(toShow));
	}
	
	if (document.getElementById(toHide) != null)
	{
		UnDisplay(document.getElementById(toHide));
	}
			
}

// for policy for text box 
function CallShowHide(ctrl)
{

	if(ctrl.value != "Self")
	{
		ShowHide('FullNameRow','');
	}
	else
	{
		ShowHide('','FullNameRow');
	}
}

function Display(displayControl)
{
	if(displayControl != null)
	{
		displayControl.style.display='';			
	}
}
function UnDisplay(displayControl)
{
	if (displayControl != null)
	{
		displayControl.style.display='none';
	}
}