<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function NoneWithCheck(ss) {
if (typeof ss.length == 'number')
{
    for(var i = 0; i < ss.length; i++) 
    {
	    if(ss[i].checked) { return false; }
	}	
}
else
{
    if(ss.checked) { return false; }
}
return true;
}

function validatesub(myform){

alert(myform.elements['numLocation_ID_Sub'].value);


}

// validateform(form) function
// by Andrew Thompson, Dec 2002
// validates all forms on the page, displays error message and highlights problem inputs
// fields should have an id attribute formatted id="FriendlyName,Required,DataType"
// for example <input type="text" name="txtBlahBlah" id="Text Box,1,txt">
// data types can be {txt,num,eml, dte}
// field names starting with 'num' will be checked that they're numeric
// ############################# MODIFIED FOR T&C CHECKBOX HANDLING TRICK ############################3
function validateform(myform) {
	var elementname;						// name attribute
	var elementvalue						// value attribute
	var valid = true;						// becomes false when any error is encountered
	var errData = "";						// names of bad Data fields
	var errReq = "";						// names of missing required fields
	var id, arrid;							// array with contents of form element's id attribute
	var req;								// temp variable for required field check
	var friendly;							// friendly field name string
	var datatype;							// data type, string, eg txt, num, eml, dte
	var strError = "";
	var iTmp1;
	var sTmp1;
	var sTmp2;
	var sTmp3;
	var arremail;
	var subvalid=true;
	
	for (j = 0; j < myform.elements.length; j++) {
		
		elementname = myform.elements[j].name;
		elementvalue = myform.elements[j].value;
		req = false;
		friendly = "";
		datatype = "";
		
		// check for an id attribute, and draw out friendly name, etc.
		if (myform.elements[j].id != "") {
			id = myform.elements[j].id;
			arrid = id.split(",")
			friendly = arrid[0];
			if (parseInt(arrid[1])) req = true;
			datatype = arrid[2];
		}

		// reset background colours in case fields were previously highlighted
		myform.elements[j].style.backgroundColor = "";

		// check for invalid data type if type was specified and field is not blank
		// as this will be handled later.
		// ################ MODIFIED FOR T&C CHECKBOX TRICK ######################
		if (((datatype != "") && !(elementvalue == "")) || (datatype =="chk")) { 
			if (datatype == "pwd") {
				if (myform.elements["cmdPasswordConfirm"].value != "" ) {
					if(myform.elements["cmdPasswordConfirm"].value != elementvalue){
						valid = false;
						errData += " - Your passwords do not match.\n";
						myform.elements[j].style.backgroundColor = "#CCCCFF"; 
						myform.elements["cmdPasswordConfirm"].style.backgroundColor = "#CCCCFF";
					}
				}
			}
			if (datatype == "num") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue)) {
					valid = false;
					errData += " -  " + friendly + " must be numeric.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
			}

			if (datatype == "num+") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue)) {
					valid = false;
					errData += " -  " + friendly + " must be numeric.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
				else if (parseFloat(elementvalue) <= 0) {
					valid = false;
					errData += " -  " + friendly + " must be a positive number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
								
			}
			if (datatype == "float") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue)) {
					valid = false;
					errData += " -  " + friendly + " must be numeric.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
				else if (parseFloat(elementvalue) < 0) {
					valid = false;
					errData += " -  " + friendly + " must be a positive number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
			}
			if (datatype == "int") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue) || (parseInt(elementvalue) != parseFloat(elementvalue))) {
					valid = false;
					errData += " -  " + friendly + " must be a whole number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
			}
			if (datatype == "int+") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue) || (parseInt(elementvalue) != parseFloat(elementvalue))) {
					valid = false;
					errData += " -  " + friendly + " must be a positive whole number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
				else if (parseFloat(elementvalue) <= 0) {
					valid = false;
					errData += " -  " + friendly + " must be a positive whole number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
			}
			if (datatype == "dte") {
				if (isNaN(Date.parse(elementvalue))) {
					valid = false;
					errData += " -  " + friendly + " must be a valid date.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
			}
			if (datatype == "phone") {
				elementvalue = elementvalue.replace("(", "");
				elementvalue = elementvalue.replace(")", "");
				elementvalue = elementvalue.replace(/[\s]+/g, "");
				if (isNaN(elementvalue) || ((elementvalue.length < 7) && (elementvalue.charAt(0) != "1") && (elementvalue.charAt(1) != "3")) || ((elementvalue.charAt(0) == "1") && (elementvalue.charAt(1) == "3") && (elementvalue.length != 6) && (elementvalue.length !=10))) {
					valid = false;
					errData += " -  " + friendly + " (" + elementvalue + ") has an invalid format.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF";  
				}
				
				else if (parseFloat(elementvalue) <= 0) {
					valid = false;
					errData += " -  " + friendly + " must be a positive number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor ="#CCCCFF"; 
				}
			}
			if (datatype == "eml") {
				// put into an array to enable test for multiple email addresses
				arremail = elementvalue.split(",")
				for (var loop=0; loop < arremail.length; loop++) { 
					// new and improved RegExp
					myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					if (arremail[loop].search(myRegExp) == -1  && arremail[loop] !='') {
						valid = false;
						errData += " -  " + friendly + " has an invalid e-mail address:'" + arremail[loop] + "'\n";
						if (loop > 0) {
							errData += "    (separate multiple addresses with ',')\n";
						}
						// highlight this problem field
						myform.elements[j].style.backgroundColor = "#CCCCFF"; 
					}
				} 
			}
			if (datatype == "url") {
				// new and improved RegExp
				myRegExp = /^((http:\/\/)?([a-zA-Z0-9_\.\@\-])+\.)+([a-zA-Z0-9_\.\@\-\/])+$/;
				if (elementvalue.search(myRegExp) == -1  && elementvalue !='') {
					valid = false;
					errData += " -  " + friendly + " has an invalid URL format\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
			}
			if (datatype == "tme") {
  				iTmp1 = elementvalue.indexOf(":") 
  				if (iTmp1 == -1) { 
					valid = false;
					errData += " -  " + friendly + " must be a valid time.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}
  				else { 
					sTmp1 = elementvalue.substr(0 , iTmp1) 
					sTmp2 = elementvalue.substr(iTmp1 + 1, 2) 
					sTmp3 = elementvalue.substr(iTmp1 + 4, 2) 
					sTmp4 = elementvalue.substr(iTmp1 + 7)
  				  	if (!((!isNaN(sTmp1)) && (!isNaN(sTmp2)) && (!isNaN(sTmp3)) && (sTmp1>=0) && (sTmp1<24) && (sTmp2>=0) && (sTmp2<60) && (sTmp3>=0) && (sTmp3<60))) {
						valid = false;
						errData += " -  " + friendly + " must be a valid time.\n";
						// highlight this problem field
						myform.elements[j].style.backgroundColor = "#CCCCFF"; 
					}
				} 
			}
			//######################################################
			// TERMS & CONDITIONS checkbox trick
			//datatype for ensuring that a checkbox has been ticked 
			if (datatype == "chk")
			{
				j += 1;
				if (!(myform.elements[j].checked))
				{
					valid = false;
					errData += " -  " + friendly + " must be checked.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = "#CCCCFF"; 
				}

			}
			//######################################################
			if (datatype == "checkboxes")
			{
				if (NoneWithCheck(myform[elementvalue]))
				{
					valid = false;					
					errReq += " - At least one of the "+friendly+" has to be selected.\n";
					for(var k = 0; k < myform[elementvalue].length; k++) {
						myform[elementvalue][k].style.backgroundColor = "#CCCCFF"; 
					}
				}
				j +=  myform[elementvalue].length;
			}

		}
		// check for required field being blank
		if (req && (elementvalue == "")) {
			// if no sublocation is present (for example 'Brisbane'), then let it be valid	
			if(elementname == "numLocation_ID_Sub" && myform[j].length < 2)
			{
				//do nothing, let it pass through
			}
			else
			{
				valid = false;
				
				errReq += " -  " + friendly + " is required.\n" ;
				// highlight this problem field
				myform.elements[j].style.backgroundColor = "#CCCCFF"; 
			}
		}

	}
	
	if (myform.name == "frmSearch" && isKeyword == true && keywordValue != "")
		valid = true;

	if (!valid) {	// if an error occurred, generate the error report display
	
		strError = "The data in these fields is invalid:\n\n"
		if (errReq != "") strError += errReq;
		if (errData != "") strError += errData;
		strError += "\nThe fields requiring attention have been highlighted.\n";
		
		alert(strError);
	}
	
	return valid;
}

function CheckEnabled(myform,toCheck,toEnable)
{
	if (!(myform[toCheck].checked)) {
			myform[toEnable].disabled = true;
			myform[toEnable].style.backgroundColor="#EEEEEE";	

	}
	else {
			myform[toEnable].disabled = false;	
			myform[toEnable].style.backgroundColor="#FFFFFF";
	}
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
else
	countfield.value = maxlimit - field.value.length + " characters left";
}

function textCounterSMS() {
var maxlimit = 160;
if (document.frmEOIEmail.txtMessage.value.length + document.frmEOIEmail.txtName.value.length + document.frmEOIEmail.txtEmail.value.length + document.frmEOIEmail.txtPhone.value.length + 20 > maxlimit) // if too long...trim it!
	document.frmEOIEmail.txtMessage.value = document.frmEOIEmail.txtMessage.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
else
	document.frmEOIEmail.cmdLenSMS.value = maxlimit - (document.frmEOIEmail.txtMessage.value.length + document.frmEOIEmail.txtName.value.length + document.frmEOIEmail.txtEmail.value.length + document.frmEOIEmail.txtPhone.value.length + 20) + " characters left";
}

function validateSelections(myform,toCheck)
{
	//If the first item, All, is selected make sure all others are not
	if (myform[toCheck].options[0].selected) 
	{
		for (i = 1; i<= myform[toCheck].length; i++ )
		{
			if (myform[toCheck].options[i].selected)
			{
				 myform[toCheck].options[i].selected = false;
			}
		}
	}
}

function OpenEditor(form, fieldname, css, access, imagepath,siteURL) {
	//openBrWindow('/includes/wysiwyg/fullscreen.asp?access='+access+'&css='+css+'&field=document.'+ form.name + '.'+fieldname+'&filepath='+imagepath, 'ha_fullscreen', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=640,height=480');
	
	openBrWindow('/admin/includes/rte/edit.aspx?stylesheet='+css+'&fldname=document.'+ form.name + '.'+fieldname, 'rte_fullscreen', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=710,height=520');
	return false;

	//openBrWindow('/includes/rte/rte_popup.asp?access='+access+'&css='+css+'&field=document.'+ form.name + '.'+fieldname+'&filepath='+imagepath, 'ha_fullscreen', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=545,height=420');
	return false;
}

function openBrWindow(theURL,winName,features) { //v2.0
	winName = window.open(theURL,winName,features);
	winName.focus()
}

function displayProgressBar(elementid, strMessage) {
	document.getElementById(elementid).style.display ='inline';	 		
	document.getElementById(elementid).innerHTML = "<h2>"+strMessage+"</h2>";	
	bar2.showBar();
	return true;
}

function PreviewAd(myform) {
	if (validateform(myform)) {
		return displayProgressBar('progressbar','Kidspot is building your advertisement now.<br />This may take a moment. Thank you for your patience.');
	}
	else {
		return false;
	}
}

function checkChildLocations(myform,element,elementToCheck) {
	var ToCheck, arridToCheck, idToCheck
	if (!(document.getElementById(element).checked)) {
		for(var i = 0; i < myform[elementToCheck].length; i++) {
			ToCheck = myform[elementToCheck][i].id
			arridToCheck = ToCheck.split(",")
			idToCheck = arridToCheck[0];
			if (idToCheck == document.getElementById(element).value) {
				myform[elementToCheck][i].checked = false;
			}
		}
	}
	else {
		for(var i = 0; i < myform[elementToCheck].length; i++) {
			ToCheck = myform[elementToCheck][i].id
			arridToCheck = ToCheck.split(",")
			idToCheck = arridToCheck[0];
			if (idToCheck == document.getElementById(element).value) {
				myform[elementToCheck][i].checked = true;
			}
		}
	}

}

//dependent dropdown functions
function setDynaList(arrDL){
 var oList1 = document.forms[arrDL[2]].elements[arrDL[1]]
 var oList2 = document.forms[arrDL[4]].elements[arrDL[3]]
 var arrList = arrDL[5]
 
 clearDynaList(oList2);
 
 if (oList1.selectedIndex == -1){
  oList1.selectedIndex = 0;
 }

 populateDynaList(oList2, oList1[oList1.selectedIndex].value, arrList,arrDL);
 return true;
}
 
function clearDynaList(oList){

 for (var i = oList.options.length; i >= 0; i--){
  oList.options[i] = null;
 }
 
 oList.selectedIndex = -1;
}
 
function populateDynaList(oList, nIndex, aArray,arrDL){
 var myarrID = new Array()

 MySelectedIndex = 0 
 if ((arrDL[7] == "location")) {
	oList.options[oList.options.length] = new Option("--All--","");
 }
 else {
	oList.options[oList.options.length] = new Option("--Select a sub-category--","");
 }
 for (var i = 0; i < aArray.length; i= i + 3){
  if (aArray[i] == nIndex){
   oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
   if (arrDL[6] == aArray[i+2]) {
		MySelectedIndex = oList.options.length-1;
		
   }
  }

 }

 if (oList.options.length == 0){
	 if ((arrDL[7] == "location") && (nIndex != '')) {
		oList.options[oList.options.length] = new Option("--All--","");
	 }
	 
 }

 if ((oList.options.length == 1) &&(arrDL[7] != "location")){
	 oList.options[0] = new Option("--Select a sub-category--",0);
 }

 oList.selectedIndex = MySelectedIndex;

  //for location, let multiple choice selection saved
  //050511 - PR
  if ((arrDL[7] == "location")&& (arrDL[6] != "")) {	 
		if (arrDL[6].indexOf(", ") != -1) {
			myarrID = arrDL[6].split(", ");
		}
		else {
			myarrID[0] = arrDL[6];
		}
		for(i = 0;i < oList.options.length;i++){
			for (var j=0;j < myarrID.length;j++) {
				if (myarrID[j] == oList.options[i].value) {
					oList.options[i].selected = true;
					break;
				}
				else {
					oList.options[i].selected = false;
				}
			}
		}
  }

}


function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

// selectdate takes a reference to the form in which an element sits, and the name of the target field
// NB: this function always returns false, so for image inputs, you can put onclick="return selectdate(...);"
function selectdate(form, fieldname) {
	querystring = "?field=document." + form.name + "." + fieldname;
	myfield = eval(form.name + "." + fieldname);
	// sometimes we have two fields with the same name to separately edit the date and time
	// in this case we select the first one to work with
	if (myfield.length) myfield = myfield[0]
	if (myfield.value != "") {
		var myDate = new Date(myfield.value)
		querystring += "&d=" + myDate.getDate() + "&m=" + (myDate.getMonth() + 1) + "&y=" + myDate.getFullYear()
	}
	window_popup = window.open('/includes/calendar.asp' + querystring, 'selectdate', 'width=210,height=203');
	window_popup.focus();
	return false;
}


function swapmenu(){ //v1.4 by PVII
 var i,x,tB,j=0,tA=new Array(),arg=swapmenu.arguments;
 if(document.getElementsByTagName){for(i=4;i<arg.length;i++){tB=document.getElementsByTagName(arg[i]);
  for(x=0;x<tB.length;x++){tA[j]=tB[x];j++;}}for(i=0;i<tA.length;i++){
  if(tA[i].className){if(tA[i].id==arg[1]){if(arg[0]==1){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}else{tA[i].className=arg[2];}
  }else if(arg[0]==1 && arg[1]=='none'){if(tA[i].className==arg[2] || tA[i].className==arg[3]){
  tA[i].className=(tA[i].className==arg[3])?arg[2]:arg[3];}
  }else if(tA[i].className==arg[2]){tA[i].className=arg[3];}}}}
}

function P7_writeStyles(op,a){ //v1.5 by PVII
if(op==0||document.getElementById){var tS="<sty"+"le type=\"text/css\">";
tS+=a+"<"+"/sty"+"le>";document.write(tS);document.close();}
}
P7_writeStyles(1,'.closed ul{ display:none;}.open ul{ display:block;}');


function setMultiDateBox(objForm,objTarget) {
	objTarget.value = eval('objForm.cmdDay' + objTarget.name).value;
	objTarget.value += ' ' + eval('objForm.cmdMonth' + objTarget.name).value;
	objTarget.value += ' ' + eval('objForm.cmdYear' + objTarget.name).value;
}

function ShowHelp(div, title, desc)
{
	div = document.getElementById(div);
	div.style.display = 'inline';
	div.style.position = 'absolute';
	div.style.width = '170';
	div.style.color = '#000000';
	div.style.backgroundColor = '#FAFAFA';
	div.style.border = 'solid 1px #CCCCCC';
	div.innerHTML = '<div style="padding:2px 10px 2px 10px;font-size: 10px;">' + desc + '</div>';
}

function HideHelp(div)
{
	div = document.getElementById(div);
	div.style.display = 'none';
}

function HideDropDowns() {
  for (i = 0; i < document.forms.length; i++) {
	for (j = 0; j < document.forms[i].elements.length; j++) {
	  if (document.forms[i].elements[j].type == "select-one") {
		document.forms[i].elements[j].style.visibility = "hidden";
	  }
	}
  }
  if (document.getElementById("contentframe")) {
	top.contentframe.HideDropDowns();
  }
}

function ShowDropDowns() {
  for (i = 0; i < document.forms.length; i++) {
	for (j = 0; j < document.forms[i].elements.length; j++) {
	  if (document.forms[i].elements[j].type == "select-one") {
		document.forms[i].elements[j].style.visibility = "";
	  }
	}
  }
  if (document.getElementById("contentframe")) {
	top.contentframe.ShowDropDowns();
  }
  
}

function printRecipe()
{        
    var href,windowname;
    windowname="new";
    href = window.location.href;
    if(href.charAt(href.length-1) == "#")
        href= href.substr(0,href.length-1);
    href = href + "&print=1";
    window.open(href, windowname, 'width=520,height=580,scrollbars=no,title=no');
}

function SearchFood()
{
   if(document.frmFood.numFoodCategoryID.value == "" && document.frmFood.numSpecialNeed.value == "" &&  document.frmFood.txtIngredients.value == "")
   {
        alert("Please select any one of the following");
        document.frmFood.numFoodCategoryID.style.backgroundColor = "#CCCCFF"; 
        document.frmFood.numSpecialNeed.style.backgroundColor = "#CCCCFF";
        document.frmFood.txtIngredients.style.backgroundImage = "none";
        document.frmFood.txtIngredients.style.backgroundColor = "#CCCCFF";
   }
   else
   {
        document.frmFood.submit();
   }
}

function bookmarksite(title,url)
{
    if (url == "")
        url= window.location.href;
    if(document.all)// ie
    {
	    external.AddFavorite(url, title);
	}
    else if(window.opera && window.print)
    { // opera
	    var elem = document.createElement('a');
    	elem.setAttribute('href',url);
	    elem.setAttribute('title',title);
    	elem.setAttribute('rel','sidebar');
	    elem.click();
    } 
    else if (window.sidebar)
    { // firefox
	    window.sidebar.addPanel(title, url, "");
	}
}

function chkOvulationCalci(myform)
{	
	if (myform.numCycleLength.value >=20 && myform.numCycleLength.value <= 45)
		return true;
	else
	{
		myform.numCycleLength.style.backgroundColor = "#CCCCFF";
		alert("The data in these fields is invalid:\n\n - Cycle length Must be in between 20 to 45 days.\n\n The fields requiring attention have been highlighted.");
		return false;
	}
}
//-->