﻿// JScript 文件

Date.prototype.format = function(format) {   
    /*  
     * eg:format="YYYY-MM-dd hh:mm:ss";  
     */  
    var o = {   
        "M+" :this.getMonth() + 1, // month   
        "d+" :this.getDate(), // day   
        "h+" :this.getHours(), // hour   
        "m+" :this.getMinutes(), // minute   
        "s+" :this.getSeconds(), // second   
        "q+" :Math.floor((this.getMonth() + 3) / 3), // quarter   
        "S" :this.getMilliseconds()   
    // millisecond   
    }   
  
    if (/(y+)/.test(format)) {   
        format = format.replace(RegExp.$1, (this.getFullYear() + "")   
                .substr(4 - RegExp.$1.length));   
    }   
  
    for ( var k in o) {   
        if (new RegExp("(" + k + ")").test(format)) {   
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]   
                    : ("00" + o[k]).substr(("" + o[k]).length));   
        }   
    }   
    return format;   
}  
	
var tolFlag = '';
function setCheckInDate(d)
{
	document.getElementById("hdate1").value=d;
	if(document.getElementById("hdate2").value.length==0)
	{
		showCalendar('dimg2',false,'hdate2','hdate1');
	}
}

  function getValue()
{	
	var HotelName = document.getElementById('txtHotelName').value;
	
	var hdate1 = document.getElementById('hdate1').value;
	var hdate2 = document.getElementById('hdate2').value;
	
	if(hdate1 == "" || hdate2 == "")
	{
		window.alert('请选择入住日期和离店日期!');
		return false;
	}
	if(stringToDate(hdate1,true) >= stringToDate(hdate2,true) )
	{
		window.alert('离店日期不能早于入住日期');
		return false;
	}
	
	var HotelTypeIndex = document.getElementById('ddlHotelType').selectedIndex;
	var HotelType = document.getElementById('ddlHotelType').value;
	var tol = HotelName + '|' + hdate1 + '|' + hdate2 + '|' + HotelType +'|'+HotelTypeIndex;
	//document.getElementById('HotelSearchII1_txtHidden').value = tol;
	 window.location.href='hongkong_hotels/hotel_searchresult.aspx?HotelName='+ HotelName + '&BeginDate=' + hdate1 + '&EndDate=' + hdate2 + '&HotelType='+ HotelType;		
}

var _bdhm_top = 0;
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
var _bdhm_tim = new Image(1,1);
_bdhm_tim.id = "bdhmPerimg";
_bdhm_tim.src = _bdhmProtocol + "hm.baidu.com/_tt.gif?si=95da0c581a96155640b7f98e422f9e44&rnd=" + Math.round(Math.random()*2147483647);
_bdhm_tim.onload=function(){_bdhm_top = 1;}

function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
if (i == Num)
{
   thisObj.className = "active"; 
      document.getElementById(tabObj+"_Content"+i).style.display = "block";
}else{
   tabList[i].className = "normal"; 
   document.getElementById(tabObj+"_Content"+i).style.display = "none";
}
} 
}

 
$(document).ready(function() {
 
	//Set Default State of each portfolio piece
	$(".paging").show();
	$(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageHeight = $(".window").height();
	var imageSum = $(".image_reel img").size();
	var imageReelHeight = imageHeight * imageSum;
	
	//Adjust the image reel to its new size
	$(".image_reel").css({'height' : imageReelHeight});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageHeight; //Determines the distance the image reel needs to slide
 
		$(".paging a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$(".image_reel").animate({ 
			top: -image_reelPosition
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$(".image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	$(".paging a").click(function() {	
		$active = $(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	
	
});


