var onLayer = 'Photos';
var onImagecall = '';
var offImage = '';
var offImagecall = '';

function LayerSwap(layername) {
    onImage = onLayer + 'Img';
    onImagecall = '/images/' + onImage + '_off.gif';
    offImage = layername + 'Img';
    offImagecall = '/images/' + offImage + '_on.gif';
    document.getElementById(onLayer).style.display = 'none';
    document.getElementById(onImage).src = onImagecall;
    document.getElementById(layername).style.display = 'block';
    document.getElementById(offImage).src = offImagecall;
    onLayer = layername;
}

function validate(formname) {
    //alert(formname);
    var message = "";
    message = message + eval("isValidStr(document." + formname + ".First_Name,'your First Name')");
    message = message + eval("isValidStr(document." + formname + ".Last_Name,'your Last Name')");
    message = message + eval("isValidEmail(document." + formname + ".Email)");
    message = message + eval("isValidNum(document." + formname + ".Phone,'your Phone Number')");
     
    if ( message != "" ) {
        alert(message);
        return false;
    } else {
        eval("document." + formname + ".submit()");
        return true;
    }
}

var swf_showing = "";
var storedimageID=0;
var previmageID=0;
var nextimageID=0;

function setphotourl(imgurl,imgID) {
    if ( swf_showing != "" ) {
        // there is an SWF ID showing. close it first.
        document.getElementById(swf_showing).style.display = 'none';
        document.getElementById('Photos_Main').style.display = 'block';
    }
    document.getElementById('largeimage').src = imgurl;
    storedimageID=imgID;
}

function viewlargephoto() {
	//var openphoto=document.getElementById('largeimage').src;
	//openphoto=openphoto.replace("/stills/large","/stills/original");
	//openphoto=openphoto.replace("/300/","/original/");
	if (storedimageID==0) { 
		previmageID=(jsimagearray.length-1);
	} else {
		previmageID = (storedimageID-1);
	}
	if (storedimageID==(jsimagearray.length-1)) {
		nextimageID=0;
	} else {
		nextimageID= storedimageID+1;
	}
	document.getElementById('originalimagePrev').href='javascript:changelarge(' + previmageID + ');';
	document.getElementById('originalimageNext').href='javascript:changelarge(' + nextimageID + ');';
	document.getElementById('originalimage').src = jsimagearray[storedimageID];
	document.getElementById('originalimageDIV').style.display = 'block';
}

function changelarge(changeto) {
	storedimageID=changeto;
	viewlargephoto();
}

function OpenSWF(itemname) {
    if ( swf_showing != "") {
        // there is an SWF ID showing. close it first.
        document.getElementById(swf_showing).style.display = 'none';
    }
    document.getElementById('Photos_Main').style.display = 'none';
    document.getElementById(itemname).style.display = 'block';
    swf_showing = itemname;
}
        
function OpenPrint() {
    var a = window.open('', '', 'width=450,height=500');
    a.document.open("text/html");
    a.document.write(document.getElementById('printItems').innerHTML);
    a.document.close();
    a.print();
}

function OpenEmail() {
    var a = window.open('', '', 'width=550,height=500,scrollbars');
    a.document.open("text/html");
    a.document.write(document.getElementById('emailItems').innerHTML);
}

function EstimatePayment(interest, nummonths, down, startcost) {
    compounded_interest_rate = Math.pow(1 + interest / 1200, nummonths); 
    payment = (startcost - down) * compounded_interest_rate * (interest / 1200) / (compounded_interest_rate - 1);
    document.getElementById('EstPayment').innerHTML = '$' . payment;
}
