// e-CHO Javascript Library of Common calls
// Version 2.6
// Finalised 03/07/2004
// Author: Colin Bell

//Added colour picker

//Version 2.5 update
//Changed menus to work as xml for the java vesrion

//Version 2.6 update
//Changed buttons to work with java version
//imporved banner scrit to include swf files


var agt=navigator.userAgent.toLowerCase();
var is_mac    = (agt.indexOf("mac")!=-1);
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_major = parseInt(navigator.appVersion);  
var is_minor = parseFloat(navigator.appVersion); 
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1));  
var isMinNS4 = (is_nav && (is_major == 4));//Netscape 4 
var isMinIE4 = (document.all) ? 1 : 0; 
var is_nav6 = (is_nav && (is_major == 5)); //Netscape 6 

var today = new Date();
var version;
var printNoFlash;// global so as to share with vb
var printFlash;
var timer=-1;

		if (navigator.userAgent.indexOf("MSIE 3") != -1) {  version = 1;} //...MSIE 3 PC
		if (navigator.userAgent.indexOf("Mozilla/2") != -1) {  version = 2;} //...NS 2 PC
		if (navigator.userAgent.indexOf("Mozilla/3") != -1)  {version = 3;} //... NS 3 PC
		if (navigator.userAgent.indexOf("Mozilla/2.0") != -1) {  version = 4;}
		if (navigator.userAgent.indexOf("Mozilla/4") != -1)  {version = 5;}  //...NS4
		if (navigator.userAgent.indexOf("Mozilla/4") != -1 & navigator.userAgent.indexOf("Mac")!=-1) {  version = 11;} //... NS 4 MAC
		if (navigator.userAgent.indexOf("MSIE 4") != -1) {  version = 6;} //... MSIE 4 PC
		if (navigator.userAgent.indexOf("MSIE 5") != -1) {  version = 7;} //... MSIE 5 PC
		if (navigator.userAgent.indexOf("WebTV") != -1) {  version = 8;} //...WEB TV
		if (navigator.userAgent.indexOf("MSIE 4") != -1 & navigator.userAgent.indexOf("Mac")!=-1) {  version = 9;} //...MSIE 4 MAC
		if (navigator.userAgent.indexOf("MSIE 5") != -1 & navigator.userAgent.indexOf("Mac")!=-1) {  version = 10;} //...MSIE 5 MAC
		if (navigator.userAgent.indexOf("Mozilla/5") != -1) {version = 12;} //...NS6
		if (navigator.userAgent.indexOf("MSIE 6") != -1) {  version = 13;} //... MSIE 6 PC
		if (navigator.userAgent.indexOf("MSIE 7") != -1) {  version = 14;} //... MSIE 7 PC

function inject_flash(whichFlash, whichNonFlash, whatWidth, whatHeight, whatColour){
//Ultimate Flash detection function	- Usage below	
//<!-- START JSCRIPT PLUGIN DETECTION inject_flash(flash object, non flash object, width, height, back colour) -->
//<script>inject_flash("flash.swf", "non-flash.jpg","520","300", "#91D3BC");vbFlashDetect();</script>
//<!-- END JSCRIPT PLUGIN DETECTION -->

printFlash ="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+ whatWidth +"' height='"+ whatHeight +"' codebase='http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0'>";
		printFlash +="<param name=movie value='"+ whichFlash + "'>";
		printFlash +="<param name=quality value=high>";
		printFlash +="<param name=wmode value=transparent>";
        printFlash +="<param name=scale value=exactfit>";
		printFlash +="<param name=bgcolor value='"+ whatColour +"'>";
		printFlash +="<embed src='"+ whichFlash + "' quality=high wmode=transparent";
		printFlash +=" swLiveConnect=FALSE width='"+ whatWidth +"' height='"+ whatHeight +"' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>";
		printFlash +="<\/object>";
		
		if (whichNonFlash){printNoFlash = "<img src='"+ whichNonFlash + "' width='"+ whatWidth +"' height='"+ whatHeight +"' alt='no-flash found'>";}
		else {printNoFlash = "<CENTER>No Flash Plugin Detected - Please Download the flash plugin<\/CENTER>";}

  	if ((version == 5) || (version == 6) ||(version == 9) ||(version == 10) || (version == 11) || (version == 12)){ //...We check certain browsers for the shockwave plugin

      if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
		
    	document.write(printFlash);

  	}

		
 	else {document.write(printNoFlash);}

  	}
  }
  
function vbFlashDetect() {

document.write('<SCR'+'IPT LANGUAGE=VBScript>\r');
document.write('Private i, x, MM_FlashControlVersion \r');
document.write('On Error Resume Next \r');
document.write('x = null \r');
document.write('MM_FlashControlVersion = 0 \r');
document.write('var Flashmode \r');
document.write('FlashMode = False \r');
document.write('For i = 5 To 1 Step -1 \r');
document.write('Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \r');
document.write('MM_FlashControlInstalled = IsObject(x) \r');
document.write('If MM_FlashControlInstalled Then \r');
document.write('MM_FlashControlVersion = CStr(i) \r');
document.write('Exit For \r');
document.write('End If \r');
document.write('Next \r');
document.write('FlashMode = (MM_FlashControlVersion >= 4) \r');
document.write('If FlashMode = True Then \r');
document.write('document.write printFlash \r');
document.write('Else \r');
document.write('document.write printNoFlash \r');
document.write('End If \r');
document.write('<\/SCR'+'IPT>\r');

}

//JARGON SETTINGS
function showJargon(message){
	while(message.indexOf(",") != -1) {
		message = message.replace(",", "");
	}
	var layer="information";
	if(message != ""){
		moveLayer(layer,myMouseX-20,myMouseY-107);
		var myLength = (message.length/2) + 20;
		sizeLayer(layer,180,80)
		showLayer(layer);
		message = "<TABLE WIDTH='152' BORDER='0' CELLPADDING='0' CELLSPACING='0'><TR><TD><IMG SRC='/helpimages/speech-bubble_01.gif' WIDTH='8' HEIGHT='6' ALT=''><\/TD><TD width='130'><IMG SRC='/helpimages/speech-bubble_02.gif' WIDTH='130' HEIGHT='6' ALT=''><\/TD><TD COLSPAN=2><IMG SRC='/helpimages/speech-bubble_03.gif' WIDTH=14 HEIGHT='6' ALT=''><\/TD><\/TR><TR><TD height='69'><IMG SRC='/helpimages/speech-bubble_04.gif' WIDTH='8' HEIGHT='69' ALT=''><\/TD><TD align='center' valign='middle' bgcolor='#e3e7ed' width='130' height='69' CLASS='featureboxinfo'>"+ message +"<\/TD><TD height='69'><IMG SRC='/helpimages/speech-bubble_06.gif' WIDTH='13' HEIGHT='69' ALT=''><\/TD><TD height='69'><IMG SRC='/helpimages/speech-bubble_07.gif' WIDTH='1' HEIGHT='69' ALT=''><\/TD><\/TR><TR><TD><IMG SRC='/helpimages/speech-bubble_08.gif' WIDTH='8' HEIGHT='20' ALT=''><\/TD><TD width='130'><IMG SRC='/helpimages/speech-bubble_09.gif' WIDTH='130' HEIGHT='20' ALT=''><\/TD><TD COLSPAN=2><IMG SRC='/helpimages/speech-bubble_10.gif' WIDTH=14 HEIGHT='20' ALT=''><\/TD><\/TR><\/TABLE>";
		writeLayer(layer,"",message)
	}
}


function windowFileOpen(url, mWidth, mHeight) {
	
	var win = window.open(url, "filewin", "scrollbars=1, menubar=0, status=0,screenX=200,screenY=200,left=100,top=100, width=" + mWidth + ",height=" + mHeight);
	win.focus
	}

function window_open(url, mWidth, mHeight) {
	
	var win = window.open(url, "win", "scrollbars=1, menubar=0, status=0,screenX=200,screenY=200,left=100,top=100, width=" + mWidth + ",height=" + mHeight);
	win.focus
	}
	
function chatwindow_open(url, mWidth, mHeight) {
	var chatwin = window.open(url, "chat", "scrollbars=1, menubar=0, status=0,screenX=200,screenY=200,left=100,top=100, width=" + mWidth + ",height=" + mHeight);
	chatwin.focus
	}
	
function full_window_open(url) {
	
	var win = window.open(url, "", "resizable=1, scrollbars=1, menubar=0, status=0, width=800,height=600");
	win.focus
	}
	
function window_open_plain(url, mWidth, mHeight) {
	
	var win = window.open(url, "window", "scrollbars=0, menubar=0, status=0, width=" + mWidth + ",height=" + mHeight);
	win.focus
	}
	
function window_open_scroll(url, mWidth, mHeight) {
	
	var win = window.open(url, "windowscroll", "scrollbars=1, menubar=0, status=0, width=" + mWidth + ",height=" + mHeight);
	win.focus
	}

function Get_Date() {
	var dayName = new Array("SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY");

	month = today.getMonth()+1;
	date = today.getDate();
	day = today.getDay();
	year = today.getYear() + "";

	Year = year.substring(year.length-2,year.length);
	if (month < 10) {Month = "0" + month;} else {Month = month;}
	if (date<10) {Date="0"+date;} else {Date=date;}
	
	document.write(dayName[day]+"&nbsp; . &nbsp;"+Month+"."+Date+"."+Year);
}

function onResetForm(whatForm) {
myform = eval("document." + whatForm);
	document.myform.reset();
	return false;
}

function Get_Random(n) {
//	var today = new Date();
	var bigNumber = today.getSeconds() * today.getTime() * Math.sqrt(today.getMinutes());
	var randomNum = (parseInt(bigNumber) % n) + 1;
	return randomNum;
}
  
//This section makes echo parts work in the site
var whichField = "";
var activeField = "";

function changeFocus(field, formName){
	whichField = field;
	var currentField = eval("document."+ formName +".Gholder");
	currentField.value = whichField.name;
	activeField = eval("document."+ formName +"." + whichField.name);

}

function textCounterWarn(field,maxlimit) {
	if (field.value.length > maxlimit){//too long
		field.value = field.value.substring(0, maxlimit);
		alert("Sorry but you have passed the "+ maxlimit +" character limited allowed.");
		}
	}


function textCounter(field,cntfield,maxlimit) {
	if (field.value.length > maxlimit){//too long
		field.value = field.value.substring(0, maxlimit);
		}
	else{
		cntfield.value = maxlimit - field.value.length;
		}
	}

// This section is for the menu builder

function makeCategory(levelValue, menuName, menuLink, where, uid, inpage){

this.dName = "Question " + where ;
this.dUid = uid;
this.dLevelAnswer = levelValue;
this.dMenuName = menuName;
this.dMenuAnswer = menuLink;
if(inpage == null){inpage = "false";}
this.dMenuTypeAnswer = inpage;
this.dCheck = "true";
this.dNag = "<DIV CLASS='label'>* Please add a name<\/DIV>";
vMenuFurns[where]=this;

}

// creates a drop box
function tMenuDropBox(whichItem, whatElements){
var checkData = "";
elementArray = whatElements.split(",");
checkData += '<select class="dropdownbox" name="dropQuestion'+ whichItem + '" size="1" onchange="pAnswer('+whichItem+', this.value, this, \'A\');" class="answerbox">\r';
checkData += '<option value="'+ elementArray[i] +'" class="dropdownbox">--</option>\r';

for(var i=0;i<elementArray.length;i++ ){
		if (elementArray[i] == vMenuFurns[whichItem].dLevelAnswer){checkData += '<option value="'+ elementArray[i] +'" class="answerbox" selected>'+ elementArray[i] +'</option>\r';}
		else {checkData += '<option value="'+ elementArray[i] +'" class="answerbox">'+ elementArray[i] +'</option>\r';}
}
checkData += '</select>\r';
return checkData;
}

// creates a textarea box
function tMenuTextAreaBox(whichItem){
if (is_mac){var colWidth = "30";}
else{var colWidth = "15";}
var checkData = "";
checkData += '<TABLE><TR><TD><textarea name="Question'+ whichItem +'" onchange="pAnswer('+whichItem+', this.value,,\'C\');" class="textinputbox" cols="'+ colWidth +'" rows="5" onFocus="Javascript:changeFocus(this.name, \'GENERATE\');">'+ vMenuFurns[whichItem].dLevelAnswer +'</textarea></TD></TR>\r';
checkData += '</TABLE>\r';
return checkData;
}

// creates a check box
function tMenuCheckBox(whichItem, whatElements){
var checkData = "";
elementArray = whatElements.split(",");
checkData += '<TABLE><TR>\r';

for(var i=0;i<elementArray.length;i++ ){
	if ( vMenuFurns[whichItem].dMenuTypeAnswer == "true"){checkData += '<TD class="answers"><input type="checkbox" value="'+ elementArray[i] +'" name="checkQuestion'+ whichItem +'" onClick="pAnswer('+whichItem+', this.value,this,\'D\');" class="answerbox" checked>'+ "" +'&nbsp;</TD>';}
	else {checkData += '<TD class="answers"><input type="checkbox" value="'+ elementArray[i] +'" name="Question'+ whichItem +'" onClick="pAnswer('+whichItem+', this.value, this,\'D\');" class="answerbox">'+ "" +'&nbsp;</TD>';}
}

checkData += '</TR></TABLE>\r';
return checkData;
}

// creates a text box
function tMenuTextBox(whichItem){
var checkData = "";
checkData += '<TABLE><TR><TD><input type="text" value="'+ vMenuFurns[whichItem].dMenuName +'" name="QuestionName'+ whichItem +'" onchange="pAnswer('+whichItem+', this.value,\'\',\'B\');" class="textinputbox" onFocus="Javascript:changeFocus(this.name, \'GENERATE\');" size="20"></TD>';
checkData += '<TD><input type="text" value="'+ vMenuFurns[whichItem].dMenuAnswer +'" name="QuestionLink'+ whichItem +'" onchange="pAnswer('+whichItem+', this.value,\'\',\'C\');" class="textinputbox" onFocus="Javascript:changeFocus(this.name, \'GENERATE\');" size="20"></TD></TR>';
checkData += '</TABLE>\r';
return checkData;
}

function writeLayer(inName,nestref,inText){
	var tDoc;
		if(is_nav4){
			eval("tDoc=document." + inName + ".document");
			tDoc.open();
			tDoc.write(inText);
			tDoc.close();
		}
	if  (is_ie4){document.all[inName].innerHTML=inText;	}
	if  (is_5up){document.getElementById(inName).innerHTML=inText;	}  
}

function callQuestions() {
var questionData = "";
var whatAnswer;

questionData +='<FORM NAME="GENERATE" ACTION="'+ submitLocation +'" target="_self" enctype="application/x-www-form-urlencoded" method="post">\r';

//start big table
questionData +='<TABLE WIDTH="400" padding="2">\r';

if (isMinNS4){$nagStyle = 'style="position:relative; visibility: hidden;"';} 
		else {$nagStyle = 'style="visibility: hidden;"';}
		
		//heading stuff
		questionData +='<TR><TD CLASS="label">Row</TD><TD></TD><TD NOWRAP CLASS="label">Level</TD><TD NOWRAP CLASS="label"></TD><TD WIDTH="10"></TD><TD NOWRAP CLASS="label">Menu item name</TD><TD NOWRAP class="label">Links &nbsp;</TD><TD NOWRAP class="label">Priorities &nbsp;</TD><TD NOWRAP class="label">Page menu</TD></TR>\r';

for(var whichQuestion=0;whichQuestion<vMenuFurns.length;whichQuestion++ ){
		questionData +='<TR>\r';
		questionData +='<TD WIDTH="2" CLASS="label" vAlign="bottom">'+ (whichQuestion+1) +'</TD>\r';
		if(buttonType == "userbutton"){
			questionData += '<TD NOWRAP CLASS="label" vAlign="bottom"><input onClick="Javascript:addElement('+ whichQuestion +');" type="button" value=" + " class="button">&nbsp;&nbsp;<input onClick="Javascript:deleteElement('+ whichQuestion +');" type="button" value=" - " class="button"></A></TD>';
		}
		else{
			questionData += '<TD NOWRAP CLASS="label" vAlign="bottom"><A HREF="Javascript:addElement('+ whichQuestion +');" CLASS="label"><IMG SRC="../echo/images/plus.gif" BORDER="0"></A>&nbsp;&nbsp;<A HREF="Javascript:deleteElement('+ whichQuestion +');" CLASS="label"><IMG SRC="../echo/images/minus.gif" BORDER="0"></A></TD>';
		}
		questionData += '<TD vAlign="bottom">';
		questionData += tMenuDropBox(whichQuestion, "COMMENT,0,1,2,3");
		questionData += '</TD>';
		questionData += '<TD NOWRAP CLASS="label"></TD>';
		questionData += '<TD WIDTH="10"></TD>';
		questionData += '<TD vAlign="bottom">';
		questionData += tMenuTextBox(whichQuestion);
		questionData += '</TD>';
		
		//page link button
		questionData += '<TD vAlign="top" Align="top">';
		if(buttonType == "userbutton"){
			questionData += '&nbsp;&nbsp;<input type="button" value="Add link" class="button" onMouseDown="Javascript:changeFocus(\'QuestionLink'+ whichQuestion +'\', \'GENERATE\');" onMouseUp="Javascript:pAction(\'menuUrl\');">';
		}
		else{
			questionData += '&nbsp;&nbsp;<A HREF="javascript:void(0);" onMouseDown="Javascript:changeFocus(\'QuestionLink'+ whichQuestion +'\', \'GENERATE\');document.GENERATE.qid.value = '+ whichQuestion +';" onMouseUp="Javascript:pAction(\'menuUrl\');" BORDER="0"><IMG SRC="../echo/images/addlink.gif" BORDER="0" ALT="ADD A LINK"></A>';
		}
		questionData += '</TD>';
		
		//page priorities button
		questionData += '<TD vAlign="bottom" Align="bottom">';
		if(buttonType == "userbutton"){
			questionData += '&nbsp;&nbsp;<input type="button" value="Priorities" class="button" onMouseUp="Javascript:window_open(\''+ submitLocation +'?action=prioritise&id='+ vMenuFurns[whichQuestion].dUid+'\', 500, 400);">';
		}
		else{
			questionData += '&nbsp;&nbsp;<A HREF="javascript:void(0);" onMouseUp="Javascript:window_open(\''+ submitLocation +'?action=prioritise&id='+ vMenuFurns[whichQuestion].dUid+'\', 500, 400);" BORDER="0"><IMG SRC="../echo/images/priority.gif" BORDER="0" ALT="CHANGE THIS ITEMS PAGE PRIORITIES"></A>';
		}
		questionData += '</TD>';
		
		//menu type checkbox
		questionData += '<TD vAlign="bottom">';
		questionData += tMenuCheckBox(whichQuestion, "");
		questionData += '</TD>';

questionData +='</TD></TR>\r';

}

//draw the extraCode
questionData +='<TR><TD CLASS="label" COLSPAN="7">';
questionData += writeData();
questionData +='</TD></TR>\r';

//draw the code holder
questionData +='<TR><TD CLASS="label" COLSPAN="7"><TEXTAREA NAME="Menutype" STYLE="DISPLAY:NONE" ></TEXTAREA>';
questionData +='<TEXTAREA NAME="Categories" STYLE="DISPLAY:NONE"></TEXTAREA>';
questionData +='<INPUT TYPE="hidden" NAME="Gholder" VALUE="">';
questionData +='<INPUT TYPE="hidden" NAME="action" VALUE="editFour">';
questionData +='<INPUT TYPE="hidden" NAME="key" VALUE="1">';
questionData +='<INPUT TYPE="hidden" NAME="qid" VALUE="">';
questionData +='</TD></TR>\r';

//draw the submit button
if(buttonType == "userbutton"){
	questionData +='<TR><TD CLASS="label" COLSPAN="7" align="right"><BR><input type="button" class="button" value="Save menu" onClick="Javascript:pComplete(this.form);"></TD></TR>\r';
}
else{questionData +='<TR><TD CLASS="label" COLSPAN="7"><BR><BR><CENTER><A HREF="Javascript:pComplete(this.form);" BORDER="0"> <IMG SRC="../echo/images/edit.gif" BORDER="0"></A></CENTER></TD></TR>\r';}

//end big table
questionData +='<TR><TD></TD>\r';
questionData += '</TR></TABLE>';

questionData += '</FORM>';
writeLayer("MENU",null,questionData);



}

function addElement(addindex) {
maxId++;
vMenuFurns2 = vMenuFurns;
vMenuFurns= [];
var gItemCount = 0;// global counter for naming the rows
var tName;
	for(var thisQuestion=0;thisQuestion<vMenuFurns2.length;thisQuestion++ ){
	var tName = "myRow" + gItemCount;
	
		if (thisQuestion == addindex){
			var tName = new makeCategory("", "", "", gItemCount, maxId, "");// add in the one we want
			gItemCount++;
			var tName = "myRow" + gItemCount;
			var tName = new makeCategory(vMenuFurns2[thisQuestion].dLevelAnswer,vMenuFurns2[thisQuestion].dMenuName, vMenuFurns2[thisQuestion].dMenuAnswer, gItemCount, vMenuFurns2[thisQuestion].dUid, vMenuFurns2[thisQuestion].dMenuTypeAnswer);//add in the orginal
			
			}
		else{var tName = new makeCategory(vMenuFurns2[thisQuestion].dLevelAnswer,vMenuFurns2[thisQuestion].dMenuName, vMenuFurns2[thisQuestion].dMenuAnswer, gItemCount, vMenuFurns2[thisQuestion].dUid, vMenuFurns2[thisQuestion].dMenuTypeAnswer);}
	
	gItemCount++;
	}
callQuestions();
}

function deleteElement(delindex) {
vMenuFurns2 = vMenuFurns;
vMenuFurns= [];
var gItemCount = 0;// global counter for naming the rows
var tName;
	for(var thisQuestion=0;thisQuestion<vMenuFurns2.length;thisQuestion++ ){
	var tName = "myRow" + gItemCount;
	
		if (thisQuestion == delindex){gItemCount--;}
		else{var tName = new makeCategory(vMenuFurns2[thisQuestion].dLevelAnswer,vMenuFurns2[thisQuestion].dMenuName, vMenuFurns2[thisQuestion].dMenuAnswer, gItemCount, vMenuFurns2[thisQuestion].dUid, vMenuFurns2[thisQuestion].dMenuTypeAnswer);}
	
	gItemCount++;
	}
callQuestions();

}

function pAnswer(whichQuestion, whatAnswer,whichIndex, whichElement){
var isComplete;

	if (whichElement == "A"){vMenuFurns[whichQuestion].dLevelAnswer = whatAnswer;}
	if (whichElement == "B"){vMenuFurns[whichQuestion].dMenuName = whatAnswer;}
	if (whichElement == "C"){vMenuFurns[whichQuestion].dMenuAnswer = whatAnswer;}
	if (whichElement == "D"){
			vMenuFurns[whichQuestion].dMenuTypeAnswer = whichIndex.checked;
		}

		//if they completed the question we let them know
		
		if (vMenuFurns[whichQuestion].dLevelAnswer != ""){
				//hideLayer('nag'+ whichQuestion);
				//writeLayer('qname'+ whichQuestion,null, vMenuFurns[whichQuestion].dQuestion + " - completed")
		}
		
		if (vMenuFurns[whichQuestion].dMenuName != ""){
				//hideLayer('nag'+ whichQuestion);
				//writeLayer('qname'+ whichQuestion,null, vMenuFurns[whichQuestion].dQuestion + " - completed")
		}
		
		isComplete = doChecks(whichQuestion);
		
		for(var whichQuestion=0;whichQuestion<vMenuFurns.length;whichQuestion++ ){
		//do a form check to make sure they answered all the questions
		if (vMenuFurns[whichQuestion].dCheck == "true"){
			if (vMenuFurns[whichQuestion].dLevelAnswer == ""){
				isComplete = "false";
				}
		}
		
	}
//if (isComplete != "false"){document.GENERATE.submit.disabled = false;}
}
	//whichIndex.options[whichIndex.selectedIndex].value = 3;
	

function doChecks(whichQuestion){

var isComplete = "true";
return isComplete;
}

function pComplete(whichForm){
var isItComplete = "";
	for(var whichQuestion=0;whichQuestion<vMenuFurns.length;whichQuestion++ ){
		//do a form check to make sure they answered all the questions
		// switch off all nags
		//hideLayer('nag'+ whichQuestion);
		if (vMenuFurns[whichQuestion].dCheck == "true"){
		isItComplete = doChecks(whichQuestion);
			if (vMenuFurns[whichQuestion].dLevelAnswer == ""){
				//showLayer('nag'+ whichQuestion);
				isItComplete = "false";
				}
			if (vMenuFurns[whichQuestion].dMenuName == ""){
				//showLayer('nag'+ whichQuestion);
				isItComplete = "false";
				}
		}
		
	}
saveIt();
makeItXML();	
if (isItComplete == "true"){document.GENERATE.submit();}

}

function saveIt() {// generates the code for a edit
var myDelimeter = '","';
var myCode ='\r';



for(i=0; i < vMenuFurns.length;i++)
	{
	
	myCode += 'var myRow' + i + ' = new makeCategory("';
	myCode += vMenuFurns[i].dLevelAnswer + myDelimeter;
	myCode += vMenuFurns[i].dMenuName + '","';
	myCode += vMenuFurns[i].dMenuAnswer + '",';
	myCode += i + ',';
	myCode += vMenuFurns[i].dUid +',"';
	myCode += vMenuFurns[i].dMenuTypeAnswer;
	myCode += '");\r\n';
	}

myCode +="\r\r";

document.GENERATE.Menutype.value = myCode;

}

function makeIt() {// generates the entry for showing
var myCode = "";

for(i=0; i < vMenuFurns.length;i++)
	{
	myCode += '<MENU ' + vMenuFurns[i].dLevelAnswer + '>';
	myCode += vMenuFurns[i].dMenuAnswer;
	myCode += '\n';
	}

document.GENERATE.Categories.value = myCode;

}

function makeItXML() {// generates the entry for showing
var myCode = "<menuxml>\n";
for(i=0; i < vMenuFurns.length;i++)
	{
	myCode += '	<menuitem uid="'+ vMenuFurns[i].dUid +'" level="' + vMenuFurns[i].dLevelAnswer + '" ';
	myCode += 'name="'+vMenuFurns[i].dMenuName +'" link="'+vMenuFurns[i].dMenuAnswer +'" menutype="'+vMenuFurns[i].dMenuTypeAnswer +'"';
	myCode += '>';
	myCode += '</menuitem>\n';
	}
myCode += '</menuxml>';
document.GENERATE.Categories.value = myCode;

}

function hideLayer(layer) {

if (is_nav6){
  	layer = eval('document.getElementById("'+ layer + '")');
    layer.style.visibility = "hidden";
    }

  if (isMinNS4){
  	layer = eval("document.layers."+ layer);
    layer.visibility = "hide";
    }
  if (isMinIE4){
  	layer = eval("document.all."+ layer);
    layer.style.visibility = "hidden";
    }
}

function showLayer(layer) {

	if (is_nav6){
  	layer = eval('document.getElementById("'+ layer + '")');
    layer.style.visibility = "visible";
    }

  if (isMinNS4){
  	layer = eval("document.layers."+ layer);
    layer.visibility = "show";
    }
  if (isMinIE4){
 
  	layer = eval("document.all."+ layer);
    layer.style.visibility = "visible";
    }
}

function testVisible(layer) {

	if (is_nav6){
  	layer = eval('document.getElementById("'+ layer + '")');
    if(layer.style.visibility == "visible"){return "visible";}
    }

  if (isMinNS4){
  	layer = eval("document.layers."+ layer);
    if(layer.visibility == "visible"){return "visible";}
    }
  if (isMinIE4){
 
  	layer = eval("document.all."+ layer);
    if(layer.style.visibility == "visible"){return "visible";}
    }
}

// end of menubuilder section

//ttest a field for letters
function numbersonly(myfield, e, dec){
var key;
var keychar;
if (window.event)
 key = window.event.keyCode;
else if (e)
 key = e.which;
else
 return true;
keychar = String.fromCharCode(key);
// control keys
if ((key==null) || (key==0) || (key==8) || 
 (key==9) || (key==13) || (key==27) )
 return true;
// numbers
else if ((("0123456789").indexOf(keychar) > -1))
 return true;
// decimal point jump
else if (dec && (keychar == "."))
 {
 myfield.form.elements[dec].focus();
 return false;
 }
else
 return false;
}


//tab descriptions
var vTabMenuFurns = new Array();
var tabDescriptiontimer=-1;
function tabMenuItem(name, tabid, widgetid){
	this.dName = name;
	this.dTab = tabid;
	this.dWidget = widgetid;
	vTabMenuFurns[vTabMenuFurns.length]=this;
}

function showTabDesc(tabid){
	tabDescriptiontimer = setTimeout('doShowTabDesc('+tabid +')', 1100);
}

function doShowTabDesc(tabid){
	var message = "<TABLE CELLPADDING='1' CELLSPACING='0' WIDTH='100%' BORDER='0'>";
	var layer = "information";
	var count = 0;
	for(var i=0;i<vTabMenuFurns.length;i++){
		if(vTabMenuFurns[i].dTab == tabid){
			count++;
			message = message + "<TR><TD class='body'><a href='/dynamic/tabpage"+ vTabMenuFurns[i].dTab +".jsp#"+ vTabMenuFurns[i].dWidget +"' class='link' onMouseOver='Javascript:resetTabDesc();' onMouseOut='Javascript:hideTabDesc();'>" + vTabMenuFurns[i].dName + "</a></TD></TR>";
		}
	}
	message = message + "</TABLE>";
	if(count > 0){
		moveLayer(layer,myMouseX - 100,myMouseY + 10);
		var myLength = (message.length/2) + 20;
		sizeLayer(layer,180,80)
		showLayer(layer);
		message = upsideDownBubble(message);
		writeLayer(layer,"",message);
		}
}

function upsideDownBubble(message){
	var bubble = "<TABLE WIDTH=152 BORDER=0 CELLPADDING=0 CELLSPACING=0><TR height='15'><TD width='8' height='15'><IMG SRC='/images/speech-bubble2_01.gif' WIDTH=8 HEIGHT=15 ></TD><TD width='131' height='15'><IMG SRC='/images/speech-bubble2_02.gif' WIDTH=131 HEIGHT=15 ></TD><TD width='13' height='15'><IMG SRC='/images/speech-bubble2_03.gif' WIDTH=13 HEIGHT=15 ></TD></TR><TR><TD bgcolor='#e3e7ed' width='8'><IMG SRC='/images/clearpixel.gif' WIDTH=8 HEIGHT=68 ></TD><TD bgcolor='#e3e7ed' width='131'>" + message + "</TD><TD width='13' background='/images/rightedge.gif'><IMG SRC='/images/clearpixel.gif' WIDTH=8 HEIGHT=68 ></TD></TR><TR height='12'><TD width='8' height='12'><IMG SRC='/images/speech-bubble2_07.gif' WIDTH=8 HEIGHT=12 ></TD><TD width='131' height='12'><IMG SRC='/images/speech-bubble2_08.gif' WIDTH=131 HEIGHT=12 ></TD><TD width='13' height='12'><IMG SRC='/images/speech-bubble2_09.gif' WIDTH=13 HEIGHT=12 ></TD></TR></TABLE>";
	return(bubble);
}

function resetTabDesc(){
	showLayer("information");
	clearTimeout(tabDescriptiontimer);
}

function hideTabDesc(){
	clearTimeout(tabDescriptiontimer);
	tabDescriptiontimer = setTimeout('hideLayer(\'information\')', 800);
}


// end tab descriptions
// Layer manipulation
function showMessage(layer,message){

	var myLength = (message.length/2) + 20;
	sizeLayer(layer,150,myLength)
	if(isMinNS4){message = "<TABLE BGCOLOR='#CCCCCC' CELLPADDING='3' CELLSPACING='0' WIDTH='250' BORDER='1'><TR><TD BGCOLOR='#FFFFFF' CLASS='cToolTipText'>"+ message +"</TD><\/TR><\/TABLE>";}
	else{message="<p class='cToolTipText'>" + message + "<\/p>";}
	
	myVisibility = testVisible(layer);
	if(myVisibility != "visible"){showLayer(layer);writeLayer(layer,"",message);}
	else if(myVisibility == "visible"){hideLayer(layer);writeLayer(layer,"","");}
	}

function sizeLayer(layer,w,h){
	if(isMinNS4) {
		layer = eval("document.layers."+ layer);
		layer.width=w; layer.height=h;	
	}
	if(isMinIE4) {
		layer = eval("document.all." + layer + ".style")
		layer.pixelWidth=w;	layer.pixelHeight=h;
	}
	if(is_nav6) {
		layer = eval('document.getElementById("'+ layer + '").style');
		layer.width=w+"px"; layer.height=h+"px";

	}
}

function moveLayer(layer,x,y){
	if(isMinNS4) {
		layer = eval("document.layers."+ layer);
		layer.left=x; layer.top=y;	
	}
	if(isMinIE4) {
		layer = eval("document.all." + layer + ".style")
		layer.pixelLeft=x;	layer.pixelTop=y;
	}
	if(is_nav6) {
		layer = eval('document.getElementById("'+ layer + '").style');
		layer.left=x+"px"; layer.top=y+"px";
	}
}

//UIB MENU SCOLLS
var tabMenuMovetimer=-1;
function doMenuLayerMove(layer,x,y, repeat){
	var thisLayer = layer;
	if(isMinNS4) {
		layer = eval("document.layers."+ layer);
		if((layer.left + x) <= 0){
			layer.left=layer.left + x; layer.top=layer.top + y;
		}
	}
	if(isMinIE4) {
		layer = eval("document.all." + layer + ".style")
		if((layer.pixelLeft + x) <= 0){
			layer.pixelLeft=layer.pixelLeft + x; layer.pixelTop= layer.pixelTop + y;
		}
	
	}
	if(is_nav6) {
		layer = eval('document.getElementById("'+ layer + '").style');
		var thisX = layer.left;
		var thisY = layer.top;
		thisX = thisX.replace("px", "");
		thisY = thisY.replace("px", "");
		thisX = parseFloat(thisX);
		thisY = parseFloat(thisY);
		if (isNaN(thisX)){thisX = 0;}
		if (isNaN(thisY)){thisY = 0;}
		if ((thisX + x) <= 0){
			layer.left=(thisX + x)+"px"; layer.top=(thisY + y)+"px";
			}
	}
	if(repeat == true){
		tabMenuMovetimer = setTimeout('doMenuLayerMove("'+thisLayer +'",'+ x +','+ y +',true)', 2);
	}
}

function moveMenuLayer(layer,x,y){
	tabMenuMovetimer = setTimeout('doMenuLayerMove("'+layer +'",'+ x +','+ y +',true)', 2);
}

function menuMoveTImer(layer, x, y){

}

function stopMenuLayer(layer){
	clearTimeout(tabMenuMovetimer);
}

//menu scripts
var thisSelectedCat = null;
if (document.getElementById){ 
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function activeParentMenuItems(obj){
	try{
		var el = document.getElementById("pmenuitem" + obj);
		el.style.backgroundColor= "EEEEEE";
	}//end try
	catch(Exception){}
	
}

function activateParentMenuItems(obj, bgcolour, color){
	try{
		var el = document.getElementById("pmenuitem" + obj);
		var ml = document.getElementById("pmenuitemlink" + obj);
		el.style.backgroundColor= bgcolour;
		ml.style.color= color;
	}//end try
	catch(Exception){}
	
}

function SetMenuItems(whichSetting, obj){
	var el = document.getElementById("sub" + obj);
	var ml = document.getElementById("menu" + obj);
	if(whichSetting == true){
		setInactive(ml);
	}
	if(whichSetting == false){
		//see if it was clicked
		if(el.style.display != "block"){
			setActive(ml);
		}
	}
}

function setActive(ml){
	ml.style.backgroundColor= "FFFFFF";
	ml.style.color= "515183";
}

function setInactive(ml){
	ml.style.backgroundColor= "EEEEEE";
	ml.style.color= "999999";
}

function SwitchMenu(obj){
	if(document.getElementById){
	try{
		var el = document.getElementById("sub" + obj);
		var ml = document.getElementById("menu" + obj);
		var ar = document.getElementById("masterdiv").getElementsByTagName("span");
			if(el.style.display != "block"){ 
				for (var i=0; i<ar.length; i++){
					if (ar[i].className=="submenu") 
					ar[i].style.display = "none";
				}
				setInactive(ml);
				el.style.display = "block";
			}
			else{
				//setInactive(ml);
				el.style.display = "none";
			}
		}//end try
		catch(Exception){}
	}
}
   
                  