// General Shared Code
// Includes global variables.
// Should be included in all html pages

/////////////////////////////////////////////////////////////////////////////////////
// Dave 24/08/08
// Globals for slideshow speed

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3


/******************************************* Styles & Positions for menus *****************************************/


/******************************************* General Functions *****************************************/
//////////////////////////////////////////////////////////////////////////////////////
// Kris 17/09/08
// Shows/Hides the element with the specified ID, hides the previously opened element
// Used by doQA function

var openblock;
var openblock = '';

function toggle(what){

if(document.getElementById(what).style.display != "block"){
	if(openblock != ''){
		document.getElementById(openblock).style.display = "none";
	}
	document.getElementById(what).style.display = "block";
	openblock = what;
}else{
	document.getElementById(what).style.display = "none";
	openblock = '';
}

}

//////////////////////////////////////////////////////////////////////////////////////
// Kris 17/09/08
// Inserts code to create a toggleable question/answer block
// Pass in a question string and answer string

var qnum;
qnum = 0;

function doQA(quest, ans){

qnum = qnum + 1;

document.writeln(
	'<p class="mquest"><a href="javascript:toggle(\'ans'
	+ qnum
	+ '\')">'
	+ quest
	+ '</a></p>');
document.writeln(
	'<p class="mansw" id="ans'
	+ qnum
	+ '">'
	+ ans
	+ '</p>');

}

//////////////////////////////////////////////////////////////////////////////////////
// Dave 24/08/08
// GRadient Box code.
// Place in a pre sized Div, will create a grdient box with rounded corners that fills the div
// Relies aon css style sheet items being present!!
// Relies aon images being present in /images subdir
// To write text on top of it us another div with absolute placement (like <div class="divFeatText"> from css) 

function MakeGradientBox ()
{

document.writeln('<!-- Start gradient box -->'
		 + '<img src="images/gradient.png" alt="" width="100%" height="100%">'	
                 + '<div class="divBox">' 
                 + '<div class="t"><div class="b"><div class="l"><div class="r"><div class="bl"><div class="br"><div class="tl"><div class="tr">'	
 		 +  '</div></div></div></div></div></div></div></div></div>'
                 + '<!-- End gradient box -->'
                 + ' ');

}



//////////////////////////////////////////////////////////////////////////////////////
// Dave 24/08/08
// Util function that get sthe cusrent ulr and checks to see where the web site is (on NZ server/ local machine or web)
// It also gets the pathing of a subdirectory that may be attached and apprends that to ensure we get the french menus
// etc.
//
function general_get_path( subdirtoadd ) 
{
    var strThisUrl = window.location.href;   // this items URL
	var index;
	var pathfound;
	var slashtoadd = "";

	if (subdirtoadd != "") {
		slashtoadd = "/";
	}
	//Kris 3/9/09 Cleaned up path creation, now uses relative paths with language detection
	if( strThisUrl.indexOf("french") != -1 || strThisUrl.indexOf("german") != -1 || strThisUrl.indexOf("spanish") != -1 ){
		pathfound = "../" +  subdirtoadd + slashtoadd; //Up one level if we are on a foreign language page
	} else {
		pathfound = "" +  subdirtoadd + slashtoadd; //Else standard relative path
	}

   return pathfound;
}


//////////////////////////////////////////////////////////////////////////////////////
// Dave 24/08/08
// Util function Change the imageto that of a new image name and path when rolled over or released
// This is like the pressing of a button, or mouseover for any image we are dealing with on a menu
//

function general_change_named_image(imagename, new_image_path) 
{
//	alert ( 'B4 flags[i].src ' + flags[i].src + '; i is ' + i +' \nimagename is ' 
//	+ imagename + '\n document.images[imagename].src is now,' + document.images[imagename].src 
//	+ '\ngeorge.src is ' + george.src  );

	if (document.images) document.images[imagename].src = new_image_path;

}


//////////////////////////////////////////////////////////////////////////////////////
// Dave 24/08/08
// Util function Change the url automatically after loading
// This is like the pressing of a button, or mouseover for any image we are dealing with on a menu
// It is defined for every file, but only called in the "search files"
// called like this
// <script LANGUAGE="JavaScript" FOR="window" EVENT="onLoad()">
// <!--
//  general_forward("elecdes.htm");
// -->
// </script>


function general_forward(new_url_withoutpath) 
{
	// Kris 3/9/09 Cleaned out unneeded crud, now just does a plain relative redirect
	window.location.replace (new_url_withoutpath);
}




