function addfav()
   {
   if (document.all)
      {
      window.external.AddFavorite
      ("http://www.loans4.co.uk","Loans4 Limited Low Rate Loans")
      }
   }
   
   function validatefav()
   {
   
	for (i=0;i<document.forms[0].type.length;i++) {
		
	if (document.forms[0].type[i].checked) {
		//user_input = document.forms[0].type[i].value;
		return true;
	}
	
	}

	alert('Please select whether you are a Homeowner, Tenant, or Living with Parents.');
		return false;

   }

var message="All information on this website is the copyright of Loans4. Any attempts to copy will be recorded";


function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")


var message="All information on this website is the copyright of Loans4. Any attempts to copy will be recorded";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")



function popup(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=500');");
}

function GoHREF(URL)
{
	document.location="#result";
}

	function formatCurrency(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));
			if (num == "0") {
			return "£" + "";
		}
		else {
			return (((sign)?'':'-') + '£' + num);
		}
	}
	
	function formatCurrencyBalance(field) {
		// Ignore the previous amount, caculate the balance based on the present values
		// Then format the passed currency and return
		var numbers = new Array (7);
		numbers[0] = document.forms[0].balance1.value;
		numbers[1] = document.forms[0].balance2.value;
		numbers[2] = document.forms[0].balance3.value;
		numbers[3] = document.forms[0].balance4.value;
		numbers[4] = document.forms[0].balance5.value;
		numbers[5] = document.forms[0].balance6.value;
		numbers[6] = document.forms[0].balance7.value;
	
		var num = 0;	
		for (i = 0; i< 7; i++) {
			tmp = numbers[i].replace(/£/g,'0');
			num = num + parseInt (tmp.replace(/,/g,''), 10);
		}
		
		document.forms[0].totalbalance.value = formatCurrency (num);
		return formatCurrency(field);
	}
	
	function formatCurrencyMonthly(field) {
		// Ignore the previous amount, caculate the balance based on the present values
		// Then format the passed currency and return
		var numbers = new Array (7);
		numbers[0] = document.forms[0].monthly1.value;
		numbers[1] = document.forms[0].monthly2.value;
		numbers[2] = document.forms[0].monthly3.value;
		numbers[3] = document.forms[0].monthly4.value;
		numbers[4] = document.forms[0].monthly5.value;
		numbers[5] = document.forms[0].monthly6.value;
		numbers[6] = document.forms[0].monthly7.value;
	
		var num = 0;	
		for (i = 0; i< 7; i++) {
			tmp = numbers[i].replace(/£/g,'0');
			num = num + parseInt (tmp.replace(/,/g,''), 10);
		}
		document.forms[0].totalmonthly.value = formatCurrency (num);
		return formatCurrency(field);
	}
