function getObj(oId){var d=document,el=d.getElementById?d.getElementById(oId):d.all?d.all[oId]:d[oId];if(el){return el;}}


// Clock Script Generated By Maxx Blade's Clock v2.0
// http://www.maxxblade.co.uk/clock

function tS(){ x=new Date(); x.setTime(x.getTime()); return x; } 
function lZ(x){ return (x>9)?x:'0'+x; } 
function tH(x){ if(x==0){ x=12; } return (x>12)?x-=12:x; } 
function dT(){ document.write(eval(oT)); } 
function aP(x){ return (x>11)?'PM':'AM'; } 
function y4(x){ return (x<500)?x+1900:x; } 
var dN=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'),mN=new Array('January','February','March','April','May','June','July','August','September','October','November','December'),oT="dN[tS().getDay()]+', '+mN[tS().getMonth()]+' '+tS().getDate()+', '+y4(tS().getYear())+'&nbsp;&nbsp;'+'|'+'&nbsp;&nbsp;'+tH(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '+aP(tS().getHours())";

// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

simplePreload('/skins/main_Content/images/layout/web_AnimatedProgressBar.gif');


// Mortgage Calculator Functions
function rnd(number) {
	var TP = "" + Math.round(number * 100) / 100;
	var i = TP.indexOf('.');
	if (i < 0) return TP + ".00";
	var t = TP.substring(0, i + 1) + TP.substring(i + 1, i + 3);
	if (i + 2 == TP.length) t += "0";
	return t;
}

function FormatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function trim(strValue) {
	var strAllowed = "0123456789.";
	var strResults = '';
	for (var i=0;i<strValue.length;i++) {
		for (var j=0;j<strAllowed.length;j++) {
			if (strValue.charAt(i) == strAllowed.charAt(j)) {
				strResults += strValue.charAt(i);
				break;
			}
		}
	}
	return strResults;
}


function dosum() {
	// Get Loan and Down Payment values and Calculate the Loan Amount
	var loan 				= trim(document.Form1._ctl0_txtPrice.value);
	var dpmt 				= trim(document.Form1._ctl0_DownPmt.value);
	var loanAmt 			= loan - dpmt;
	
	// Calculate and Set Monthly Interest Value
	var mi 					= trim(document.Form1._ctl0_INTEREST.value) / 1200;
	var base 				= 1;
	var mbase 				= 1 + mi;
	
	// Get the Tax Rates and set the Monthly Tax Amount
	var TaxCity			= trim(document.Form1._ctl0_TaxCity.value);
	var TaxCounty		= trim(document.Form1._ctl0_TaxCounty.value);
	var taxRateCity		= (TaxCity * loan)/100;
	var taxRateCo		= (TaxCounty * loan)/100;
	var monthlyTax		= (taxRateCity + taxRateCo)/12
	
	for (i=0; i<document.Form1._ctl0_YEAR.value * 12; i++) {
		base = base * mbase
	}

	//loan = "$" + rnd(loanAmt);
	document.getElementById("PI").innerHTML = FormatCurrency(loanAmt * mi / ( 1 - (1/base)));
	document.getElementById("MT").innerHTML = FormatCurrency(monthlyTax);
	//document.Form1.MI.value = "$" + rnd(loanAmt *.0035 / 12);
	
	var dasum = (loanAmt * mi / ( 1 - (1/base))) + (monthlyTax) // + (loanAmt *.0035 / 12);
	
	document.getElementById("MP").innerHTML = FormatCurrency(dasum);
	document.Form1._ctl0_txtPrice.value = FormatCurrency(loan);
	document.Form1._ctl0_DownPmt.value = FormatCurrency(dpmt);
	document.Form1._ctl0_TaxCity.value = TaxCity;
	document.Form1._ctl0_TaxCounty.value = TaxCounty;
}

function setDiv(div,val) {
	var theDiv;
	var isDOM = false;
	var isIE4 = false;
	var isNN4 = false;
	
	if (document.getElementById) {
		theDiv = eval("document.getElementById('" + div + "')");
	} else { 
		if (!document.getElementById && document.all) {
			theDiv = eval("document.all." + div);
		} else {
			if (!document.getElementById && document.layers) {
				theDiv = eval("document." + div);
			}
		}
	}
	if (val == 'show') {
		theDiv.style.display = 'block';
	}
	if (val == 'hide') {
		theDiv.style.display = 'none';
	}
}

function setValue(target,val) {
	var theTarget	= eval("document.Form1." + target);
	theTarget.value = val;
	theTarget.scrollIntoView();
}

function getFile(Img,W,H){ //receives the target image name, width, and size respectively
	var photoWin 	= null;
	var wScroll 	= "no";
	var reSize		= "no";
	
	/*---------------------------------------------------------------------------
	/	sets the default url for the target image.  To change the                 /
	/	url, simply replace the "/images/" with the appropriate path (URL)				/
	/	Just be sure that the target image exists in the path (URL) specified.		/
	---------------------------------------------------------------------------*/
	var URL 			= Img; 

	var aW 				= screen.availWidth;
	var aH 				= screen.availHeight;
	
	//set the width & height value for the pop-up window by adding 20 pixels to the target image's width
	//and 40 pixels to the target image's height.  If the resulting window is greater than the user's
	//available screen space, then the window width and height are set to the maximum viewable area of the
	//user's screen respectively. 
	var wW 				= 20 + (parseInt(W));
	var wH 				= 40 + (parseInt(H));
	
	if (wW > aW) { wW = aW; wScroll = "yes"; reSize = "yes"; }
	if (wH > aH) { wH = aH; wW = (wW + 30); wScroll = "yes"; reSize = "yes"; }			
	


	/*------------- Positioning the Pop-Up Window ---------------------------------------------------------
	/		 To set the default top and left locations of the pop-up window, specify the appropriate values   /
	/		 below.  winTop is the distance from the top of the user's screen (in pixels).  winLeft is the    /
	/		 distance from the left of the user's screen (in pixels). Comment and uncomment the following     /
	/    lines to set the desired location of the pop up window.																					/
	-----------------------------------------------------------------------------------------------------*/

	//##### Center Window on Screen #####//
	var winTop		= (aH - wH)/2;												
	var winLeft 	= (aW - wW)/2;
	
	//##### Position window to TOP RIGHT #####//
	//var winTop 		= 0;
	//var winLeft 	= aW - (10 + parseInt(wW));
	
	//##### Position window to TOP LEFT #####//
	//var winTop	= 0;
	//var winLeft = 0;
	
	//##### Position window to TOP CENTER #####//
	//var winTop	= 0;
	//var winLeft = (aW - wW)/2;			
	

	/*---------------------------------------------------------------------------------------------------
	/		Now, we assign the HTML that's to be dynamically written into our pop-up window to a variable		/
	/		It shouldn't be necessary to change any of the code for this variable 													/	
	---------------------------------------------------------------------------------------------------*/
	 	
	var strImage 	= "<html>\r";
			strImage += "<head>\r";
			
			//define a function that resizes the window based upon the target image width and height
			strImage += "<SCR"+"IPT language='JavaScript'> \r";
			strImage += "<!-- \r";
			strImage += "function reSize(){ \r";
			strImage += "if (window.width != "+wW+"){ \r"; 							//checks existing window width
			strImage += " var wW = "+wW+";} \r"; 					 							//sets the window width to the appropriate value
			strImage += "if (window.height != "+wH+"){ \r";							//checks existing window height
			strImage += " var wH = "+wH+";} \r";					 							//sets the window height to the appropraite value
			strImage += "  window.resizeTo(wW,wH); \r";		 							//resizes the window to the new window width & height values (if necessary)
			strImage += "  window.moveTo("+winLeft+","+winTop+"); \r";	//moves the window to the appropriate place on the screen
			strImage += "} \r";
			strImage += "//--> \r";
			strImage += "</scr"+"ipt> \r";
			//end our function
			
			strImage += "</head> \r";
			strImage += "<body bgcolor='#FFFFFF' topmargin='5' leftmargin='5' marginwidth='5' marginheight='5' onLoad='reSize();'> \r";
			strImage += "<p align='center'><a href='javascript:self.close();' title='Clicking Again will close this window.'> \r";
			strImage += "<img src='"+URL+"' border='0' width='"+W+"' height='"+H+"' alt='Clicking Again will close this window.'> \r";
			strImage += "</a></p> \r";
			strImage += "</body></html> \r";


/* Now that we've finished assigning our new HTML to a variable, it's time to open the pop-up window */				
	photoWin = window.open('','photoWin','width='+wW+',height='+wH+',left='+winLeft+',top='+winTop+',scrollbars='+wScroll+',resizable='+reSize+'');
	photoWin.window.focus();
	
	//Write the Image to the New Window & we're done.
	photoWin.document.write(strImage);
	photoWin.document.close();
}