/* Javascript stylesheet */
document.write("<link rel=\"StyleSheet\" href=\"/nosAssets/css/nosJavascript.css\" type=\"text/css\" media=\"screen\" />");

/**********************************************************************************
Client: 	NOS:
Project:	NOS Main Website
Author: 	BL
Date: 		08.04.08
**********************************************************************************/

/**********************************************************************************
@Name:			fnInit()
@Description: 	Initialisation Function to set up required styles, classes etc
@Notes: 		called by body onLoad event
************************************************************************************/
function fnInit() {}

/**********************************************************************************
Browser identification
Notes: returns true if browser is within spec
************************************************************************************/
// Global Variables
var iepc,firefox,ns7,ns8,opera,camino,safari,OS

function fnBrowser() {	
	var ua = navigator.userAgent.toLowerCase();	
	OS = ua.indexOf("windows") != -1? "PC":"MAC";		
	
	iepc = (((ua.indexOf("msie 7") != -1)||(ua.indexOf("msie 6") != -1)||(ua.indexOf("msie 5.5") != -1))&&(ua.indexOf("windows") != -1)&&(ua.indexOf("opera") == -1))? true:false;
	firefox = ua.indexOf("firefox") != -1 ? true:false; // pc or mac	
	ns7 = ua.indexOf("netscape/7") != -1 ? true:false; 
	ns8 = ua.indexOf("netscape/8") != -1 ? true:false; // firefox mode
	safari = (ua.indexOf("safari") != -1 && OS!='PC')? true:false;	
	opera = ua.indexOf("opera/9") != -1 ? true:false;
	camino = ua.indexOf("camino") != -1 ? true:false; 
	if (iepc||firefox||ns7||ns8||opera||camino||safari) {
		return true;
	} else {
		return false;
	}
}
fnBrowser(); // run on load;



/**********************************************************************************
Force Focus to move past iFrame
onfocus() event has minor browser compatability issues. Not used for Mozilla Browser.
Selects the moveTo ID and jumps to the first link within 
@param: moveTo - must be an ID within the page
************************************************************************************/
function fnMoveFocus(moveToID) {
	if(iepc) {
		document.getElementById(moveToID).getElementsByTagName("A")[0].focus();
	}
}




/********************************************************************************

Name: 					Flash detect.
Description:			boolean true/false if installed and version number 
						accessed via flash.version
@var flash.installed	true is flash is installed
@var flash.version		flash player version
*********************************************************************************/

var flash = new Object();	
flash.installed = false;

if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {		
			flash.installed = true;					
			flash.version = eval(navigator.plugins[x].description.split('Shockwave Flash ')[1].split('.')[0]);					
			break;
		}
	}
}
else if (window.ActiveXObject) {
	for (x = 2; x <= 20; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {		
				flash.installed = true;	
				flash.version = x;
			}
		}
		catch(e) {}
	}
}



	
/********************************************************************************

Name: 				Flash embed
Description:		Writeout flash code. Fixes Eolas update for IE as well.
@param	swf			String path to swf file
@param	width		Number value of movie width
@param	height		Number value of movie height
@param	minVersion	minimum required version of flash for swf. defaults to 6
@param 	nonFlashId	the id of the container for non-flash content. 

*********************************************************************************/

flash.insert = function(swf,width,height,minVersion,nonFlashId) {		
	swf = swf.replace(/\./g,"%2E") // encode periods as %2e	

	if(!minVersion){minVersion = 6;}	
	if (flash.installed) {
		if(flash.version > minVersion) {		
			flashObject = '<embed src="'+swf+'" menu="false" width="'+width+'" height="'+height+'" scale="noscale" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" salign="T" />';	
			fnHide(nonFlashId);
			document.write(flashObject);	
		}
		else {
			fnShow(nonFlashId);
		}	
	}
}


function fnHide(id) {
	if(!document.getElementById(id)){return false};
	var oTarg = document.getElementById(id).style;
	oTarg.position = "absolute";
	oTarg.top = "-5000px";
	oTarg.left = "0";
}

function fnShow(id) {
	if(!document.getElementById(id)){return false};
	var oTarg = document.getElementById(id).style;
	oTarg.position = "static";
	oTarg.top = "";
	oTarg.left = "";
}


/**
 * Remove the initial text in the search box when you focus on it.
 */
function fnSearchBoxFocus(oBox) {
    if(oBox.value == 'Search') {
        oBox.value = '';
    }
}


/**
 * Toggle hides text in div with id="hide_this"
 */
// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {
 
// choose text for the show/hide link
var showText="Show the hidden text";
var hideText="Hide the text";
 
// create the toggle link
$("#hide_this").before("<p><a href='#' id='toggle_link'>"+showText+"</a>");
 
// hide the content
$('#hide_this').hide();
 
// capture clicks on the newly created link
$('a#toggle_link').click(function() {
 
// change the link text
if ($('a#toggle_link').text()==showText) {
$('a#toggle_link').text(hideText);
}
else {
$('a#toggle_link').text(showText);
}
 
// toggle the display
$('#hide_this').toggle('slow');
 
// return false so any link destination is not followed
return false;
                });
 
});
