var cssmenuids=["cssmenu1"] //Enter id(s) of CSS Horizontal UL menus, separated by commas
var csssubmenuoffset=-1 //Offset of submenus from main menu. Default is 0 pixels.

function createcssmenu2(){
for (var i=0; i<cssmenuids.length; i++){
  var ultags=document.getElementById(cssmenuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+csssubmenuoffset+"px"
    	var spanref=document.createElement("span")
			spanref.className="arrowdiv"
			spanref.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;"
			ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
    	ultags[t].parentNode.onmouseover=function(){
					this.style.zIndex=100
    	this.getElementsByTagName("ul")[0].style.visibility="visible"
					this.getElementsByTagName("ul")[0].style.zIndex=0
    	}
    	ultags[t].parentNode.onmouseout=function(){
					this.style.zIndex=0
					this.getElementsByTagName("ul")[0].style.visibility="hidden"
					this.getElementsByTagName("ul")[0].style.zIndex=100
    	}
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", createcssmenu2, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu2)



//validating forms.
function checkFields(){	
	var frommail = document.frmrefer.fromEmail.value;
	var fromname = document.frmrefer.fromName.value;
	
	if(fromname==''){
		alert("Your name is missing.");
		do_blink(document.frmrefer.fromName);
		return false;
	}
	
	if(frommail==''){
		alert("Your email address is missing.");
		do_blink(document.frmrefer.fromEmail);
		return false;
	}	
	
	return true;
}
var field_main;

function do_blink(field)
{
	var errorcolor="#ff0000";
	field.focus();
	field.select();
	field.style.background=errorcolor;
    field_main=field;
	setInterval("temp()",1000);    
}

function temp(field)
{
	var okcolor="#ffffff";
	field_main.style.background=okcolor;
}

function validate(field)
{
	
	try
	{
	valiclass=field.getAttribute("valiclass");
	valimessage=field.getAttribute("valimessage");
	if(valiclass=="required")
	{
		req=field.getAttribute("req");
		pattern="\\w{"+req+",}";
		if(!field.value.match(pattern))
		{
			alert(valimessage);do_blink(field);return false;
		}
	}
	
	else if(valiclass=="email")
	{
		if(!isValidEmail(field.value))
		{
			 alert("Please enter a valid email address");
			 do_blink(field);return false;
        	 return false;
		}
		
		/*var dotcount = 0;
		var atcount = 0;
		
		for(var i=0;i<field.value.length;i++){
			if(field.value.charAt(i) == '.'){
				dotcount +=1;
			}else if(field.value.charAt(i) == '@'){
				atcount +=1;
				//alert(atcount);
			}
		}
		if(field.value == ''){
			alert('your email is blank.');
			do_blink(field);return false;
		}
		else if(dotcount==0 || atcount !=1){			
			alert(valimessage);do_blink(field);return false;
		}		*/
	
	}
	
	else if(valiclass=="number")
	{
		if((field.value.length>1)||isNaN(field.value))
		{
			alert(valimessage);do_blink(field);return false;
		}
		
	}

	
	else if(valiclass=="select")
	{
		if(field.options[field.selectedIndex].value=="")
		{
			alert(valimessage);
			field.focus();
			return false;
		}		
	}
	
	else if(valiclass=="date")
	{
		pattern="[0-9]{4}\\/[0-9]{1,2}\\/[0-9]{1,2}$";
		if(!field.value.match(pattern))
		{
			alert(valimessage);do_blink(field);return false;
		}
	}
	
	return true;
	}
	
	catch(ex)
	{
	alert(ex.message);
	return true;
	}
}

function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

function call_validate(form,from,to)
{
	for(counter=from;counter<to;counter++)
	{
		bool=validate(form[counter]);
		if(!bool)
		{
			return false;
			break;
		}
	}
	form.submit();
}

function sign_up(form)
{
	call_validate(form,0,form.length);
}



// array of possible cities in the same order as they appear in the hotel selection list 
 var hotelLists = new Array(4) 
 hotelLists["empty"] = ["Select a City"]; 
 hotelLists["Kathmandu"] = ["Hotel Ambassador", "Marcopolo Business Hotel"]; 
 hotelLists["Nagarkot"] = ["Club Himalaya Nagarkot", "The Tea House Inn"]; 
 hotelLists["Chitwan"] = ["Shanti Ban Resort"]; 
 hotelLists["Pokhara"]= ["Trek-O-Tel Hotel"]; 
 /* hotelChange() is called from the onchange event of a select element. 
 * param selectObj - the select object which fired the on change event. 
 */ 
 function hotelChange(selectObj) 
 { 
	 // get the index of the selected option 
	var idx = selectObj.selectedIndex; 
	 // get the value of the selected option 
	var which = selectObj.options[idx].value; 
	 // use the selected option value to retrieve the list of items from the hotelLists array 
	cList = hotelLists[which]; 
	 // get the hotel select element via its known id 
	var cSelect = document.getElementById("hotel"); 
	 // remove the current options from the hotel select 
	var len=cSelect.options.length; 
 	while (cSelect.options.length > 0) 
	{ 
 		cSelect.remove(0); 
 	} 
	 var newOption; 
	 // create new options 
	 for (var i=0; i<cList.length; i++) 
	 { 
		 newOption = document.createElement("option"); 
		 newOption.value = cList[i];  // assumes option string and value are the same 
		 newOption.text=cList[i]; 
		 // add the new option 
		 try 
		 { 
			cSelect.add(newOption);  // this will fail in DOM browsers but is needed for IE 
		 } 
		 catch (e) 
		 { 
			cSelect.appendChild(newOption); 
		 } 
 	  } 
	  
	  document.reservation.Rhotel.style.display='none';
 }
 
 function combochange()
{
	document.reservation.reservation_city.style.display='none';
	document.reservation.hotel.style.display='none'
}


var roomLists = new Array(4) 
 roomLists["empty"] = ["Select a Hotel"]; 
 roomLists["Hotel Ambassador"] = ["Economy(Non A/C)", "Standard(A/C)"]; 
 roomLists["Marcopolo Business Hotel"] = ["Economy(Non A/C)", "Standard(A/C)"]; 
 roomLists["Club Himalaya Nagarkot"] = ["Deluxe"]; 
 roomLists["The Tea House Inn"]= ["Budget"]; 
 roomLists["Trek-O-Tel Hotel"]= ["Standard(A/C)"]; 
 roomLists["Shanti Ban Resort"]= ["Standard(A/C)"]; 

 function roomChange(selectObj) 
 { 
	 // get the index of the selected option 
	var idx = selectObj.selectedIndex; 
	 // get the value of the selected option 
	var which = selectObj.options[idx].value; 
	 // use the selected option value to retrieve the list of items from the hotelLists array 
	cList = roomLists[which]; 
	 // get the hotel select element via its known id 
	var cSelect = document.getElementById("room_type"); 
	 // remove the current options from the hotel select 
	var len=cSelect.options.length; 
 	while (cSelect.options.length > 0) 
	{ 
 		cSelect.remove(0); 
 	} 
	 var newOption; 
	 // create new options 
	 for (var i=0; i<cList.length; i++) 
	 { 
		 newOption = document.createElement("option"); 
		 newOption.value = cList[i];  // assumes option string and value are the same 
		 newOption.text=cList[i]; 
		 // add the new option 
		 try 
		 { 
			cSelect.add(newOption);  // this will fail in DOM browsers but is needed for IE 
		 } 
		 catch (e) 
		 { 
			cSelect.appendChild(newOption); 
		 } 
 	  } 
} 

<!-- text box enable
function enable() {
	if(document.feedback.OthersCheckBox.checked)
	{
	document.feedback.other_looks.disabled=false;
	}
	
	else
	{
	document.feedback.other_looks.disabled=true;
	}
}

function txtenable() {

	if(document.feedback.txtKnowOthers.checked)
	{
	document.feedback.from_others.disabled=false;
	}
	
	else
	{
	document.feedback.from_others.disabled=true;
	}
}
//-->

function SwitchList(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("menudiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function MM_jumpMenu(targ,selObj,restore)
{ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->

function deleteconfirm()
{
	if(confirm("Are you sure you want to delete"))
	{
		return true;
	}else{
		return false;	
	}
}