/*** CHECK DATE FUNCTIONS ***/
// Declaring valid date character, minimum year and maximum year
d = new Date();
cYear = d.getUTCFullYear();
var minYear=cYear-100;
var maxYear=cYear+1;

function daysInFebruary (strYear){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    strYear = parseFloat(strYear);
    return (((strYear % 4 == 0) && ( (!(strYear % 100 == 0)) || (strYear % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this
}

function validate_year (strYear)
{
	if (strYear.length != 4 || parseFloat(strYear)==0 || parseFloat(strYear)<parseFloat(minYear) || parseFloat(strYear)>parseFloat(maxYear))
		return false;
 	else
		return true;
}

function validate_month(strMonth)
{
	if (strMonth.length<1 || parseFloat(strMonth)<1 || parseFloat(strMonth)>12)
		return false;
	else
		return true;
}

function validate_day(strDay, strMonth, strYear)
{
	var daysInMonth = DaysArray(12)
	if (strDay.length<1 || parseFloat(strDay)<1 || parseFloat(strDay)>31 || (parseFloat(strMonth)==2 && parseFloat(strDay)>daysInFebruary(strYear)) || parseFloat(strDay) > daysInMonth[strMonth])
		return false;
	else
		return true;
}

function isDate(dtStr){
	var pos1=dtStr.indexOf("/")
	var pos2=dtStr.indexOf("/",pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYear.charAt(0)=="0" && strYear.length>1) strYear=strYear.substring(1)
	}
	if (
		(pos1==-1 || pos2==-1) ||
		!validate_year(strYear) ||
		!validate_month(strMonth) ||
		!validate_day(strDay, strMonth, strYear))
		return false;
	else
		return true;
}

function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
		window.onload = func;
	else
	{
		window.onload = function()
		{
			if (oldonload) oldonload();
			func();
		}
	}
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain )
{
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// this function gets the cookie, if it exists
function Get_Cookie( name )
{
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
function checkPhone(str)
{
	rePhoneNumber = new RegExp(/^[0-9]{0,3}\s?\-?\s?[0-9]{7,10}$/);
	if (!rePhoneNumber.test(str))
		return false;

	return true;

}
function checkEmail(str) {
///// function for validating email address
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1){
		    return false
		} else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		    return false
		} else 	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		} else  if (str.indexOf(at,(lat+1))!=-1){
		    return false
		} else 	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   return false
		} else  if (str.indexOf(dot,(lat+2))==-1){
		    return false
		} else if (str.indexOf(" ")!=-1){
		     return false
		} else {
 		 	return true
 		}
}

function getFlashMovieObject(movieName)
{
	if (document.embeds && document.embeds[movieName])
		return document.embeds[movieName];
	if (window.document[movieName])
		return window.document[movieName];
	if (navigator.appName.indexOf("Microsoft Internet")==1)
		return document.getElementById(movieName);
}



function getHTTPObject()
{
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	try { return new XMLHttpRequest(); } catch(e) {}
	alert("XMLHttpRequest not supported");
	return null;
 }

function LoadHTML(url)
{

	var xmlHttp = getHTTPObject();
	xmlHttp.open("GET",url, false);
	xmlHttp.onreadystatechange = function()
	{
		   if (xmlHttp.readyState != 4)  { return; }
		   var serverResponse = xmlHttp.responseText;

	}
	xmlHttp.send(null);
	return xmlHttp.responseText;
}
function LoadXML(url)
{
	var xmlHttp = getHTTPObject();
	xmlHttp.open("GET",url, false);
	xmlHttp.onreadystatechange = function()
	{
		   if (xmlHttp.readyState != 4)  { return; }
		   var serverResponse = xmlHttp.responseText;
	};
	xmlHttp.send(null);
	return xmlHttp.responseXML.documentElement;
}

function PostXML(url,params)
{
	xmlHttp = false;
	// branch for native XMLHttpRequest object
	if(window.XMLHttpRequest && !(window.ActiveXObject))
	{
		try {
			xmlHttp = new XMLHttpRequest();
		} catch(e) {
			xmlHttp = false;
		}
		// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject)
	{
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				xmlHttp = false;
			}
		}
	}

	if (xmlHttp)
	{
		xmlHttp.open( "POST", url, false );
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
		return xmlHttp.responseXML.documentElement;
	}
}

function IsNumeric(sText)
{
   var 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 trim(strText) {
/// TRIM STRING FUNCTION
    // this will get rid of leading spaces
    while (strText.substring(0,1) == ' ')
        strText = strText.substring(1, strText.length);
    // this will get rid of trailing spaces
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
   return strText;
}

function escapeString(sString)
{
// DETECT WHAT TO PUT STRING IN FOR HTML FORM ( ' OR " ) DEPANDING ON STRING CONTENTS
	if (sString.indexOf("'") == -1)
		valSep = "'";
	else
		valSep = '"';
	return valSep+sString+valSep;
}

function replaceSubstring(inputString, fromString, toString) {
 // GOES THROUGH THE INPUTSTRING AND REPLACES EVERY OCCURRENCE OF FROMSTRING WITH TOSTRING
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
}

function popupWin(popUrl, width, height)
{
	if (!navigator.appName.indexOf("Microsoft")) width+=20;
	height+=5;
	topVar=((screen.height / 2)-(height/2));
	leftVar=((screen.width / 2)-(width/2));
	window.open(popUrl, "PopUp", "height="+height+", width="+width+", top="+topVar+", left="+leftVar+", scrollbars=yes, status=no, location=no, resize=yes, menubar=no, titlebar=no, toolbar=no");
}

function focusField(f, def)
{
	if (f.value == def) f.value = "";
}

function blurField(f, def)
{
	f.value = trim(f.value);
	if (f.value == "") f.value = def;
}

function getFileExtension(filename)
{
	if( filename.length == 0 ) return "";
	var dot = filename.lastIndexOf(".");
	if( dot == -1 ) return "";
	var extension = filename.substr(dot,filename.length);
	return extension
}

function fix_external_links() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");

	var basicPattern = new RegExp('^(http:\/\/|https:\/\/)');
	var pattern = new RegExp('^(http:\/\/|https:\/\/)'+location.hostname);

	for (var i = 0; i < anchors.length; i++)
	{
		var anchor = anchors[i];
		if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
		}
		else if (getFileExtension(anchor.href) == ".pdf") {
			anchor.target = "_blank";
		}
		else if (!anchor.href.match(basicPattern))  // this is for links such as "javascript" or "#" which do not include http or https at all !!
			continue;
		else if (!anchor.href.match(pattern) && !anchor.getAttribute("rel") || (anchor.getAttribute("rel") && anchor.getAttribute("rel") != "ibox")) {
			anchor.target = "_blank";
		}
	}
}

function submit_joinML(email_field){
	if (email_field.value==""){
	 	alert (_joinML_empty);
	 	email_field.focus();
	} else if (!checkEmail(email_field.value)){
	 	alert (_joinML_invalid);
	 	email_field.focus();
	} else {
		var url = "xml_joinML.php?joinML_email="+email_field.value;
		var xml = LoadXML(url);
		if(xml != null)
		{
			var response = xml.getElementsByTagName('rsp_stat')[0].firstChild.data;
			if (response=="ok")
			{
				email_field.value="";
				alert (_joinML_confirm);
			}
		}
	}
	return false;
}


// 14.03.07
function showGBform(f,l)
{
	feedback_f = document.getElementById(f);
	if (feedback_f.style.display == "block")
	{
		feedback_f.style.display = "none";
		l.innerHTML = _sendGB;
	}
	else
	{
		feedback_f.style.display = "block";
		l.innerHTML = _closeGB;
	}
}


function saveGB(f) {

	// disable submit button and change its class
	submitButton = document.getElementById("submitForm");
	submitButton.disabled = true;

	ReqFields = new Array("fullName","subject","comment");
	for (i=0;i<ReqFields.length; i++)
	{
		fieldName = ReqFields[i];
		if (trim(f[fieldName].value) == "")
		{
			cMessage = eval("_"+fieldName);
			alert(cMessage);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}
	}

	if (confirm(_contact_confirm))
	{
		advAJAX.submit(f, {
		    onSuccess : function(obj) {
		    		if (obj.responseText == "success")
		    		{
		    			alert (_guestbook_success);
		    			f.reset();
		    			submitButton.disabled = false;
		    			l = document.getElementById("addGB");
		    			showGBform('contact', l);
		    		}
		    		else
		    		{
		    			alert (_contact_fail);
		    			submitButton.disabled = false;
		    		}
		    }
		});
		return false;
	}

	submitButton.disabled = false;
	return false;
}


function confirmGB(f, fAction)
{
	switch (fAction) {
		case "delete":
			f.action = _base + "/travel_ajax.php?action=guestbook_delete";
			break;
		case "accept":
			f.action = _base + "/travel_ajax.php?action=guestbook";
			break;
		default:
			return false;
	}

	cMessage = eval("_confirm_tb_"+fAction);
	if (confirm(cMessage))
	{
		advAJAX.submit(f, {
		    onSuccess : function(obj) {
		    		if (obj.responseText == "success")
		    		{
		    			cMessage = eval("_confirm_tb_success_"+fAction);
		    			alert (cMessage);
		    			f.reset();
		    		}
		    		else
		    		{
		    			alert (_contact_fail);
		    		}
		    }
		});
		return false;
	}

	return false;
}

// NEWS SCROLLER FUNCTIONS //

function startScroller(){
	if (sc_totalPosition>maxScroll){
		document.getElementById(sc_id).scrollTop=-1;
		sc_totalPosition=0;
	}
	scroll_pause=setTimeout("sc_main()", sc_delay);
}

function sc_main(){
		scroll_Int=setInterval ("scrollNews()",sc_speed);
}

function scrollNews(){
	if (sc_curPosition > sc_height){
		sc_curPosition=0;
		clearInterval(scroll_Int);
		startScroller();
	} else {
		sc_totalPosition+=sc_sAmount;
		sc_curPosition+=sc_sAmount;
		document.getElementById(sc_id).scrollTop=sc_totalPosition;
	}
}

function scControl(cntrlMethod){
	clearTimeout(scroll_pause);
	if (!cntrlMethod){
		clearInterval(scroll_Int);
	} else {
		sc_main();
	}

}

function scLink(curLink){
	location.href=curLink;
}

/******** End News **********/

function submit_search(f) {
	v = f.sStr.value;
	if (v == "" || v == quickSearch_default) {
		alert (_alert_quickSearch);
		f.sStr.focus();
		return false;
	}
}

/************ NEWS ROTATOR ************/

function tyco_nr_switch(nr_id)
{
	for (var a = 0; a < nr_total; a ++) {
		cb = document.getElementById("nr_b_"+a);
		cb.className  = (a != nr_id) ? "" : "nr_scriptthis";
	}

	c = document.getElementById("nr_contents");
	d = nr_data[nr_id];
	if (d != null) c.innerHTML = d;

	nrc++;
	if (nrc >= nr_total) nrc = 0;
	clearTimeout (nr_int);
	if (autoSwitch) nr_int = setTimeout ( "tyco_nr_switch(nrc)", nr_delay );
}

function tyco_nr_init(nr_id)
{
	nrc = nr_id;
	clearTimeout (nr_int);
	origSwitch = autoSwitch;
	autoSwitch = false;
	tyco_nr_switch(nrc);
	mc = document.getElementById("nr_script");
	if (origSwitch) {
		mc.onmouseout = function () {
			autoSwitch = true;
			nr_int = setTimeout ( "tyco_nr_switch(nrc)", nr_delay );
			mc.onmouseout = null;
		}
	}
	return false;
}



//ie6 link fixer - Liran Oz
function tyco_nr_ie6_fix() {
	//find menu
	var elms = document.getElementById("nr_scriptmenu");
	if (!elms)
		return;

	//get li's
	var lis = elms.getElementsByTagName("li");
	for (var i=0; i<lis.length; i++) {
		lis[i].onclick = function() {
			//find link
			var hrefs = this.getElementsByTagName("a");
			if (hrefs.length == 0)
				return;

			//activate onclick
			hrefs[0].onclick();
		};
	}
}

/*********** END NEWS ROTATOR **************/


/*********** TYCO NEWS TICKER ******************/

  function tyco_nt_start()
  {
  	if (document.getElementById) {
		var tick = 	'<div style="position:relative;margin-top:0px;width:'+tWidth+';height:'+tHeight+';overflow:hidden;" onmouseover="cps=0" onmouseout="cps=tSpeed">'+
					'<div id="mq" style="position:absolute;right:0px;top:0px;white-space:nowrap;">'+
					'<\/div><\/div>';
		document.getElementById('tyco_nt').innerHTML = tick;
		mq = document.getElementById("mq");
		mq.style.right=(parseInt(tWidth)+10)+"px";
		mq.innerHTML=content;
		aw = document.getElementById("mq").offsetWidth;
		lefttime=setInterval("tyco_nt_scroll()",50);
  	}
  }

  function tyco_nt_scroll(){
  	mq.style.right = (parseInt(mq.style.right)>(-10 - aw)) ?parseInt(mq.style.right)-cps+"px" : parseInt(tWidth)+10+"px";
   }

/*************** END TYCO NEWS TICKER *************/

function addToTrip(id) {
	trip = Get_Cookie("trip_data");

	var count_trip = 0;
	var exists_trip = false;
	
	var new_trip = "";
	if (trip != null) {
		trips = trip.split(";");
		for (a in trips) {
			if (trips[a] == id ) {
				//alert (_add_trip_exists);
				//return;
				exists_trip = true;
			}
			if( trips[a] != "" && trips[a] != ";" ) {
				count_trip++;
				new_trip += trips[a]+";"			
			}
		}
	}
	else {
		new_trip = "";
	}

	var tool_tip_text = "";
	if( !exists_trip ) {
		new_trip += id+";";
		count_trip++;
		tool_tip_text = "הפריט התווסף בהצלחה למסלול שלכם.";
	}
	else {
		tool_tip_text = "הפריט כבר קיים במסלול שלכם";
	}
//	$(".add_trip").qtip({
//		content: { text: tool_tip_text },
//		updateContent: tool_tip_text
//	});
	
	Set_Cookie( "trip_data", new_trip);
	count_trips();
	
	alert(_add_trip_confirm);
}

function count_trips() {
	trip = Get_Cookie("trip_data");
	//console.log(trip);
	var count_trip = 0;
	if (trip != null) {
		trips = trip.split(";");
		for (a in trips) {
			if( trips[a] != "" && trips[a] != ";" ) {
				count_trip++;				
			}
		}
	}
	
	if( count_trip < 1 ) 
		$("#trip_count").html(_track_no_items);
	else
		$("#trip_count").html(count_trip+_track_items);
}

function removeFromTrip(id, dom_id) {
	trip = Get_Cookie("trip_data");
	trips = trip.split(";");
	trip = "";
	for (a in trips) {
		if ( trips[a] != id && trips[a] != ";" && trips[a] != "") {
			trip += trips[a]+";";
		}
	}

	Set_Cookie( "trip_data", trip);

	location.reload();
}


/*** CONTACT SUBMIT **/
function submitContact(f)
{
	// disable submit button and change its class
	submitButton = document.getElementById("submitForm");
	submitButton.disabled = true;

	ReqFields = new Array("contact_fName","contact_lName","contact_phone","contact_email");
	for (i=0;i<ReqFields.length; i++)
	{
		fieldName = ReqFields[i];
		if (trim(f[fieldName].value) == "")
		{
			cMessage = eval("_"+fieldName);
			alert(cMessage);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (fieldName == "contact_email" && !checkEmail(f[fieldName].value))
		{
			alert(_contact_emailInvalid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (fieldName == "contact_phone" && !checkPhone(f[fieldName].value))
		{
			alert(_contact_phoneInvalid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

	}

	if (confirm(_contact_confirm))
	{
		advAJAX.submit(f, {
		    onSuccess : function(obj) {
		    		if (obj.responseText == "success")
		    		{
		    			alert (_contact_success);
		    			f.reset();
		    			submitButton.disabled = false;
		    		}
		    		else
		    		{
		    			alert (_contact_fail);
		    			submitButton.disabled = false;
		    		}
		    }
		});
		return false;
	}

	submitButton.disabled = false;
	return false;
}


function checkReservation(f)
{
	// disable submit button and change its class
	submitButton = document.getElementById("submitForm");
	submitButton.disabled = true;

	ReqFields = new Array("contact_fName","contact_lName","contact_phone","contact_email", "hotel_id", "hotel_room", "hotel_room_quant", "date_arrive", "date_depart", "num_adult");

	for (i=0;i<ReqFields.length; i++)
	{
		fieldName = ReqFields[i];
		if (trim(f[fieldName].value) == "")
		{
			cMessage = eval("_"+fieldName);
			alert(cMessage);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (fieldName == "contact_email" && !checkEmail(f[fieldName].value))
		{
			alert(_contact_emailInvalid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (fieldName == "contact_phone" && !checkPhone(f[fieldName].value))
		{
			alert(_contact_phoneInvalid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		 if (fieldName == "hotel_room_quant" && parseFloat(f[fieldName].value) < 1)
		 {
		 	alert(_hotel_room_quant);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		 }

		 if (fieldName == "num_adult" && parseFloat(f[fieldName].value) < 1)
		 {
		 	alert(_num_adult);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		 }

	}

	 if (f.termsConfirm && !f.termsConfirm.checked)
	 {
	 	alert(_siteTerms);
		submitButton.disabled = false;
		return false;
	 }

	if (confirm(_contact_confirm))
	{
		advAJAX.submit(f, {
		    onSuccess : function(obj) {
		    		if (obj.responseText == "success")
		    		{
		    			alert (_order_success);
		    			f.reset();
		    			submitButton.disabled = false;
		    		}
		    		else
		    		{
		    			alert (_contact_fail);
		    			submitButton.disabled = false;
		    		}
		    }
		});
		return false;
	}

	submitButton.disabled = false;
	return false;
}

function change_rooms(f, id, room)
{
	rooms = f.hotel_room;
	rooms.options.length = 0;
	if (id != "" && id != "none")
	{
		var url = "xml_getRooms.php?hotel_id="+id;
		var xml = LoadXML(url);
		if(xml != null || xml.getElementsByTagName('rsp')[0].firstChild.data != "0")
		{
			num_rows = xml.getElementsByTagName('num_rows')[0].firstChild.data;
			if (num_rows < 1)
					rooms.options[0] = new Option (_noRooms,'');
			for (i=0; i<num_rows; i++)
			{
				cOption = new Option (xml.getElementsByTagName('desc_'+i)[0].firstChild.data, xml.getElementsByTagName('id_'+i)[0].firstChild.data, false, false);
				rooms.options[i] = cOption;
				if (room != null && room == xml.getElementsByTagName('id_'+i)[0].firstChild.data) {
					rooms.selectedIndex = i;
				}
			}
		}
	}
	else
		rooms.options[0] = new Option (_firstSelectHotel,'');
}

function checkMembers(f)
{
	// disable submit button and change its class
	submitButton = document.getElementById("submitForm");
	submitButton.disabled = true;

	ReqFields = new Array("contact_fName","contact_lName","contact_phone","contact_email");

	for (i=0;i<ReqFields.length; i++)
	{
		fieldName = ReqFields[i];
		if (trim(f[fieldName].value) == "")
		{
			cMessage = eval("_"+fieldName);
			alert(cMessage);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (fieldName == "contact_email" && !checkEmail(f[fieldName].value))
		{
			alert(_contact_emailInvalid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (fieldName == "contact_phone" && !checkPhone(f[fieldName].value))
		{
			alert(_contact_phoneInvalid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (f.birthday.value != "dd/mm/yyyy" && !isDate(f.birthday.value ))
		{
			alert(_tpl_birthdayNotValid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

	}

	 if (f.termsConfirm && !f.termsConfirm.checked)
	 {
	 	alert(_siteTerms);
		submitButton.disabled = false;
		return false;
	 }

	if (confirm(_contact_confirm))
	{
		advAJAX.submit(f, {
		    onSuccess : function(obj) {
		    		if (obj.responseText == "success")
		    		{
		    			alert (_join_members_success);
		    			f.reset();
		    			submitButton.disabled = false;
		    		}
		    		else
		    		{
		    			alert (_contact_fail);
		    			submitButton.disabled = false;
		    		}
		    }
		});
		return false;
	}

	submitButton.disabled = false;
	return false;
}

function submitFeedback(f)
{
	// disable submit button and change its class
	submitButton = document.getElementById("submitForm");
	submitButton.disabled = true;

	ReqFields = new Array("contact_fName","contact_lName","contact_phone","contact_email");
	for (i=0;i<ReqFields.length; i++)
	{
		fieldName = ReqFields[i];
		if (trim(f[fieldName].value) == "")
		{
			cMessage = eval("_"+fieldName);
			alert(cMessage);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (fieldName == "contact_email" && !checkEmail(f[fieldName].value))
		{
			alert(_contact_emailInvalid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

		if (fieldName == "contact_phone" && !checkPhone(f[fieldName].value))
		{
			alert(_contact_phoneInvalid);
			f[fieldName].focus();
			submitButton.disabled = false;
			return false;
		}

	}

	// CHECK FEEDBACK
	ReqFields = new Array("recerption_service","receoption_info","room_clean","rooms_props", "rooms_anticipation","site_clean","site_props");
	for (i=0;i<ReqFields.length; i++)
	{
		fieldName = f["fb_"+ReqFields[i]];
		rCheck = false;
		for (c = 0; c < fieldName.length; c++)
		{
			if (fieldName[c].checked) {
				rCheck = true;
			}
		}
		if (!rCheck) {
			alert(_feedback_check);
			submitButton.disabled = false;
			return false;
		}
	}

	if (confirm(_contact_confirm))
	{
		advAJAX.submit(f, {
		    onSuccess : function(obj) {
		    		if (obj.responseText == "success")
		    		{
		    			alert (_feedback_success);
		    			f.reset();
		    			submitButton.disabled = false;
		    		}
		    		else
		    		{
		    			alert (_contact_fail);
		    			submitButton.disabled = false;
		    		}
		    }
		});
		return false;
	}

	submitButton.disabled = false;
	return false;
}

function mapInit() {
	if (map_loc == "") return;
	g_waze_map.find(map_loc,'find_callback');
}

function find_callback(response){
	var map = g_waze_map.map;
	var first_result = response[0];
	if (map_lon == "" || map_lat == "") {
		var lonlat = new OpenLayers.LonLat(first_result.location.lon,first_result.location.lat);
		g_waze_map.map.setCenter(lonlat);
	} 
	var size = new OpenLayers.Size(40,40);
	var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
	var icon = new OpenLayers.Icon(_base+'/images/map_point.png',size,offset);
	var markers = new OpenLayers.Layer.Markers( "Markers" );
	map.addLayer(markers);
	markers.addMarker(new OpenLayers.Marker(lonlat,icon));
	map.addPopup(new OpenLayers.Popup.FramedCloud("test",lonlat,null,
				"<div style='font:normal 12px arial;text-align:center;color:#00b1ef;'>"+first_result.name+"<div>",
				anchor=null,true,null));
};

