// JavaScript Document
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenu_1(targ,selObj,restore){ //v3.0

	var a = selObj.options[selObj.selectedIndex].value;

	if (a.substring(0,4) == 'http')
	{
		popupWindow(a, 'external', 800, 600);
		selObj.selectedIndex=0;
	}
	else
	{
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
		if (restore) selObj.selectedIndex=0;
	}
}

function popupWindow(fileName, id, width, height, resizable)
{
	window.open(fileName, ((id) ? id : ''), "width=" + ((width) ? width : 500) + ", height=" + ((height) ? height : 350) + ", status=no, toolbar=no, menubar=no, location=no, scrollbars=yes" + ((resizable) ? " resizable=yes" : ""));
//	window.open(fileName, ((id) ? id : ''), "width=" + ((width) ? width : 500) + ", height=" + ((height) ? height : 350) + ", status=no, toolbar=no, menubar=no, location=no" + ((resizable) ? " resizable=yes" : "")) + ((scrollbar) ? " scrollbar=yes" : "")));
}


function openMortgageDoctor()
{
//	var pageURL = "http://www.mortgages.tv/callme/request.php?l=admin&x=1&deptid=1&page=http%3A//www.mortgages.tv/";
	var pageURL = "http://www.mortgages.tv/contactus/request.php?l=admin&x=1&deptid=1&page=http%3A//www.mortgages.tv/mortgage_doctor.php";
	popupWindow(pageURL, 'md', 470, 360);
}

function openOnlineApplication()
{
	var pageURL = "/enquiry/step-1.php";
	window.location = pageURL;
}

function openCallMeBackForm()
{
	var pageURL = "/enquiry/step-4.php?callme=1";
	window.location = pageURL;
}

function openCallMeBackFormFTB()
{
	var pageURL = "/enquiry/step-4.php?callme=1&ftb=1";
	window.location = pageURL;
}

function hide(id)
{
	var div = returnElementById(id);
	if (div){
		div.style.display = 'none';
	}
	else
	{
		alert("failed to hide");
	}
}


function show(id)
{
	var div = returnElementById(id);
	if (div){
		div.style.display = 'block';
	}
}

function returnElementById(id)
{
	if(document.getElementById){
//			alert("document.getElementById(id)");
			return document.getElementById(id);
	  }
	  else if (document.all){
//			alert("document.all[id]");
			return document.all[id];
	  }
	  else {
		   alert("Warning: Your browser should be upgraded to work with this site");
		   return false;
	  }
}



function formatBritishCurrency(num) 
{
	alert("num: "+num);
	num = num.toString().replace(/\£|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	alert("returning: "+(((sign)?'':'-') + '£' + num + '.' + cents));
	return (((sign)?'':'-') + '£' + num + '.' + cents);
} 
//-->
