	sfHover = function() {
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
	if (window.attachEvent) window.attachEvent("onload", sfHover);
	
	function displaySpecial(){
		$(".special").each (function (){
			var temp = $(this).children(".specialDetails").text();
			$(this).qtip({
		   		content: temp,
		   		position: { adjust: { x: 0, y: -60} },
		   		show: {when: { event: 'mouseover', effect:'fade', length: 1200} },
		   		style: { border: { width: 2, radius: 5 , color: '#222222' }, tip: 'topLeft' }
		   	});
		});
	}
//	function startGallery() {
//var myGallery = new gallery(Moo.$('slideshow'), {
//timed: false,
//showArrows: true,
//showArrows: true,
//showCarousel: false
//});
//}
//window.addEvent('domready', startGallery);
$(document).ready(function(){
	displaySpecial();
	
	$(function(){$('#more-info-tabs').tabs();});
	
        $("table tbody tr td:nth-child(even)").addClass("alt");
          $("#sidebar ul li.top-ten ol li:nth-child(odd)").addClass("alt");
  
	
	  
      /*  $("fieldset#bidding").css("display","none");

      $(".book").click(function(){
        if ($(".book").is(":checked"))
        {
	       $("input.book:checked").parent('td').addClass("checked");
            $("fieldset#bidding").slideDown("fast", function() {
			$("input#submit-booking").animate({backgroundColor: '#ff5501'}, 1500);});
}
        else
        {  
	       $("input.book").parent('td').removeClass("checked");
           $("fieldset#bidding").hide("fast");
           $("input#submit-booking").css({'background-color': '#2c2928'});
        }
      });*/
  
    //JQueryCycle
    $('#small-slideshow .pictures').cycle({ 
    fx:     'fade', 
    speed:  'fast', 
    timeout: 0, 
    pager:  '#slide-nav' 
});

    //JQueryCycle
    $('#offers-cycle .ads').cycle({ 
    fx:     'scrollUp', 
    speed:  1000, 
    timeout: 15000
});
    

  $('#footer .form-container').hide();
//  $('a#search-again').click(function() {
// $('#footer .form-container').slideToggle(400);
// return false;
//  });
  
    $('#search-results #content table.availability').hide();
  $('a.toggle-av').click(function() {
 $('#search-results #content table.availability').slideToggle(400);
 $('a.toggle-av span').css ({'background-position': 'left top'});
 return false;
  });

  $('#content .full-entry').hide();
  $('a.read-more').click(function() {
  	$('#content .full-entry').slideToggle(400);
 		return false;
  });
  
$(function()
{
	//$('.date-picker').datePicker().val(new Date().asString()).trigger('change');
});
});

// when the DOM is ready...
$(document).ready(function () {

var $panels = $('#slider form > div');
var $container = $('#slider form');

// if false, we'll float all the panels left and fix the width 
// of the container
var horizontal = true;

// float the panels left if we're going horizontal
if (horizontal) {
  $panels.css({
    'float' : 'left',
    'position' : 'relative' // IE fix to ensure overflow is hidden
  });
  
  // calculate a new width for the container (so it holds all panels)
  //$container.css('width', $panels[0].offsetWidth * $panels.length);
}

// collect the scroll object, at the same time apply the hidden overflow
// to remove the default scrollbars that will appear
var $scroll = $('#slider .scroll').css('overflow', 'hidden');



// handle nav selection
function selectNav() {
  $(this)
    .parents('ul:first')
      .find('a')
        .removeClass('selected')
      .end()
    .end()
    .addClass('selected');
}

$('#slider #steps').find('a').click(selectNav);

// go find the navigation link that has this target and select the nav
function trigger(data) {
  var el = $('#slider #steps').find('a[href$="' + data.id + '"]').get(0);
  selectNav.call(el);
}

if (window.location.hash) {
  trigger({ id : window.location.hash.substr(1) });
} else {
  $('ul#steps a:first').click();
}

// offset is used to move to *exactly* the right place, since I'm using
// padding on my example, I need to subtract the amount of padding to
// the offset.  Try removing this to get a good idea of the effect
var offset = parseInt((horizontal ? 
  $container.css('paddingTop') : 
  $container.css('paddingLeft')) 
  || 0) * -1;


var scrollOptions = {
  target: $scroll, // the element that has the overflow
  
  // can be a selector which will be relative to the target
  items: $panels,
  
  navigation: '.navigation a',
  
  // selectors are NOT relative to document, i.e. make sure they're unique
  prev: 'img.left', 
  next: 'img.right',
  
  // allow the scroll effect to run both directions
  axis: 'xy',
  
  onAfter: trigger, // our final callback
  
  offset: offset,
  
  // duration of the sliding effect
  duration: 500,
  
  // easing - can be used with the easing plugin: 
  // http://gsgd.co.uk/sandbox/jquery/easing/
  easing: 'swing'
};

// apply serialScroll to the slider - we chose this plugin because it 
// supports// the indexed next and previous scroll along with hooking 
// in to our navigation.
//$('#slider').serialScroll(scrollOptions);

// now apply localScroll to hook any other arbitrary links to trigger 
// the effect
//$.localScroll(scrollOptions);

// finally, if the URL has a hash, move the slider in to position, 
// setting the duration to 1 because I don't want it to scroll in the
// very first page load.  We don't always need this, but it ensures
// the positioning is absolutely spot on when the pages loads.
//scrollOptions.duration = 1;
//$.localScroll.hash(scrollOptions);

});

/* to open a page in popup*/
function popup(mypage, myname, w, h, scroll) {
	
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable, location=0';
		window.open(mypage, myname, winprops)
	
}

function LTrim( value ) {

	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");

}

// Removes ending whitespaces
function RTrim( value ) {

	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");

}

function isImage(value){

		return (/(.*?)\.(gif|Gif|GIF|jpg|Jpg|JPG|jpeg|png|PNG)/.test(value));
}

function isPDF(value){

		return (/(.*?)\.(pdf|PDF|Pdf)/.test(value));
}

function isSwf(value){

		return (/(.*?)\.(swf|SWF|Swf)/.test(value));
}
function isAmount(value)
{
		return (/^\d+(\.\d{1,2})?$/.test(value));

}

// Removes leading and ending whitespaces
function trimboth( value ) {

	return LTrim(RTrim(value));

}
//return true if value is alphnumeric
function isAlphanumeric(value)	{
		return (/^[A-Za-z0-9 ]+$/.test(value));
}
//return true if value is alphabets
function isAlphabets(value)	{
		return (/^[A-Za-z ]+$/.test(value));
}

//return true if value is phone number
function isPhone(value){
		return (/^[0-9\s+\(\)]+$/.test(value));
		//return (/^\d+\s\d+$/.test(value));
}

//return true if value is number
function isNumeric(value){
		return (/^[0-9\.+-]+$/.test(value));

}

// this function validate currency format
function isCurrency (val) {
	str = trimboth(val);
	return (/^\d+(\.\d{1,2})?$/.test(str));
	//return (/^[0-9]+\.?[0-9][0-9]$/.test(str));
    //return /^\$?[1-9][0-9]{0,5}(,[0-9]{3})*(\.[0-9]{2})?$/.test(str);
}


//to validate an email address
function validEmail(obj)
	{
		var str=obj.value;
		var a;
		var len=str.length;
		var reg=new RegExp("@");
		var ind=str.search(reg);
		
		var c,d=0;
		var b=0;
		for(a=0;a<=str.length;a++)
		{

			if(str.charAt(a)=="@")
			{
				b++;
			}

		}

		if(b>1)
			{
				alert("You need to provide a valid email address.");
				obj.focus();
				return false;
			}
		else
			{
				for(a=0;a<=str.length;a++)
				{
					if(str.charAt(a)==".")
					{
						d=a;
					}

				}
				if((ind>d)||(ind==-1)||(d==0)||(ind+1==d)||(d+1==len) || (str.indexOf(" ")!=-1) )
				{
					alert ("You need to provide a valid email address.");
					obj.focus();
					return false;
				}
				else
				{
					return true;
				}
			}


	}//function end vaild enmail
	
//validate DateRange User for room.php
function validateDateRange(objForm){	
	var numChk = objForm.chkBookingDate.length;
	var endDate = "";//objForm.endDate.value;
	var intPreId = 0;
	var intIdsDiff = 0;
	var arrIds = new Array();
	var chkFlag = 0;
	for( intIndex=0; intIndex < numChk; intIndex++ ) {		
		if( objForm.chkBookingDate[intIndex].checked){			
			if(chkFlag == 0){
				if(endDate != ""){
					if(objForm.chkBookingDate[intIndex].value != endDate){
						alert("You must choose continuous dates.");
						objForm.chkBookingDate[intIndex].checked = false;
						totalPrice(objForm);
						return false;
					}
				}
				chkFlag = 1;
			}else{
				intPreId = intIndex-1;				
				if(objForm.chkBookingDate[intPreId].checked == false){
					//objForm.chkBookingDate[intIndex].checked = false;
					alert("You must choose continuous dates.");
					return false;
				}
			}
		}//end if
	}//end for
	totalPrice(objForm);
}//end validateDateRange

// noted by leo 5.20 2010
//function checkRoomPay(objForm){
//	//check checkbox has selected
//	var numChk = objForm.chkBookingDate.length;
//	var chkFlag = 0;
//	for( intIndex=0; intIndex < numChk; intIndex++ ) {
//		if(objForm.chkBookingDate[intIndex].checked){
//			chkFlag=1;
//			break;
//		}
//	}
//	if(chkFlag == 0){
//		alert("Please select booking date!");
//		return false;
//	}
//	//check mybidprice is not null
//	var mybidprice=objForm.mybidprice.value;	
//	if(isAmount(trimboth(mybidprice))){
//		objForm.submit();
//	}else{
//		alert("Please input numbers!");
//	}
//	return false;
//}

function checkRoomPay(objForm){
	//check checkbox has selected
	var numChk = objForm.chkBookingDate.length;
	var chkFlag = 0;
	for( intIndex=0; intIndex < numChk; intIndex++ ) {
		if(objForm.chkBookingDate[intIndex].checked){
			chkFlag=1;
			break;
		}
	}
	if(chkFlag == 0){
		alert("Please select booking date!");
		return false;
	}
		objForm.submit();
	
}


function totalPrice(objForm){
	var fullPrice=$("#real_price").val();
	var roomId = $("#room_id").val();
	var propertyId = $("#property_id").val();
	
	var numChk = objForm.chkBookingDate.length;
	var checkIn="";
	var chkFlag = 0;
	var count=0;
	for( intIndex=0; intIndex < numChk; intIndex++ ) {
		if(objForm.chkBookingDate[intIndex].checked){
			if(chkFlag==0){
				checkIn=objForm.chkBookingDate[intIndex].value;
				chkFlag=1;
			}
			count++;
		}
	}
		$.ajax({
			    url: 'ajax.php',
			    type: 'post',
			    data:"&fullPrice="+fullPrice+"&count="+count+"&check_date="+checkIn+"&task=total_price"+"&roomId="+roomId+"&propertyId="+propertyId,
			    error: function(msg){
			        $("#total").html(msg);
			    },
			    success: function(html){
			    	 $("#total").html(html);
			    },
			    beforeSend: function()
			    {
			    	 $("#total").html('waiting...');
			    }
			});	
}

/**
** check payment form, used for payment.php
**/
function checkPaymentForm(form,cYear,cMonth){
	//alert(cYear+" "+cMonth);
	//adults
	if(trimboth(form.txtAdults.value) == "" ) {
		alert("Please select Adults.");
		form.txtAdults.focus();
		return false;
	}
	//arrival date
	if(trimboth(form.arrival_date.value) == "" ) {
		alert("Please enter Arrive Date.");
		form.arrival_date.focus();
		return false;
	}
	//first name
	if(trimboth(form.firstName.value) == "" ) {
		alert("Please enter first name.");
		form.firstName.focus();
		return false;
	}
	//first name
	if(trimboth(form.firstName.value) == "" ) {
		alert("Please enter first name.");
		form.firstName.focus();
		return false;
	}else if(!isAlphabets(form.firstName.value)) {
		alert("This is not valid first name.");
		form.firstName.focus();
		return false;
	}	
	//last name
	if(trimboth(form.lastName.value) == "" ) {
		alert("Please enter last name.");
		form.lastName.focus();
		return false;
	}else if(!isAlphabets(form.lastName.value)) {
		alert("This is not valid last name.");
		form.lastName.focus();
		return false;
	}
	//password

	//email address
	if(trimboth(form.emailAddress.value) == "" ) {
		alert("Please enter Email Address.");
		form.emailAddress.focus();
		return false;
	}else if(validEmail(form.emailAddress) == false) {
		return false;
	}
	
	//address
	if(trimboth(form.address.value) == "" ) {
		alert("Please enter address.");
		form.address.focus();
		return false;
	}
	//suburb city
	if(trimboth(form.suburb.value) == "" ) {
		alert("Please enter city.");
		form.suburb.focus();
		return false;
	}else if(!isAlphabets(form.suburb.value)) {
		alert("This is not valid city.");
		form.suburb.focus();
		return false;
	}
	//state
	if(trimboth(form.state.value) == "" ) {
		alert("Please enter state.");
		form.state.focus();
		return false;
	}else if(!isAlphabets(form.state.value)) {
		alert("This is not valid state.");
		form.state.focus();
		return false;
	}
	//country
	if(trimboth(form.country.value) == 0 ) {
		alert("Please select Country Name.");
		form.country.focus();
		return false;
	}
	//phone
	if(trimboth(form.phoneNumber.value) == "" ) {
		alert("Please enter Phone Number.");
		form.phoneNumber.focus();
		return false;
	}else if(!isPhone(form.phoneNumber.value)) {
		alert("This is not valid Phone Number.");
		form.phoneNumber.focus();
		return false;
	}
	//mobile
	if(trimboth(form.mobileNumber.value) != "" ) {
		if(!isPhone((form.mobileNumber.value))) {
			alert("This is not valid Mobile Number.");
			form.mobileNumber.focus();
			return false;
		}
	}

	
	if(!form.cancel_cond.checked || !form.terms_cond.checked){
		alert("Sorry,but you can't go on unless you agree to the top 2 boxes.");
		return false;
	}
	//card validate
	if(form.cardType.value == ''){
		alert("Please select Card Type.");
		form.cardType.focus();
		return false;
	}
	
	if(form.cardNumber.value == ""){
		alert("Please enter Card Number.");
		form.cardNumber.focus();
		return false;
	}else if(!isNumeric(form.cardNumber.value)){
		alert("This is not valid Card Number.");
		form.cardNumber.focus();
		return false;
	}
	
	if(form.cardNumber.value != ""){
		cardLength = form.cardNumber.value.length;
		if(cardLength <16){
			alert("This is not valid Card Number.");
			form.cardNumber.focus();
			return false;
		}
	}
	if(form.cardHolder.value == ''){
		alert("Please enter Card Holder Name.");
		form.cardHolder.focus();
		return false;
	}else if(!isAlphabets(form.cardHolder.value)){
		alert("This is not a valid Card Holder Name.");
		form.cardHolder.focus();
		return false;
	}
	
	if(form.cvvNumber.value == ''){
		alert("Please enter CVV Number.");
		form.cvvNumber.focus();
		return false;
	}
	
	if(form.expiryMon.value == ''){
		alert("Please select Expiry Month.");
		form.expiryMon.focus();
		return false;
	}
	
	if(form.expiryYear.value == ''){
		alert("Please select Expiry Year.");
		form.expiryYear.focus();
		return false;
	}
	
	if(cYear > form.expiryYear.value){
		alert("Card Expiry Year must be greater than current year.");
		form.expiryYear.focus();
		return false;
	}else if(cYear == form.expiryYear.value){		
		if(cMonth > form.expiryMon.value){
			alert("Card Expiry Month must be greater than current month.");
			form.expiryYear.focus();
			return false;
		}
	}
	
	if(form.confirm_code.value==''){
			alert("Please input confirm code.");
			return false;
	}
	
	return true;	
}


//check mail
function checkMail(form_id){
	var form=document.getElementById(form_id);
	if(!form){
		return false;
	}
	
	var firstName=form.first_name.value;
	if(firstName=="" || firstName=="Your First Name"){
		alert("Please enter first name");
		return false;
	}
	
	var lastName=form.last_name.value;
	if(lastName=="" || lastName=="Your Last Name"){
		alert("Please enter last name");
		return false;
	}
	
	var address=form.address.value;
	if(address=="Your Address"){
		form.address.value ="";
	}
	
	var email=trimboth(form.email.value);
	if(email=="" || email=="Your Email Address"){
		alert("Please enter email");
		return false;
	}
	if(validEmail(form.email)==false){
		return false;
	}
	
	var enquiry =form.enquiry.value;
	if(enquiry=="Your Enquiry" || enquiry==""){
		alert("Please enter enquiry");
		return false;
	}	
	
	var number = form.number.value;
	var code = form.code.value;
	if(number==""){
		alert("Please enter validate code");
		return false;
	}	
	if(number != code){
		alert("Sorry validate code is wrong!");
		return false;
	}

	return true;
}

function calculateAmount(submitUrl,form,bookingID, propertyID,configInitialPayable,configBookingFees)
{
	//alert(url+" "+propertyID);
	var adminForm=document.getElementById(form);
		fromDate = adminForm.check_in.value;
		toDate =  adminForm.check_out.value;
		adults =  adminForm.txtAdults.value;
		extraPerson = adminForm.extraPerson.value;
		children =  adminForm.txtChildren.value;
		roomID =  adminForm.room_id.value;
		configInitialPayable = configInitialPayable;
		configInitialPayable = (parseFloat(configInitialPayable)/100).toFixed(2);
		configBookingFees = configBookingFees;
		adults = Number(adults)+ Number(extraPerson);
		var intIndex = 0;
		numberOfRooms = 1;

		
		$.ajax({
		    url: submitUrl+'/ajaxamount.php',
		    type: 'post',
		    data:'bookingID='+ bookingID + '&propertyID='+ propertyID + '&roomID='+ roomID +'&fromDate='+fromDate+'&toDate='+toDate+'&adults='+adults+'&numberOfRooms='+numberOfRooms+'&children='+children,
		    error: function(msg){
				jQuery("#paynow").html('error');
		        $("#ggggg").html('error');
		    },
		    success: function(html){		    	
		    	$("#ggggg").html(html);
		    	var fees=0;
		    	var arrivePrice=0;
		    	var totalPrice=jQuery("#totalPrice1").val();
		    	var arriveObj=jQuery("#onarriveprice");
		    	var needPayNow=0;
		    	var needPayArrival=0;
		    	var totalAmount=0;

		    	if(totalPrice==undefined){
		    		totalPrice=0;
		    		fees='null';
		    		needPayNow='null';
		    		needPayArrival='null';
		    		totalAmount='null';
					//	arriveObj.html('null');
					//jQuery("#needPayNow").html('null');
					//jQuery("#needPayArrival").html('null');
		    	}else{
		    		
		    	//	fees='$'+(totalPrice * configInitialPayable+ parseFloat(configBookingFees).toFixed(2)) + ' USD';
		    		
		    		fees='$'+parseFloat(totalPrice * configInitialPayable+ parseFloat(configBookingFees)).toFixed(2) + ' USD';
		    		
		    		arrivePrice='$'+parseFloat(totalPrice * (1-configInitialPayable)).toFixed(2) + ' USD';
		    		
		    		needPayNow=configInitialPayable*100 + '%' + ' of ' + parseFloat(totalPrice).toFixed(2) + ' + ' +
		    		'Booking fee ' + configBookingFees + '(10% tax 0.05$)' + ' = ' + fees;
		    		
		    		needPayArrival=(1-configInitialPayable)*100 + '%' + ' of ' + totalPrice + " = " + arrivePrice;
		    		
		    		totalAmount ='$'+ totalPrice + ' USD';
		    	}

		    	jQuery("#paynow").html(needPayNow);
		    	arriveObj.html(needPayArrival);    	
	    		jQuery("#totalAmount").html(totalAmount);	
		    	//jQuery("#needPayNow").html(needPayNow);
	    		//jQuery("#needPayArrival").html(needPayArrival);		
		    	
		    },
		    beforeSend: function()
		    {
		    	jQuery("#paynow").html('waiting...');
		    	$("#ggggg").html('waiting...');
		    			    	
		    }
		});
}



















