// ***** INITIALIZE PAGE FOR CURRENT CLIENT BROWSER ****
//Determine browser, set additional stylesheet and perform setup functions (default browser is IE 6.x)
//See _script/sniffer.js and _script/sniffer.htm for browser check documentation 
/*
if ([condition]) {
	document.write('<link rel="stylesheet" type="text/css" href="_css/_browsers/[file]" />');
}
*/

//SAFARI
if (is_safari) {
	document.write('<link rel="stylesheet" type="text/css" href="_css/Safari-fix.css" />');
}

// ***** /INITIALIZE PAGE FOR CURRENT CLIENT BROWSER ****

// ***** SET FOOTER ****
//Get window height 
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
//Set footer
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('content').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
			}
			else {
				footerElement.style.position = 'static';
			}
		}
	}
}
window.onload = function() {
	setFooter();
}
window.onresize = function() {
	setFooter();
}
// ***** SET FOOTER ****

// ***** APPEARANCE COOKIE (FONT, CONTRAST) ****
//Set accesibility cookie	
function setAppearanceCookie(sParam) {
	var cookieName = 'p6AppCookie';
	var cookieValue = '';
	//create cookie value for sParam = Font
	if (sParam == 'Font') {
		//set new font value
		cookieValue = 'Font*on|Contrast*' + sContrast;
		if (sFont == 'on') {
			cookieValue = 'Font*off|Contrast*' + sContrast;	
		}
	}
	//create cookie value for sParam = Contrast
	if (sParam == 'Contrast') {
		//set new contrast value
		cookieValue = 'Font*' + sFont + '|Contrast*on';
		if (sContrast == 'on') {
			cookieValue = 'Font*' + sFont + '|Contrast*off';
		}
	}
	//write cookie
  	document.cookie = cookieName + "=" + escape(cookieValue) + "; ";
	location.reload();
}
// ***** /APPEARANCE COOKIE (FONT, CONTRAST) ****

// ***** FOLD AND UNFOLD OBJECTS ****
//Call as foldItem('itemId','imageId'/false)
function foldItem(oFold,oImage) {
	//fold or unfold item
	if (document.getElementById(oFold).style.display == 'block') {
		document.getElementById(oFold).style.display = 'none';
	}
	else {
		document.getElementById(oFold).style.display = 'block';
	}
	//swap image (if oImage is not false)
	if (oImage != false) {
		//get and set image status
		var sNewExtension = '';
		var aImageUrl = document.getElementById(oImage).src.split('/');
		aImageUrl = aImageUrl[aImageUrl.length-1].split('_');
		//set closed
		if (aImageUrl[aImageUrl.length-1].indexOf('open.gif') != '-1') {
			sNewExtension = 'closed.gif'
		}
		//set open
		if (aImageUrl[aImageUrl.length-1].indexOf('closed.gif') != '-1') {
			sNewExtension = 'open.gif'
		}
		//create new src string
		var sNewSrc = '';
		for (var i=0;i<aImageUrl.length-1;i++) {
			sNewSrc += aImageUrl[i] + '_';
		}
		sNewSrc += sNewExtension;
		//swap image
		document.getElementById(oImage).src = '_img/' + sNewSrc;
	}
}
// ***** /FOLD AND UNFOLD OBJECTS ****

// ***** /FORMS ****
//Toggle field lead text
/* Toggle the field lead text. Function uses element title to reset cleared lead texts. */
function frmLeadToggle(oField,e) {
	switch (e.type) {
		case 'focus':
			if (oField.value == oField.title) { 
				oField.value = ''; 
			}
			oField.style.color = '#000000';
			return false;
			break;
		case 'blur':
			if (oField.value.length == 0) {
				oField.value = oField.title;
				oField.style.color = '';
			}
			return false;
			break;
	}
}
// ***** /FORMS ****

// ***** MAIL ****
//Send mail
function doSend(suff,name,domain) {
	location.href = 'mailto:' + name + '@' + domain + '.' + suff;
}
// ***** /MAIL ****

// ***** INITIALIZE PAGE ****
// Initialize page onload
window.onload = function() {
	initPage();
}

//Initialize page
function initPage() {
	//Replace heading classes
	replaceHeadingClasses();
	//Replace sIFR 2.0 classes
	//sIFRreplacementCalls();
}

//Set heading and container classes and colors
//arrays containing classes and colors
var aBusinessAreaClasses = new Array('box-1','box-2','box-3','box-4');
function replaceHeadingClasses() {
	//replace classes for main column headings
	var cMainColHeadings = document.getElementById('columns-mid').getElementsByTagName('H1');
	for (var i=0;i<cMainColHeadings.length;i++) {
		if (i==0) {
			cMainColHeadings[i].className = 'main-first';
		}
		else {
			cMainColHeadings[i].className = 'main-other';
		}
	}
}

// ***** INITIALIZE PAGE ****