var objBehaviours = {
	'.bodyBehaviours' : function(el)
	{	
		var pathName = window.location.pathname;	
		var pagePath = pathName.split("/");
		
	},
	'.clickable' : function(el)
	{
		el.onmouseover = function(){el.style.textDecoration = "underline";}
		el.onmouseout = function(){el.style.textDecoration = "";}
	},		
	
	'#listCountry' : function(el){	
			el.onchange = function()
			{	
				objGetPlaces.getCityRegion(el.value,'listPlaces');				
			}	
	},
	
	'#quickSearchGo' : function(el){	
			el.onsubmit = function()
			{
				
				var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
				var sParam = $('searchParam').value;
				var wSearch = $('whereSearch').value;
				
  				for (var i = 0; i < sParam.length; i++) {
  					if (iChars.indexOf(sParam.charAt(i)) != -1) {
  					alert ("Invalid keywords. \nSpecial characters are not allowed.\nPlease remove them and try again.");
  					return false;
  					}
			  	}
				
				if(sParam != "" && sParam != "keywords"){
					el.action = domainHome+"boutique-hotels/"+wSearch+"/"+sParam+"/";
				}
				else
				{
					alert("Please enter a keyword");	
				}
			}
	},
	
	'#hJump' : function(el){
		
				el.onclick = function()
				{ 
					//for preloader
					/*if($('checkIn').value != '')
					{
						$('preloader').style.display = 'block'
						
						if($('listPlaces').value.toUpperCase() != 'ALL')
						{
							var pl = $('listPlaces').value.replace("-"," ");						
						}
						else
						{
							var pl = $('listCountry').value.replace("-"," ");						
						}
						pl = pl.toUpperCase()
						$('pl').innerHTML = pl					
						
						a = $('checkIn').value.split('-')
						d = $('checkOut').value.split('-')
						
						$('from').innerHTML = a[2]+'-'+a[1]+'-'+a[0]
						$('to').innerHTML = d[2]+'-'+d[1]+'-'+d[0]
					}*/
					//end for preloader
					var ctry = $('listCountry'); 
					var plc = $('listPlaces');
					var chkIn = $('checkIn').value;
					var chkOut = $('checkOut').value;					
					
					if(ctry.value == "")
					{
						alert("Please select a country from the list");
						return false;
					}
					
					if(plc.options[plc.selectedIndex].text == "Select city")
					{
						alert("Please select a city from the list");
						return false;
					}
					
					if(!objSetCalendar.checkDate(chkOut,chkIn) && chkOut != "" && chkIn != "")
					{
						alert("Checkout date cannot be earlier than the checkin date");
						return false;
					}
																									
					var action = domainHome+"boutique-hotels/"+$("listCountry").value+"/";
					
					if($('listPlaces').value != "" && $('listPlaces').value != "All")
					{
						action += $('listPlaces').value.toLowerCase()+"/";
					}
													
					
					$('loctype').value = (plc.options[plc.selectedIndex].text.split(":")[0].toLowerCase());
					
					if($('loctype').value == "all"){$('loctype').value = "";}
					else if($('loctype').value != "region"){$('loctype').value = "city";}
					
					$('arrival').value = chkIn;
					$('departure').value = chkOut;
					
					$('numAdults').value = $('Adults').value;
					$('numChil').value = $('Children').value;
					
					$('addtlFeats').action = action;
					
					
					$('addtlFeats').submit();
				}
		
		
	},
	
	//integration nov 23
	'#eJump' : function(el){
		
				el.onclick = function()
				{
					
					var eK = $('tempKey').value;
					
					var ctry = $('listCountry');
					var plc = $('listPlaces');
					var type = $('listTypes');
					var chkIn = $('checkIn').value;
					var chkOut = $('checkOut').value;					
					
					if(ctry.value == "")
					{
						alert("Please select a country from the list");
						return false;
					}
					
					if(plc.options[plc.selectedIndex].text == "Select city")
					{
						alert("Please select a city from the list");
						return false;
					}
					
					if(type.options[type.selectedIndex].text == "Select type")
					{
						alert("Please select an event type from the list");
						return false;
					}
					
					if(!objSetCalendar.checkDate(chkOut,chkIn) && chkOut != "" && chkIn != "")
					{
						alert("Event start date cannot be earlier than the event end date");
						return false;
					}
																									
					var action = domainHome+"events/"+ctry.value+"/"															
					
					if(plc.value != "" && plc.value != "All")
					{
						action += plc.value+"/";
					}
					else
					{
						action += "all/";
					}
					
					
					if($('listTypes').value != "")
					{
						action += $('listTypes').value+"/";
					}
					else
					{
						action += "all/";	
					}										

					if(eK != " keywords")
					{						
						$('eventKey').value = eK;
					}
					
					$('loctype').value = (plc.options[plc.selectedIndex].text.split(":")[0].toLowerCase());
					if($('loctype').value == "all"){$('loctype').value = "";}
					else if($('loctype').value != "region"){$('loctype').value = "city";}
					
					$('eventBegin').value = chkIn;
					$('eventEnd').value = chkOut;										
					
					$('addtlFeats').action = action;
					$('addtlFeats').submit();
				}
		
		
	},
	
	'.searchParam' : function(el){	
			el.onclick = function()
			{			
				el.value = "";				
			}
	
	},
	
	// for news letter (nov. 13, 2006)
	'#btnNLGoSpam' : function (el)
	{
		el.onclick =function ()
		{
			clientName = $('txtNLName').value;
			clientEmail = $('txtNLEmail').value;
			
			antiSpamCode = $('txtNLNameSpam').value;
			
			url = domainHome + "toolbar-newsletter.php";
			
			var params = "clientName="+clientName+"&clientEmail="+clientEmail+"&antiSpamCode="+antiSpamCode;

				var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post',  	
					asynchronous: true,
					postBody: params || "",
					onComplete: function(){
						
						eval(myAjax.transport.responseText);

						if(validCode == true)
						{						
							$('newsConfirm').style.display = "";
							 confirmationMsg = "<p>" + clientName + ", thank you for signing-up.</strong></p>";
							 $('antiSpam').style.display = "none";
							 $('newsConfirm').innerHTML = confirmationMsg;
							 $('newsBack').style.display = "";
							$('formConfirm').style.display = "none";
							$('imageChange').innerHTML = "";
						}
						else
						{
							alert("Invalid verification code.");
						}
						
						}
					
				}
				
				);
		}
	},
	
	'#btnNLGo' : function (el)
	{
		el.onclick = function ()
		{
			valid = true;
			clientName = $('txtNLName').value;
			clientEmail = $('txtNLEmail').value;
			remarks = "";
			
			if(clientName == "name")
			{
				clientName = "";
			}
			if(clientEmail == "")
			{
				clientEmail = "";
			}
			
			if(clientName == "" || clientEmail == "")
			{
				remarks += "Some fields are missing.";
				valid = false;
			}
			else
			{ 
				if(clientEmail.search("@") < 0)
				{
					remarks += "Invalid email. ";
					valid = false;
				}
			}
			
			if(valid == true)
			{
				$('imageChange').innerHTML = "<img src='font-image/index.php?randomId="+Math.random()+"&red=200&green=37&blue=45' alt='Anti Spam' title='Anti Spam'/>";
				$('antiSpam').style.display = "";
			 $('newsBack').style.display = "none";
			$('formConfirm').style.display = "none";											
			}
			else
			{
				alert("The following errors occurred: " + remarks);
				$('antiSpam').style.display = "none";
				 $('newsBack').style.display = "none";
				$('formConfirm').style.display = "";
			}
			
		}
	},
	
	'#buttonNewsBack' : function (el)
	{
		el.onclick = function ()
		{
			$('antiSpam').style.display = "none";
			$('newsConfirm').style.display = "none";
			 $('newsBack').style.display = "none";
			$('formConfirm').style.display = "";		
			$('frmTBNewsletter').reset();
		}
	},
	
	'#specialOfferHome' : function (el)
	{
		el.onclick = function ()
		{						
			window.location.href = el.name;
		}
	},
	
	'#topDestinationHome' : function (el)
	{
		el.onclick = function ()
		{
			var destinationLink = el.name;			
			window.location.href = domainHome + "boutique-hotels-destinations/" + destinationLink + "/";
		}
	},
	
	'#offerForTheMonthList' : function (el)
	{
		el.onchange = function ()
		{
			if(el.value != '')
			{
				window.location.href = el.value;
			}
		}
	},
	//for destinations dropdown
	'#menuAllDestinations' : function (el)
	{
		el.onchange = function ()
		{
			var destinationLink = el.value;				
			window.location.href = domainHome + "boutique-hotels-destinations/" + destinationLink + "/";
		}
	},
	
	'.scrollbar-button-top' : function (el)
	{
		el.onclick = function(){			
				scrollSlide(-17,'scrollContent');
		}
	},
	
	'.scrollbar-button-bottom' : function (el)
	{
		el.onclick = function(){
				scrollSlide(17,'scrollContent');
		}
	},
	
	'.edetail' : function(el)
	{
		el.onclick = function(){
										
			window.location.href = domainHome+"events-details/"+el.id.replace(/_/g,"/")+"/";
		}
		
	},
	
	//newsletter
	'#txtNLName' : function (el)
	{
		el.onclick = function ()
		{
			$('txtNLName').value = "";
		}
	},
	
	'#txtNLEmail' : function (el)
	{
		el.onclick = function ()
		{
			$('txtNLEmail').value = "";
		}
	},
	
	'#txtNLNameSpam' : function (el)
	{
		el.onclick  = function  ()
		{
			$('txtNLNameSpam').value = "";
		}
	},
	
	'#lnkCAPrintPage' : function (el)
	{
		el.onclick = function()
		{										
			print();	
		}		
		
	},
	
	//:: for sidebody special offers
	'.sidebodyOfferImg' : function (el)
	{
		el.onclick = function ()
		{
			window.status = "Loading page "+el.title+"...";
			window.location.href = el.title;
		}
	},
	
	'.top_table' : function(el)
	{
		el.onclick = function(){
			$url = domainHome+"top-table/search-restaurant.php?"+el.id.replace("_","=");
			
			if($('checkIn').value != "")
			{$url += "&date="+$('checkIn').value;}
			
			window.open($url,"Top_Table", 'status=1,height=600,width=515,resizable=0,scrollbars=1');
		}					
	},
		
	'#ulHdrMainMenu a' : function(el)
	{
		el.onclick = function()
		{				
			window.status = "Loading page "+el.href+"...";	
		}
	},
	
	'#ulHomeList li a' : function(el)
	{
		el.onclick = function()
		{				
			expandCollapse(el.id);
		}
	},
	'#imgBookingWithChildren' :function(el)
	{
		el.onclick = function()
		{
			pos = findPos(el); 
			$('divBookingWithChildren').style.top = (pos[1]-100)+'px';
			$('divBookingWithChildren').style.left = (pos[0]+8)+'px';
			$('divBookingWithChildren').style.display = 'block';
		}
	},
	'#closeBookingWithChildren' : function(el)
	{
		el.onclick = function()
		{
			$('divBookingWithChildren').style.display = 'none';
		}
	},
	'.onRequestLink' : function(el)
	{
		el.onmouseover = function()
		{ 
			if($('divRequestNow'+el.title).style.display == 'none')
			{
				$('divRequestNow'+el.title).style.display = 'block';
			}
		}
	},
	
	'.closeRequestNow' : function(el)
	{
		el.onclick = function()
		{
			$('divRequestNow'+el.title).style.display = 'none';
		}
	}
		
};
Behaviour.register(objBehaviours);

function hideSearchTip(tiptitle)
		{  
			if($('divRequestNow'+tiptitle).style.display == 'block')
			{
				$('divRequestNow'+tiptitle).style.display = 'none';
			}

		}
function findPosyX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosyY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }