 //init method invokes generic page code
function fInit () {
	//set on each page - common menu
	//fSetMenuRollovers();
	//fSetMenuRolloversManual();
	//sets up rollovers inside divs specified in array
	//fSetContentRollovers(new Array("iBigLinks","iFooterNav","footerPortBroc"));
	//fSetContentRollovers(new Array("iBigLinks","iFooterNav","footerPortBroc", "iContainer"));
	//find any fader text sections
	faderObj = getElementsByClassName(document, "span", "textFade");
	if (faderObj.length > 0) {
		fSetupFaders(faderObj);
	}
	//just in case the flash fails, make sure content gets shown on homepage
	defaultContent = setTimeout("fShowHomePage()", 10000);
	//changetext();
	if ($('#headerimage').length > 0) {
		if ($('#headerimage').children().length > 1) {
			$('#headerimage').innerfade({
				speed: 'slow',
				timeout: 5000,
				type: 'sequence',
				containerheight: '232px' });
		} else  {
			$('#headerimage').children(0).show();
		}
	}
}

//Popup Script
function fPopup(location) {
window.open( location, "Headland", 
"status = 1, height = 500, width = 500, resizable = 1, scrollbars = 1" )
}

//make the menu work
function fSetMenuRollovers () {
	img = document.getElementById("iLHS").getElementsByTagName("IMG");
	for (i = 0; i < img.length; i++) {
		img[i].onmouseover = img[i].onmouseout = function () {
			c = this.src.toString().split("/")
			c = c[c.length-1];
			if (this.className != "selected") {
				if (c.indexOf("_off") > -1) {
					c = c.replace(/_off/, "_on");
					this.src = "./images/navigation/on/" + c;
				} else {
					c = c.replace(/_on/, "_off");
					ppImg = new Image();
					ppImg.src = "./images/navigation/off/" + c
					this.src = "./images/navigation/off/" + c;
				}
			}
		}
	}
}

var currentImageName = "";

//make the menu work
function fSetMenuRolloversManual () {
	img = document.getElementById("iRollover").getElementsByTagName("IMG");
	for (i = 0; i < img.length; i++) {
		img[i].onmouseover = img[i].onmouseout = function () {
			if (this.src.toString() = currentImageName)
			{
				alert("yes");
				c = this.src.toString().split("/")
				c = c[c.length-1];
				c = c.replace(/_off/, "_on");
				this.src = "./images/navigation/on/" + c;
			}
			else
			{
				if (this.src.toString().match("_off") || this.src.toString().match("_on"))
				{
					alert("no");
					c = this.src.toString().split("/")
					c = c[c.length-1];
					if (this.className != "selected") {
						if (c.indexOf("_off") > -1) {
							c = c.replace(/_off/, "_on");
							this.src = "./images/navigation/on/" + c;
						} else {
							c = c.replace(/_on/, "_off");
							ppImg = new Image();
							ppImg.src = "./images/navigation/off/" + c
							this.src = "./images/navigation/off/" + c;
						}
					}
				}
			}
		}
	}
}
//sets rollovers for items froun in the main content div
function fSetContentRollovers (a) {
	for (k = 0; k < a.length; k++) {
		var bl = document.getElementById(a[k]);
		if (bl) {
			j = bl.getElementsByTagName("IMG");
			for (i=0;i<j.length;i++) {
				j[i].onmouseover = j[i].onmouseout = function () {
					if (this.src.toString() == currentImageName)
					{
						m = bl.getElementsByTagName("IMG");
						for (l=0;l<m.length;l++) {
							d = m[l].src.toString().split("/");
							d = d[d.length-1];
							d = d.replace(/_on/, "_off");
							m[l].src = "images/layout/" + d;
							//alert(m[l].src.toString() + " : " + "./images/library/" + d);
						}
						//alert("yes");
						c = this.src.toString().split("/");
						c = c[c.length-1];
						c = c.replace(/_off/, "_on");
						this.src = "images/layout/" + c;
					}
					else
					{
						if (this.src.toString().match("_off") || this.src.toString().match("_on"))
						{
							//alert("no");
							c = this.src.toString().split("/")
							c = c[c.length-1];
							p = c[c.length-2];
							//fe(c);
							if (c.indexOf("_off") > -1) {
								c = c.replace(/_off/, "_on");
								this.src = "images/layout/" + c;
							} else {
								c = c.replace(/_on/, "_off");
								ppImg = new Image(); //preload
								ppImg.src = "images/layout/" + c
								this.src = "images/layout/" + c;
							}
						}
					}	
				}
			}
		}
	}
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d, a) {
		
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
var bl = document.getElementById(a);
	if (bl) {
		j = bl.getElementsByTagName("IMG");
		if (currentImageName == "")
		{
			currentImageName = j[0].src.toString();	
				m = bl.getElementsByTagName("IMG");
				for (i=0;i<m.length;i++) {
					if (m[i].src.toString() == currentImageName)
					{
						c = m[i].src.toString().split("/");
						c = c[c.length-1];
						c = c.replace(/_off/, "_on");
						m[i].src = "images/layout/" + c;
					}
				}
		}
		else
		{
			var y = new Array("lay0","lay1","lay2");
			currentImageName = j[0].src.toString();
			if (bl) {		
				for (z = 0; z < y.length; z++) {
					var blz = document.getElementById(y[z]);
					m = blz.getElementsByTagName("IMG");
					for (l=0;l<m.length;l++) {
						k = m[l].src.toString().split("/");
						k = k[k.length-1];
						k = k.replace(/_on/, "_off");
						m[l].src = "images/layout/" + k;
						if (m[l].src.toString().substring(0, 70) == currentImageName.substring(0, 70))
						{
							k = m[l].src.toString().split("/");
							k = k[k.length-1];
							k = k.replace(/_off/, "_on");
							m[l].src = "images/layout/" + k;
						}
					}
				}
			}	
		}
	}
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
//loops each fader and assigns timeout
function fSetupFaders (a) {
	var g = 0;
	while (g < a.length) {
		t = setTimeout("fDoFade()", 5000);
		g++;
	}
}
//does fade in
function fDoFade () {
	new Effect.Morph(faderObj[0], {style:'background:#333131; color:#fff;', duration:0.5})
}
//controls the case studies bit
function fHighlightHidden (o, t) {
	if (fExists(o)) {
		//alert(document.getElementById(o).innerHTML);
		if (t) {
			document.getElementById(o).style.display = "inline";
		} else {
			document.getElementById(o).style.display = "none";
		}
	}
}
//returns array of elemenets qith classname x
function getElementsByClassName (oElm, strTagName, strClassName){
	//getElementsByClassName(document, "span", "fadeText");
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];      
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}   
	}
	return (arrReturnElements)
}
//writes flash embed object into the DOM
function fWriteFlash (s, w, h, t) {
	if (fFlashOK()) {
		n = "temp_SwfObject";
		if (s != undefined) {
			str = ''; 
			str += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"	width="' + w + '" height="' + h + '" id="' + n + '">';
			str += '<param name=movie value="' + s + '">';
			str += '<param name=quality value=high>';
			str += '<embed src="' + s + '" quality=high width="' + w + '" height="' + h + '" name="myMovieName" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" menu=false>';
			str += '</embed></object>';
			document.write (str);
		}
	} else {
		document.write ("<p>Flash player required...</p>");
	}
}
//flash detection... needs implementing!
function fFlashOK () {
	//return true;
	var contentVersion = 6;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if (plugin) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i = 0; i < words.length; ++i) {
			if (isNaN(parseInt(words[i])))
			continue;
			var PluginVersion = words[i]; 
		    }
		var FlashCanPlay = PluginVersion >= contentVersion;
	}
	return FlashCanPlay;	
}
//check to see if DOM element exists
function fExists (c) {
	if (document.getElementById(c)) return true;
	return false;
}
//hides hello message
function fShowHomePage() {
	if (fExists("iHello")) {document.getElementById("iHello").style.display = "none";}
	if (fExists("iHomeContent")) {document.getElementById("iHomeContent").style.display = "inline";}
	
}
//debug method
function fe (s) {
	document.getElementById("iDebug").innerHTML = s;
}




function showHide(theid){
	
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);

        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
}

function popUpLink() {
day = new Date();
id = day.getTime();
fullURL = "flvplayer";
eval("page" + id + " = window.open(fullURL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=640,height=480');");
}

var min=8;
var max=18;
var y = new Array("div","p","h1","h2","h3","h4");	
function increaseFontSize(sSize) {
	for (z = 0; z < y.length; z++) {
	   var p = document.getElementsByTagName(y[z]);
	   for(i=0;i<p.length;i++) {
		  if(p[i].style.fontSize) {
			 var s = parseInt(p[i].style.fontSize.replace("px",""));
		  } else {
			 var s = 12;
		  }
		  if(s!=max) {
			 s += 1;
		  }
		  p[i].style.fontSize = sSize+"px"
	   }
	}
}
function decreaseFontSize(sSize) {
	for (z = 0; z < y.length; z++) {
	var p = document.getElementsByTagName(y[z]);
		for(i=0;i<p.length;i++) {
		  if(p[i].style.fontSize) {
			 var s = parseInt(p[i].style.fontSize.replace("px",""));
		  } else {
			 var s = 12;
		  }
		  if(s!=min) {
			 s -= 1;
		  }
		  p[i].style.fontSize = sSize+"px"
		}  
	}
}

