
	function returnWindowWidth(windowRef) {
		var width = 0;
		if (!windowRef) {
			windowRef = window;
		}
		if ( document.documentElement ) {
			//width = document.documentElement.clientWidth;
			width = document.documentElement.offsetWidth;
		} else {
			if (typeof(windowRef.innerWidth) == 'number') {
				width = parseInt((windowRef.innerWidth - 1) - (windowRef.outerWidth - windowRef.innerWidth));
			}
			if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') {
				width = windowRef.document.body.clientWidth;
			}
		}
		if (width < 750) {
			width = 750;
		}
		return width;
	}

	function getObj(name) {
		//alert(name);
		if (document.getElementById) {
			this.obj = document.getElementById(name);
			this.style = document.getElementById(name).style;
		} else if (document.all) {
			this.obj = document.all[name];
			this.style = document.all[name].style;
		} else if (document.layers) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		}
	}

	function ChangeImage(anchorRef,imgRef) {
		document.images[anchorRef].src = "includes/img/toolbox-" + imgRef + ".gif";
	}
	
	var arrFeatures = new Array();
	var intCounter = 0;
	var objFeature;
	var strFeatureID;
	var intFeatureTimeout;
	var intFeatureTime = "10000"; // Set timer to timeout every 10 seconds
	
	function ShowFeature() {
	
			// Clear the timer
			clearTimeout(intFeatureTimeout);
			
			// Hide all features
			for ( i=0; i<arrFeatures.length; i++ ) {
				strFeatureID = "feature"+i;
				objFeature = new getObj(strFeatureID);
				objFeature.style.visibility = "hidden";
			}
			
			// Show the feature we're currently at
			strFeatureID = "feature"+intCounter;
			objFeature = new getObj(strFeatureID);
			objFeature.style.visibility = "visible";
			
			// Increment the feature counter, check it hasn't reached it's limit
			intCounter++;
			if ( intCounter == arrFeatures.length ) {
				intCounter = 0;
			}
			
			// Set the TimeOut to do it all again
			intFeatureTimeout = setTimeout("ShowFeature()",intFeatureTime);
	
	}
	



 function toSt(n)
 {s=""
  if(n<10) s+="0"
  return s+n.toString();
 }
 
 function countdown()
 {
 var eventdate = new Date("July 1, 2007 00:00:00 GMT+1000");
  cl=document.clock;
  d=new Date();
  count=Math.floor((eventdate.getTime()-d.getTime())/1000);
  if(count<=0)
    {cl.days.value ="----";
     cl.hours.value="--";
     cl.mins.value="--";
     cl.secs.value="--";
     return;
    }
  cl.secs.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.mins.value=toSt(count%60);
  count=Math.floor(count/60);
  cl.hours.value=toSt(count%24);
  count=Math.floor(count/24);
  cl.days.value=count;    
  
  setTimeout("countdown()",500);
 }




	function init() {
	
		var intWindowWidth = returnWindowWidth();
		var intToolboxPosition = (intWindowWidth - 415) / 2;
		var objToolbox = new getObj("toolbox");
		objToolbox.style.left = intToolboxPosition + "px";
		objToolbox.style.visibility = "visible";
		
		// Clear the timer
		clearTimeout(intFeatureTimeout);

		if ( arrFeatures.length > 0 ) {
			intFeatureTimeout = setTimeout("ShowFeature()",1000);
		}
		countdown()
	
	}
	

// ####################################
// Windows & Alerts
// ####################################

// ====================
// Function:    Popup
//
// Purpose:     Open a popup window with a series of option settings.
//
// Input:       strPage - The URL of the page to open in the popup window.
//              intWidth - The window width in pixels 
//              intHeight - The window height in pixels
//              strID - The ID of the popup window. (This is important if the
//                window may be called on by other functions or if there are
//                multiple popup windows in a site.)
//              strScrollbars - Switch visible scrollbars on/off ("yes"/"no")
//              strLocation - Switch visible location bar on/off ("yes"/"no")
//              strToolbar - Switch visible toolbar on/off ("yes"/"no")
//              strStatus - Switch visible status bar on/off ("yes"/"no")
//              strResizable - Window is resizable or not ("yes"/"no")
//
// Output:      Window opens containing the specified URL.
//
// Assumptions: -
//
// History:     DDSN created back in the Distant Past
// ====================
function Popup(strPage,intWidth,intHeight,strID,strScrollbars,strLocation,strToolbar,strStatus,strResizable)
{
	if (!strPage)
	{
		strPage = "/";
	}
	if (!intWidth)
	{
		intWidth = 500;
	}
	if (!intHeight)
	{
		intHeight = 320;
	}
	if (!strID)
	{
		strID = "PopupWindow";
	}
	if (!strScrollbars)
	{
		strScrollbars = "yes";
	}
	if (!strLocation)
	{
		strLocation = "no";
	}
	if (!strToolbar)
	{
		strToolbar = "no";
	}
	if (!strStatus)
	{
		strStatus = "no";
	}
	if (!strResizable)
	{
		strResizable = "yes";
	}
	//if (isLoaded == 0)
	//{
	//	location.reload();
	//}
	idPopup = window.open(strPage,strID,"width="+intWidth+",height="+intHeight+",scrollbars="+strScrollbars+",location="+strLocation+",toolbar="+strToolbar+",status="+strStatus+",resizable="+strResizable);
	if (window.focus)
	{
		idPopup.focus();
	}
	return false;
}

// ====================
// Function:    PopdownLink
//
// Purpose:     Open a link in a popup window in a specified main window and
//              close the popup window. If the specified link window does not
//              exist it is created. If no window is specified the link is
//              targeted to the original opener of the popup window.
//
// Input:       strURL - The URL of the page to open
//              strWindowID - The ID of the window in which to open the link
//
// Output:      Navigates to selected URL in selected window and closes current
//              window.
//
// Assumptions: -
//
// History:     DDSN created back in the Distant Past
//              2004 Multiple window targets added. (Previously could only
//                   target the opener.)
// ====================
function PopdownLink(strURL,strWindowID)
{
	if (!strWindowID)
{
		top.opener.location.href = strURL;
}
	else
{
		if (strWindowID.location)
	{
			strWindowID.location.href = strURL;
	}
		else
	{
			window.open(strURL,strWindowID);
	}
}
	top.close();
}

// ====================
// Function:    toggleElement
//
// Purpose:     Turn visibility of any element on or off.
//
// Input:       strDivId - ID of the element being altered
//              strDisplayVal = "block", "inline" or "none"
//
// Output:      Turns specified element on or off.
//
// Assumptions: Specified element exists in document hierarchy.
//
// History:     SW Taken from cancervic staging 2007-12-19
// ====================
function toggleElement(strDivId,strDisplayVal)
{
	if (!strDisplayVal)
	{
		strDisplayVal = document.getElementById(strDivId).style.display;

		switch (strDisplayVal)
		{
			case "block" :
				strDisplayVal = "none";
				break;
			case "inline" :
				strDisplayVal = "none";
				break;
			case "none" :
				strDisplayVal = "block";
				break;
			case "" :
				break;
		}
	}
	document.getElementById(strDivId).style.display = strDisplayVal;
}



// ====================
// Function:    CheckWords
//
// Purpose:     to check form input for bad words
//                  also replaces javascript writelabel function
//
// Input:       ="javascript:CheckWords();" or something similar...
// Input:       ="javascript:CheckWords(strFormName,strInputLabelField,strField1,strField2-up to strField5);" or something similar...
//                 strFormName - name of the form
//                 strInputLabelField - the field to use for generating a label - e.g. use an email field like 'Field003'
//                 strFieldx - name of the field(s) to check. Expects at least one, others are optional and theres a max of 5.
//
// Output:      Gives alert and stops form submission if bad words are found
//
// Assumptions:      Label is passed through in the form. Text ID handled separately from form.
//
// History:     SW Taken from smokefree 2008-03-04, made to work with more than one form and field
// ====================

	//var arrWords = new RegExp("\bpenis\b","\banalingus\b","\barse\b","\bass\b");
	var arrWords = new Array("penis","analingus","arse","ass","ballock","ballocks","blouser","bollock","bollocks","boner","boobies","boong","bucksnort","bum","butt","porn","clart","clit","clitty","cock","cojones","coon","cootch","cooze","cornhole","cracksman","creamstick","culo","culty","cum","cunny","cunt","cuntino","danglers","dicky","dinger","dodaddy","doniker","dooflicker","dummock","dyke","eel-skinner","eff","everythingathon","faggot","fagot","fanny","fart","farting","fartleberries","firk","fisting","flatbacker","floosie","fluffer","fluzz","frinding","fuck","furbox","furburger","gayboy","gazongas","get laid","ginch","gobble-prick","gonsel","goober","goodwrench","goolies","grassback","greeking","gully-hole","gunch","gurk","hard-on","hat-rack","have it away","have it off","heinie","hen-hussy","himmer","honey-hive","honey-pot","honkers","Honkie","hooters","horner","hornington","horns-to-sell","horny","hose-bag","hot-assed","hunkers","hussy","jaboos","jang","jaxy","jemson","Jerk off","jerking","Jigaboo","jing","jink","jism","jizz","jizzum","jollies","juggs","kazongas","kielbasa","lesbo","lesbyterian","letching","letch-water","lezzie","lezzo","lickety","lickety-split","lick-spigot","light-foot","limp-wrist","lobcock","loblollies","loose woman","loose women","love muscle","luds","lues","malkin","mammets","root","mazola","mcmuff","mean-on","meatroll","merkin","mintle","moll","momzer","monger","muff","mugget","naf","naggle","nance","nancies","nards","nates","nerk","nig","nigger","nigra","ninnies","nockstress","noogies","noony","nooty","notchery","nubbies","nug","nympho","oat-bin","onan's","orgies","palookas","panderer","pects","pee-pee","penwiper","pillow-biter","pisser","pissing","plimpton","plugtail","poo","poof","pooftah","poontang","poot","poove","porker","preggers","preggy","prosser","prossy","pucky","pussy","puta","putz","quiff","quim","quimstake","quimsticking","raped","rimadonna","ring-snatcher","rootle","rooty","roundheel","roundies","schlong","scumbag","scumber","scut","scutz","sexpert","sexpot","shagstress","shit","shmock","shvontz","siff","sissy","sixty nine","sixty niner","slakin","slammin","slappin","Slut","snappin","snarf","SOB","soft-jaw","bitch","sove","spazo","split-rump","spratz","squattin","stiffy","tail-work","tally-whacker","third-sexer","three-dollar","tickle-gizzard","tickle-tail","tinker's dam","tinker's damn","tit","tits","titties","tool-chest","tootsie","tosser","touch-crib","toy-toy","trap-stick","tribadist","tug-mutton","tumple","turd","tush","twanger","twangers","twank","twat","twixter","twofers","two-finger","uranist","vag","wag-tail","waldos","wang","wank","wanker","wazoo","whacker","whiffer","whiskin","whizzin","whomp","Whore","will-knots","wizzer","wongas","wonk","wooly-booger","wop","yabbos","yackum","yawne","yentz","yid","yosh","zook");
	//var arrWords = new Array("penis ","analingus ","arse ","ass ","ballock ","ballocks ","blouser ","bollock ","bollocks ","boner ","boobies ","boong ","bucksnort ","bum ","butt ","porn ","clart ","clit ","clitty ","cock ","cojones ","coon ","cootch ","cooze ","cornhole ","cracksman ","creamstick ","culo ","culty ","cum ","cunny ","cunt ","cuntino ","danglers ","dicky ","dinger ","dodaddy ","doniker ","dooflicker ","dummock ","dyke ","eel-skinner ","eff ","everythingathon ","faggot ","fagot ","fanny ","fart ","farting ","fartleberries ","firk ","fisting ","flatbacker ","floosie ","fluffer ","fluzz ","frinding ","fuck ","furbox ","furburger ","gayboy ","gazongas ","get laid ","ginch ","gobble-prick ","gonsel ","goober ","goodwrench ","goolies ","grassback ","greeking ","gully-hole ","gunch ","gurk ","hard-on ","hat-rack ","have it away ","have it off ","heinie ","hen-hussy ","himmer ","honey-hive ","honey-pot ","honkers ","Honkie ","hooters ","horner ","hornington ","horns-to-sell ","horny ","hose-bag ","hot-assed ","hunkers ","hussy ","jaboos ","jang ","jaxy ","jemson ","Jerk off ","jerking ","Jigaboo ","jing ","jink ","jism ","jizz ","jizzum ","jollies ","juggs ","kazongas ","kielbasa ","lesbo ","lesbyterian ","letching ","letch-water ","lezzie ","lezzo ","lickety ","lickety-split ","lick-spigot ","light-foot ","limp-wrist ","lobcock ","loblollies ","loose woman ","loose women ","love muscle ","luds ","lues ","malkin ","mammets ","root ","mazola ","mcmuff ","mean-on ","meatroll ","merkin ","mintle ","moll ","momzer ","monger ","muff ","mugget ","naf ","naggle ","nance ","nancies ","nards ","nates ","nerk ","nig ","nigger ","nigra ","ninnies ","nockstress ","noogies ","noony ","nooty ","notchery ","nubbies ","nug ","nympho ","oat-bin ","onan's ","orgies ","palookas ","panderer ","pects ","pee-pee ","penwiper ","pillow-biter ","pisser ","pissing ","plimpton ","plugtail ","poo ","poof ","pooftah ","poontang ","poot ","poove ","porker ","preggers ","preggy ","prosser ","prossy ","pucky ","pussy ","puta ","putz ","quiff ","quim ","quimstake ","quimsticking ","raped ","rimadonna ","ring-snatcher ","rootle ","rooty ","roundheel ","roundies ","schlong ","scumbag ","scumber ","scut ","scutz ","sexpert ","sexpot ","shagstress ","shit ","shmock ","shvontz ","siff ","sissy ","sixty nine ","sixty niner ","slakin ","slammin ","slappin ","Slut ","snappin ","snarf ","SOB ","soft-jaw ","bitch ","sove ","spazo ","split-rump ","spratz ","squattin ","stiffy ","tail-work ","tally-whacker ","third-sexer ","three-dollar ","tickle-gizzard ","tickle-tail ","tinker's dam ","tinker's damn ","tit ","tits ","titties ","tool-chest ","tootsie ","tosser ","touch-crib ","toy-toy ","trap-stick ","tribadist ","tug-mutton ","tumple ","turd ","tush ","twanger ","twangers ","twank ","twat ","twixter ","twofers ","two-finger ","uranist ","vag ","wag-tail ","waldos ","wang ","wank ","wanker ","wazoo ","whacker ","whiffer ","whiskin ","whizzin ","whomp ","Whore ","will-knots ","wizzer ","wongas ","wonk ","wooly-booger ","wop ","yabbos ","yackum ","yawne ","yentz ","yid ","yosh ","zook ");
	var arrFieldsToCheck = new Array();
	var strWord;
	var strFieldToCheck = '';
	var strWordFound;
	var strListOfWordsFound = '';
	var strMsg = 'WARNING\n\nThe following words found in your comments \nare NOT permitted on our website. To successfully \nsubmit your comments, please edit them out.\n';
		 
	 function CheckWords(strFormName,strInputLabelField,strField1,strField2,strField3,strField4,strField5) {
	 	
		if (!strFormName)
		{
			strFormName = "contact";
		}
		if (!strInputLabelField)
		{
			strInputLabelField = "form submission";
		}
		
	 	// Warn the user to be patient
	 	// alert('Thank you. Your comments are being submitted. \n\nPlease be patient and do not press the submit button a second \ntime: submission of comments can take up to 30 seconds. ');
	 	
	 	// Incase the user has already attempted to submit, clear the previous
	 	// list of non-permitted words found.
	 	strListOfWordsFound = '';

		// Set up an array of fields to check;
	 	arrFieldsToCheck[0] = document.forms[strFormName].elements[strField1].value;
		if (strField2) {
			arrFieldsToCheck[1] = document.forms[strFormName].elements[strField2].value;
		}
		if (strField3) {
			arrFieldsToCheck[2] = document.forms[strFormName].elements[strField3].value;
		}
		if (strField4) {
			arrFieldsToCheck[3] = document.forms[strFormName].elements[strField4].value;
		}
		if (strField5) {
			arrFieldsToCheck[4] = document.forms[strFormName].elements[strField5].value;
		}
		
		// Loop through the fields to check and check them against the list of non-permitted words
		for ( j = 0; j < arrFieldsToCheck.length; j++ ) {
			strFieldToCheck = arrFieldsToCheck[j];
		alert('strFieldToCheck = ' + strFieldToCheck);
			for ( i = 0; i < arrWords.length; i++ ) {
				strWord = arrWords[i];
		//alert('strWord = ' + strWord);
				//if ( strWord.match(strFieldToCheck) ) {
				if ( strFieldToCheck.match(strWord) ) {
					//strWordFound = strWord.match(strFieldToCheck);
					strWordFound = strFieldToCheck.match(strWord);
		//alert('strWordFound = ' + strWordFound);
					if ( strWordFound == strWord ) {
						strListOfWordsFound = strListOfWordsFound + '\n' + strWordFound;
		//alert('strListOfWordsFound = ' + strListOfWordsFound);
					}
				}
			}
		}
		// Loop through the fields to check and check them against the list of non-permitted words
	//	alert('hm');
	//	for ( j = 0; j < arrWords.length; j++ ) {
	//		arrWords = arrWords[j];
			//alert('strFieldToCheck = ' + strFieldToCheck);
	//		for ( i = 0; i < strFieldToCheck.length; i++ ) {
	//			strWord = arrWords[j];
				//if ( strWord.match(strFieldToCheck) ) {
	//			if ( strFieldToCheck.match(strWord) ) {
					//strWordFound = strWord.match(strFieldToCheck);
	//				strWordFound = strFieldToCheck.match(strWord);
					//alert('strWordFound = ' + strWordFound);
	//				if ( strWordFound == strWord ) {
	//					strListOfWordsFound = strListOfWordsFound + '\n' + strWordFound;
						//alert('strListOfWordsFound = ' + strListOfWordsFound);
	//				}
	//			}
	//		}
	//	}
	 	
	 	if ( strListOfWordsFound != '' ) {
	 		alert(strMsg+strListOfWordsFound);
	 	} else {
			document.forms[strFormName].elements['Label'].value = document.forms[strFormName].elements['Label'].value + document.forms[strFormName].elements[strInputLabelField].value;
	 		document.forms[strFormName].submit();
	 	}
	 	
	 }
