// JavaScript Document

$(document).ready(function(){
	//show clock time
	ShowToday();StartTime();
	//round conner
		$('.tour_left').corner("round 5px");
	/*exp & video control */
	var set_pos=0;
	$("#hotsellingtour_control_back,#hotsellingtour_control_next").click(function()
	{
		var control_id=$(this).index();
		control_id==0 ? set_pos=-1 : set_pos=1;
		play_bestselling_tour();		
		
	});
	function play_bestselling_tour()
	{
		var content_wrap="hotsellingtour_content";
		var content_active="hotsellingtour_content_active";
		var number_content=$("#"+content_wrap+" ul").length;		
		var cur_pos=$("."+content_wrap+" ul."+content_active).index();
		cur_pos=cur_pos+set_pos;
		cur_pos>(number_content-1) ? cur_pos=0 : ''; //index start 0
		cur_pos<0 ? cur_pos=(number_content-1) : '';
		$("#"+content_wrap+" ul").removeClass(content_active);
		$("#"+content_wrap+" ul").eq(cur_pos).addClass(content_active);
		
	}
	var isSelected=getCookie("menu");
	
	//alert(isSelected);
	$("#topnav li.child_wrap").mouseenter(function()
	{
		$(".children").hide();
		var menuchild = $(this).children('ul').attr('id');

		//remove active class
		$("#topnav li.child_wrap").removeClass("active");
		//add this element class active
		$(this).addClass("active");
		//count number li in ul#menuchild 
		
		//show submenu with fadeIn effect
		$("#topnav li "+"#"+menuchild).fadeIn(200);
	});
	$("#topnav li.child_wrap").mouseleave(function()
	{
		$(".children").hide();
	});
	
	$("#topnav li.child_wrap").click(function(){
		var menuchild = $(this).children('ul').attr('id');
		setCookie("menu",this.id,36000);
		setCookie("menuchild",menuchild,36000);
		
	});

	$("#room_back").click(function(){
		window.history.go(-1);
	});

	var isSelected=getCookie("menu");
	if(isSelected!=null || isSelected!='')
	{
		$("#"+isSelected).addClass("active");

	}	
	//alert(isSelected);
	$("#topnav li").click(function()
	{
		var menuchild = $(this).children('ul').attr('id');

		//remove active class
		$("#topnav li").removeClass("active");
		//add this element class active
		$(this).addClass("active");
		//count number li in ul#menuchild 
		
		//show submenu with fadeIn effect
		//$("#topnav li "+"#"+menuchild).fadeIn(200);
	});


	/* tab content */
	$(".product_title_tab li").click(function (){
		var sid=$(this).children('a').attr('id');
		//alert(sid);
		$(".product_title_tab li a").removeClass('tab_active');
		$('#'+sid).addClass('tab_active');
		$(".product_detail_content").removeClass('content_active');
		switch(sid)
		{
			case 'product_title_tab_1': $('#product_content_tab_1').addClass('content_active'); break;	
			case 'product_title_tab_2': $('#product_content_tab_2').addClass('content_active'); break;	
			case 'product_title_tab_3': $('#product_content_tab_3').addClass('content_active'); break;	
			case 'product_title_tab_4': $('#product_content_tab_4').addClass('content_active'); break;	
			case 'product_title_tab_5': $('#product_content_tab_5').addClass('content_active'); break;	
		}
		
		
	});	



	$("#topnav li.child_wrap").click(function(){
		//var menuchild = $(this).children('ul').attr('id');
		setCookie("menu",this.id,36000);
		//setCookie("menuchild",menuchild,36000);
		
	});
	
	$("#cancel-button").click(function() {
		$("#close-button").stopTime();
	});	

	//clear text search
	$("#input_search").focus(function(){
		this.value='';
	});
	
	$("#yahoo_block").mouseenter(function(){
		$("#support_yahoo_wrap").show();
	});
	$("#support_yahoo_wrap").mouseleave(function(){
		$("#support_yahoo_wrap").hide();
	});
	
	$(".page_wrap").click(function(){
		$("#support_yahoo_wrap").hide();
		//$("#support_skype_wrap").hide();
	});
	//load image product silder
	//$('ul#basic_config').carouFredSel();
	$('#carousel').carouFredSel({
		auto: true,
		prev: "#prev",
		next: "#next",
		items               : 5,
		direction           : "left",
		scroll : {
			items           : 1,
			effect          : "easeOutBounce",
			duration        : 500,                        
			pauseOnHover    : false
		}  				
				
	});	
	
	//lightbox
	$('#gallery_img_right a,.tour_right a,.product_detail_content a,.room_rate_right a,#room_rate_block_left a,#product_detail_left a').lightBox({ 
		imageLoading:			rewritepath+'images/lightbox/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
		imageBtnPrev:			rewritepath+'images/lightbox/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
		imageBtnNext:			rewritepath+'images/lightbox/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
		imageBtnClose:			rewritepath+'images/lightbox/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
		imageBlank:				rewritepath+'images/lightbox/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
		fixedNavigation:		false,		// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
		containerResizeSpeed:	400,			 // Specify the resize duration of container image. These number are miliseconds. 400 is default.
		overlayBgColor: 		"#000",		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
		overlayOpacity:			.9,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
		txtImage:				'Hình ảnh',				//Default text of image
		txtOf:					'/'
	});
	
	//set lang
	//if($('#langkey').val()=='') $('#langkey').val('vn');
	var obj_show_news=document.getElementById('showLastestNews');
	var obj_random_img=document.getElementById('banner_wrap_img');
	var timer1="";
	var timer2="";

    $(window).load(function() {
        $('#slider').nivoSlider({
			effect: 'random', // Specify sets like: 'fold,fade,sliceDown'
			slices: 15, // For slice animations
			boxCols: 10, // For box animations
			boxRows: 5, // For box animations
			animSpeed: 300, // Slide transition speed
			pauseTime: 3000, // How long each slide will show
			startSlide: 0, // Set starting Slide (0 index)
			directionNav: false, // Next & Prev navigation
			directionNavHide: true, // Only show on hover
			controlNav: false, // 1,2,3... navigation
			controlNavThumbs: false, // Use thumbnails for Control Nav
			controlNavThumbsFromRel: false, // Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', // Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
			keyboardNav: false, // Use left & right arrows
			pauseOnHover: false, // Stop animation while hovering
			manualAdvance: false, // Force manual transitions
			captionOpacity: 0.8, // Universal caption opacity
			/*prevText: 'Prev', // Prev directionNav text
			nextText: 'Next', // Next directionNav text
			beforeChange: function(){}, // Triggers before a slide transition
			afterChange: function(){}, // Triggers after a slide transition
			slideshowEnd: function(){}, // Triggers after all slides have been shown
			lastSlide: function(){}, // Triggers when last slide is shown
			afterLoad: function(){} // Triggers when slider has loaded		});
			
			*/
    	})
	});	
});

