<!--
/* (CC) 2007 Eden Design 
Default javascript file for Content

Structure of this file:         
1. Implementation of namespace:
	- Content 
2. Definition global variables
3. Content.init(): start javascript app
4. Specific functions

'namespace': Lib = library */
/* 'namespace': Content */
var Content = {};

/* global variables */
// Content....

/* initialise javascript on page */
Content.init = function() {
	//used for debugging - set to true in debugging mode
	Lib.debug = true;
	try {	
		Lib.setPageIsStyled();
		
		//add scalings links
		Lib.addScalingLinks();
		
		Lib.setScreenWidth();
		
		// replace standard dropdown boxes by style ones
		Lib.selectAlternate();
				
		//add clearing text input fields on focus
		Lib.inputAutoClear();
		
		Lib.addImageButtonHovers(); //add hover functionalty image buttons
		Lib.addButtonHovers(); //add hover functionalty button buttons
		
		//Lib.buttonHover();
		
		//add opening/closing faq
		Content.addFaq();
		
		Content.addFlashMovie();
		
		//footer
		Lib.addPrintLink();
		//Lib.positionFooter();		
	} 
	catch (ex){ Lib.errHandler(ex); }	
}

Content.doResize = function() {
	try {	
		Lib.setScreenWidth();
		//Lib.positionFooter();
	} 
	catch (ex){ Lib.errHandler(ex); }	
}

/* Faq ----------------------------------------------------------------*/
Content.addFaq = function () {
	var  faqDivs = Lib.getElementsByClassName("faqs", "div");
	
	for(var i=0; i<faqDivs.length; i++) {
		var h4s = faqDivs[i].getElementsByTagName("h4");
		for(var j=0; j<h4s.length; j++) {
			var hyperlink = document.createElement("a");
			hyperlink.innerHTML = h4s[j].innerHTML;
			hyperlink.href="#";
			hyperlink.onclick= function () { Content.toggleFaqAnswer(this); return false;};
			Lib.eventCache.add(hyperlink, "onclick", function () { Content.toggleFaqAnswer(this); return false;}, false); 	
			
			h4s[j].innerHTML = "";
			h4s[j].className = "loaded";
			h4s[j].appendChild(hyperlink);
		}
	}
}

Content.toggleFaqAnswer = function (hyperlink) {
	var h4 = hyperlink.parentNode;
	var answer = Lib.getNextElement(h4);
	if(h4.className=="loaded") {
		h4.className = "loaded open"
		answer.className = "answer";
	}
	else {
		h4.className = "loaded";
		answer.className = "answer hide";
	}
}

Content.addFlashMovie = function () {
	if(Lib.pageIsStyled && document.getElementsByTagName("body")[0] && (document.getElementsByTagName("body")[0].id == "locations" || document.getElementsByTagName("body")[0].id == "corporateMovie")) {
		var majorFlashVersion = 0;
		if(Flash.FlashVersion()) {
			majorFlashVersion = Flash.FlashVersion()[0];
		}	
		
		if(parseInt(majorFlashVersion) >=8) {
			var mainContent = document.getElementById("mainContent");
			mainContent.className = "flash";
			
			var holder = document.createElement("div");
			holder.id = "flashMovieHolder";
			mainContent.appendChild(holder);
			
			if(document.getElementsByTagName("body")[0].id == "locations") {
				var qs = new Lib.querystring();
				country = qs.get("country");
			
				Flash.loadSwf(holder, Lib.flashLocationFinder +"?xmlFile=" + Lib.flashLocationFinderXML + "&countryCode=" + country, 532, 600, "left", "lt");	
			}
			else if (document.getElementsByTagName("body")[0].id == "corporateMovie") {
				Flash.loadSwf(holder, "/swf/CorporateMovie.swf", 532, 300, "left", "lt", "displayheight=259&height=279&width=496&file=/swf/video_geodiswilson.flv&image=/swf/firstframe.jpg&showdigits=false&autostart=true&overstretch=fit");	
			}
		}
		else if ( document.getElementById("noFlash")) { document.getElementById("noFlash").className = ""; }		
	}
}


Content.loadFlash = function (flashMovie, height, width) {
	var majorFlashVersion = 0;
	if(Flash.FlashVersion()) {
		majorFlashVersion = Flash.FlashVersion()[0];
	}	
	
	if(parseInt(majorFlashVersion) >=8) {
		var mainContent = document.getElementById("mainContent");
		mainContent.className = "flash";
		
		var holder = document.createElement("div");
		holder.id = "flashMovieHolder";
		mainContent.appendChild(holder);
        Flash.loadSwf(holder, flashMovie, height, width, "left", "lt" + "&autostart=true&overstretch=fit");	
	}
	else if ( document.getElementById("noFlash")) {document.getElementById("noFlash").className = "";}		
}


/* End Faq ----------------------------------------------------------------*/

//add stylesheet when javascript is enabled
Lib.addStyleSheet("/styles/javascript.css");
//set fontsize
if(Lib.getCookie("fontsize")) { Lib.scaleFont(Lib.getCookie("fontsize"), false);};


Lib.addEvent(window, "load", Content.init);
Lib.eventCache.add(window, "load", Content.init, false); 	

Lib.addEvent(window, "resize", Content.doResize );
Lib.eventCache.add(window, "resize", Content.doResize, false);


//-->
