String.prototype.isvalid = function(){
 return !!this.match(/^([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9]{1})@([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9]{1})\.([a-zA-Z]{2,4})$/)
}
function dropdown_validator() {
 if (document.form1.name.value=="") {
  alert("Please Enter Your Name.");
  return false;
 } else if (!document.form1.email.value.isvalid()) {
  alert("Please Enter A Valid Email Address.");
  return false;
 } else {
 return true;
 }
}


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=410,height=270,left = 376,top = 357');");
}



function MakeCurrency() {
	var fPrinc, fDownp, fInter, fPymnt, fPeriod,fPrincVal , fDownpVal;
	var cntr, NumOfPays , MIntrst, Cmpnd, Prncpl, MPayment, Downpymnt;
	var frm = self.document.frmMortgage;
	
	with (frm) {
		fPrinc = txtPrincipal.value;
		fDownp = txtDownpayment.value;
		fInter = parseFloat(cboInterest[cboInterest.selectedIndex].value);
		fPeriod = parseFloat(cboPeriod[cboPeriod.selectedIndex].value);
		fPymnt = txtPayments.value;
	}	
	
	fPrincVal = CleanNumber(fPrinc);
	fDownpVal = CleanNumber(fDownp);
		
	if (isNaN(fPrincVal)) {
		alert( "Please enter digits only in the Principal box");
		return;
	}
	if (isNaN(fDownpVal)) {
		alert( "Please enter digits only in the Downpayment box");
		return;
	}	
	
	Prncpl = fPrincVal.length == 0 ? 0 : parseFloat(fPrincVal);
	Downpymnt = fDownpVal.length == 0 ? 0 * parseFloat(Prncpl) : parseFloat(fDownpVal);

	if (Downpymnt >= Prncpl && Prncpl.length > 0) {
		alert("To use this calculator your principal amount must be higher than your down payment.");
		return;
	}

	Prncpl = Prncpl - Downpymnt ;	/* amount borrowed */
	
	NumOfPays = fPeriod * 12;		/* number of payments in the loan period */
	MIntrst = fInter / 1200 ;	/* Monthly interest */
	Cmpnd = 1 ;		/* compounded interest */
	for (cntr=0 ; cntr<NumOfPays; cntr++) {
		Cmpnd = Cmpnd * (1 + MIntrst);	
	}
	
	MPayment = (Prncpl * Cmpnd * MIntrst)/(Cmpnd - 1);
	//frm.txtPayments.value = "$" + parseInt(MPayment, 10 );
	frm.txtPayments.value =  parseInt(MPayment, 10 );
}

//---------------------------------------------------------------------------------------
function CleanNumber(Dollar) {
	var nInd;
	var strLeft, strRight , strFormat;
	var DLen = Dollar.length;
	
	nInd = Dollar.indexOf(",",0);
	strLeft = "";
	strRight = Dollar.substring(0);
	if (nInd == -1) {
		return Dollar;
	}
	while( nInd != -1 ) {
		strLeft = strLeft + strRight.substring(0, nInd);
		strRight = strRight.substring(nInd + 1);
		nInd = strRight.indexOf(",",0)
	}	
	strFormat = strLeft + strRight;
	return strFormat;
}



/************************************************************************************************************
Ajax dynamic content
Copyright (C) November, 2005  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com


************************************************************************************************************/	
var slideshow2_noFading = false;
var slideshow2_timeBetweenSlides = 10000;	// Amount of time between each image(1000 = 1 second)
var slideshow2_fadingSpeed = 5;	// Speed of fading	(Lower value = faster)


var slideshow2_stats = new Array();

var slideshow2_slideIndex = new Array();	// Index of current image shown
var slideshow2_slideIndexNext = new Array();	// Index of next image shown
var slideshow2_imageDivs = new Array();	// Array of image divs(Created dynamically)
var slideshow2_currentOpacity = new Array();	// Initial opacity
var slideshow2_imagesInGallery = new Array();	// Number of images in gallery
var Opera = navigator.userAgent.indexOf('Opera')>=0?true:false;
function createParentDivs(imageIndex,divId)
{
	if(imageIndex==slideshow2_imagesInGallery[divId]){	
		showGallery(divId);
	}else{
		var imgObj = document.getElementById(divId + '_' + imageIndex);	
		if(Opera)imgObj.style.position = 'static';
		if(!slideshow2_imageDivs[divId])slideshow2_imageDivs[divId] = new Array();
		slideshow2_imageDivs[divId][slideshow2_imageDivs[divId].length] =  imgObj;

		imgObj.style.visibility = 'hidden';	
		imageIndex++;
		createParentDivs(imageIndex,divId);	
	}		
}

function showGallery(divId)
{
	if(slideshow2_slideIndex[divId]==-1)slideshow2_slideIndex[divId]=0; else slideshow2_slideIndex[divId]++;	// Index of next image to show
	if(slideshow2_slideIndex[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndex[divId]=0;
	slideshow2_slideIndexNext[divId] = slideshow2_slideIndex[divId]+1;	// Index of the next next image
	if(slideshow2_slideIndexNext[divId]==slideshow2_imageDivs[divId].length)slideshow2_slideIndexNext[divId] = 0;

	
	slideshow2_currentOpacity[divId]=100;	// Reset current opacity

	// Displaying image divs
	slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'visible';
	if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'inline';
	if(navigator.userAgent.indexOf('Opera')<0){
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.visibility = 'visible';
	}
	
	if(document.all){	// IE rules
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity=100)';
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity=1)';
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = 0.99;	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = 0.01;
	}		
	

	setTimeout('revealImage("' + divId + '")',slideshow2_timeBetweenSlides);		
}

function revealImage(divId)
{

	if(slideshow2_noFading){
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';
		if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';
		showGallery(divId);
		return;
	}
	slideshow2_currentOpacity[divId]--;
	if(document.all){
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.filter = 'alpha(opacity='+slideshow2_currentOpacity[divId]+')';
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.filter = 'alpha(opacity='+(100-slideshow2_currentOpacity[divId])+')';
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.opacity = Math.max(0.01,slideshow2_currentOpacity[divId]/100);	// Can't use 1 and 0 because of screen flickering in FF
		slideshow2_imageDivs[divId][slideshow2_slideIndexNext[divId]].style.opacity = Math.min(0.99,(1 - (slideshow2_currentOpacity[divId]/100)));
	}
	if(slideshow2_currentOpacity[divId]>0){
		setTimeout('revealImage("' + divId + '")',slideshow2_fadingSpeed);
	}else{
		slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.visibility = 'hidden';	
		if(Opera)slideshow2_imageDivs[divId][slideshow2_slideIndex[divId]].style.display = 'none';		
		showGallery(divId);
	}
}

function initImageGallery(divId)
{
	var slideshow2_galleryContainer = document.getElementById(divId);
	
	
	slideshow2_slideIndex[divId] = -1;
	slideshow2_slideIndexNext[divId] = false;
	
	var galleryImgArray = slideshow2_galleryContainer.getElementsByTagName('IMG');
	for(var no=0;no<galleryImgArray.length;no++){
		galleryImgArray[no].id = divId + '_' + no;
	}
	
	slideshow2_imagesInGallery[divId] = galleryImgArray.length;
	createParentDivs(0,divId);		
	
}