function popChat(){
	u = "http://srv6.velaro.com/visitor/requestchat.aspx?siteid=1216";
	xWindow.openCenter(u,"chat",600,550);
}

function popform(u,w){
	//alert("coming soon");
	if(w == null){
		xWindow.openCenterScroll(u,"chat",300,330);
	}else{
		xWindow.openCenterScroll(u,"chat",w,330);
	}
	
}





////////////////////
// XSWAP
////////////////////
xSwap = function(name){
	this.name = name;
	this.images = {};
	this.restoresrc = null;
	this.nest = "undefined";
};
xSwap.prototype.add = function(state,src){
	this.images[state] = new Image();
	this.images[state].src = src;	
};
xSwap.prototype.swap = function(state){
	var img = this.getImage();
	this.restoresrc = img.src;
	img.src = this.images[state].src;
};
xSwap.prototype.restore = function(){
	if(this.restoresrc){
		this.getImage().src = this.restoresrc;
		this.restoresrc = null;
	}
};
xSwap.prototype.getImage = function(){// Private
	if(document.layers && this.nest == "undefined") this.nest = this.getLayer();
	if(document.layers && this.nest != false){
		return this.nest.document.images[this.name];
	}else{
		return document.images[this.name];
	}
};
xSwap.prototype.getLayer = function(root){// Private
	var i, k, layer, found = false;
	if(!root) root = window;
	for(i = 0; i < root.document.layers.length; i++){
		layer = root.document.layers[i];
		for(k = 0; k < layer.document.images.length; k++){
			if(layer.document.images[k].name == this.name){
				return layer;
			}
		}
		if(layer.document.layers.length) found = this.getLayer(layer);
		if(found) return found;
	}
	return false;
};
////////////////////
// NAVIGATION
////////////////////
// ROLLOVERS
//hom_obj = new xSwap ("hom_btn");
//hom_obj.add ("over","/images/navigation/nav_hom_o.gif");


////////////////////
// xscreen
////////////////////
if(typeof(xScreen) == "undefined") xScreen = {};

xScreen.getWidth = function(){
	return window.screen ? window.screen.availWidth : 0;
};
xScreen.getHeight = function(){
	return window.screen ? window.screen.availHeight : 0;
};



////////////////////
// xwindowopen
////////////////////
// Requires: xscreen.js
if(typeof(xScreen) == "undefined") alert("xScreen Required");

// ||||||||||||||||||||||||||||||||||||||||||||||||||

if(typeof(xWindow) == "undefined") xWindow = {};

xWindow.open = function(url,name,width,height,xpos,ypos,chrome,scroll,fullscreen){
	var x, y, w, h, moveX=0, moveY=0, features="";
	chrome = chrome ? "yes" : "no";
	scroll = scroll ? "yes" : "no";
	features += "toolbar="+chrome;
	features += ",menubar="+chrome;
	features += ",location="+chrome;
	features += ",status="+chrome;
	features += ",scrollbars="+scroll;
	features += ",resizable="+scroll;
	if(width) features += ",width="+width;
	if(height) features += ",height="+height;
	if(fullscreen) features += ",fullscreen=yes";
	if(xpos){
		w = xScreen.getWidth();
		width = parseInt(width);
		switch(xpos){
			case "left": x = 0; break;
			case "center": x = Math.round((w-width)/2); break;
			case "right": x = w-width; break;
			default: x = xpos;
		}
		features += ",screenX="+x+",left="+x;
		var moveX = x;
	}
	if(ypos){
		h = xScreen.getHeight();
		height = parseInt(height);
		switch(ypos){
			case "top": y = 0; break;
			case "middle": y = Math.round((h-height)/2); break;
			case "bottom": y = h-height; break;
			default: y = ypos;
		}
		features += ",screenY="+y+",top="+y;
		var moveY = y;
	}
	xWindowOpenReference = window.open(url,name,features);
	if(moveX || moveY){
		if(xWindowOpenReference != null && !xWindowOpenReference.closed){
			// position the window for browsers that don't recognize screenX, screenY
			xWindowOpenReference.moveTo(moveX,moveY);
		}
	}
};
xWindow.openScroll = function(url,name,width,height){
	this.open(url,name,width,height,false,false,false,"scroll");
};
xWindow.openCenter = function(url,name,width,height){
	this.open(url,name,width,height,"center","middle");
};
xWindow.openCenterScroll = function(url,name,width,height){
	this.open(url,name,width,height,"center","middle",false,"scroll");
};
xWindow.openFull = function(url,name){
	this.open(url,name,xScreen.getWidth(),xScreen.getHeight(),"0","0",false,true);
};
xWindow.openKiosk = function(url,name){
	this.open(url,name,xScreen.getWidth(),xScreen.getHeight(),"0","0",false,false,true);
};




////////////////////
// XBROWSER
////////////////////
xBrowser = function(){
	this.agent = navigator.userAgent.toLowerCase();
	// Platform
	this.mac = this.agent.indexOf("mac")!=-1;
	this.win = this.agent.indexOf("win")!=-1;
	this.win32 = this.win && this.agent.indexOf("16bit")==-1;
	this.unix = this.agent.indexOf("x11")!=-1 || this.agent.indexOf("linux")!=-1;
	// Browser
	this.w3c = document.getElementById ?true:false;
	this.iex = document.all ?true:false;
	this.ie4 = this.iex && !this.w3c;
	this.ie5up = this.iex && this.w3c;
	this.ns4 = document.layers ?true:false;
	this.ns6up = !this.iex && !this.ns4 && this.w3c;
	this.nsx = this.ns4 || this.ns6up;
};
xBrowser.prototype.dump = function(){
	var html = "";
	for(i in this) if(typeof(this[i]) != "function") html += i+" = "+this[i]+"<br>";
	document.write(html);
};
xBrowser = new xBrowser();


// edited on 030401
if(jsSiteUrl==null)
var jsSiteUrl = 'http://mortgageease.com/';
//window.status = jsSiteUrl + "/images/navigation/nav_purchase_o.gif";
// edited on 030401

nav_purchase_obj = new xSwap ("nav_purchase");
nav_purchase_obj.add ("over",jsSiteUrl + "/images/navigation/nav_purchase_o.gif");

nav_refinance_obj = new xSwap ("nav_refinance");
nav_refinance_obj.add ("over",jsSiteUrl + "/images/navigation/nav_refinance_o.gif");

nav_homeequity_obj = new xSwap ("nav_homeequity");
nav_homeequity_obj.add ("over",jsSiteUrl + "/images/navigation/nav_homeequity_o.gif");

nav_reverse_obj = new xSwap ("nav_reverse");
nav_reverse_obj.add ("over",jsSiteUrl + "/images/navigation/nav_reverse_o.gif");

nav_calculators_obj = new xSwap ("nav_calculators");
nav_calculators_obj.add ("over",jsSiteUrl + "/images/navigation/nav_calculators_o.gif");

nav_loanprograms_obj = new xSwap ("nav_loanprograms");
//nav_loanprograms_obj.add ("over","/images/navigation/nav_loanprograms_o.gif");
nav_loanprograms_obj.add ("over",jsSiteUrl + "/images/navigation/nav_about_o.gif");

nav_rates_obj = new xSwap ("nav_rates");
nav_rates_obj.add ("over",jsSiteUrl + "/images/navigation/nav_rates_o.gif");






////////////////////
// SEARCH RATES
////////////////////



mandatory_array = new Array(1);

function null_check() {
	mandatory_array[0] = new Array(document.loan_search.loan_amount.value, " loan amount field for question #4.");
	mandatory_array[1] = new Array(document.loan_search.property_value.value, " property value field for question #5.");
	
	var len = mandatory_array.length;
	for (o=0; o < len; o++) { 
		if (mandatory_array[o][0] == ""){
			alert("Please enter a value for the" + mandatory_array[o][1]);
			return false;
		}
	}
	return true;
}

function programCheck(){
    if(document.loan_search.program[document.loan_search.program.selectedIndex].value == ""){
    	alert("Please Select a Loan Program");
		document.loan_search.program.focus();
    	return false;
	}
    return true;	
}

function stateCheck(){
    if(document.loan_search.state[document.loan_search.state.selectedIndex].value == ""){
    	alert("Please Select a state");
		document.loan_search.state.focus();
    	return false;
	}
    return true;	
}

function purposeCheck(){
    if(document.loan_search.purpose_of_loan[document.loan_search.purpose_of_loan.selectedIndex].value == ""){
    	alert("Please Select a loan purpose");
		document.loan_search.purpose_of_loan.focus();
    	return false;
	}
    return true;	
}

function propertyCheck(){
    if(document.loan_search.property_type[document.loan_search.property_type.selectedIndex].value == ""){
    	alert("Please Select a property type");
		document.loan_search.property_type.focus();
    	return false;
	}
    return true;	
}





function loan_limit(){
	var program = document.loan_search.program[document.loan_search.program.selectedIndex].value;
	if(( program.charAt(0) == 'C' && parseFloat(document.loan_search.loan_amount.value) > parseFloat(359650) ) || ( program.charAt(0) == 'J' && parseFloat(document.loan_search.loan_amount.value) <= parseFloat(359650) )){
		alert("The loan amount has fallen out of the Range of your program selection." +
			  "If you enter an amount that is greater than 359650 please select a jumbo program. " +
			  "If you enter an amount equal to or less than 359650 please select a conforming program. "); 
		return false;
	}
	return true;
}



function number_validation(val){
	edited_value = "";
	var len=val.length;
	var dot_cntr = 0;
	
	for(i=0;i<len;++i){
		if((val.charAt(i) >= 0 && val.charAt(i) <= 9) || val.charAt(i) == "."){
			if(val.charAt(i) == "." ){
				++dot_cntr;
				if(dot_cntr >= 2){
					alert("There are two decimals in the amount field the amount field will be zeroed out.");
					edited_value = 0;
					break;
				}
			}
			edited_value = edited_value + val.charAt(i);
		}
 	}
	
	if(val == "" || val == " " || val.substring(1,2) == " "){
		edited_value = 0;
		return edited_value;
	}
	
	return edited_value;
}
 
 

function validate(){
	retval = true;
	
	if(programCheck() == false){
		return false;
	}
	if(stateCheck() == false){
		return false;
	}
	if(purposeCheck() == false){
		return false;
	}
	if(propertyCheck() == false){
		return false;
	}
	 

    retval =  number_validation(document.loan_search.loan_amount.value);
	if ((retval == "") || (document.loan_search.loan_amount.value == 0)) {
	    alert("Please enter a valid loan amount.");
		document.loan_search.loan_amount.value = "";
		document.loan_search.loan_amount.focus();
		return false;
	}	

    retval = number_validation(document.loan_search.property_value.value);	
	if ((retval == "") || (document.loan_search.property_value.value == 0)) {
	    alert("Please enter a valid property value.");
		document.loan_search.property_value.value = "";
		document.loan_search.property_value.focus();
		return false;
	}	

	/*xWindow.openScroll("","subwin",750,600);

	document.loan_search.action = "http://ratesearch.myersinternet.com/br_ratesearch/ratesearch_out.cfm?RequestTimeout=50000";
	document.forms[0].submit();*/
	return true;

}


function newsletterSubmit(){
	xWindow.openScroll("","newssub",750,600);
	document.nform.action = "http://www.imakenews.com/eletra/mod_input_proc.cfm";
	document.forms[0].submit();
	return true;
}

