//Top Menu Generator
//Edited By Michael
//April 03, 2001



var whole_width=0;
var whole_height=0;
var buttonspace=0;
var vertlinestyle=true;
var buttonwidth = 100;
var buttonheight= 20;
var buttoncolor = "#cccccc";

var btNAME=0;
var btALT=1;
var btSELECTED=2;
var btURL=3;
var btTEXTPIC=4;
var btBUTTONPIC=5;
var btBUTTONINPIC=6;
var btTYPE=7;
var btBUTTONCOLOR=8;

var basename="";
var basetext="";


function draw_layerStart(groupID,grouptext,xPos,yPos,bwidth,bheight,bspace,bcolor,vert,numButtons){ 
	var barheight=0;
	var barwidth=0;
	var button_Total=1;
	var thehtml=""; 
	
	basename=groupID;
	basetext=grouptext;
	buttonwidth = bwidth;
	buttonheight= bheight;
	buttonspace=bspace;
	buttoncolor=bcolor;
	whole_width=0;
	whole_height=0;

	if (vert){ 
		barwidth = buttonwidth;
		barheight = (buttonheight+buttonspace)*numButtons;
		vertlinestyle=true;
	}else {
		barheight = buttonheight;
		barwidth = (buttonwidth+buttonspace)*numButtons;
	 	vertlinestyle=false;	
	}	
	thehtml += "<table BORDER=0 CELLPADDING=0 CELLSPACING=0 width="+buttonwidth+">"
	if(vert) thehtml +="<tr><td width="+buttonwidth+"><font size=+2><b>"+ basetext+"</b><font></td></tr>";	
	thehtml += "<tr><td width="+buttonwidth+">\n";
	if (document.layers) {
		Begin_LayerOrDiv = "<ilayer id=\""+basename+"\" top="+yPos+" left="+xPos+" height="+barheight+
	 			" width="+barwidth+" z-index=1 visibility=SHOW >\n";
	} else if (document.all) {	
		Begin_LayerOrDiv = "<div id=\""+basename+"\" style=\" position:relative;  top:"+yPos+"; left:"+
		 	xPos+"; width:"+barwidth+"; height:"+barheight+";  z-index:1; visibility:visible; \">";
	} else if (document.getElementById) {
		Begin_LayerOrDiv = "<div id=\""+basename+"\" style=\" position:relative;  top:"+yPos+"; left:"+
		 	xPos+"; width:"+barwidth+"; height:"+barheight+";  z-index:1; visibility:visible; \">";
	} 
	thehtml += Begin_LayerOrDiv;
	
	document.writeln(thehtml);
}


function draw_layerEnd() {

	if (document.layers) {
		End_LayerOrDiv = "</ilayer>\n</td></tr></table>";
	} else if (document.all) {	
		End_LayerOrDiv = "</div>\n</td></tr></table>";
	} else if (document.getElementById) {
		End_LayerOrDiv = "</div>\n</td></tr></table>";
	}
	document.writeln(End_LayerOrDiv);
}



function draw_buttons(buttonTotal){ 
	var thehtml = "";
	var p;
	
	whole_width=0;
	whole_height=0;
	
	
	for( var currNum=1; currNum <= buttonTotal; ++currNum) {
		if ((p = eval("window."+basename+currNum))){
			thehtml += draw_buttonlayer(p,currNum);		
		}	
	}
	document.writeln(thehtml);
}



function draw_buttonlayer(p,n){
	var buttoninpic= getButtonInPic(p);
	var buttonpic= getButtonPic(p);
	var buttonsl = getButtonSelected(p);
	var strhtml="";
	
	if (document.layers) {
		Begin_LayerOrDiv1 = "<layer id=\"";
		Begin_LayerOrDiv2 = "\" top="+whole_height+" left="+whole_width+" width="+buttonwidth+" height="+buttonheight+" visibility=SHOW z-index=";
		Begin_LayerOrDiv3 = " bgcolor="+getButtonColor(p)+" ";
		Begin_LayerOrDiv4 = " >\n";
		End_LayerOrDiv = "</layer>";

	} else if (document.all) {	
		Begin_LayerOrDiv1 = "<div id=";
		Begin_LayerOrDiv2 =" style=\"position:absolute;  top:"+whole_height+"; left:"+whole_width+"; width:"+buttonwidth+"; height:"+buttonheight+"; visibility:visible; z-index:";
		Begin_LayerOrDiv3 = "; background-color:"+getButtonColor(p)+";\"";
		Begin_LayerOrDiv4 = " >\n";
		End_LayerOrDiv = "</div>";
	} else if (document.getElementById) {

		Begin_LayerOrDiv1 = "<div id=";
		Begin_LayerOrDiv2 =" style=\"position:absolute;  top:"+whole_height+"; left:"+whole_width+"; width:"+buttonwidth+"; height:"+buttonheight+"; visibility:visible; z-index:";
		Begin_LayerOrDiv3 = "; background-color:"+getButtonColor(p)+";\"";
		Begin_LayerOrDiv4 = " >\n";
		End_LayerOrDiv = "</div>";

	}	
		strhtml += Begin_LayerOrDiv1 + basename+"bin"+n+ Begin_LayerOrDiv2 + "2"+ Begin_LayerOrDiv3;
		strhtml += Begin_LayerOrDiv4;
		strhtml += "<img src=\""+buttoninpic+"\" width="+buttonwidth+" height="+buttonheight+" border=0>";
		strhtml += End_LayerOrDiv;
	if (buttonsl==false){	
		strhtml += Begin_LayerOrDiv1 + basename+"b"+n+ Begin_LayerOrDiv2 + "3"+ Begin_LayerOrDiv3;
		strhtml += Begin_LayerOrDiv4;
		strhtml += "<img src=\""+buttonpic+"\" width="+buttonwidth+" height="+buttonheight+" border=0>";
		strhtml += End_LayerOrDiv;
	}
	strhtml += draw_textlayer(p,n);
	
	if (vertlinestyle) {whole_height += buttonheight+buttonspace;} else {whole_width +=buttonwidth + buttonspace;}	
	
	return strhtml;
}

function draw_textlayer(p,n){
	var buttonalt = getButtonAlt(p);
	var buttonURL = getButtonURL(p);
	var textpic = getTextPic(p);
	var buttonsl = getButtonSelected(p);	
	var linkType = getLinkType(p);
	var strhtml="";
	
	if (document.layers) {

		Begin_LayerOrDiv1 = "<layer id=\""+ basename+"t"+n+"\" top="+whole_height+" left="+whole_width+" width='"+
		buttonwidth+"' height='"+buttonheight+"'  z-index=4 visibility=SHOW ";
		Begin_LayerOrDiv2 = ">\n";
		End_LayerOrDiv = "</layer>";
	} else if (document.all) {	

		Begin_LayerOrDiv1 = "<div id=\""+ basename+"t"+n+"\" style=\" position:absolute; top:"+whole_height+"; left:"+whole_width+"; width:'"+
		buttonwidth+"'; height:'"+buttonheight+"';  z-index:4; visibility:visible; \" ";
		Begin_LayerOrDiv2 = ">\n";
		End_LayerOrDiv = "</div>";
	} else if (document.getElementById) {

		Begin_LayerOrDiv1 = "<div id=\""+ basename+"t"+n+"\" style=\" position:absolute; top:"+whole_height+"; left:"+whole_width+"; width:'"+
		buttonwidth+"'; height:'"+buttonheight+"';  z-index:4; visibility:visible; \" ";
		Begin_LayerOrDiv2 = ">\n";
		End_LayerOrDiv = "</div>";
	}
	strhtml = Begin_LayerOrDiv1;
	strhtml += (buttonsl)? "":" onMouseOver=\"hide('"+ basename+"b"+n+"','"+basename+"');\"  onMouseOut=\"show('"+ basename+"b"+n+"','"+basename+"');\"";
	strhtml += Begin_LayerOrDiv2;

	if( !buttonsl ) {
		if( linkType == "normal" ) {	
			strhtml += "<a href='"+buttonURL+"'>";

		} else if( linkType == "popup" )  {
			strhtml += "<a href='"+buttonURL+"' target='help' onClick='doPop(this)' >";
		} else if( linkType == "form" )  {
			strhtml += "<input name='doit' value='search' type='submit'></input>";//width="+buttonwidth+" height="+buttonheight+" src='"+textpic+"' type='image'>";
		}
	}
//	if( linkType != "form" ) {
		strhtml += "<img src='"+textpic+"' alt='"+buttonalt+"' width="+buttonwidth+" height="+buttonheight+" border=0>";
//	}

	if( !buttonsl ) {
		if( linkType == "normal" ) {	
			strhtml += "</a>";
		} else if( linkType == "popup" )  {
			strhtml += "</a>";
		} else if( linkType == "form" )  {
			strhtml += "";
		}
	}
	strhtml += End_LayerOrDiv;
	
	
	return strhtml;
}


function show(ObjId, ParentObjId) {
	if (document.layers) {
		if (eval(document.layers[ObjId])==null) document.layers[ParentObjId].document.layers[ObjId].visibility = "show"
		else document.layers[ObjId].visibility = "show";			
	} else if (document.all) {
     			 
		document.getElementById(ObjId).style.visibility = "visible";
	} else if (document.getElementById) {
		 document.getElementById(ObjId).style.visibility = "visible";
	}
}

function hide(ObjId, ParentObjId) {
	if (document.layers) {
		if (eval(document.layers[ObjId])==null) document.layers[ParentObjId].document.layers[ObjId].visibility = "hide"
		else document.layers[ObjId].visibility = "hide";			
	} else if (document.all) {
		
		document.getElementById(ObjId).style.visibility = "hidden";
	} else if (document.getElementById) {
		document.getElementById(ObjId).style.visibility = "hidden";
	}
}

function setSelected(buttonname, groupID){
	var basename=groupID;
	var i=1;
	while (eval("window."+basename+i)){
		p = eval ("window."+basename+i);
		p[btSELECTED]=(p[btNAME]==buttonname)? true:false;
		i++;
	}
}

function getButtonAlt(menuarray){
	return menuarray[btALT];
}

function getButtonSelected(menuarray){
	return menuarray[btSELECTED];
}

function getButtonURL(menuarray){
	return menuarray[btURL];
}

function getTextPic(menuarray){
	return menuarray[btTEXTPIC];
}

function getButtonPic(menuarray){
	return menuarray[btBUTTONPIC];
}

function getButtonInPic(menuarray){
	return menuarray[btBUTTONINPIC];
}


function getLinkType(menuarray) {
	return menuarray[btTYPE];
}

function getButtonColor(menuarray) {
	return menuarray[btBUTTONCOLOR];
}


function setCollection(subsection) {
	var i = 0;
	//confirm( "gro: " + document.pickList.collection[i] );
	var re = /^_Z_nope_Z$/g;
	while( document.pickList.collection[i] ) {
		//confirm(i + document.pickList.collection[i].value);
		arr = document.pickList.collection[i].value.match( re );
	 	if( arr != null ) {
			// selected a non value so just close;
			//confirm( ")_sdlkfsdflsdf");
			window.close();
			break;
		}

		if( document.pickList.collection[i].checked ) {
			//confirm(document.pickList.collection[i].value);
			var cmd = "parent.window.opener.setCollName( '" + subsection + "', '" + 
				document.pickList.collection[i].value + "')";
			//confirm( cmd );
			eval( cmd );
			window.close();
			break;
	
		}
		++i;
		//confirm( "tried: " + i );
	}
}


function setCollName( subsection, collName ) {
	//confirm( subsection + ":" + collName );	
	var stmt = "document.addForm.cal" + subsection + ".value='" + collName + "';";
	//confirm( stmt);
	eval(stmt);
}


function openOtherCalGroupList( url, isResMgr, is24hour  ) {

	if( isResMgr ) {
		var yearIdx = document.addForm.year.selectedIndex;
		var monthIdx = document.addForm.month.selectedIndex;
		var dayIdx = document.addForm.day.selectedIndex;
		var hourIdx = document.addForm.hour.selectedIndex;
		var minuteIdx = document.addForm.minute.selectedIndex;
		var dhoursIdx = document.addForm.durationHours.selectedIndex;
		var dminutesIdx = document.addForm.durationMinutes.selectedIndex;

		var year = document.addForm.year.options[yearIdx].text;
		var month = document.addForm.month.options[monthIdx].text;
		var day = document.addForm.day.options[dayIdx].text;
		var hour = document.addForm.hour.options[hourIdx].text;
		var minute = document.addForm.minute.options[minuteIdx].text;
		var dhours = document.addForm.durationHours.options[dhoursIdx].text;
		var dminutes = document.addForm.durationMinutes.options[dminutesIdx].text;

		var ampm = (is24hour)? "none":document.addForm.ampm.selectedIndex;
		if( is24hour ) ampm == "none";
		else if( ampm == 0 ) ampm = "AM";
		else ampm="PM";

		url = url + "&date=" + day + "/" + month + "/" + year + "/" + hour + "/" +minute + "/" + ampm;
		url = url + "&hours=" + dhours;
		url = url + "&minutes=" + dminutes;
	}
	window.open( url, "ocgl", "toolbar=no,resizable=1,scrollbars=1,height=400,width=500" );

}

function openOtherCalGroupList2( path ) {
	if( document.myForm.calSelect.selectedIndex > 0 ) {
		var subSect = document.myForm.calSelect.options[document.myForm.calSelect.selectedIndex].value;
		var url = "../../../../s@" + subSect + "/collections/listCollections.html?activeMethod=list&docid=" + path;
		//confirm( url );
		window.open( url, "cgl" ); //"toolbar=no,resizable=1,scrollbars=1,height=400,width=500" );
	}
}

function openOtherResGroupList2( path ) {

	if( document.myForm.resSelect.selectedIndex > 0 ) {
		var subSect = document.myForm.resSelect.options[document.myForm.resSelect.selectedIndex].value;
		var url = "../../../../s@" + subSect + "/collections/listCollections.html?activeMethod=list&docid=" + path;
		//confirm( url );
		window.open( url, "rgl" ); //"toolbar=no,resizable=1,scrollbars=1,height=400,width=500" );
	}
}

function openCopyForm(  ) {

	var docid = document.pickList.docid.value;
	//confirm( docid );
	var colName = "";
	var i = 0;
	while( document.pickList.elements[i] ) {
		//confirm(document.pickList.elements[i].name);
		//confirm(document.pickList.elements[i].checked);
		if( document.pickList.elements[i].checked ) {
			colName = document.pickList.elements[i].value;
			break;
		}
		++i;
	}
	var url = "departments/" + colName + "/getFormView.html?dsd=event&mode=copy&docid=" + docid;
	window.open( url, "_top" ); //"toolbar=no,resizable=1,scrollbars=1,height=400,width=500" );
}



function openRelatedItemsSelector( url, isResMgr, is24hour  ) {

	if( isResMgr ) {

		var yearIdx = document.addForm.year.selectedIndex;
		var monthIdx = document.addForm.month.selectedIndex;
		var dayIdx = document.addForm.day.selectedIndex;
		var hourIdx = document.addForm.hour.selectedIndex;
		var minuteIdx = document.addForm.minute.selectedIndex;
		var dhoursIdx = document.addForm.durationHours.selectedIndex;
		var dminutesIdx = document.addForm.durationMinutes.selectedIndex;

		var year = document.addForm.year.options[yearIdx].text;
		var month = document.addForm.month.options[monthIdx].text;
		var day = document.addForm.day.options[dayIdx].text;
		var hour = document.addForm.hour.options[hourIdx].text;
		var minute = document.addForm.minute.options[minuteIdx].text;
		var dhours = document.addForm.durationHours.options[dhoursIdx].text;
		var dminutes = document.addForm.durationMinutes.options[dminutesIdx].text;

		var ampm = (is24hour)? "none":document.addForm.ampm.selectedIndex;
		if( is24hour ) ampm == "none";
		else if( ampm == 0 ) ampm = "AM";
		else ampm="PM";

		var allday = (document.addForm.allday.checked)? "on":"no";
		var ridata   = document.addForm.ridata.value;

		if( ridata.match( /^\s+$/g ) ) {
			url = url + "allday=" + allday + "&mode=Select+Related+Items&date=" + 
		     	day + "/" + month + "/" + year + "/" + hour + "/" +minute + "/" + ampm;
		} else {
			url = url + "ridata=" + ridata + "&allday=" + allday + "&mode=Select+Related+Items&date=" + 
		     	day + "/" + month + "/" + year + "/" + hour + "/" +minute + "/" + ampm;
		}	
		url = url + "&hours=" + dhours;
		url = url + "&minutes=" + dminutes;
		//confirm (url);
	}
	window.open( url, "ris", "toolbar=no,resizable=1,scrollbars=1,height=400,width=500" );

}


function setRIInfo( s ) {
	var stmt = "document.addForm.ridata.value='" + s + "';";
	//confirm( stmt);
	eval(stmt);
}


function setRelatedItems() {
	var s = "";
	var i = 0;
	while( document.riselect.elements[i] ) {
		var index = document.riselect.elements[i].name.lastIndexOf( "reqn" );
		if( index != -1 ) {
			s += document.riselect.elements[i].name.substring(0,index) + ":" + 
				document.riselect.elements[i].selectedIndex + "|";

		}
		++i;
	
	}
	//confirm (s);
	var cmd = "parent.window.opener.setRIInfo( '" + s + "')";
	//confirm( cmd );
	eval( cmd );
	window.close();
}



function openUsersSelector( url, isResMgr, is24hour, isGrps  ) {
	if( isGrps && document.addForm.usrgrps.selectedIndex == 0 ) return;

	if( isResMgr ) {

		var yearIdx = document.addForm.year.selectedIndex;
		var monthIdx = document.addForm.month.selectedIndex;
		var dayIdx = document.addForm.day.selectedIndex;
		var hourIdx = document.addForm.hour.selectedIndex;
		var minuteIdx = document.addForm.minute.selectedIndex;
		var dhoursIdx = document.addForm.durationHours.selectedIndex;
		var dminutesIdx = document.addForm.durationMinutes.selectedIndex;

		var year = document.addForm.year.options[yearIdx].text;
		var month = document.addForm.month.options[monthIdx].text;
		var day = document.addForm.day.options[dayIdx].text;
		var hour = document.addForm.hour.options[hourIdx].text;
		var minute = document.addForm.minute.options[minuteIdx].text;
		var dhours = document.addForm.durationHours.options[dhoursIdx].text;
		var dminutes = document.addForm.durationMinutes.options[dminutesIdx].text;

		var ampm = (is24hour)? "none":document.addForm.ampm.selectedIndex;
		if( is24hour ) ampm == "none";
		else if( ampm == 0 ) ampm = "AM";
		else ampm="PM";

		var allday = (document.addForm.allday.checked)? "on":"no";
		var users   = document.addForm.users.value;

		if( month < 10 ) month = "0" + month;
		if( day < 10 ) day = "0" + day;
		if( hour < 10 ) hour = "0" + hour;
		if( minute < 10 ) minute = "0" + minute;

		if( users.match( /^\s+$/g ) ) {
			//confirm( "space space: " + users );
			url = url + "allday=" + allday + "&mode=Book+Users&date=" + 
				day + "/" + month + "/" + year + "/" + hour + "/" +minute + "/" + ampm;

		} else {
			//confirm( "no: " + users );
			url = url + "users=" + users + "&allday=" + allday + "&mode=Book+Users&date=" + 
				day + "/" + month + "/" + year + "/" + hour + "/" +minute + "/" + ampm;
		}

		url = url + "&hours=" + dhours;
		url = url + "&minutes=" + dminutes;

		if( isGrps ) {
			var gi = document.addForm.usrgrps.selectedIndex;
			url = url + "&grps=" + document.addForm.usrgrps.options[gi].value;				
		}

	}
	window.open( url, "us", "toolbar=no,resizable=1,scrollbars=1,height=400,width=500" );
}




function openView( kind  ) {
	var url = "searchGroupsByDate.html?viewtype=monthly&offset=none&list-search=List";
		
	url = url + "&start-time=" + document.actSelect.Startmonth[document.actSelect.Startmonth.selectedIndex].value + "+" 
		+ document.actSelect.Startday[document.actSelect.Startday.selectedIndex].value + "%2C+" 
		+ document.actSelect.Startyear[document.actSelect.Startyear.selectedIndex].value
		+ "+00%3A00%3A00+" + document.actSelect.Starttime.value 
		+ "&Startday=" + document.actSelect.Startday[document.actSelect.Startday.selectedIndex].value 
		+ "&Startmonth=" + document.actSelect.Startmonth[document.actSelect.Startmonth.selectedIndex].value
		+ "&Startyear=" + document.actSelect.Startyear[document.actSelect.Startyear.selectedIndex].value 
		+ "&Stopday=" + document.actSelect.Stopday[document.actSelect.Stopday.selectedIndex].value 
		+ "&Stopmonth=" + document.actSelect.Stopmonth[document.actSelect.Stopmonth.selectedIndex].value 
		+ "&Stopyear=" + document.actSelect.Stopyear[document.actSelect.Stopyear.selectedIndex].value;

	var logic = "agentID=";
	var doOr = 1;

	// for department group selected.
	var   gi = document.actSelect.typeSelect.selectedIndex;
	url = url + "&category=departments%2F" + document.actSelect.typeSelect.options[gi].value;				
	if( document.actSelect.typeSelect.options[gi].value == "all-groups" ) {
		url = url + "&dept-inner-logic=all";
		logic = logic + "all:";
	}
	else {
		url = url + "&dept-inner-logic=any";
		logic = logic + "any:";
		doOr = 0;
	}	

	if( document.actSelect.activitySelect != null ) {
		// for topical group selected.
		gi = document.actSelect.activitySelect.selectedIndex;
		url = url + "&category=topical%2F" + document.actSelect.activitySelect.options[gi].value;				
		if( document.actSelect.activitySelect.options[gi].value == "all-groups" ) {
			url = url + "&top-inner-logic=all";
			logic = logic + "all:";
		}
		else {
			url = url + "&top-inner-logic=any";
			logic = logic + "any:";
			doOr = 0;
		}	
	}

	// for interest group selected
	gi = document.actSelect.viewSelect.selectedIndex;
	url = url + "&category=interest%2F" + document.actSelect.viewSelect.options[gi].value;
	if( document.actSelect.viewSelect.options[gi].value == "all-groups" ) {
		url = url + "&int-inner-logic=all";
		logic = logic + "all:";
	}
	else {
		url = url + "&int-inner-logic=any";
		logic = logic + "any:";
		doOr = 0;
	}	

	logic =  logic + "or";
	url = url + "&" + logic;

	if( doOr == 0 ) url = url + "&inter-logic=and";

	//confirm ( url );				
	window.open( url, "_top" );
}


function addDepartments( dname ) {
	var dlen = this.departmentarr.length;
	this.departmentarr[dlen] = dname;
	//confirm( this.departmentarr[dlen] );
}

function addTopics( tvalue, ttext ) {
	var dlen = this.departmentarr.length;
	var tlen = this.topicvalue[dlen].length;
	if (tlen == 0) tlen = 1;
	if (tvalue != null && tvalue != "" ) this.topicvalue[dlen][tlen] = tvalue;
	if (ttext != null && ttext != "" )   this.topictext[dlen][tlen] = ttext;
	//confirm( this.topicvalue[dlen][tlen] );
}

function addActivies( tvalue, ttext ) {
	//confirm( tvalue + ";" + ttext );
	var alen = this.actvalue.length;
	if (alen == 0) alen = 1; //0 is All
	if (tvalue != null && tvalue != "" ) this.actvalue[alen] = tvalue;
	if (ttext != null && ttext != "" )   this.acttext[alen] = ttext;
}

function searchTopical( ) {

	var   gi = document.actSelect.typeSelect.selectedIndex;
	
	if (gi == 0) {
		//var   gj = actvalue.length > 0 ? actvalue.length - 1 : 0;
	    if (actvalue.length > 0) {
	    	var   gj = actvalue.length -1;
		document.actSelect.activitySelect.options.length = gj
	
		for (var i=0;i<gj;i++)
		{
			document.actSelect.activitySelect.options[i+1] = new Option(acttext[i+1], actvalue[i+1]);
		}
	    }
	} else {
		//var   gj = topicvalue[gi].length > 0 ? topicvalue[gi].length - 1 : 0;
	    if (topicvalue[gi].length > 0) {
	    	var   gj = topicvalue[gi].length - 1;
		document.actSelect.activitySelect.options.length = gj
	
		for (var i=0;i<gj;i++)
		{
			document.actSelect.activitySelect.options[i+1] = new Option(topictext[gi][i+1], topicvalue[gi][i+1]);
		}
	    }
	}
}


function setUsersInfo( s ) {
	var stmt = "document.addForm.users.value='" + s + "';";
	//confirm( stmt);
	eval(stmt);
}


function setUserItems() {
	var s = "";
	var i = 0;
	var comma = "";
	while( document.userselect.elements[i] ) {
		var index = document.userselect.elements[i].name.lastIndexOf( "reqn" );
		if( index != -1 && 
		    document.userselect.elements[i].checked ) {
			
			s += comma + document.userselect.elements[i].name.substring(0,index);
			comma = ",";

		}
		++i;
	}
	//confirm (s);
	var cmd = "parent.window.opener.setUsersInfo( '" + s + "')";
	//confirm( cmd );
	eval( cmd );
	window.close();
}


function setRadio( name, path ) {
//	confirm( name + ":" + path);
	var i = 0;
	while( document.approveForm.elements[i] ) {
		var index = document.approveForm.elements[i].name.indexOf( path );
		if( index != -1 && document.approveForm.elements[i].value == name ) {
			//confirm( document.approveForm.elements[i].value +":" +
			//document.approveForm.elements[i].name );
			document.approveForm.elements[i].checked = true;
		}
		i++;
	}
}

function setAllRadios( name ) {

	var i = 0;
	while( document.approveForm.elements[i] ) {
		if( document.approveForm.elements[i].value == name ) {
			document.approveForm.elements[i].checked = true;
		}
		i++;
	}
}

function openSelectFormList(url, categoryList, categoryName, formName, formLongName) {
	
	categoryId=eval("document.addForm." + categoryList)[eval("document.addForm." +categoryList).selectedIndex].value;
	
	var stmt = "document.addForm.cal" + categoryName + ".value='" + categoryId + "';";
	eval(stmt);
	
	url = url + "&group=" + categoryId + "&formName=" + formName + "&formDesc=" + formLongName;
	window.open( url, "sfl", "toolbar=no,resizable=1,scrollbars=1,height=400,width=500" );

}

function setForm(formList, formName, formLongName) {

	var 	cmd = "parent.window.opener.setCollName( '" + formName + "', '')";
		eval( cmd );
		cmd = "parent.window.opener.setCollName( '" + formLongName + "', '')";
		eval( cmd );
	
	var i = 0;
	while( eval(formList)[i]) {
		if( eval(formList)[i].checked ) {

			formValue=eval(formList)[i].value;
			arrayOfStrings = formValue.split(";");

			cmd = "parent.window.opener.setCollName( '" + formName + "', '" + arrayOfStrings[0] + "')";
			eval( cmd );
			cmd = "parent.window.opener.setCollName( '" + formLongName + "', '" + arrayOfStrings[1] +  "')";
			eval( cmd );
			
			window.close();
			break;
		}
		++i;
	}

// It will be excute when form is only one.
	if( eval(formList).checked ) {

			formValue=eval(formList + ".value");
			arrayOfStrings = formValue.split(";");

			cmd = "parent.window.opener.setCollName( '" + formName + "', '" + arrayOfStrings[0] + "')";
			eval( cmd );
			cmd = "parent.window.opener.setCollName( '" + formLongName + "', '" + arrayOfStrings[1] + "')";
			eval( cmd );

		window.close();
	}else {
		window.close();
	}

}


function showAbstractHelp() {
	
    helpString =
        "<HTML><HEAD><TITLE>Detail Requirement</TITLE></HEAD>\n" +
	"<BODY bgcolor=\"#DDDDDD\">" +
	"<FORM>" +
	"<TABLE><TR><TD>" +
	"<P>You can either enter text below as your booking abstract or upload by using the browse button above to select a file on your computer.</P>" + 
	"<P><B>Note: </B>If you upload an html file the following rules apply:</P>" +
	"<BR/>" +
	"<UL>" + 
		"<LI>Maximum html file size is 32K. (Images and other binaries NOT included)</LI>" +
		"<LI>Your html must contain only defined unicode chars. (Don't try to upload binaries here!)</LI>" +
		"<LI>Files containing FRAME, FRAMESET, or SCRIPT tags will be ignored</LI>" +
		"<LI>All images in the page must be uploaded using the browse buttons that will appear for each of these on the preview(next) page.</LI>" +
		"<LI>Only the BODY portion will be used.  The HEAD of the page will be stripped out.</LI>" +
		"<LI>Try to make your html page size as close as possible to the default booking page size.</LI>" +
	"</UL>" +
	"</TD></TR>" +
	"<TR><TD align=\"center\">" +
		"<INPUT type=\"button\" onclick=\"window.close();\" value=\"close this window\"/>" +
	"</TD></TR></TABLE>" +
	"</FORM>" +
	"</BODY></HTML>";

	abstractWinFeatures = "dependent=yes,width=550,height=380,titlebar=yes,screenX=200,screenY=80";
	window.open("javascript:parent.opener.helpString", "abstractWin", abstractWinFeatures );
}

function addAttachFiles( url ) {

	attachWinFeatures = "dependent=yes,width=600,height=450,titlebar=yes,screenX=200,screenY=80";
	url = url + "?mode=Attach+Files";
	window.open( url, "attachWin", attachWinFeatures );
}

function importVEvent( url ) {
	
    helpString =
        "<HTML><HEAD><TITLE>Detail Requirement</TITLE></HEAD>\n" +
	"<BODY>" +
	"<FORM name=\"importForm\" method=\"POST\" enctype=\"multipart/form-data\"" + "action=\"" + url + "\">" +
	"<TABLE>" +
	"<TR><TD> </TD></TR>" +
	"<TR><TD> </TD></TR>" +
	"<TR><TD> </TD></TR>" +
	"<TR><TD> </TD></TR>" +
	"<TR><TD>" +
	"<B>Here you can import Events from local file which is compatible with vCalendar format.</B>" +
	"</TD></TR>" +
	"<TR><TD> </TD></TR>" +
	"<TR><TD></TD></TR>" +
	"<TR><TD> </TD></TR>" +
	"<TR><TD align=\"center\">" +
	"<INPUT type=\"file\" name=\"importFile\" size=\"30\">" +
	"</TD></TR>" +
	"<TR><TD> </TD></TR>" +
	"<TR><TD> </TD></TR>" +
	"<TR><TD align=\"center\">" +
	"<INPUT type=\"submit\" value=\"Import VEvent\" name=\"mode\">" +
	"<INPUT type=\"button\" onclick=\"window.close()\" value=\"Done\">" +
	"</TD></TR>" +
	"</TABLE>" +
	"</FORM>" +
	"</BODY></HTML>";

	abstractWinFeatures = "dependent=yes,width=500,height=250,titlebar=yes,scrollbars=yes,screenX=200,screenY=80";
	
	window.open("javascript:parent.opener.helpString", "abstractWin", abstractWinFeatures );
}

function showGroupSelectHelp( ) {
	helpWinFeatures = "dependent=yes,width=750,height=600,titlebar=yes,scrollbars=yes";
	window.open( "/jscript/filtering-selecting.htm", "groupSelectHelp", helpWinFeatures );
}

function doNothing() {}