﻿function swapfeed(varFeed)
{
 document.getElementById('marker-good').style.display = "none";
 document.getElementById('marker-fair').style.display = "none";
 document.getElementById('marker-poor').style.display = "none";

 document.getElementById('marker-' + varFeed).style.display = "block";
}

function swapmorgfeed(varFeed, pageLoad)
{
document.getElementById('fixed').style.display = "none";
document.getElementById('flexible').style.display = "none";
document.getElementById('discount').style.display = "none";
//document.getElementById('capped').style.display = "none";
document.getElementById('first').style.display = "none";
document.getElementById('self').style.display = "none";
document.getElementById('buytolet').style.display = "none";
document.getElementById('adverse').style.display = "none";
document.getElementById('offset').style.display = "none";
document.getElementById('variable').style.display = "none";

document.getElementById('marker-fixed').className = "";
document.getElementById('marker-flexible').className = "";
document.getElementById('marker-discount').className = "";
//document.getElementById('marker-capped').className = "";
document.getElementById('marker-first').className = "";
document.getElementById('marker-self').className = "";
document.getElementById('marker-buytolet').className = "";
document.getElementById('marker-adverse').className = "";
document.getElementById('marker-offset').className = "";
document.getElementById('marker-variable').className = "";

document.getElementById('marker-' + varFeed).className = "selected";
document.getElementById(varFeed).style.display = "block";
}


function calcHeight()
{
//find the height of the internal page
var the_height=document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;

//change the height of the iframe
document.getElementById('the_iframe').height = the_height;
}

function calcHeightParent()
{
//find the height of the internal page
var the_height=document.body.scrollHeight;

//change the height of the iframe
if(window.frameElement.id = 'the_iframe'){
window.frameElement.height = the_height;
}
}

function debtCalculator()
{

//Simple addition and subtraction to create total.

var totalIncome = 0, totalExpenditure = 0, monthTotal = 0;

arrIncome = new Array("salary", "savingsIn", "pension", "benefits", "otherIn");

arrExpenditure = new Array("bills", "insurance", "food", "transport", "debt", "savingsOut", "family", "recreational", "oneOff", "clothes", "otherOut");

/* Get the sum of all the income */
for(i = 0; i < arrIncome.length; i++){
if(document.getElementById(arrIncome[i]).value == ""){
document.getElementById(arrIncome[i]).value = 0;
}
totalIncome = Number(totalIncome) + Number(document.getElementById(arrIncome[i]).value);
}

/* Get the sum of all the expenditure */
for(i = 0; i < arrExpenditure.length; i++){
if(document.getElementById(arrExpenditure[i]).value == ""){
document.getElementById(arrExpenditure[i]).value = 0;
}
totalExpenditure = Number(totalExpenditure) + Number(document.getElementById(arrExpenditure[i]).value);
}

/* Work out the total */
monthTotal = Number(totalIncome) - Number(totalExpenditure);

/* Rounding issue */
var newnumber = 0;
if (monthTotal > 8191 && monthTotal < 10485) {
monthTotal = monthTotal-5000;
newnumber = Math.round(monthTotal*Math.pow(10,2))/Math.pow(10,2);
newnumber = newnumber+5000;
} else {
newnumber = Math.round(monthTotal*Math.pow(10,2))/Math.pow(10,2);
}
monthTotal = newnumber;

document.getElementById('monthTotal').value = monthTotal;

return true;

}

function navigation() {
    if (document.all&&document.getElementById) {
    navRoot = document.getElementById("navigation");

        for (i=0; i<navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName=="LI" || node.nodeName=="li") {
                node.onmouseover=function() {
                    this.className+=" over";
                }
                node.onmouseout=function() {
                    this.className=this.className.replace(" over", "");
                }
            }
        }
    }
}

 function resize_frame()
	 {
		
		//var f = 
		//alert(parent.document.getElementById('TB_iframeContent').contentWindow.document.body.offsetHeight  + "px");

 //alert(parent.document.getElementById('TB_iframeContent').contentWindow.document.body.scrollHeight);
	//	        alert( parent.document.getElementById('TB_iframeContent').contentDocument.body.offsetHeight);
		     //   alert(body.offsetHeight);
           
           
      //  alert(parent.document.getElementById('TB_iframeContent'));   
       // alert(parent.document.getElementById('TB_iframeContent').contentDocument);
       // alert(parent.document.getElementById('TB_iframeContent').contentWindow);
        		
		if(parent.document.getElementById('TB_iframeContent').contentDocument)  
		{
                parent.document.getElementById('TB_iframeContent').style.height = parent.document.getElementById('TB_iframeContent').contentDocument.body.scrollHeight + 20 + "px"; 
		}
		else if(parent.document.getElementById('TB_iframeContent').contentWindow) 
		{
		       
				parent.document.getElementById('TB_iframeContent').style.height = parent.document.getElementById('TB_iframeContent').contentWindow.document.body.scrollHeight + 20 + "px"; 
		}
   
		 



		}

		
	/*	
		function tb_position() {


			var MIN_WIDTH = 550;

			var oDiv = window.parent.document.getElementById("TB_window");
			var TB_WIDTH = oDiv.style.width;
			var TB_HEIGHT = oDiv.style.height;
			
			var oImage = document.getElementById("TB_Image");

			

			if (oImage.width  < MIN_WIDTH)
			{
				//alert('image smaller than minimum width');
				var imageWidth = parseInt(oImage.width);
				oDiv.style.width = MIN_WIDTH + 35 + 'px';
				//sort out left margin to central align
				
				//oImage.marginLeft = ((MIN_WIDTH - imageWidth) / 2) + 'px';
				//alert(imageWidth);
			}
			else
			{
				//alert('image greater than minimum width');
				oDiv.style.width = oImage.width + 35 + 'px';
			}

			

			//alert('-' + (parseInt(oDiv.style.width.replace('px','')) / 2) + 'px');

			var marginLeft = parseInt(oDiv.style.width.replace('px','')) / 2;
			marginLeft = marginLeft - 90;


			oDiv.style.marginLeft = '-' + marginLeft + 'px';
			oDiv.style.marginTop = - 200 + 'px';

			
		}	*/	
		
