function openBrWindow(theURL,winName,features,width,height) {
	x = 0;
	y = 0;
	if (parseInt(navigator.appVersion) >= 4) {
		x = (screen.width / 2) - (width / 2);
		y = (screen.height / 2) - (height / 2);
	}
	features = features + ",top=" + y + ",left=" + x + ",width=" + width + ",height=" + height;
	window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_validateForm2() { //v4.0
  var errors_highlight='#FFFF7F';
  var errors_unhighlight='#FFFFFF';
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm2.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { obj=val;obj.style.backgroundColor=errors_unhighlight;nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) { errors+='- '+nm+' must contain an e-mail address.\n';obj.style.backgroundColor=errors_highlight; }
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) { errors+='- '+nm+' must contain a number.\n';obj.style.backgroundColor=errors_highlight; }
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) { errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';obj.style.backgroundColor=errors_highlight; }
		  }
          if (test.indexOf('aboveMin') != -1) {
            min=test.substring(9);
            if (num<min) { errors+='- '+nm+' must contain a number above '+min+'.\n';obj.style.backgroundColor=errors_highlight; }
      } } } else if (test.charAt(0) == 'R') { errors += '- '+nm+' is required.\n';obj.style.backgroundColor=errors_highlight; } }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers2() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers2.arguments;
	for (i=0; i<(args.length-2); i+=3) {
		if ((obj=MM_findObj(args[i]))!=null) {
			v=args[i+2];
			v2=args[i+2];
		}
		if (obj.style) {
			obj=obj.style;
			v=(v=='show')?'visible':(v=='hide')?'hidden':v;
			v2=(v2=='show')?'block':(v2=='hide')?'none':v2;
		}
		obj.visibility=v;
		obj.display=v2;
	}
}

function confirmemail() {
	if (document.MM_returnValue && (document.contactform.subscribe[0].checked == false && document.contactform.subscribe[1].checked == false)) {
		alert("Please complete:\n- Do you wish to receive regular email updates?");
		document.MM_returnValue = false;
	}
}

function complete_any(form_object, fields_array) {
	var errors_highlight='#FFFF7F';
	var errors_unhighlight='#FFFFFF';
	//if (document.MM_returnValue) {
		var found = false;
		var msg = 'Please complete any of the following:';
		for (var i in fields_array) {
			if (form_object.elements[fields_array[i]]) {
				form_object.elements[fields_array[i]].style.backgroundColor = errors_unhighlight;
				if (form_object.elements[fields_array[i]].value != '') {
					found = true;
				}
				msg += "\n-" + fields_array[i];
			}
		}
		if (!found) {
			for (var i in fields_array) {
				if (form_object.elements[fields_array[i]]) {
					form_object.elements[fields_array[i]].style.backgroundColor = errors_highlight;
				}
			}
			alert(msg);
			document.MM_returnValue = false;
		}
	//}
}

//http://www.4guysfromrolla.com/webtech/vb2java.shtml
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.
 
	RETVAL:
		The formatted number!
 **********************************************************************/
{ 
        if (isNaN(parseInt(num, 10))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number
	
	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign
	
	
	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);
		
	//trailing zeros mod
	if (tmpNumStr.indexOf(".") != -1) {
		if (tmpNumStr.length-tmpNumStr.indexOf(".")-1 < decimalNum) {
			for (n = tmpNumStr.length-tmpNumStr.indexOf(".")-1; n < decimalNum; n++) {
				tmpNumStr += "0";
			}
		}
	} else {
		tmpNumStr += ".";
		for (n = 0; n < decimalNum; n++) {
			tmpNumStr += "0";
		}
	}

	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}		
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	return tmpNumStr;		// Return our formatted string!
}

function calculate_total_monthly_income() {
	var total = 0;
	total += parseFloat("0" + document.contactform.Net_Monthly_Salary.value);
	total += parseFloat("0" + document.contactform.Car_Allowance.value);
	total += parseFloat("0" + document.contactform.Partners_Net_Salary.value);
	total += parseFloat("0" + document.contactform.Other_Income.value);
	document.contactform.Total_Monthly_Income.value = FormatNumber(parseFloat(total), 2, true, false, false);
}

function calculate_total_monthly_expenditure() {
	var total = 0;
	total += parseFloat("0" + document.contactform.Mortgage_Rent.value);
	total += parseFloat("0" + document.contactform.Utility_Bills.value);
	total += parseFloat("0" + document.contactform.Credit_Cards.value);
	total += parseFloat("0" + document.contactform.Current_Car_Payments.value);
	total += parseFloat("0" + document.contactform.Other_Expenses.value);
	document.contactform.Total_Monthly_Expenditure.value = FormatNumber(parseFloat(total), 2, true, false, false);
}

function calculate_initial_payment() {
	var total = parseFloat("0" + document.contactform.Monthly_budget.value) * 6;
	document.contactform.Initial_payment.value = FormatNumber(parseFloat(total), 2, true, false, false);
}

function toggle_layers(l, c) {
	if (c.checked) {
		MM_showHideLayers2(l,'','show');
	} else {
		MM_showHideLayers2(l,'','hide');
	}
}

/*Example CSS for the two demo scrollers*/

/*#pscroller1{
width: 200px;
width: 100px;
border: 1px solid black;
padding: 5px;
background-color: lightyellow;
}

#pscroller2{
width: 350px;
width: 20px;
border: 1px solid black;
padding: 3px;
}

#pscroller2 a{
text-decoration: none;
}

.someclass{ //class to apply to your scroller(s) if desired
}*/


/*Example message arrays for the two demo scrollers*/

/*var pausecontent=new Array()
pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
pausecontent[1]='<a href="http://www.codingforums.com">Coding Forums</a><br />Web coding and development forums.'
pausecontent[2]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'

var pausecontent2=new Array()
pausecontent2[0]='<a href="http://www.news.com">News.com: Technology and business reports</a>'
pausecontent2[1]='<a href="http://www.cnn.com">CNN: Headline and breaking news 24/7</a>'
pausecontent2[2]='<a href="http://news.bbc.co.uk">BBC News: UK and international news</a>'*/


/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%; z-index:1" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden; filter: alpha(opacity=0); -moz-opacity: 0; z-index:2" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivleft=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be left padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivleft*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
ie5  = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
this.opac = 0;
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}

// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){// was +-1 50
var scrollerinstance=this



////if (parseInt(this.hiddendiv.style.left)>(this.visibledivleft+2)){
if(this.opac < 100){
    this.opac+=2;
    if (ie5) this.hiddendiv.style.filter='alpha(opacity='+this.opac+')';
    if (ns6) this.hiddendiv.style.MozOpacity = this.opac/100;
////this.visiblediv.style.left=parseInt(this.visiblediv.style.left)-2+"px"
////this.hiddendiv.style.left=parseInt(this.hiddendiv.style.left)-2+"px"
setTimeout(function(){scrollerinstance.animateup()}, 10)
}
else{
this.opac = 0;
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv.innerHTML=this.hiddendiv.innerHTML
if (ie5) this.hiddendiv.style.filter='alpha(opacity=0)';
if (ns6) this.hiddendiv.style.MozOpacity = 0;
//this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
div1.style.left=this.visibledivleft+"px"
////div2.style.left=Math.max(div1.parentNode.offsetWidth, div1.offsetWidth)+"px"
div2.style.left=div1.style.left
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingLeft"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-left")
else
return 0
}