
search_mortgage = function()
{
//	get inputs
	loanamount = document.getElementById('amount_search_input').value;
	product = document.getElementById('product_search_input').value;
	type = document.getElementById('product_search_type').value;
	zip = document.getElementById('zip_search_input').value;
	
	if(loanamount == "" || product == "" ||  zip == "" || type == "")
	{
		alert('Please Fill out all the product information.');
	}
	else
	{
		//redirect
		local_arr = this.location.href.split("?");
		this.location.href = type + product + '-' + zip + '?loanamount='+loanamount;
	}
	
}

//when image is clicked on show phone number and push sync url to a hidden image to communicate click
phone_sync = function(id){
	var top_val = 0;
	
	// get the offset of the clicked link
	 var iReturnValue = 0;
	 oElement = document.getElementById(id+"_phone");
	
	
	ele = document.getElementById(id+"_phone");
	ele_sync = document.getElementById(id+"_sync");
	ele_img = document.getElementById("sync_image");
	
	top_val = 550 + id * 70;
	top_val = top_val+'px';
	
	phone_num = ele.innerHTML;
	
	ele_dialog = document.getElementById('phone_dialog');
	ele_dialog.style.top = top_val;
	ele_dialog_content = document.getElementById('phone_dialog_content');
	
	ele_dialog_content.innerHTML = phone_num;
	ele_dialog.style.display = 'block';
	
	ele_img.src = ele_sync.innerHTML.replace(/amp;/g,"");
}

close_phone_dialog = function(){

	ele_dialog = document.getElementById('phone_dialog');
	ele_dialog.style.display = 'none';

	ele_img = document.getElementById("sync_image");
	ele_img.src = '';
}

sort_data = function(key){

	loanamount = document.getElementById('amount_search_input').value;
	
	//redirect
	local_arr = this.location.href.split("?");	
	this.location.href = local_arr[0] +  '?sort_key='+key+'&loanamount='+loanamount;

}