/*
	Copyright David Trewern Design         :: www.dtdesign.com ::
	Unauthorised modification / use is a criminal offence, and
	will be prosecuted to the fullest extent permitted by law.
	All Rights Reserved
*/

NAVarr = new Array("navhome", "navrevolution", "navloans", "navfaqs", "navapply", "navabout", "navcontact", "navbanking", "subnavfeatures", "subnavausunity", "subnavbp", "subnavrequest",
									 "go", "findoutmore", "findoutmore2", "applynow", "applynowblue", "ausunitycalculator", "comparenow", "download", "bpwebsite", "clear", "submit");
if (document.images)
{
	for (var NAVitem in NAVarr)
	{ 
		 for (var NAVicount=0; NAVicount < 2; NAVicount++)
		 { 
				eval("b" + NAVarr[NAVitem] + NAVicount + " = new Image()");
				eval("b" + NAVarr[NAVitem] + NAVicount + ".src = '/assets/swap_" + NAVarr[NAVitem] + "_" + NAVicount + ".gif'");
		 } 
	} 
}

function BturnOn(imageName)
{
	if (document.images)
	{
		var imageNumber = "";
		if (arguments.length > 1) imageNumber = arguments[1];
		document [imageName + imageNumber].src = eval("b" + imageName + "1.src");
	}
}

function BturnOff(imageName)
{
	if (document.images)
	{
		var imageNumber = "";
		if (arguments.length > 1) imageNumber = arguments[1];
		document [imageName + imageNumber].src = eval("b" + imageName + "0.src");
	}
}

function mNavSetOn(obj) {
	obj.src = obj.src.replace(/off/,'on');
}

function mNavSetOff(obj) {
	obj.src = obj.src.replace(/on/,'off');
}

function BturnOnInput(obj,imageName)
{
	if (obj.src)
	{
		obj.src = eval("b" + imageName + "1.src");
	}
}

function BturnOffInput(obj,imageName)
{
	if (obj.src)
	{
		obj.src = eval("b" + imageName + "0.src");
	}
}
function toggleFAQ(id, obj)
{
	if (document.getElementById(id).style.display == "none")
	{
		document.getElementById(id).style.display = "block";
		obj.style.backgroundImage = "url(/assets/bullet02.gif)";
	}
	else
	{
		document.getElementById(id).style.display = "none";
		obj.style.backgroundImage = "url(/assets/bullet01.gif)";
	}
}

function hideAnswers()
{
	
	//The number of FAQ's categories	
	var TOTALCATEGORY = 3;
	var TOTALQA = 50;
	
	// Loop through all categories
	// i is the category number
	for (i = 1; i <= TOTALCATEGORY; i++)
	{
		// j is the question/answer
		for (j = 1; j < TOTALQA; j ++)
		{
			var id = "category" + i + "answer" + j;
			
			if (document.getElementById(id) != null)
			{
				document.getElementById(id).style.display = "none";
			}
		}
	}
}

function imgPopup(path)
{
	if (path)
	{
		window.open("utils_imagepopup.html?path=" + path, "popup", "width=400, height=300, toolbar=no, status=no, scrollbars=yes, resizable=yes");
	}
}

function ddRedirect(dd)
{
	if (dd.options[dd.selectedIndex].value != "") self.location = dd.options[dd.selectedIndex].value;
}

function resizeWindow(layoutAdjustmentW, layoutAdjustmentH)
{
	if ((document.images) && (document.theimage) && (document.theimage.width))
	{

		var imageW = document.theimage.width;
		var imageH = document.theimage.height;

		var screenW = screen.availWidth;
		var screenH = screen.availHeight;

		var resizeToScreen = false;

		if (imageW <= screenW)
		{
			resizeW = imageW;
		}
		else
		{
			resizeW = screenW;
			resizeToScreen = true;
		}

		if (imageH <= screenH)
		{
			resizeH = imageH;
		}
		else
		{
			resizeH = screenH;
			resizeToScreen = true;
		}

		var userAgent = navigator.userAgent;

		//Windows Adjustments
		if (userAgent.indexOf("Windows") != -1)
		{
			if (userAgent.indexOf("MSIE 5") != -1)
			{
				resizeW += 29;
				resizeH += 38;

				if (resizeToScreen)
				{
					resizeW -= 29;
				}
			}
			if (userAgent.indexOf("MSIE 6") != -1)
			{
				resizeW += 31;
				resizeH += 61;
			}
			if (userAgent.indexOf("Firefox") != -1)
			{
				resizeW += 8;
				resizeH += 56;

				if (resizeToScreen)
				{
					resizeW -= 8;
				}
			}
			if (userAgent.indexOf("Netscape/7") != -1) {
				resizeW += 8;
				resizeH += 36;

				if (resizeToScreen)
				{
					resizeW -= 8;
				}
			}
		}

		//Mac Adjustments
		if (userAgent.indexOf("Mac") != -1)
		{
			if (userAgent.indexOf("Safari") != -1)
			{
				resizeW += 0;
				resizeH += 23;
			}
			if (userAgent.indexOf("MSIE 5") != -1)
			{
				resizeW += 0;
				resizeH += 0;
			}
			if (userAgent.indexOf("Firefox") != -1)
			{
				resizeW += 0;
				resizeH += 18;
			}
			if (userAgent.indexOf("Netscape/7") != -1)
			{
				resizeW += 0;
				resizeH += 2;
			}
		}

		if (!isNaN(layoutAdjustmentW))
		{
			resizeW += layoutAdjustmentW;
		}
		if (!isNaN(layoutAdjustmentH))
		{
			resizeH += layoutAdjustmentH;
		}

		if (resizeToScreen)
		{
			window.moveTo(0,0);
		}
		window.resizeTo(resizeW, resizeH);

	}
}

function toggleField(obj, fieldID)
{
	var f = document.getElementById(fieldID);
		
	if (obj.value.toLowerCase() == "yes")
	{
		f.style.display = "block";
	}
	else
	{
		f.style.display = "none";
	}
}

function toggleBooleanField(obj, fieldID)
{
	var f = document.getElementById(fieldID);
		
	if (obj.checked == true)
	{
		f.style.display = "block";
	}
	else
	{
		f.style.display = "none";
	}
}
