/*********************************************************************************************
*************** javaScripts- © illism webolution code library (www.illism.com) ***************
*********************************************************************************************/


// "View" Cookie
	function changeView(theView) {
		switch(theView) {
			case 'Caption': theView = 'Caption'; break;
			case 'Picture': theView = 'Picture'; break;
			case 'List': theView = 'List'; break;
			default: return 0;
		}

		theNow = new Date();
		theExpire = new Date();
		theExpire.setTime(theNow.getTime() + 3600000 * 24 * 30);
		document.cookie = 'view=' + theView + ';expires=' + theExpire.toGMTString();

		if (changeView) {refresh();}
	}
	var sURL = unescape(window.location.pathname); function refresh() {window.location.href = sURL;}
	function refresh() {window.location.replace( sURL );}
	function refresh() {window.location.reload( false );}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Show Hidden Layer ///////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function show_Financing(val) {
		if	((val == "") || (val == "Never")) document.getElementById('Financing').style.display = "none";
		else document.getElementById('Financing').style.display = "";
	}
	function show_Repossessions(val) {
		if ((val == "Less than a year") || (val == "1 - 3 years") || (val == "3+ years ago")) document.getElementById('Repossessions').style.display = "";
		else document.getElementById('Repossessions').style.display = "none";
	}
	function show_Bankruptcies(val) {
		if ((val == "Discharged")) document.getElementById('Bankruptcies').style.display = "";
		else document.getElementById('Bankruptcies').style.display = "none";
	}
	function show_Trade(val) {
		if ((val == "Yes")) document.getElementById('Trade').style.display = "";
		else document.getElementById('Trade').style.display = "none";
	}




	function Maintenance(val) {
		if ((val == "maintenance")) document.getElementById('Maintenance').style.display = "";
		else document.getElementById('Maintenance').style.display = "none";
	}








////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Same Address/Phone As Primary ///////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	var co_ph1 = "";
	var co_ph2 = "";
	var co_ph3 = "";
	var co_add1 = "";
	var co_add2 = "";
	var co_add3 = 0;
	var co_add4 = "";
	var co_add5 = 0;
	var co_add6 = 0;
	var co_add7 = 0;
	var co_add8 = "";

	function InitSaveVariables(form) {
		co_add1 = form.co_add1.value; 
		co_add2 = form.co_add2.value; 
		co_add3Index = form.co_add3.selectedIndex; 
		co_add4 = form.co_add4.value; 
		co_add5Index = form.co_add5.selectedIndex; 
		co_add6Index = form.co_add6.selectedIndex; 
		co_add7Index = form.co_add7.selectedIndex; 
		co_add8 = form.co_add8.value;
	}

	function SamePhone(form) {
		if (form.copy.checked) {InitSaveVariables(form);
			form.co_ph1.value = form.ap_ph1.value; 
			form.co_ph2.value = form.ap_ph2.value; 
			form.co_ph3.value = form.ap_ph3.value; 
		} else {
			form.co_ph1.value = co_ph1; 
			form.co_ph2.value = co_ph2; 
			form.co_ph3.value = co_ph3; 
		}
	}

	function SameAddress(form) {
		if (form.copy.checked) {InitSaveVariables(form);
			form.co_add1.value = form.ap_add1.value; 
			form.co_add2.value = form.ap_add2.value; 
			form.co_add3.selectedIndex = form.ap_add3.selectedIndex; 
			form.co_add4.value = form.ap_add4.value; 
			form.co_add5.selectedIndex = form.ap_add5.selectedIndex; 
			form.co_add6.selectedIndex = form.ap_add6.selectedIndex; 
			form.co_add7.selectedIndex = form.ap_add7.selectedIndex; 
			form.co_add8.value = form.ap_add8.value;
		} else {
			form.co_add1.value = co_add1; 
			form.co_add2.value = co_add2; 
			form.co_add3.selectedIndex = co_add3Index; 
			form.co_add4.value = co_add4; 
			form.co_add5.selectedIndex = co_add5Index; 
			form.co_add6.selectedIndex = co_add6Index; 
			form.co_add7.selectedIndex = co_add7Index; 
			form.co_add8.value = co_add8;
		}
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Agree To Terms //////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function checkme() {
		missinginfo = "";
		if (!document.ContactForm.agree.checked) {missinginfo += "You must read and agree to the terms!\n Please check \"I Agree\" to continue.";
		alert(missinginfo);	return false;} else {return true;}
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Auto Tab ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	var isNN = (navigator.appName.indexOf("Netscape")!=-1);

	function autoTab(input, len, e) {
		var keyCode = (isNN) ? e.which : e.keyCode; 
		var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
			if(input.value.length >= len && !containsElement(filter,keyCode)) {
				input.value = input.value.slice(0, len);
				input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
			return found;
	}
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
				else i++;
			return index;
		}
		return true;
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Show Element onMouseOver ////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function toggleDiv(id,flagit) {
	if (flagit=="1"){
		if (document.layers) document.layers[''+id+''].visibility = "show"
		else if (document.all) document.all[''+id+''].style.visibility = "visible"
		else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
	} else
		if (flagit=="0"){
		if (document.layers) document.layers[''+id+''].visibility = "hide"
		else if (document.all) document.all[''+id+''].style.visibility = "hidden"
		else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
	}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Currency Format /////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function currency(which){
		currencyValue = which.value;
		currencyValue = currencyValue.replace(",", "");
		decimalPos = currencyValue.lastIndexOf(".");
		if (decimalPos != -1){
				decimalPos = decimalPos + 1;
		}
		if (decimalPos != -1){
				decimal = currencyValue.substring(decimalPos, currencyValue.length);
				if (decimal.length > 2){
						decimal = decimal.substring(0, 2);
				}
				if (decimal.length < 2){
						while(decimal.length < 2){
							 decimal += "0";
						}
				}
		}
		if (decimalPos != -1){
				fullPart = currencyValue.substring(0, decimalPos - 1);
		} else {
				fullPart = currencyValue;
				decimal = "00";
		}
		newStr = "";
		for(i=0; i < fullPart.length; i++){
				newStr = fullPart.substring(fullPart.length-i-1, fullPart.length - i) + newStr;
				if (((i+1) % 3 == 0) & ((i+1) > 0)){
						if ((i+1) < fullPart.length){
							 newStr = "," + newStr;
						}
				}
		}
		which.value = newStr + "." + decimal;
	}

	function normalize(which){
		alert("Normal");
		val = which.value;
		val = val.replace(",", "");
		which.value = val;
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Capitolize ALL Letters //////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	function Upper(e,r) {r.value = r.value.toUpperCase();}















