/*@Author - Chirstopher V Lapa *@content - Javascripts common to all pages in CL *@Date - 01/10/08 */ // front page tabs control function switchTabs(myTab){var arr_tabs = new Array('news','events','contact');	var arLen=arr_tabs.length;	for ( var i=0, len=arLen; i<len; ++i ){				var myArrayTab = arr_tabs[i]+"Tab";				var myTabContent = arr_tabs[i]+"Content";				if(myArrayTab == myTab){			getElement(myTab).className = arr_tabs[i]+"Tab_up";			getElement(myTabContent).style.display = "block";		}else{			getElement(myArrayTab).className = arr_tabs[i]+"Tab_down";			getElement(myTabContent).style.display ="none";		}		}	// garbage collect	myTabContent = "";	myTab = "";} // show / hide content function showHideContent(myEl,myType){	// check which DOM	if(document.all) {		var myDOM = "ie";	} else {		var myDOM = "ff";	}		// get the hidden / showing element from the link clicked		var containerElement = myEl.parentNode;		var mainContentElement = containerElement.parentNode;		if(myDOM == "ie"){				// main or sub?		if(myType == "main"){			var contentElement = mainContentElement.childNodes[1];		}else{			var contentElement = mainContentElement.childNodes[2];		}			}else{		// main or sub?		if(myType == "main"){			var contentElement = mainContentElement.childNodes[3];		}else{			var contentElement = mainContentElement.childNodes[5];		}	}		// check if this is MAIN or SUB content and show or hide		//check if its MAIN or SUB	var mainSubRegEx = /main_/;		//check if its SHOW or HIDE	var showHideRegEx = /_hide/;		var myClassname = contentElement.className;		var mainSub = myClassname.search(mainSubRegEx);		var showHide = myClassname.search(showHideRegEx);		if(mainSub != -1){	// Match! its a MAIN element			if(showHide != -1){		// Match! its HIDDEN			contentElement.className = "main_content_show";		}else{			contentElement.className = "main_content_hide";		}			}else{	// its SUB			if(showHide != -1){		// Match! its HIDDEN			contentElement.className = "sub_content_show";		}else{			contentElement.className = "sub_content_hide";		}	}	} // Show / hide answers in resources / learning activites  function showHideAnswer(myEl){	// check which DOM	if(document.all) {		var myDOM = "ie";	} else {		var myDOM = "ff";	}		// get the hidden / showing element from the link clicked		var containerElement = myEl.parentNode;		var mainContentElement = containerElement.parentNode;		(mainContentElement.className == 'resource_link') ? myLinkEl = true: myLinkEl = false;	if(myDOM == "ie"){		// check if its a double liner link	(myLinkEl == true) ?  contentElement = mainContentElement.parentNode.childNodes[2] : contentElement = mainContentElement.childNodes[2];			}else{			// check if its a double liner link		(myLinkEl == true) ?  contentElement = mainContentElement.parentNode.childNodes[5] : contentElement = mainContentElement.childNodes[5];	}		var myClassname = contentElement.className;		//check if its SHOW or HIDE	var showHideRegEx = /_hide/;		var showHide = myClassname.search(showHideRegEx);		if(showHide != -1){		// Match! its HIDDEN			contentElement.className = "resource_show";		}else{			contentElement.className = "resource_hide";		}	}// get the element across IE and FFfunction getElement(elementID) {	// if its IE	if(document.all) {		return document.all[elementID];	// otherwise	} else {		return document.getElementById(elementID);	}}// buttons image swapfunction swap_image(imageID,imageSource){	// get the object	var imgObj = getElement(imageID);	// change its src	imgObj.src = imageSource;}// menu toggle functionvar previousHeaderElement = '';function toggleMenuSub(menuEl){	// if menu El is undefined set it as the index	(!menuEl) ? menuEl = "menu_index_header" : menuEl = menuEl;			//check if its a click thru or a page load	(!menuEl.parentNode) ? headerMenuElement = getElement(menuEl) : headerMenuElement = menuEl.parentNode;	// get the sub menu ID	var subMenuElement = headerMenuElement.childNodes[2];		// get URL from A obj	var myLink = headerMenuElement.childNodes[0].href;		//get the classname of the header so we can see if it is a red menu item	var headerString = headerMenuElement.className;		// if it is a red menu item	if(headerString.indexOf('red') != -1){						if(headerMenuElement.className == "red_header_closed"){								headerMenuElement.className = "red_header_open";								subMenuElement.className = "sub_open";				}else{								headerMenuElement.className = "red_header_closed";								subMenuElement.className = "sub_closed";							}				}else{			if(previousHeaderElement == headerMenuElement.id){		if(subMenuElement.className == "sub_closed"){				// show the submenu				subMenuElement.className = "sub_open";								// change the plus on the item header to a minus				headerMenuElement.className = "header_open";						}else{								// show the submenu				subMenuElement.className = "sub_closed";								// change the plus on the item header to a minus				headerMenuElement.className = "header_closed";								// change location				(window.location != myLink) ? window.location = myLink : headerString = headerMenuElement.className;		}			}else if(previousHeaderElement != headerMenuElement.id){						// set the previous items vars				previousHeaderElement = getElement(previousHeaderElement);								// previous sub menu element				previousSubMenuElement = previousHeaderElement.childNodes[2];						// show the submenu				subMenuElement.className = "sub_open";								// change the plus on the item header to a minus				headerMenuElement.className = "header_open";							// show the submenu				previousSubMenuElement.className = "sub_closed";								// change the plus on the item header to a minus				previousHeaderElement.className = "header_closed";								// change location				window.location = myLink;			}		}		previousHeaderElement = headerMenuElement.id;}// make the breadcrumbs for the pagefunction makeBreadcrumbs(){	// get the current directory	var path = document.location.pathname;	var currentDir = path.substring(path.indexOf('/', 7)+2, path.lastIndexOf('/'));		currentDir = currentDir.substr(0, 1).toUpperCase() + currentDir.substr(1);		//get the page title	// if its IE	var pageTitleRaw = document.title;		var pageTitleArray  = pageTitleRaw.split(" - ");		pageTitle = pageTitleArray[1];		var rootIndex = '../index.php';		var crumbStr = '<a href="'+rootIndex+'" class="breadcrumbs">Home</a> &gt; <a href="index.php" class="breadcrumbs">'+currentDir+'</a> &gt; <span class="breadcrumbs_active">'+pageTitle+'</span>';		getElement('breadCrumbs').innerHTML = crumbStr;		// THIS IS HERE BECAUSE I WANTED TO UPDATE ONE PAGE NOT EVERY PAGE		// it jumps to the open resource that someone sourced	// get the query string for the resource id	$.urlParam = function(name){		var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);		if (!results) {return 0;}		return results[1] || 0;	}				var resourceID = $.urlParam('rid');	if(resourceID != ''){		resourceID = '#resource_'+resourceID;		$.scrollTo(resourceID,800);	}}// taget _blank work aroundfunction targetBlank(){	window.open(this.href);}// form validation for about/register_updates.php// validate the formfunction validateUpdatesForm(){	var myForm = getElement('regform'); 	var errors = "";		// check profession	if(myForm.title.selectedIndex == 0){		errors += "Please select your title. \n";		getElement('title').className = "form_label_red";	}else{	getElement('title').className = "form_label";	}		//check first name	if(myForm.fname.value == ""){	errors += "Please enter your first name. \n";	getElement('fname').className = "form_label_red";	}else{	getElement('fname').className = "form_label";	}		// check surname	if(myForm.surname.value == ""){	errors += "Please enter your surname. \n";	getElement('surname').className = "form_label_red";	}else{	getElement('surname').className = "form_label";	}		// check profession	if(myForm.prof.selectedIndex == 0){		errors += "Please select your profession. \n";		getElement('prof').className = "form_label_red";	}else{	getElement('prof').className = "form_label";	}		// check email is good	var emailFilter=/^.+@.+\..{2,3}$/;	if (!(emailFilter.test(myForm.email.value))) { 		errors += "Please enter a valid email. \n";		getElement('email').className = "form_label_red";	}else{	getElement('email').className = "form_label";	}		// if there are errors then show the alert	if(errors){		alert(errors);		return false;	}else{		myForm.submit();	}	// submit if good, or display errors if not good	}// header search bar submit functionfunction headerSearchSubmit(){	var myForm = getElement('header_search_form'); 	var errors = "";		// check they have entered a value into the search field	if(myForm.query.value == ""){	errors += "Please enter a search query.";	}		// if there are errors then show the alert	if(errors){		alert(errors);		return false;	}else{		myForm.submit();	}}// opens pop up window pre sized to 850x800function popUp(URL) {day = new Date();id = day.getTime();eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=850,height=800,left = 560,top = 200');");}var indexImageSrc = Array('cl_images/find_index_image.jpg','cl_images/build_index_image.jpg','cl_images/plan_index_image.jpg');var indexImageHolder = getElement('main_section_image');function rotateIndexImages(imgHolder,Start){			if(Start>=indexImageSrc.length){			Start=0;		}			  		getElement('main_section_image').src = indexImageSrc[Start];		  		window.setTimeout("rotateIndexImages("+imgHolder+","+(Start+1)+",1)",3000);alert('IMAGE: '+indexImageSrc[Start]+"\n imgHolder: "+imgHolder+"start: "+Start); } // front page image/link mouseover changerfunction indexSectionImageSwap(sectionName){		//break the loop	sectionNumber = 4;		var imageName = "cl_images/"+sectionName+"_index_image.jpg";	var sectionImageDiv = getElement("section_image");	var sectionImageHTML = '<a href="'+sectionName+'/index.php"><img src="'+imageName+'" width="493" height="300" id="main_section_image" alt="" /></a>';		sectionImageDiv.innerHTML = sectionImageHTML;	}function showHideResource(resourceID){	//check if its SHOW or HIDE	//var showHideRegEx = /_hide/;		//var showHide = myClassname.search(showHideRegEx);		var myResourceEl = getElement(resourceID);		if(myResourceEl.className == 'resource_hide'){		// Match! its HIDDEN			myResourceEl.className = "resource_show";		}else{			myResourceEl.className = "resource_hide";		}}function showOtherTextField(hiddenFld){		// set up the duration of the fade in	var myMorph = new Fx.Morph(hiddenFld, { 'duration': 1000 });		//fade in		myMorph.start({					'display':'block',					'color':'#999999',					'background-color':'#FFFFFF',					'border-color':'#000000',					'border-style':'solid',					'border-width':'1px',					'margin-top':'10px'					});		}	function hideOtherTextField(hiddenFld){	var myMorph = new Fx.Morph(hiddenFld);		myMorph.set({					'display': 'none',					'color':'#FFFFFF',					'border': '1px solid #FFFFFF'	});}		function clearField(fld, defaulttext) {		if (fld.value == defaulttext) {			fld.value = "";			fld.style.color = '#000000';		}	}		function setField(fld, defaulttext) {		if (fld.value == "") {			fld.value = defaulttext;			fld.style.color = '#999999';		}	}		// validate resource details	function validate_resource_details(){		// form obj	myForm = $('resource_details');		errors = '';	errorsList = '';		//fld_resource_name	if(myForm.fld_resource_name.value == ''){		errorsList += '- Resource name.\n';	}		//fld_resource_publisher	if(myForm.fld_resource_publisher.value == ''){		errorsList += '- Resource publisher.\n';	}		//fld_target_audience	if($('fld_target_audience').options[$('fld_target_audience').selectedIndex].text == 'Please select...'){		errorsList += '- Target audience.\n';	}else if($('fld_target_audience').options[$('fld_target_audience').selectedIndex].text == 'Other (Please specify)'){		//fld_primary_purpose_other		if($('fld_target_audience_other').value == 'Please specify target audience...'){			errorsList += '- Target audience other field.\n';		}	}		//fld_resource_format	if($('fld_resource_format').options[$('fld_resource_format').selectedIndex].text == 'Please select...'){		errorsList += '- Resource format.\n';	}else if($('fld_resource_format').options[$('fld_resource_format').selectedIndex].text == 'Other (Please specify)'){		//fld_primary_purpose		if($('fld_resource_format_other').value == 'Please specify resource format...'){			errorsList += '- Resource format other field.\n';		}	}		//fld_country_of_origin	if($('fld_country_of_origin').options[$('fld_country_of_origin').selectedIndex].text == 'Please select...'){		errorsList += '- Country of Origin.\n';	}else if($('fld_country_of_origin').options[$('fld_country_of_origin').selectedIndex].text == 'Other (Please specify)'){		//fld_primary_purpose_other		if($('fld_country_of_origin_other').value == 'Please specify country of origin...'){			errorsList += '- Country of Origin.\n';		}	}		//fld_accessibility	if($('fld_accessibility').options[$('fld_accessibility').selectedIndex].text == 'Please select...'){		errorsList += '- Accessibility.\n';	}else if($('fld_accessibility').options[$('fld_accessibility').selectedIndex].text == 'Other (Please specify)'){		//fld_primary_purpose_other		if($('fld_accessibility_other').value == 'Please specify accessibility...'){			errorsList += '- Accessibility.\n';		}	}		//fld_cost	if($('fld_cost').options[$('fld_cost').selectedIndex].text == 'Please select...'){		errorsList += '- Cost.\n';	}else if($('fld_cost').options[$('fld_cost').selectedIndex].text == 'Other (Please specify)'){		//fld_interest_area_other		if($('fld_cost').value == 'Please specify cost...'){			errorsList += '- Cost.\n';		}	}		// trigger the func that makes the input available for validation	tinyMCE.triggerSave();		//fld_resource_description	if(myForm.fld_resource_description.value == ''){		errorsList += '- Resource desription.\n';	}	//fld_resource_url	if(myForm.fld_resource_url.value == ''){		errorsList += '- Resource URL.\n';	}		//fld_development_date	if(myForm.fld_development_date.value == ''){		errorsList += '- Development date.\n';	}		if(errorsList){		errors = 'The following fields must be completed\:\n\n';				errors += errorsList;				alert(errors);		return false;	}else if(myForm.fld_resource_description.value){		}else{		//alert('SUBMIT RESOURCE DETAILS');		//myForm.submit();		return true;	}		}			function get_radio_value(radioObj){		var radioObject = $(radioObj);		for (var i=0; i < radioObject.length; i++){	   if (radioObject[i].checked){		  return radioObject[i].value;	   }	}}// validate CHECKLIST ONEfunction validate_checklist_one(){		var errors = '';		var checklistOneCheck = '';	var resourceNotValid = '';	var notChecked = false;	var myOption = -1;		// form obj	myForm = $('checklist_one');		//fld_resource_name	if(myForm.fld_resource_name.value == ''){		errors += '- Resource name.\n';	}		//fld_resource_publisher	if(myForm.fld_resource_publisher.value == ''){		errors += '- Resource publisher.\n';	}		//fld_resource_url	if(myForm.fld_resource_url.value == ''){		errors += '- Resource URL.\n';	}		// @FIXME 22/07/09 - could not get a loop working for this.		// "Is the resource on a topic relevant for inclusion on Cancer Learning?"	for (i=myForm.fld_topic_relevant.length-1; i > -1; i--){				if (myForm.fld_topic_relevant[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the topic relevant for Cancer Learning?\n';			}else if(myForm.fld_topic_relevant[myOption].value == '2'){			resourceNotValid = 'one';		}	myOption = -1;		// "Is the resource current? (IE: Developed within the last five years)?"	for (i=myForm.fld_current.length-1; i > -1; i--){				if (myForm.fld_current[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the resource current?\n';			}else if(myForm.fld_current[myOption].value == '2'){			resourceNotValid = 'two';		}	myOption = -1;		// "Is the resource listed on the HealthInsite website?"	for (i=myForm.fld_on_health_insite.length-1; i > -1; i--){				if (myForm.fld_on_health_insite[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the resource listed on the HealthInsite website?\n';			}else if(myForm.fld_on_health_insite[myOption].value != '1'){				checklistOneCheck += '1';			}	myOption = -1;		// "Is the resource accredited by the Health on the Net (HON) Foundation Code of Conduct?"	for (i=myForm.fld_hon_code.length-1; i > -1; i--){				if (myForm.fld_hon_code[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the resource accredited by the Health on the Net?\n';			}else if(myForm.fld_hon_code[myOption].value != '1'){				checklistOneCheck += '1';			}	myOption = -1;		// "Is the resource an article published in a peer-reviewed journal?"	for (i=myForm.fld_peer_reviewed.length-1; i > -1; i--){				if (myForm.fld_peer_reviewed[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the resource an article in a peer-reviewed journal?\n';			}else if(myForm.fld_peer_reviewed[myOption].value != '1'){				checklistOneCheck += '1';			}	myOption = -1;	// fld_developed_by DROP DOWN	if(myForm.fld_developed_by.options[myForm.fld_developed_by.selectedIndex].text == 'Please select...'){		errors += '- Please specify who this resource was developed by.\n';	}else if(myForm.fld_developed_by.options[myForm.fld_developed_by.selectedIndex].text == 'Not in this list.'){				checklistOneCheck += '1';			}		if (errors){				// If there were no selections made display an alert box		errors = 'The following fields must be completed\:\n\n'+errors;		alert(errors);		return (false);			}else if(resourceNotValid){		myForm.action = 'web_details.php';		myForm.submit();		//alert('web_details.php');				return (false);			// if there is less than 4 values in that string, that means there is a NO in there, and we need	// we need to submit to checklist TWO	}else if(checklistOneCheck.length > 0){				myForm.action = 'checklist_two.php';		myForm.submit();		//alert('checklist_two.php: '+checklistOneCheck.length);			// if THREE thru to SIX are YES, then go to web_details.php	}else if(checklistOneCheck.length == 0){				myForm.action = 'resource_details.php';		myForm.submit();		//alert('resource_details.php: '+checklistOneCheck.length);	}	}// validate checklist TWOfunction validate_checklist_two(){		// form obj	myForm = $('checklist_two');		var errors = '';		var checklistTwoCheck = '';	var commericalSponsor = 0;	var myOption = -1;		//fld_resource_name	if(myForm.fld_resource_name.value == ''){		errors += '- Resource name.\n';	}		//fld_resource_publisher	if(myForm.fld_resource_publisher.value == ''){		errors += '- Resource publisher.\n';	}		//fld_resource_url	if(myForm.fld_resource_url.value == ''){		errors += '- Resource URL.\n';	}		// "Is the aim of the resource clear?"	for (i=myForm.fld_clear_aim.length-1; i > -1; i--){				if (myForm.fld_clear_aim[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the aim of the resource clear?\n';			}else if(myForm.fld_clear_aim[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;		// "Does the content address the stated aim / purpose?"	for (i=myForm.fld_content_address_aim.length-1; i > -1; i--){				if (myForm.fld_content_address_aim[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Does the content address the stated aim / purpose?\n';			}else if(myForm.fld_content_address_aim[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;	// "Is the date of development / update of the resource provided?" @FIXME this can be done bfore this page	for (i=myForm.fld_development_date_provided.length-1; i > -1; i--){				if (myForm.fld_development_date_provided[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the date of development / update of the resource provided?\n';			}else if(myForm.fld_development_date_provided[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;	// "Are the authors / editorial board clearly stated?"	for (i=myForm.fld_authors_stated.length-1; i > -1; i--){				if (myForm.fld_authors_stated[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Are the authors / editorial board clearly stated?\n';			}else if(myForm.fld_authors_stated[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;	// "Is the content / layout well developed?"	for (i=myForm.fld_content_well_developed.length-1; i > -1; i--){				if (myForm.fld_content_well_developed[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the content / layout well developed?\n';			}else if(myForm.fld_content_well_developed[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;	// "Are references provided?"	for (i=myForm.fld_references_provided.length-1; i > -1; i--){				if (myForm.fld_references_provided[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Are references provided?\n';			}else if(myForm.fld_references_provided[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;	// "are references current?"	for (i=myForm.fld_references_current.length-1; i > -1; i--){				if (myForm.fld_references_current[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Are references current?\n';			}else if(myForm.fld_references_current[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;	// "Are links to websites functional and current?"	for (i=myForm.fld_links_functional.length-1; i > -1; i--){				if (myForm.fld_links_functional[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Are links to websites functional and current?\n';			}else if(myForm.fld_links_functional[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;	// "Is the funding body clearly stated?"	for (i=myForm.fld_funding_body_clear.length-1; i > -1; i--){				if (myForm.fld_funding_body_clear[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Is the funding body clearly stated?\n';			}else if(myForm.fld_funding_body_clear[myOption].value != '1'){				checklistTwoCheck += '1';			}	myOption = -1;	// "Does the resource have a commercial sponsor?"	for (i=myForm.fld_commercial_sponsor.length-1; i > -1; i--){				if (myForm.fld_commercial_sponsor[i].checked) {			myOption = i;			i = -1;		}			}		if (myOption == -1) {				errors += '- Does the resource have a commercial sponsor?\n';			}else if(myForm.fld_commercial_sponsor[myOption].value != '0'){				checklistTwoCheck += '1';		//commericalSponsor = 1;			}	myOption = 1;		if(errors){		// If there were no selections made display an alert box		errors = 'The following fields must be completed\:\n\n'+errors;		alert(errors);				return (false);	// if there are NO values, then it is invalid, so mark it as such and we are done!!!	}else if(checklistTwoCheck.length == '0'){						//$('action_do').value = 'new';		myForm.action = 'resource_details.php';		myForm.submit();		//alert('resource_details.php: '+checklistTwoCheck.length);			// if THREE thru to SIX are YES, then go to resource_Details.php	}else{				//$('action_do').value = 'new';		myForm.action = 'web_details.php';		myForm.submit();		//alert('web_details.php: '+checklistTwoCheck.length);			}}function validate_web_details(){		myForm = $('web_details');		var WebDetailsCheck = '';	var errors = '';	var myOption = -1;		// "Is this resource approved for the web?"	for (i=myForm.fld_web_approved.length-1; i > -1; i--){				if (myForm.fld_web_approved[i].checked) {			myOption = i;			i = -1;		}			}	if (myOption == -1) {				errors += '- Please select if this resource is approved to go live.\n';			}	myOption = -1;		// check first page field is set	if(myForm.fld_page1.options[myForm.fld_page1.selectedIndex].text == 'Select resource page...' || myForm.fld_section1.options[myForm.fld_section1.selectedIndex].text == 'Select resource section...'){		errors += '- Please select at least ONE page and section for this resource.\n';	}		//if it is check the section fields of two or three are set		if (errors){		// If there were no selections made display an alert box		errors = 'The following fields must be completed\:\n\n'+errors;		alert(errors);		return (false);	}else{			//myForm.action = 'resource_details.php';		myForm.submit();		//alert('PAGE: '+myForm.fld_page.options[myForm.fld_page.selectedIndex].value+' SECTION: '+myForm.fld_section.options[myForm.fld_section.selectedIndex].text);		}}// validate resource managment display resources formfunction validate_resource_management(){			myForm = $('management_main');				if(myForm.search_term.value != ''){			window.location = 'search.php?search_term='+myForm.search_term.value+'&page=1';		}else{						getResources();				}}// DATE PICKER// ijnsert the date into the field/* * DatePicker * @author Rick Hopkins * @modified by Micah Nolte and Martin Vašina * @version 0.3.2 * @classDescription A date picker object. Created with the help of MooTools v1.11 * MIT-style License.-- start it up by doing this in your domready:$$('input.DatePicker').each( function(el){	new DatePicker(el);}); */var DatePicker = new Class({	/* set and create the date picker text box */	initialize: function(dp){		// Options defaults		this.dayChars = 1; // number of characters in day names abbreviation		this.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];		this.daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];		this.format = 'dd/mm/yyyy';		this.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];		this.startDay = 7; // 1 = week starts on Monday, 7 = week starts on Sunday		this.yearOrder = 'desc';		this.yearRange = 20;		this.yearStart = (new Date().getFullYear());		// Finds the entered date, or uses the current date		if(dp.value != '') {			dp.then = new Date(dp.value);			dp.today = new Date();		} else {			dp.then = dp.today = new Date();		}		// Set beginning time and today, remember the original		dp.oldYear = dp.year = dp.then.getFullYear();		dp.oldMonth = dp.month = dp.then.getMonth();		dp.oldDay = dp.then.getDate();		dp.nowYear = dp.today.getFullYear();		dp.nowMonth = dp.today.getMonth();		dp.nowDay = dp.today.getDate();		// Pull the rest of the options from the alt attr		if(dp.alt) {			options = JSON.decode(dp.alt);		} else {			options = [];		}		dp.options = {			monthNames: (options.monthNames && options.monthNames.length == 12 ? options.monthNames : this.monthNames) || this.monthNames, 			daysInMonth: (options.daysInMonth && options.daysInMonth.length == 12 ? options.daysInMonth : this.daysInMonth) || this.daysInMonth, 			dayNames: (options.dayNames && options.dayNames.length == 7 ? options.dayNames : this.dayNames) || this.dayNames,			startDay : options.startDay || this.startDay,			dayChars : options.dayChars || this.dayChars, 			format: options.format || this.format,			yearStart: options.yearStart || this.yearStart,			yearRange: options.yearRange || this.yearRange,			yearOrder: options.yearOrder || this.yearOrder		};		dp.setProperties({'id':dp.getProperty('name'), 'readonly':true});		dp.container = false;		dp.calendar = false;		dp.interval = null;		dp.active = false;		dp.onclick = dp.onfocus = this.create.pass(dp, this);	},	/* create the calendar */	create: function(dp){		if (dp.calendar) return false;		// Hide select boxes while calendar is up		if(window.ie6){			$$('select').addClass('dp_hide');		}				/* create the outer container */		dp.container = new Element('div', {'class':'dp_container'}).injectBefore(dp);				/* create timers */		dp.container.onmouseover = dp.onmouseover = function(){			$clear(dp.interval);		};		dp.container.onmouseout = dp.onmouseout = function(){			dp.interval = setInterval(function(){				if (!dp.active) this.remove(dp);			}.bind(this), 500);		}.bind(this);				/* create the calendar */		dp.calendar = new Element('div', {'class':'dp_cal'}).injectInside(dp.container);				/* create the date object */		var date = new Date();				/* create the date object */		if (dp.month && dp.year) {			date.setFullYear(dp.year, dp.month, 1);		} else {			dp.month = date.getMonth();			dp.year = date.getFullYear();			date.setDate(1);		}		dp.year % 4 == 0 ? dp.options.daysInMonth[1] = 29 : dp.options.daysInMonth[1] = 28;				/* set the day to first of the month */		var firstDay = (1-(7+date.getDay()-dp.options.startDay)%7);								/* create the month select box */		monthSel = new Element('select', {'id':dp.id + '_monthSelect'});		for (var m = 0; m < dp.options.monthNames.length; m++){			monthSel.options[m] = new Option(dp.options.monthNames[m], m);			if (dp.month == m) monthSel.options[m].selected = true;		}				/* create the year select box */		yearSel = new Element('select', {'id':dp.id + '_yearSelect'});		i = 0;		dp.options.yearStart ? dp.options.yearStart : dp.options.yearStart = date.getFullYear();		if (dp.options.yearOrder == 'desc'){			for (var y = dp.options.yearStart; y > (dp.options.yearStart - dp.options.yearRange - 1); y--){				yearSel.options[i] = new Option(y, y);				if (dp.year == y) yearSel.options[i].selected = true;				i++;			}		} else {			for (var y = dp.options.yearStart; y < (dp.options.yearStart + dp.options.yearRange + 1); y++){				yearSel.options[i] = new Option(y, y);				if (dp.year == y) yearSel.options[i].selected = true;				i++;			}		}				/* start creating calendar */		calTable = new Element('table');		calTableThead = new Element('thead');		calSelRow = new Element('tr');		calSelCell = new Element('th', {'colspan':'7'});		monthSel.injectInside(calSelCell);		yearSel.injectInside(calSelCell);		calSelCell.injectInside(calSelRow);		calSelRow.injectInside(calTableThead);		calTableTbody = new Element('tbody');				/* create day names */		calDayNameRow = new Element('tr');		for (var i = 0; i < dp.options.dayNames.length; i++) {			calDayNameCell = new Element('th');			calDayNameCell.appendText(dp.options.dayNames[(dp.options.startDay+i)%7].substr(0, dp.options.dayChars)); 			calDayNameCell.injectInside(calDayNameRow);		}		calDayNameRow.injectInside(calTableTbody);				/* create the day cells */		while (firstDay <= dp.options.daysInMonth[dp.month]){			calDayRow = new Element('tr');			for (i = 0; i < 7; i++){				if ((firstDay <= dp.options.daysInMonth[dp.month]) && (firstDay > 0)){					calDayCell = new Element('td', {'class':dp.id + '_calDay', 'axis':dp.year + '|' + (parseInt(dp.month) + 1) + '|' + firstDay}).appendText(firstDay).injectInside(calDayRow);				} else {					calDayCell = new Element('td', {'class':'dp_empty'}).appendText(' ').injectInside(calDayRow);				}				// Show the previous day				if ( (firstDay == dp.oldDay) && (dp.month == dp.oldMonth ) && (dp.year == dp.oldYear) ) {					calDayCell.addClass('dp_selected');				}				// Show today				if ( (firstDay == dp.nowDay) && (dp.month == dp.nowMonth ) && (dp.year == dp.nowYear) ) {					calDayCell.addClass('dp_today');				}				firstDay++;			}			calDayRow.injectInside(calTableTbody);		}				/* table into the calendar div */		calTableThead.injectInside(calTable);		calTableTbody.injectInside(calTable);		calTable.injectInside(dp.calendar);				/* set the onmouseover events for all calendar days */		$$('td.' + dp.id + '_calDay').each(function(el){			el.onmouseover = function(){				el.addClass('dp_roll');			}.bind(this);		}.bind(this));				/* set the onmouseout events for all calendar days */		$$('td.' + dp.id + '_calDay').each(function(el){			el.onmouseout = function(){				el.removeClass('dp_roll');			}.bind(this);		}.bind(this));				/* set the onclick events for all calendar days */		$$('td.' + dp.id + '_calDay').each(function(el){			el.onclick = function(){				ds = el.axis.split('|');				dp.value = this.formatValue(dp, ds[0], ds[1], ds[2]);				this.remove(dp);			}.bind(this);		}.bind(this));				/* set the onchange event for the month & year select boxes */		monthSel.onfocus = function(){ dp.active = true; };		monthSel.onchange = function(){			dp.month = monthSel.value;			dp.year = yearSel.value;			this.remove(dp);			this.create(dp);		}.bind(this);				yearSel.onfocus = function(){ dp.active = true; };		yearSel.onchange = function(){			dp.month = monthSel.value;			dp.year = yearSel.value;			this.remove(dp);			this.create(dp);		}.bind(this);	},		/* Format the returning date value according to the selected formation */	formatValue: function(dp, year, month, day){		/* setup the date string variable */		var dateStr = '';				/* check the length of day */		if (day < 10) day = '0' + day;		if (month < 10) month = '0' + month;				/* check the format & replace parts // thanks O'Rey */		dateStr = dp.options.format.replace( /dd/i, day ).replace( /mm/i, month ).replace( /yyyy/i, year );		dp.month = dp.oldMonth = '' + (month - 1) + '';		dp.year = dp.oldYear = year;		dp.oldDay = day;				/* return the date string value */		return dateStr;	},		/* Remove the calendar from the page */	remove: function(dp){		$clear(dp.interval);		dp.active = false;		if (window.opera) dp.container.empty();		else if (dp.container) dp.container.destroy();		dp.calendar = false;		dp.container = false;		$$('select.dp_hide').removeClass('dp_hide');	}});window.addEvent('domready', function(){	$$('input.DatePicker').each( function(el){		new DatePicker(el);	});});function setCurrentDate(){tempDate = new Date();curDay = tempDate.getDate();curMonth = tempDate.getMonth();curYear = tempDate.getFullYear();currentDate = curDay+"/"+curMonth+"/"+curYear;$('fld_development_date').value = currentDate;}// set drop downsfunction setSelect(selectObj, selectData){		var selectLength = selectObj.length;	var selectOther = selectObj.toString()+'_other';	selectOther = $(selectOther);		for(i=0;i<selectLength;i++){		if(selectObj.options[i].text == selectData.toString()){			selectObj.options[i].selected = i;		}	}}// set drop downsfunction setSelectWithValue(selectObj, selectData){	var selectLength = selectObj.length;	var selectOther = selectObj.toString()+'_other';	selectOther = $(selectOther);		for(i=0;i<selectLength;i++){		if(selectObj.options[i].value == selectData.toString()){			selectObj.options[i].selected = i;		}	}}// for setting radio button valuesfunction setRadioValue(radioObj, newValue) {		var radioLength = radioObj.length;		if(radioLength == undefined) {		radioObj.checked = (radioObj.value == newValue.toString());	}		for(var i = 0; i < radioLength; i++) {		radioObj[i].checked = false;		if(radioObj[i].value == newValue.toString()) {			radioObj[i].checked = true;		}	}}// show other field for a radio buttonfunction showRadioOther(myState, myOtherField){		// get the objects for the other fields	//var myOtherField = $('myOtherField');		// check if we are showing or hiding the 'other' field - 1 is SHOW - 0 is HIDE	if(myState == 1){		showOtherTextField(myOtherField);	}else{		hideOtherTextField(myOtherField);	}}function checkForOther(selectList, otherTextFld) { 		if (!document.layers) { 			if (selectList.options[selectList.selectedIndex].text == 'Other (Please specify)') {								// gives the text field the name of the drop-down, for easy processing 				showOtherTextField(otherTextFld);			} else { 				hideOtherTextField(otherTextFld);			}		} 	} // function to take users to previous pagefunction backTrackChecklist(myPage){		window.location=myPage;}
