
var isW3C = (document.getElementById)?true:false;
var isAll = (document.all)?true:false;

function openFAQ(anc, sdom)
{
	try
	{
		var ifr = document.getElementById("fra");

		if (ifr)
		{	
			ifr.src = sdom + "faqs/Index.asp?answers=1#" + anc;
		}	
	}
	catch(e)
	{}
	finally
	{
		return false;
	}
}

function newwindow(mypage, myname, w, h, scroll, sContent) {
	try	
	{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
		win = window.open(mypage, myname, winprops);
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		if (sContent.length > 0){win.document.writeln(sContent);}
	}
	catch(e)
	{
		window.alert('A window was trying to open but was blocked by your browser.\n\nTo view the content unrestrict popups and try again');
	}
	return false;
}

function sB(va)
{
	document.getElementById('butHyper').disabled = false;
	document.getElementById('txtSelection').value=va.id;
}

function changeHeaderImage(what, resetDisplay)
{
	try
	{
		var o = getObject('tmpBanner');

		if ( o != null )
			o.src="_images/content_pages_top/" + what;

		o = getObject('resetTag');

		if ( o != null )
			o.style.visibility = resetDisplay;
	}
	catch(e)
	{
		window.alert(e.description);
	}
}

function resetTemplate(what)
{
	try
	{
		var o = getObject('selTemplates');

		o.value = what;
		changeHeaderImage(what, "hidden");
	}
	catch(e)
	{}
	finally
	{
		return false;
	}
}

function cacheImgs()
{
	var img1 = new Image();
	img1.src = "_images/navigation/home2_hig.gif";
	var img2 = new Image();
	img2.src = "_images/navigation/contact_us2_hig.gif";
	var img2 = new Image();
	img2.src = "_images/navigation/about_us_hig.gif";
	var img3 = new Image();
	img3.src = "_images/navigation/contact_us_directions_hig.gif";
	var img4 = new Image();
	img4.src = "_images/navigation/faqs_hig.gif";
	var img5 = new Image();
	img5.src = "_images/navigation/home_hig.gif";
	var img6 = new Image();
	img6.src = "_images/navigation/marketing_comms_hig.gif";
	var img7 = new Image();
	img7.src = "_images/navigation/news_hig.gif";
	var img8 = new Image();
	img8.src = "_images/navigation/policy_documents_hig.gif";
	var img9 = new Image();
	img9.src = "_images/navigation/recruitment_hig.gif";
	var img10 = new Image();
	img10.src = "_images/navigation/services_hig.gif";
	var img11 = new Image();
	img11.src = "_images/navigation/testimonials_hig.gif";
	var img12 = new Image();
	img12.src = "_images/home/bkt_digital_asset_mana_hig.gif";
	var img13 = new Image();
	img13.src = "_images/home/bkt_smart_print_hig.gif";
	var img14 = new Image();
	img14.src = "_images/home/search_hig.gif";
	var img15 = new Image();
	img15.src = "_images/home/sign_up_hig.gif";
	var img16 = new Image();
	img16.src = "_images/search_site_button_hig.gif";
}

//returns form elements
function getObject(s)
{
	var o = null;

	if  ( isW3C )
	{
		if ( document.getElementById(s) != null )
			o = document.getElementById(s);
	}
	else if ( isAll )
	{
		if ( document.all[s] != null )	
			o = document.all[s];
	}
	
	return o;
}

//restrict user input to integer values only
function RestrictUserInput(elem) 
{
    	if (/[^\d]/g.test(elem.value))
       		elem.value = elem.value.replace(/[^\d]/g, '');
}

//toggles a textbox value based upon checkbox value
function toggleTextfromCheck(chk,text)
{
	var o = getObject(text);

	if ( o != null )
	{
		o.value = ( chk.checked ) ? 1 : 0;
	}
}

//toggles a textbox value based upon checkbox value
function toggleTextfromCheckInt(chk,text,val)
{
	var o = getObject(text);

	if ( o != null )
	{
		o.value = ( chk.checked ) ? val : 0;
	}	
}

//compare two text boxes
function compareBox(txt1, txt2)
{
	var o = getObject(txt1);
	var p = getObject(txt2);
	var status = false;

	if ( o != null && p != null )
	{
		status = ( o.value == p.value );
	}

	return status;
}

//notify's caller of comparison of boxes
function matchBoxes(txt1, txt2, divEl, rtnText)
{
	var display = "";
	var o = getObject(divEl);

	if ( o != null )
	{
		if ( !compareBox(txt1, txt2) )
			display = rtnText;			
	}

	o.innerHTML = display;
}
