/* --------------------------------------------------------------------------- */
/* Scripts/javascript.js                                                       */
/* 11-Jan-007 JS - Add CloseandRefresh function.                               */
/* 18-Jan-2007 JS - Change Booking Summary report to point to Detail and create*/
/*					new Book Summary. (User: Bill)         */
/* 25-Jan-2007 JS - Add Organization colour (light brown). (User: Jeremy)      */
/* 15-Feb-2007 JS - Add query string parameter to URL for URL pdf generators   */
/*                  address issue where one cannot email a copy of the pdf     */
/*                  file.  Adobe Reader makes the filename the string after the*/
/*                  last slash. (User: Jeremy)                                 */
/* 19-Feb-2007 JS - Add New Team Booking form with View and Print options.     */
/*                  (User: Pauline)                                            */
/* 21-Feb-2007 JS - Add new Validation routines (editKeyBoard and others) for  */
/*                  Organization screens. (Rory)                               */
/* 26-Feb-2007 JS - Add link to VieworSend_Input screen so one screen can be  */
/*                  used to View or Send PDFs with form name as a parameter.   */
/*                  (User: Jeremy)                                             */
/* 15-Mar-2007 JS - Increase height of calendar control so it will display     */
/*                  all of the calendar on Chris' PC. (User: Chris)            */
/* 21-Mar-2007 JS - Function Checkeventlogin was pointing to wrong form.       */
/*                  (User: Jeremy)                                             */
/* 21-Mar-2007 JS - Add organization find, edit, and view functions to be used */
/*                  by Event Add and Modify screens. (User: Jeremy)            */
/* 26-Mar-2007 JS - Change name from TeamBook_Form.php to                      */
/*                  Secure_TeamBook_Form.php.  (User: Jeremy)                  */
/* 04-Apr-2007 JS - Add confirmation message for Group Rooming List screen     */
/*                  revised date. (User: Rory)                                 */
/* 08-Apr-2007 JS - Move Front end project to LIVE. (User: Jeremy)             */
/* 14-Apr-2007 JS - Change goTeamBookReport used by Team Booking screen so     */
/*                  GroupRoomingList or GroupRoomingListRevised is passed to   */
/*                  VieworSendInput.php to View or Send PDF.  Note             */
/*                  GroupRoom_List.php uses a local copy of goTeamBookreport   */
/*                  as it passes a drop down box parameter. (User: Jeremy)     */
/* 09-May-2007 JS - Add ViewMap4 to be used with /Tournaments/Google_Event.php */
/*                  to create "mashup" program combinining PHP, database, XML  */
/*                  data, and Goolge maps. (User: Bill)                        */
/* 22-May-2007 JS - Adjust window size of Viewmap4. (User: Jeremy)             */
/* 27-Jun-2007 JS - Increase height of calendar window so Chris can see months */
/*                  with many days. (User: Chris)                              */
/* 31-Jul-2007 JS - Add Complex colour. (User: Jeremy)                         */
/* 01-Aug-2007 JS - Add Complex Search, View, and Edit functions. (User: Jeremy*/
/* 07-Aug-2007 JS - Add Add Complex and Remove Complex functions. (User: Jeremy*/
/* 24-Oct-2007 JS - Move new Google maps to Live. (User: Bill)                 */
/* 07-Feb-2008 JS - Add View or Send PDF functionality for BB. (User: Chris)   */
/* 08-Feb-2009 JS - Add agent name to goEventReport. (User: Theresa)           */
/* 23-Feb-2009 JS - Add getElementsByClassName redefinition because the        */
/*                  function is not IE compatible.  (User: Jeremy)             */
/* 11-Mar-2009 JS - Add select_all, select_none, and select_inverse control.   */
/*                  (User: Chris)                                              */
/* 15-Mar-2009 JS - Add View Email button to Block Batch Emailer. (User: Bill) */
/* 09-Apr-2009 JS - Make BlockBooking_Form "View or Send" as the only option.  */
/* 06-Dec-2010 JS - Add function so for BlockBooking Mod when one clicks       */
/*                  emailed or faxed the emailed_date or faxed_date gets       */
/*                  updated. (User: Bill)                                      */
/* 09-Jun-2011 JS - Add LiveCount option for goBlockBookReport. (User: Pamela) */
/* 16-Sep-2011 JS - Add Event Login Link. (User: Chris)                        */
/*                                                                             */
/* --------------------------------------------------------------------------- */


function setDD(DDField, Val){
//Changes the DD box to match what is in the Text box
	for (var i = 0; i<(DDField.length); i++){
		if (DDField.options[i].value == Val){
			DDField.options[i].selected = true;
			break;
		}
	}	// End For
}



function setDDDisplay(DDField, Val){
//Changes the DD box to match what is in the Text box
	for (var i = 0; i<(DDField.length); i++){

		if (DDField.options[i].text == Val){
			DDField.options[i].selected = true;
			break;
		}
	}

}


function getCboValue(fldName){
//Gets Value from DD
	var Indx = fldName.selectedIndex;
	return fldName.options[Indx].value;
	
}

function setRadio(getFldName, getFldValue){
	var fldName = eval(getFldName);
	var fldValue = getFldValue;
	var i="";
	
	for (var i = 0; i < fldName.length; i++) {
		if (fldName[i].value == fldValue){
			fldName[i].checked = true;
		}
	}
}

function getRadio(getFldName){
	var fldName = eval(getFldName);
	var fldValue = null;
	
	for (var i = 0; i < fldName.length; i++) {
		if (fldName[i].checked == true){
			fldValue = fldName[i].value;
		}
	}
	return fldValue;
}

function openFeedback(nameFile){
//Opens the feed back form and populates it.
	var win = window.open("/Support/Feedback_Input.php?Comp=CSTT&Progm=web&Env="+navigator.appName+" "+navigator.appVersion+"&FormName="+nameFile, "feedback", "height=520, width=550, resizable=yes, scrollbars=no");
	win.focus();
}

function openPublicFeedback(nameFile){
//Opens the feed back form and populates it.
	var win = window.open("/Support/Public-FeedBack_Input.php?Comp=CSTT&Progm=web&Env="+navigator.appName+" "+navigator.appVersion+"&FormName="+nameFile, "feedback", "height=485, width=540, resizable=yes, scrollbars=no");
	win.focus();
}

function openRegistration(type, getID, request_type){
//Opens the registration and populates it based on what type it is (Event, Hotel etc.)
	parameters = "";
	switch(type){
		case 'BB': 	
			parameters = "?bbid="+getID;
			break;
			
		case 'Event':
			parameters = "?eventid="+getID;
			request_type = "";
			break;
	}

	form = "";
	switch(request_type){
			case 'team':
				form = '/Tournaments/HotelRequest_Input.php';
				break;
			case 'individual':
				form = '/Tournaments/HotelIndRequest_Input.php';
				break;
	}
	
	var win = window.open(form+parameters, "hotelregistrtion", "height=765, width=975, resizable=yes, scrollbars=yes");
	win.focus();
}

function ViewWeb(getField){
//Opens up new window for web site viewing
	var Fld = eval("document."+getField);
	var win = window.open("http://"+Fld.value, "webpage", "height=400, width=600, resizable=yes, scrollbars=yes, menubar=yes");
	win.focus();
}

function ViewMap(getPostalCode, getCountry){
//Opens up new window for web site viewing
	var PCfld = eval("document."+getPostalCode);
	var Countryfld = getCboValue(eval("document."+getCountry));
	var CountryValue = "";
	
	switch(Countryfld){
		case "Canada":
			CountryValue = "ca"
			break;

		case "USA":
			CountryValue = "us"
			break;
		
	}
		
	var win = window.open("http://maps.yahoo.com/maps_result?csz="+PCfld.value+"&country="+CountryValue, "webpage", "height=400, width=600, resizable=yes, scrollbars=yes, menubar=yes");
	win.focus();

}

function ViewMap2(getPostalCode, getCountry){
//Opens up new window for web site viewing
	var PCfld = getPostalCode;
	var Countryfld = getCountry;
	var CountryValue = "";
	
	switch(Countryfld){
		case "Canada":
			CountryValue = "ca"
			break;

		case "USA":
			CountryValue = "us"
			break;
		
	}
		
	var win = window.open("http://maps.yahoo.com/maps_result?csz="+PCfld.value+"&country="+CountryValue, "webpage", "height=400, width=600, resizable=yes, scrollbars=yes, menubar=yes");
	win.focus();

}

function ViewMap3(getPostalCode, getCountry){
//Opens up new window for web site viewing
	var PCfld = getPostalCode;
	var Countryfld = getCountry;
	var CountryValue = "";
	
	switch(Countryfld){
		case "Canada":
			CountryValue = "ca"
			break;

		case "USA":
			CountryValue = "us"
			break;
		
	}
		
	var win = window.open("http://maps.yahoo.com/maps_result?csz="+PCfld+"&country="+CountryValue, "webpage", "height=400, width=600, resizable=yes, scrollbars=yes, menubar=yes");
	win.focus();

}

function ViewMap4(p1_EventID, p2_selectedhotelid){
//Opens up new window for Google map event
//	var win = window.open("http://maps.yahoo.com/maps_result?csz="+PCfld+"&country="+CountryValue, "webpage", "height=400, width=600, resizable=yes, scrollbars=yes, menubar=yes");
/*
	var win = window.open("http://secure.cstt.com/Tournaments/Google_Event.php?eventid="+$EventID+"hotelid="+&p1_selectedhotelid, "webpage", "height=400, width=600, resizable=yes, scrollbars=yes, menubar=yes");
*/
	var win = window.open("https://secure.cstt.com/Tournaments/Google_Event.php?eventid="+p1_EventID+"&hotelid="+p2_selectedhotelid, "webpage", "width=950, height=700, resizable=yes, scrollbars=yes, menubar=yes toolbar=yes");

//	win.focus();

}

function ViewMap4_New(p1_EventID, p2_selectedhotelid){
//Opens up new window for Google map event
//	var win = window.open("http://maps.yahoo.com/maps_result?csz="+PCfld+"&country="+CountryValue, "webpage", "height=400, width=600, resizable=yes, scrollbars=yes, menubar=yes");
/*
	var win = window.open("http://secure.cstt.com/Tournaments/Google_Event.php?eventid="+$EventID+"hotelid="+&p1_selectedhotelid, "webpage", "height=400, width=600, resizable=yes, scrollbars=yes, menubar=yes");
*/
	var win = window.open("https://secure.cstt.com/Tournaments/Google_Event.php?eventid="+p1_EventID+"&hotelid="+p2_selectedhotelid, "webpage", "width=950, height=700, resizable=yes, scrollbars=yes, menubar=yes toolbar=yes");

//	win.focus();

}

function SendEmail(getField){
//Opens up new window for web site viewing
	var Fld = eval("document."+getField);
	var win = window.open("mailto: "+Fld.value);

}

function setFldElem(getID, getFld, getElemID){
//Sets text in element to field value
	var teamFld = eval("document.form1."+getFld+getID); 
	var teamNode = window.opener.document.getElementById(getElemID);
	teamNode.childNodes[0].nodeValue = teamFld.value;
}



function setEmail(getID, getFld, getElemID){
//Sets mailto link in href to field value
	var teamFld = eval("document.form1."+getFld+getID); 
	var teamNode = window.opener.document.getElementById(getElemID);
	teamNode.setAttribute("href", "mailto: "+teamFld.value);
}

function openCalendar(fldName){
//Opens Calendar and then sets field to populate after selection	

//04-Apr-2007
	var Continue = true;
	if (fldName == "rl_revised_date") {
		if (confirm("Are you sure you want to change this date?")) {
			Continue = true;
		}
		else {
			Continue = false;
		};
	};

	if (Continue) {
		getFld = eval("document.form1."+fldName);
	
		if(getFld.value == ""){
			curDate = new Date();
		}else{
			curDate = new Date(Date.parse(getFld.value));
		}
	
		setDate = curDate.getDate() + "-"+(curDate.getMonth()+1) + "-"+ curDate.getFullYear();
	
		var openStr = "/calendar.php?date=" + setDate + "&openerField=" + fldName;
	
	//15-Mar-2007
	// 27-JUn-2007 - Change height from 275 to 300
		var win = open(openStr, "calendar", "height=300, width=350 scrollbars=no, menubar=no, toolbar=no, resizeable=no, status=no");
		win.focus();
	};
}

function addDays(firstDate, numDays){
//Returns new date when you add the number of days to the first date
	
	origDate = new Date(firstDate);
	
	if(isNaN(origDate) || isNaN(numDays)){ return ""}

	var newDateNum = (origDate.valueOf())+ numDays*(24*60*60*1000);
	
	var newDate = new Date(newDateNum);
	
	//Checks to see if it goes over time change in October.  If so, add another hour
	if(newDate.getTimezoneOffset() > origDate.getTimezoneOffset()){
		var newDateNum = newDateNum + (1*60*60*1000);
		var newDate = new Date(newDateNum);
	}

	switch(newDate.getMonth()){
			case 0:
				var ndMonth = "Jan"
				break;
	
			case 1:
				var ndMonth = "Feb"
				break;
				
			case 2:
				var ndMonth = "Mar"
				break;
	
			case 3:
				var ndMonth = "Apr"
				break;
				
			case 4:
				var ndMonth = "May"
				break;
	
			case 5:
				var ndMonth = "Jun"
				break;
	
			case 6:
				var ndMonth = "Jul"
				break;
	
			case 7:
				var ndMonth = "Aug"
				break;
	
			case 8:
				var ndMonth = "Sep"
				break;
	
			case 9:
				var ndMonth = "Oct"
				break;
	
			case 10:
				var ndMonth = "Nov"
				break;
	
			case 11:
				var ndMonth = "Dec"
				break;
		}
	
	return ndMonth+" "+newDate.getDate()+", "+newDate.getFullYear();
}

function setDepart(){
//  FOR TEAM BOOKING CALENDAR POPUPS
//Checks to see if the values are in place, if they are, calculate departure date.
	var doDepDate = true;
	
	if(isNaN(document.form1.numofnights.value) || document.form1.numofnights.value == ""){
		alert("Please enter the number of nights.");
		doDepDate = false;
		document.form1.numofnights.focus();
	}
	

	if(document.form1.arrivaldate.value == ""){
		alert("Please select an arrival date.");
		doDepDate = false;
		document.form1.arrivaldate.focus()
	}
	
	if(doDepDate == true){	
		var newDate = addDays(document.form1.arrivaldate.value, document.form1.numofnights.value);
		
		document.form1.departdate.value = newDate;
		
		teamNode = document.getElementById("departdatebx");
		teamNode.childNodes[0].nodeValue = newDate;

	}// End if if doDepDate = true
}

function BBsetDepart(){
//  FOR TEAM BOOKING CALENDAR POPUPS
//Checks to see if the values are in place, if they are, calculate departure date.
	var doDepDate = true;
	
	if(isNaN(document.form1.bbnumofnights.value) || document.form1.bbnumofnights.value == ""){
		alert("Please enter the number of nights.");
		doDepDate = false;
		document.form1.bbroomnights.focus();
	}

	if(document.form1.bbarrivaldate.value == ""){
		alert("Please select an arrival date.");
		doDepDate = false;
		document.form1.bbarrivaldate.focus()
	}
	
	if(doDepDate == true){	
		var newDate = addDays(document.form1.bbarrivaldate.value, document.form1.bbnumofnights.value);
		
		document.form1.bbdepartdate.value = newDate;
		
		teamNode = document.getElementById("departdatebx");
		teamNode.childNodes[0].nodeValue = newDate;

	}// End if if doDepDate = true

}

function setGroupNumNights(){
//Populates number of nights based on Arrival Date

//Calculate how many nights are available.  Subtracts selected date in dd box from total dates (num nights avail)
	var niteTotal = document.form1.arrivaldate.length;
	var niteSelected = document.form1.arrivaldate.selectedIndex;
	
	var niteAvail = niteTotal - niteSelected;
	

//Populates NumNights DD box
	document.form1.numofnights.options.length = 0;
	
	for(i=1; i <= niteAvail; i++){
		var OptNum = i-1;
		document.form1.numofnights.options[OptNum] = new Option(i, i);	
	}
	
//Sets Departure date	
	setGroupDepart();

}

function setGroupDepart(){
//Calculates departure date based	
	var newDate = addDays(getCboValue(document.form1.arrivaldate), getCboValue(document.form1.numofnights));

	document.form1.departdate.value = newDate;
		
	teamNode = document.getElementById("departdatebx");
	teamNode.childNodes[0].nodeValue = newDate;
}

function setNodeVal($getElement, $getValue){
//Sets a node/text area to value
	getNode = document.getElementById($getElement);
	getNode.childNodes[0].nodeValue = $getValue;
}

function setNodeValName(getElement, getValue){
//Sets a node/text area to value
	//alert(document.getElementsByName($getElement))
	alert(document.getElementsByTagName("table"))
	tableArray = getElementsByTagName("table");
	
	for (i = 0; i < tableArray.length; i++) {
		getNode = nodeArray[i];
		alert(getNode.childNodes[0].nodeValue);
	}

/*
	var cell = document.TableRowElements.cells;
	nodeArray = cell.namedItem(getElement);
	
	for (i = 0; i < nodeArray.length; i++) {
		getNode = nodeArray[i];
		getNode.childNodes[0].nodeValue = getValue;
	}
*/
	
}	//end function


function getNodeVal(getElement){
//Returns node/text area value
	getNode = document.getElementById(getElement);
	return getNode.childNodes[0].nodeValue;
}


function setNumber(getNumber){
//returns a number or 0 if blank or null
	if(getNumber == "" || isNaN(getNumber)){
		return 0;
	}else{
		return parseFloat(getNumber);
	}
}


function checkNumber(getField){
//returns a number or 0 if blank or null
	getNumber = getField.value;
	
	if(isNaN(getNumber)){
		alert("Please enter a number.");
		getField.focus()
		return false;
	} else {
		return true
	}
}

//-----------

function goHotelReport(getHotID){
// 15-Feb-2007 - Add "&file=/" to each openStr command
	
	var rpt = getCboValue(document.formSubMenu.HotelReport);
	openStr = "";
	
	switch(rpt){
		case "Preferred_Hotel":
			openStr = "/Hotel/PDF/Preferred_Hotel.php?hotid="+getHotID+"&file=/Preferred_Hotel.pdf";
		break;
	}
	
	if (openStr != ""){
		newWin = open(openStr, 'childRep', "height=500, width=500, dependent=yes, scrollbars=yes, resizable=yes");
		setDD(document.formSubMenu.HotelReport, "")
		newWin.focus();
	}
}

function goTeamBookReport(getTeamBookID){
// 14-Feb-2007 - Add "&file=/" to each openStr command
// 12-Mar-2007 - Launch rooming list program based on rooming list parameter
	
	var rpt = getCboValue(document.formSubMenu.TeamBookReport);
//	var rooming_list = getCboValue(document.form1.rl_form);
	openStr = "";
	

	switch(rpt){
/*
case "TeamBook_Form":
			openStr = "/Team_Booking/PDF/Secure_TeamBook_Form.php?teambookid="+getTeamBookID+"&file=/TeamBook_Form.pdf";
		break;
*/
		case "TeamBook_Form":
			openStr = "/Team_Booking/PDF/VieworSend_Input.php?teambookid="+getTeamBookID+"&form=TeamBook_Form";
		break;

		case "TeamBook_Notes":
			openStr = "/Team_Booking/PDF/TeamBook_Notes.php?teambookid="+getTeamBookID+"&file=/TeamBook_Notes.pdf";
		break;
		
		case "Client-Fax_Input":
			openStr = "/Team_Booking/PDF/Client-Fax_Input.php?teambookid="+getTeamBookID;
		break;
		
/*
case "Hotel-Fax_Input":
			openStr = "/Team_Booking/PDF/Hotel-Fax_Input.php?teambookid="+getTeamBookID;
		break;
	
		case "Cancellation_Input":
			openStr = "/Team_Booking/PDF/Cancellation_Input.php?teambookid="+getTeamBookID;
		break;
*/
		case "Cancellation":
			openStr = "/Team_Booking/PDF/VieworSend_Input.php?&teambookid="+getTeamBookID+	"&file=/Cancellation.pdf&form=Cancellation_Form";
		break;
		case "Confirmation":
			openStr = "/Team_Booking/PDF/Confirmation.php?teambookid="+getTeamBookID+"&file=/Confirmation.pdf";
		break;
		
//08-Apr-2007 - Old
/*
		case "Confirmation_Blank":
			openStr = "/Team_Booking/PDF/Confirmation_Blank.php?teambookid="+getTeamBookID+"&file=/Confirmation_Blank.pdf";
		break;
*/
//19-Feb-2007
//26-Feb-2007
//08-Apr-2007 - Move to Live
		case "Confirmation_Blank":
			openStr = "/Team_Booking/PDF/VieworSend_Input.php?teambookid="+getTeamBookID+"&form=Confirmation_Blank";
		break;
		
		case "TeamLoginEmail":
			openStr = "/Team_Booking/PDF/TeamLogin-Email_Input.php?teambookid="+getTeamBookID;
		break;
/*		
		case "GroupRoomingList":
			openStr = "/Team_Booking/PDF/GroupRooming_List.php?teambookid="+getTeamBookID+"&file=/Group_Rooming_List.pdf";
		break;
*/
// 26-Feb-2007
// 14-Apr-2007
case "GroupRoomingList":
			openStr = "/Team_Booking/PDF/VieworSend_Input.php?teambookid="+getTeamBookID+"&form="+document.formSubMenu.rooming_list.value;
		break;


		
//26-Feb-2007
/*
case "GroupRoomingList_New":
			openStr = "/Team_Booking/PDF/VieworSend_Input.php?teambookid="+getTeamBookID+"&form="+rooming_list;
		break;
*/
}
	
	if (openStr != ""){
		newWin = open(openStr, 'childRep', "height=500, width=500, dependent=yes, scrollbars=yes, resizable=yes");
		setDD(document.formSubMenu.TeamBookReport, "")
		newWin.focus();
	}
}


function goBlockBookReport(getID, bbnum){
// 15-Feb-2007 - Add "&file=/" to each openStr command
	
	var rpt = getCboValue(document.formSubMenu.BlockBookReport);
	openStr = "";
	
	switch(rpt){
		/*
		case "BlockBooking_Form":
			openStr = "/Block_Booking/PDF/BlockBooking.php?blockbookid="+getID+"&file=/BlockBooking.pdf";
		break;
		*/
		case "BlockBooking_Notes":
			openStr = "/Block_Booking/PDF/BlockBook_Notes.php?blockbookid="+getID+"&file=/BlockBooking_Notes.pdf";
		break;
/* 18-Jan-2007 */		
		case "BookingDetail":
			window.location = "/Block_Booking/PDF/Booking_Detail.php?blockbookid="+getID;
			break;
		case "BookingSummary":
			//openStr = "/Block_Booking/PDF/Booking_Summary.php?blockbookid="+getID;
			window.location = "/Block_Booking/PDF/Booking_Summary.php?blockbookid="+getID;
		break;
/* 07-Feb-2008 */
		case "BlockBooking_Form":
			openStr = "/Block_Booking/PDF/VieworSend_Input.php?blockbookid="+getID+"&form=BlockBook_Form";
		break;
		case "LiveCount":
			window.location = "/Reports/BlockBooking/BlockBooking_LiveCount.php?bbnum="+bbnum;
		break;
	}
	
	if (openStr != ""){
		newWin = open(openStr, 'childRep', "height=500, width=500, dependent=yes, scrollbars=yes, resizable=yes");
		setDD(document.formSubMenu.BlockBookReport, "")
		newWin.focus();
	}
}


function goEventReport(getID, getOffice, agent){
// 15-Feb-2007 - Add "&file=/" to each openStr command
	
	var rpt = getCboValue(document.formSubMenu.EventReport);
	openStr = "";
	
	switch(rpt){
		case "OrgLogin":
			openStr = "/Event/PDF/EventLogin-Email_Input.php?id="+getID+"&agent="+agent;
		break;
		
		case "EventPrint":
			openStr = "/Reports/Event/Event_PDF.php?id="+getID+"&office="+getOffice+"&file=/Event.pdf";
		break;
		
	}
	
	if (openStr != ""){
		newWin = open(openStr, 'childRep', "height=500, width=500, dependent=yes, scrollbars=yes, resizable=yes");
		setDD(document.formSubMenu.EventReport, "")
		newWin.focus();
	}
	
	
}



function OpenTeamBookDel(getID){
  if (confirm("Are you sure you want to delete this booking?")) {
	openStr = "/Team_Booking/TeamBook_Del.php?teambookid="+getID+"&respg=Mod";
	newWin = open(openStr, 'child', "height=325, width=675, dependent=yes");
	newWin.focus();
  }
}


function OpenBlockBookDel(getID){
  if (confirm("Are you sure you want to delete this booking?")) {
	openStr = "/Block_Booking/BlockBook_Del.php?blockbookid="+getID+"&respg=Mod";
	newWin = open(openStr, 'child', "height=325, width=675, dependent=yes");
	newWin.focus();
  }
}



function viewBB(getFld){
//Goes to list of all block bookings with this ID
	Fld = eval(getFld);
	
	if(Fld.value != ""){
		window.location = "/Block_Booking/BlockBook_List.php?BBNum="+Fld.value;
	}else{
		alert("Enter a Block Booking Number");
		Fld.focus();
	}
}


function removeBB(getFld, getNode){
//Sets field and span to blank
	Fld = eval(getFld);
	
	Fld.value = "";

	setNodeVal(getNode, " ")
}


function findTeam(getOpener){
//Opens search for event window 
	openStr = "/Team/Team-LU_Input.php?openerid="+getOpener;
	newWin = open(openStr, 'child', "height=400, width=650, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
}


function CheckTeamLogin(){
//Checks team booking login to see if it's being used yet.

	var getUN = document.form1.grprm_username.value;
	var getPW = document.form1.grprm_password.value;

	var win = window.open("/Team_Booking/UN-PW_Lookup.php?un="+getUN+"&pw="+getPW, "UNPWLookup", "height=300, width=350 scrollbars=no, menubar=no, toolbar=no, resizeable=no, status=no");
	win.focus();
}




function CheckEventLogin(){
//Checks team booking login to see if it's being used yet.
//21-Mar-2007 - Change from frm to form1

	var getUN = document.form1.org_username.value;
	var getPW = document.form1.org_password.value;

	var win = window.open("/Event/UN-PW_Lookup.php?un="+getUN+"&pw="+getPW, "UNPWLookup", "height=300, width=350 scrollbars=no, menubar=no, toolbar=no, resizeable=no, status=no");
	win.focus();
}



function TeamBookedReserved(getTeambooking){
//Opens up Rserve vs Booked report
	openStr = "/Team_Booking/PDF/Reserve-Booked.php?teambookid="+getTeambooking;
	newWin = open(openStr, 'child', "height=330, width=450, dependent=yes, scrollbars=no, resizable=yes");
	newWin.focus();
}

function BookedvsReserved(getTeambooking){
//Opens up Booked vs Reserved miniwindow 
	openStr = "/Team_Booking/BookedvsReserved.php?teambookingid="+getTeambooking;
	newWin = open(openStr, 'child', "height=330, width=550, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
}



function setColours(getModule){
//Sets PageName and Feature ID's to module colours

	switch(getModule){
	
		case "BlockBooking":
			 //var colourPgName = "#E7F6F7";
			 var colourPgName = "#EBE5EB"
			 var colourFeature = "#EBE5EB";
			break;

		case "Event":
			 //var colourPgName = "#C8E2D9";
			 var colourPgName = "#EDFAE3";
			 var colourFeature = "#EDFAE3";
			break;

		case "Hotel":
			 //var colourPgName = "#DAE9F0";
			 var colourPgName = "#E8F2F6";
			 var colourFeature = "#E8F2F6";
			break;
					
		case "Team":
			 //var colourPgName = "#FDFEC6";
			 var colourPgName = "#FFFFEB";
			 var colourFeature = "#FFFFEB";
			break;

		case "TeamBooking":
			 //var colourPgName = "#F5E4CF";
			 var colourPgName = "#F8EBDC";
			 var colourFeature = "#F8EBDC";
			break;
			
		case "Organization":
			var colourPgName = "#D9D2BA";
			var colourFeature = "#D9D2BA";
			break;

		case "Complex":
			var colourPgName = "#FAE6E6";
			var colourFeature = "#FAE6E6";
			break;

}
	
	var ElemPgName = document.getElementById("pageName");
	var ElemFeature = document.getElementById("feature");
		
	if (ElemPgName != null){
		ElemPgName.style.backgroundColor = colourPgName;
	}
	
	if (ElemFeature != null){
		ElemFeature.style.backgroundColor = colourFeature;
	}
	
}



function searchBBNum(getOpener){
//Opens window to add or select a BBNum

	//openStr = "/Block_Booking/BBNum-LU_Input.php?openerid="+getOpener+"&bbnum="+getBBNum;
	openStr = "/Block_Booking/BBNum-LU_Input.php?openerid="+getOpener;
	newWin = open(openStr, 'child', "height=400, width=650, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();


}

function newBBNum(getFld){
//Opens window to get new unused BBNum
	openStr = "/Block_Booking/BBNum-New.php?fld="+getFld;
	newWin = open(openStr, 'child', "height=500, width=550, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();

}

function getPassword(getFld){
//Opens Password form, populates box with password.
	newWin = open("/Create-PW.php?fld="+getFld, 'child', "height=200, width=200, dependent=yes");

}


//ID and Name have to be the same because of differences in IE and Netscape

function showElement(getName){
//Displays elements with name
	arrayElement = document.getElementsByName(getName);
	for(var i = 0; i < arrayElement.length; i++){
		elem = arrayElement[i]
		elem.style.display = "inline";
	}
}


function hideElement(getName){
//Hides elements with name
	arrayElement = document.getElementsByName(getName);
	for(var i = 0; i < arrayElement.length; i++){
		elem = arrayElement[i]
		elem.style.display = "none";
	}
}


//==== DATA ROW ======
function DataRow_On(getElem){
// Highlights or returns to normal row clicked is pointing to
	 var ElemArea = document.getElementById(getElem);
	 
	 if(ElemArea.style.fontWeight == "bold"){
		ElemArea.style.backgroundColor = ""
		ElemArea.style.fontWeight = "";
	 } else {
		 ElemArea.style.backgroundColor = "#E8F2F6";
		 ElemArea.style.fontWeight = "bold";
	 }

}

function DataRow2_On(getName){
//Hides elements with name
	arrayElement = document.getElementsByName(getName);
	for(var i = 0; i < arrayElement.length; i++){
		elem = arrayElement[i]
		 if(elem.style.fontWeight == "bold"){
			elem.style.backgroundColor = ""
			elem.style.fontWeight = "";
		 } else {
			 elem.style.backgroundColor = "#E8F2F6";
			 elem.style.fontWeight = "bold";
		 }
	}
}



function DataRow_Off(getElem){
//Returns Row to normal
 var ElemArea = document.getElementById(getElem);
 ElemArea.style.backgroundColor = ""
 ElemArea.style.fontWeight = "";

}


//---- CSTT Rown On -----
//==== DATA ROW ======
function CSTTDataRow_On(getElem){
// Highlights or returns to normal row clicked is pointing to
	 var ElemArea = document.getElementById(getElem);
	 ElemArea.className = "tableData_highlight";
	
}

function CSTTDataRow_Off(getElem){
// Highlights or returns to normal row clicked is pointing to
	 var ElemArea = document.getElementById(getElem);

	ElemArea.className = "tableData";	
}
//==== END OF DATA ROW ======

//==== DATA ROW ======
function Tournament_DataRow_On(getElem){
// Highlights or returns to normal row clicked is pointing to
	 var ElemArea = document.getElementById(getElem);
	 ElemArea.className = "tournament_highlight";
	
}
function Tournament_DataRow_Off(getElem){
// Highlights or returns to normal row clicked is pointing to
	 var ElemArea = document.getElementById(getElem);

	ElemArea.className = "tournament_highlight_off";	
}
//==== END OF DATA ROW ======

function openHotelListResults(eventid, cancity, uscity, sport){
//Opens the registration and populates it based on what type it is (Event, Hotel etc.)
	
	var form = "/Tournaments/HotelList_Results.php?eventid="+eventid+"&canCity="+cancity+"&usCity="+uscity+"&sport="+sport;
//	openHotelListResults(<?php echo $row['eventid'] ?>, '<?php echo $canCity ?>', '<?php echo $usCity ?>', '<?php echo $Sport ?>')">
	
//	/Tournaments/HotelList_Results.php?eventid=<?php echo $row['eventid'] ?>&canCity=<?php echo $canCity ?>&usCity=<?php echo $usCity ?>&sport=<?php echo $Sport ?>"
	
	var win = window.open(form, "hotellistresults", "height=765, width=975, resizable=yes, scrollbars=yes");
	win.focus();
}

function addComment(getField, getAgent){
//Adds date etc. to end of comment

	var Field = eval(getField);
	var CurDate = new Date();
	
	if(Field.value == ""){
		Field.value = Field.value + " ***** "+getMonthText(CurDate.getMonth())+" "+CurDate.getDate()+", "+CurDate.getFullYear()+ " - "+getAgent+ " ***** \r\n ";
	} else {
		Field.value = Field.value + "\r\n \r\n ***** "+getMonthText(CurDate.getMonth())+" "+CurDate.getDate()+", "+CurDate.getFullYear()+ " - "+getAgent+ " ***** \r\n ";
	}
	Field.focus();

}


function getMonthText(getMonthNum){
//Returns Name of Month
	switch(getMonthNum){
			case 0:
				return "Jan"
				break;
	
			case 1:
				return "Feb"
				break;
				
			case 2:
				return "Mar"
				break;
	
			case 3:
				return "Apr"
				break;
				
			case 4:
				return "May"
				break;
	
			case 5:
				return "Jun"
				break;
	
			case 6:
				return "Jul"
				break;
	
			case 7:
				return "Aug"
				break;
	
			case 8:
				return "Sept"
				break;
	
			case 9:
				return "Oct"
				break;
	
			case 10:
				return "Nov"
				break;
	
			case 11:
				return "Dec"
				break;
		}
}



//======= Prov State
function ddProvState(selCountry, fldProvVal){
//Puts states in when US choosen and Provinces in when Canada choosen

	ProvDD = eval(fldProvVal)

	//var Indx = document.frm.ddCountry.selectedIndex;
	//var selCountry = document.frm.ddCountry.options[Indx].value;

	switch (selCountry){
		//case "United States" :

		case "USA" :
				var getProv= "-- Select One --#Armed Forces Americas#Alaska#Alabama#Armed Forces Pacific#Arkansas#American Samoa#Arizona#California#Colorado#Connecticut#District of Columbia#Delaware#Florida#Georgia#Guam#Hawaii#Iowa#Idaho#Illinois#Indiana#Kansas#Kentucky#Louisiana#Massachusetts#Maryland#Maine#Michigan#Minnesota#Missouri#Mississippi#Montana#North Carolina#North Dakota#Nebraska#New Hampshire#New Jersey#New Mexico#Nevada#New York#Ohio#Oklahoma#Oregon#Pennsylvania#Puerto Rico#Rhode Island#South Carolina#South Dakota#Tennessee#Texas#Utah#Virginia#Virgin Islands#Vermont#Washington#Wisconsin#West Virginia#Wyoming";
				var getProvAbr = " #AA#AK#AL#AP#AR#AS#AZ#CA#CO#CT#DC#DE#FL#GA#GU#HI#IA#ID#IL#IN#KS#KY#LA#MA#MD#ME#MI#MN#MO#MS#MT#NC#ND#NE#NH#NJ#NM#NV#NY#OH#OK#OR#PA#PR#RI#SC#SD#TN#TX#UT#VA#VI#VT#WA#WI#WV#WY";

				arrayProv = getProv.split('#');
				arrayProvAbr = getProvAbr.split('#');
				break

		//case "Canada" :
		case "Canada" :
				var getProv = "-- Select One --#Alberta#British Columbia#Manitoba#New Brunswick#Newfoundland#Nova Scotia#Northwest Territories#Nunavut#Ontario#Prince Edward Island#Quebec#Saskatchewan#Yukon Territory";
				var getProvAbr = " #AB#BC#MB#NB#NL#NS#NT#NU#ON#PE#QC#SK#YT";
				
				arrayProv = getProv.split('#');
				arrayProvAbr = getProvAbr.split('#');
				break

		//case "Australia" :
		case "3" :
				var getProv = "-- Select One --#Australian Capital Territory#New South Wales#Northern Territory#Queensland#South Australia#Tasmania#Victoria#Western Australia";
				var getProvAbr = " #ACT#NSW#NT#QLD#SA#TAS#VIC#WA"; 
				
				arrayProv = getProv.split('#');
				arrayProvAbr = getProvAbr.split('#');
				break
	
		default :
				var getProv= "--";
				var getProvAbr ="" 

				arrayProv = getProv.split('#');
				arrayProvAbr = getProvAbr.split('#');
				break
		
	}


	//clearList(document.frm.ddProvince);
	clearList(ProvDD);

	for (var i = 0; i < arrayProv.length; i++){
		//addElement(document.frm.ddProvince, arrayProv[i], arrayProv[i])
		addElement(ProvDD, arrayProv[i], arrayProvAbr[i])
	}

}


function clearList(list) {
//Clears dd box for ddProvState
    var i = 0;
    var o = list.options;

    for (i = o.length; i >= 0; --i)
		o[i] = null;
    list.disabled = true;
    }


function addElement(list, text_in, value_in){
//Updates dd box for ddProvState

    var o = list.options;
    var nIdx;
	if (o.length < 0)// IE for Mac 4.5 sets length to -1 if list is empty
		nIdx = 0;
	else
		nIdx = o.length;

	o[nIdx] = new Option(text_in, value_in);
	list.disabled = false;
}

//============  End of Prov/State 

//11-Jan-2007
function CloseandRefresh(){
//Close current window and refresh parent window.  Can be used when data is changed in child
//window and the parent window needs to display changed data.
	opener.location.reload();
	window.close();
}


//20-Feb-2007 - Validation functions

//One will need one or more of the following variables in the Javascript tag
//in order to use the following 5 Validation functions.
var keybYN = new keybEdit('yn','Valid values are \'Y\' or \'N\'.');
var keybNumeric = new keybEdit('01234567890','Numeric input only.');
var keybAlpha = new keybEdit('abcdefghijklmnopqurstuvwxy ','Alpha input only.');
var keybAlphaNumeric = new keybEdit('abcdefghijklmnopqurstuvwxy01234567890 ','Alpha-numeric input only.');
var keybDecimal = new keybEdit('01234567890.','Decimal input only.');
var keybSDecimal = new keybEdit('01234567890.-','Decimal input only.');
var keybDate =  new keybEdit('01234567890/','Date input only');;
var keybYNNM = new keybEdit('yn');
var keybNumericNM = new keybEdit('01234567890');
var keybAlphaNM = new keybEdit('abcdefghijklmnopqurstuvwxy');
var keybAlphaNumericNM = new keybEdit('abcdefghijklmnopqurstuvwxy01234567890');
var keybDecimalNM = new keybEdit('01234567890.');
var keybDateNM = new keybEdit('01234567890/');;

function keybEdit(strValid, strMsg) {
	/*	Function:		keybEdit
		Creation Date:	October 11, 2001
		Programmer:		Edmond Woychowsky
		Purpose:		The purpose of this function is to be a constructor for
						the keybEdit object.  keybEdit objects are used by the
						function editKeyBoard to determine which keystrokes are
						valid for form objects.  In addition, if an error occurs,
						they provide the error message.
						
						Please note that the strValid is converted to both
						upper and lower case by this constructor.  Also, that
						the error message is prefixed with 'Error:'.
						
						The properties for this object are the following:
							valid	=	Valid input characters
							message	=	Error message
							
						The methods for this object are the following:
							getValid()	=	Returns a string containing valid
											characters.
							getMessage()=	Returns a string containing the
											error message.

		Update Date:	Programmer:			Description:
	*/

	//	Variables
	var reWork = new RegExp('[a-z]','gi');		//	Regular expression\

	//	Properties
	if(reWork.test(strValid))
		this.valid = strValid.toLowerCase() + strValid.toUpperCase();
	else
		this.valid = strValid;

	if((strMsg == null) || (typeof(strMsg) == 'undefined'))
		this.message = '';
	else
		this.message = strMsg;

	//	Methods
	this.getValid = keybEditGetValid;
	this.getMessage = keybEditGetMessage;
	
	function keybEditGetValid() {
	/*	Function:		keybEdit
		Creation Date:	October 11, 2001
		Programmer:		Edmond Woychowsky
		Purpose:		The purpose of this function act as the getValid method
						for the keybEdit object.  Please note that most of the
						following logic is for handling numeric keypad input.

		Update Date:		Programmer:			Description:
	*/

		return this.valid.toString();
	}
	
	function keybEditGetMessage() {
	/*	Function:		keybEdit
		Creation Date:	October 11, 2001
		Programmer:		Edmond Woychowsky
		Purpose:		The purpose of this function act as the getMessage method
						for the keybEdit object.

		Update Date:	Programmer:			Description:
	*/
	
		return this.message;
	}
}




void function editKeyBoard(objForm, objKeyb) {
	/*	Function:		editKeyBoard
		Creation Date:	October 11, 2001
		Programmer:		Edmond Woychowsky
		Purpose:		The purpose of this function is to edit edit keyboard input
						to determine if the keystrokes are valid.
	
		Update Date:		Programmer:			Description:
	*/

	strWork = objKeyb.getValid();
	strMsg = '';							// Error message
	blnValidChar = false;					// Valid character flag

	// Part 1: Validate input
	if(!blnValidChar)
		for(i=0;i < strWork.length;i++)
			if(window.event.keyCode == strWork.charCodeAt(i)) {
				blnValidChar = true;

				break;
			}

	// Part 2: Build error message
	if(!blnValidChar) {
		if(objKeyb.getMessage().toString().length != 0)
			alert('Error: ' + objKeyb.getMessage());

		window.event.returnValue = false;		// Clear invalid character
		objForm.focus();						// Set focus
	}
}

void function setEvents() {
	document.all.txtYN.onkeypress = new Function('editKeyBoard(this,keybYN)');
	document.all.txtNumeric.onkeypress = new Function('editKeyBoard(this,keybNumeric)');
	document.all.txtAlpha.onkeypress = new Function('editKeyBoard(this,keybAlpha)');
	document.all.txtAlphaNumeric.onkeypress = new Function('editKeyBoard(this,keybAlphaNumeric)');
	document.all.txtDecimal.onkeypress = new Function('editKeyBoard(this,keybDecimal)');
	document.all.txtDate.onkeypress = new Function('editKeyBoard(this,keybDate)');
}

//End of 5 previous Validation functions


// 21-Mar-2007

function findOrganization(getOpener){
//Opens search for event window 
	openStr = "/Organization/Organization-LU_Input.php?openerid="+getOpener;
	newWin = open(openStr, 'child', "height=400, width=650, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
}

function viewOrganization(){
//Goes to Event detail page
	var organizationID = document.form1.organizationid.value;
	if(organizationID == ""){
		alert("Select an organization.");
	} else{
		openStr = "/Organization/Organization_View.php?organizationid="+organizationID;
		newWin = open(openStr, 'child', "height=400, width=650, dependent=yes, scrollbars=yes, resizable=yes");
		newWin.focus();
	}
}

function editOrganization(){
//Goes to Edit Page for Organization
	var organizationID = document.form1.organizationid.value;
	if(organizationID == ""){
		alert("Select an organization.");
	} else{
		window.location = "/Organization/Organization_ModInput.php?organizationid="+organizationID;
	}

}

// 01-Aug-2007 - Complex
function AddComplex(getOpener, eventid){
//Opens search for event window to add complex
	openStr = "/Complex/Complex-LU_Input.php?openerid="+getOpener+"&eventid="+eventid;
	newWin = open(openStr, 'child', "height=400, width=650, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
}

function RemoveComplex(eventid, complexid){
//Opens search for event window to add complex
	openStr = "/Complex/Complex_Remove_Link.php?eventid="+eventid+"&complexid="+complexid;
	newWin = open(openStr, 'child', "height=400, width=650, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
}


function viewComplex(){
//Goes to Event detail page
	var complexID = document.form1.complexid.value;
	if(complexID == ""){
		alert("Select a complex.");
	} else{
		openStr = "/Complex/Complex_View.php?complexid="+complexID;
		newWin = open(openStr, 'child', "height=400, width=650, dependent=yes, scrollbars=yes, resizable=yes");
		newWin.focus();
	}
}

function editComplex(){
//Goes to Edit Page for Complex
	var complexID = document.form1.complexid.value;
	if(complexID == ""){
		alert("Select a complex.");
	} else{
		window.location = "/Complex/Complex_ModInput.php?complexid="+complexID;
	}

}

/*
	Developed by Robert Nyman, http://www.robertnyman.com
	Code/licensing: http://code.google.com/p/getelementsbyclassname/
	version 1.0.1
	This function is necessary because IE does not support getElementsByClassName.
*/	
var getElementsByClassName = function (className, tag, elm){
	if (document.getElementsByClassName) {
		getElementsByClassName = function (className, tag, elm) {
			elm = elm || document;
			var elements = elm.getElementsByClassName(className),
				nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
				returnElements = [],
				current;
			for(var i=0, il=elements.length; i<il; i+=1){
				current = elements[i];
				if(!nodeName || nodeName.test(current.nodeName)) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	else if (document.evaluate) {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = "",
				xhtmlNamespace = "http://www.w3.org/1999/xhtml",
				namespaceResolver = (document.documentElement.namespaceURI === xhtmlNamespace)? xhtmlNamespace : null,
				returnElements = [],
				elements,
				node;
			for(var j=0, jl=classes.length; j<jl; j+=1){
				classesToCheck += "[contains(concat(' ', @class, ' '), ' " + classes[j] + " ')]";
			}
			try	{
				elements = document.evaluate(".//" + tag + classesToCheck, elm, namespaceResolver, 0, null);
			}
			catch (e) {
				elements = document.evaluate(".//" + tag + classesToCheck, elm, null, 0, null);
			}
			while ((node = elements.iterateNext())) {
				returnElements.push(node);
			}
			return returnElements;
		};
	}
	else {
		getElementsByClassName = function (className, tag, elm) {
			tag = tag || "*";
			elm = elm || document;
			var classes = className.split(" "),
				classesToCheck = [],
				elements = (tag === "*" && elm.all)? elm.all : elm.getElementsByTagName(tag),
				current,
				returnElements = [],
				match;
			for(var k=0, kl=classes.length; k<kl; k+=1){
				classesToCheck.push(new RegExp("(^|\\s)" + classes[k] + "(\\s|$)"));
			}
			for(var l=0, ll=elements.length; l<ll; l+=1){
				current = elements[l];
				match = false;
				for(var m=0, ml=classesToCheck.length; m<ml; m+=1){
					match = classesToCheck[m].test(current.className);
					if (!match) {
						break;
					}
				}
				if (match) {
					returnElements.push(current);
				}
			}
			return returnElements;
		};
	}
	return getElementsByClassName(className, tag, elm);
};

function toggle_allfile () {
/* Toggle file number class color based on All checkbox */

	var filegroup = getElementsByClassName('file');
	
	if (document.getElementById('allfile').checked == true) {
		document.getElementById('filefrom').disabled = true;
		document.getElementById('fileto').disabled = true;
		document.getElementById('fileheader').style.color = "#CCCCCC";
		for (i=0, limit=filegroup.length; i< limit; i++) {
			filegroup[i].style.color = "#CCCCCC";
		}
	}
	else {			
		document.getElementById('fileheader').style.color = "#496F89";		
		document.getElementById('filefrom').disabled = false;
		document.getElementById('fileto').disabled = false;
		for (i=0, limit=filegroup.length; i< limit; i++) {
			filegroup[i].style.color = "#000000";
		}
	}
	
}

function enable_files() {
/* Enable file fields so post action occurs correctly. */

	document.getElementById('filefrom').disabled = false;
	document.getElementById('fileto').disabled = false;

}

function submit_invoice_import() {

	if (document.pressed == 'Submit') {
		
		if (document.getElementById('allfile').checked == true && document.getElementById('checkinvoicecriteria').checked == false ) {
			if (confirm("Are you sure you wish to display all files?")) {
				enable_files();
			}
			else {
				return false;
			}
		}
		else {
				enable_files();
		}
	}
	
	return true;

}

function select_all(classname) {

	var allgroup = getElementsByClassName(classname);
	for (i=0, limit=allgroup.length; i<limit; i++) {
		allgroup[i].checked = true;	
	}
}

function select_none(classname) {

	var allgroup = getElementsByClassName(classname);
	for (i=0, limit=allgroup.length; i<limit; i++) {
		allgroup[i].checked = false;	
	}
}

function select_inverse(classname) {

	var allgroup = getElementsByClassName(classname);
	for (i=0, limit=allgroup.length; i<limit; i++) {
		if (allgroup[i].checked == true) {
			allgroup[i].checked = false;
		}
		else {
			allgroup[i].checked = true;
		}
	}
}

function block_batch_email_preview () {
	
	var openStr = "/Emailer/Block_Batch_Send/Block_Batch_View_Email.php";
	newWin = open(openStr, 'childRep', "height=500, width=900, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
	
}

function rl_batch_email_preview (rl_date, officeid, name, email) {
	
	var openStr = "/Emailer/RL_Reminder_Batch_Send/RL_Reminder_View_Email.php?rl_date="+rl_date+"&officeid="+officeid+"&name="+name+"&email="+email;
	newWin = open(openStr, 'childRep', "height=500, width=900, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
	
}

function hgp_batch_email_preview (rl_date_from, rl_date_to, officeid, name, email) {
	
	var openStr = "/Emailer/HGP_Reminder_Batch_Send/HGP_Reminder_View_Email.php?rl_date_from="+rl_date_from+"&rl_date_to="+rl_date_to+"&officeid="+officeid+"&name="+name+"&email="+email;
	newWin = open(openStr, 'childRep', "height=500, width=900, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
	
}

function IsNumeric(sText, type)

{
   var ValidChars = ".";

   if (type == "decimal") { ValidChars = "0123456789."; }
   if (type == "signeddecimal") { ValidChars = "0123456789.-"; }

   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

function update_date (flag) {
	
	var currenttime = new Date();
	var year = currenttime.getFullYear();
	var month = currenttime.getMonth() + 1;
	var day = currenttime.getDate();
	var hour = currenttime.getHours();
	var minute = currenttime.getMinutes();
	var now = year + "-" + month + "-" + day + " " + hour + ":" + minute;

	if (flag == 'emailed') { document.getElementById('emailed_date').value = now; }
	if (flag == 'faxed') { document.getElementById('faxed_date').value = now; }

}	

function find_hotel(openerid){
//Opens search for Hotel window.  Used in Peak Dates input but could be adapted for other screens

	openStr = "/Hotel/Hotel-LU_Input.php?openerid="+openerid; 
	newWin = open(openStr, 'child', "height=400, width=650, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();
}

function toggle_date() {
/* Toggle date style color based on date toggle checkbox */
	
	var dategroup = getElementsByClassName('date');

	if (document.getElementById('date_check').checked == true) {
		document.getElementById('entry_fromdate').disabled = false;
		document.getElementById('entry_todate').disabled = false;
		for (i=0, limit=dategroup.length; i< limit; i++) {
			dategroup[i].style.color = "#000000";
		}
	}
	else {			
		document.getElementById('entry_fromdate').disabled = true;
		document.getElementById('entry_todate').disabled = true;
		for (i=0, limit=dategroup.length; i< limit; i++) {
			dategroup[i].style.color = "#CCCCCC";
		}
	}
	
}

function view_audit(teambookingid, screen) {

	openStr = "/Team_Booking/AuditTrail_View.php?teambookingid="+teambookingid+"&screen="+screen;
	newWin = open(openStr, 'child', "height=550, width=950, dependent=yes, scrollbars=yes, resizable=yes");
	newWin.focus();

}

function UpdateCountry(){

	var current_state_province;
	var USstate_id = '#AL#AK#AS#AZ#AR#CA#CO#CT#DE#DC#FM#FL#GA#GU#HI#ID#IL#IN#IA#KS#KY#LA#ME#MH#MD#MA#MI#MN#MS#MO#MT#NE#NV#NH#NJ#NM#NY#NC#ND#MP#OH#OK#OR#PW#PA#PR#RI#SC#SD#TN#TX#UT#VT#VA#VI#WA#WV#WI#WY';
	var Canadaprovince_id = '#AB#BC#MB#NB#NF#NT#NS#ON#PE#QC#SK#YT';
		
	current_state_province = getCboValue(document.form1.stateprov);

	if (USstate_id.indexOf(current_state_province) != -1) {
		setDD(document.form1.country, 'USA');
	}
	if (Canadaprovince_id.indexOf(current_state_province) != -1) {
		setDD(document.form1.country, 'Canada');
	}
}

function send_eventlogin(getID){

	if (confirm("Are you sure you want to send the Event Login Link?")) {
		url_redirect = "/Event/Event_ModInput.php?eventid="+getID+"&send_email=1"; 
		window.location = url_redirect;
	}
}

function create_requestforproposal(secure_url, eventid) {

	var url = secure_url+"/Event/Rfp/Rfp-lu_input.php?eventid="+eventid;
	var win = window.open(url, "webpage", "height=600, width=1200, resizable=yes, scrollbars=yes, menubar=yes");
	win.focus();
	
}

function confirm_send() {

	if (!confirm("Do you wish to send an email to all selected hotels?")) {
		return false;
	}
		
	return true;	
}

function rfp_status_change() {

	document.form1.submit();
}

function goOrderBy(sql_fieldname) {

	document.getElementById("sortby").value = sql_fieldname;
	document.form1.action = "/Event/RFP/RFP-LU_Results.php";
	document.form1.submit();
	
}

function goOrderBy_rfp(sql_fieldname) {

	document.getElementById("sortby").value = sql_fieldname;
	document.form1.action = "/RFP/rfp_list.php";
	document.form1.submit();
	
}


