// JavaScript Document

//==========================================================================================
/*--------------------------------------------------------------------------------- Client System ------------------------------------------------------------------------------*/
//==========================================================================================

function startWeb(page){
	
	switch (page){
		
			case '' : hide_Data();
			break;
			
			case 'room' : switchData('room_rate');
			break;
		
	}
	
	// Hide Light of All Main Menu
	
	$('#light1,#light2,#light3,#light4,#light5,#facebook_alpha').hide();
	
	// Hide Icon Home & Map hover
	
	$('#icon_home_hover,#icon_map_hover').hide();
	
	// Hide Menu Button Home
	
	$('#menu_home,#LOGO_home').hide();
	$('#menu_home_footer').show();
	
	// Show Menu Button
	
	$('#menu1,#menu2,#menu3,#menu4,#menu5').show();
	$('#menu1_footer,#menu2_footer,#menu3_footer,#menu4_footer,#menu5_footer').hide();
	
	// Start Showcase
	
	$('#showcase_pic1,#showcase_pic2,#showcase_pic3,#showcase_pic4,#showcase_pic5').hide();
	$('#showcase_pic1_click,#showcase_pic2_click,#showcase_pic3_click,#showcase_pic4_click,#showcase_pic5_click').hide();
	$('#showcase1_click,#showcase2_click,#showcase3_click,#showcase4_click,#showcase5_click,#BG_showcase').hide();
	
	
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false");
	
}

function hide_Data(){
	
		$('#promotion_all_detail ,#package_detail,#gallery_tour,#gallery_waterfall,#room_rate,#reserve_room,#contact,#map_hover,#activities,#food_menu').hide();
}

function fadeData(){
	
		$('#promotion_all_detail ,#package_detail,#gallery_tour,#gallery_waterfall,#room_rate,#reserve_room,#contact,#map_hover,#activities,#food_menu').fadeOut(700);
}


//==========================================================================================
//------------------------------------------------------------------------------ Main menu cotroller -----------------------------------------------------------------------------
//==========================================================================================


//--------------------------------------------------------------------------- Menu Effect : Main Menu -------------------------------------------------------------------------

function showLight(id){
	
		var light = "#light" + id;
		
		$(light).show();
	
}

function hideLight(id){
	
		var light = "#light" + id;
		
		$(light).hide();
	
}

//-------------------------------------------------------------------------- Menu Effect : HOME & MAP -----------------------------------------------------------------------

function showIcon(name){
	
		var icon = "#icon_" + name + "_hover";
		
		$(icon).fadeIn(300);
	
}

function hideIcon(name){
	
		var icon = "#icon_" + name + "_hover";
		
		$(icon).fadeOut(300);
	
}

function effectFacebook(fade){
	
		if(fade == "out"){
			
				$('#facebook_alpha').show();
			
		}else{
			
				$('#facebook_alpha').hide();
			
		}
	
}


//------------------------------------------------------------------------------------ Switch Data ---------------------------------------------------------------------------------

function switchData(data){
	
		var data_ID = "#"+data;
	
		fadeData();
	
				switch(data){
					
						case 'home' : show_row_packageTour();  controlMenu('menu_home');
						break;
						
						case 'promotion_all_detail' : $(data_ID).hide().delay(700).fadeIn(1000); show_row_packageTour();  $('#promotion_picture').hide();
						break;
			
						case 'gallery_tour' : $(data_ID).hide().delay(700).fadeIn(1000); show_row_packageTour();  controlMenu('menu_home');
						break;
			
						case 'gallery_waterfall' : $(data_ID).hide().delay(700).fadeIn(1000); show_row_packageTour();  controlMenu('menu_home');
						break;
						
						case 'room_rate' : $(data_ID).hide().delay(700).fadeIn(1000); hide_row_packageTour();  controlMenu('menu1');
						break;

						case 'reserve_room' : $(data_ID).hide().delay(700).fadeIn(1000); hide_row_packageTour();  controlMenu('menu2');
						break;
						
						case 'activities' : $(data_ID).hide().delay(700).fadeIn(1000); hide_row_packageTour();  controlMenu('menu3');
						break;
						
						case 'food_menu' : $(data_ID).hide().delay(700).fadeIn(1000); hide_row_packageTour();  controlMenu('menu4');
						break;
						
						case 'contact' : $(data_ID).hide().delay(700).fadeIn(1000); hide_row_packageTour(); controlMenu('menu5');
						break;
			
				}
		

}

function package_detail(){
	
	var btn = $('#switch_button').attr('src');
	
	if(btn == "Picture/Background/btn_plus.gif"){
	
		$('#package_detail').hide().delay(700).fadeIn(1000); show_row_packageTour();  controlMenu('menu_home');
		
		$('#switch_button').attr({src:'Picture/Background/btn_minus.gif'});

	}else{
	
		$('#package_detail').fadeOut(1000); show_row_packageTour();  controlMenu('menu_home');
		
		$('#switch_button').attr({src:'Picture/Background/btn_plus.gif'});

	}
	
}

//-------------------------------------------------------------------------------- Control all Button Menu ------------------------------------------------------------------------

function controlMenu(name){
	
		switch (name){
			
				case "menu_home" :
				
				$('#menu_home,#LOGO_home').hide();
				$('#menu_home_footer').show();
				
				$('#menu1,#menu2,#menu3,#menu4,#menu5').show();
				$('#menu1_footer,#menu2_footer,#menu3_footer,#menu4_footer,#menu5_footer').hide();
				
				break;
				
				case "menu1" :
				
				$('#menu1').hide();
				$('#menu1_footer').show();
				
				$('#menu_home,#LOGO_home,#menu2,#menu3,#menu4,#menu5').show();
				$('#menu_home_footer,#menu2_footer,#menu3_footer,#menu4_footer,#menu5_footer').hide();
				
				break;
				
				case "menu2" :
				
				$('#menu2').hide();
				$('#menu2_footer').show();
				
				$('#menu_home,#LOGO_home,#menu1,#menu3,#menu4,#menu5').show();
				$('#menu_home_footer,#menu1_footer,#menu3_footer,#menu4_footer,#menu5_footer').hide();
				
				break;
				
				case "menu3" :
				
				$('#menu3').hide();
				$('#menu3_footer').show();
				
				$('#menu_home,#LOGO_home,#menu1,#menu2,#menu4,#menu5').show();
				$('#menu_home_footer,#menu1_footer,#menu2_footer,#menu4_footer,#menu5_footer').hide();
				
				break;
				
				case "menu4" :
				
				$('#menu4').hide();
				$('#menu4_footer').show();
				
				$('#menu_home,#LOGO_home,#menu1,#menu2,#menu3,#menu5').show();
				$('#menu_home_footer,#menu1_footer,#menu2_footer,#menu3_footer,#menu5_footer').hide();
				
				break;
				
				case "menu5" :
				
				$('#menu5').hide();
				$('#menu5_footer').show();
				
				$('#menu_home,#LOGO_home,#menu1,#menu2,#menu3,#menu4').show();
				$('#menu_home_footer,#menu1_footer,#menu2_footer,#menu3_footer,#menu4_footer').hide();
				
				break;
			
			
		}
	
}


//==========================================================================================
//------------------------------------------------------------------------------- Gallery Showcase ------------------------------------------------------------------------------
//==========================================================================================

function showcase(number){
	
			var button_on = "Picture/Background/btn_showcase_on.png";
			var button_off = "Picture/Background/btn_showcase_off.png";
			
			var delay = 6000;

			
			switch (number){
				
						case 1 : $('#showcase_pic1').fadeIn(1500).delay(delay).fadeOut(1500,function(){ showcase(2); });
									  $('#btn_showcase1').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase2,#btn_showcase3,#btn_showcase4,#btn_showcase5').attr({src:button_off}).show();
									 
						break;
						
						case 2 : $('#showcase_pic2').fadeIn(1500).delay(delay).fadeOut(1500,function(){ showcase(3); });
								   	  $('#btn_showcase2').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase1,#btn_showcase3,#btn_showcase4,#btn_showcase5').attr({src:button_off}).show();

									  
						break;
						
						case 3 : $('#showcase_pic3').fadeIn(1500).delay(delay).fadeOut(1500,function(){ showcase(4); });
									  $('#btn_showcase3').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase1,#btn_showcase2,#btn_showcase4,#btn_showcase5').attr({src:button_off}).show();

						break;
						
						case 4 : $('#showcase_pic4').fadeIn(1500).delay(delay).fadeOut(1500,function(){ showcase(5); });
									  $('#btn_showcase4').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase1,#btn_showcase2,#btn_showcase3,#btn_showcase5').attr({src:button_off}).show();

						break;
						
						case 5 : $('#showcase_pic5').fadeIn(1500).delay(delay).fadeOut(1500,function(){ showcase(1); });
									  $('#btn_showcase5').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase1,#btn_showcase2,#btn_showcase3,#btn_showcase4').attr({src:button_off}).show();

						break;
						
						
				
			}
			
}



function showcase_click(number){
	
	
			$('#showcase_pic1_click,#showcase_pic2_click,#showcase_pic3_click,#showcase_pic4_click,#showcase_pic5_click').hide();
			$('#showcase1_click,#showcase2_click,#showcase3_click,#showcase4_click,#showcase5_click,#BG_showcase').show();
	
			var button_on = "Picture/Background/btn_showcase_on.png";
			var button_off = "Picture/Background/btn_showcase_off.png";
			
			var delay = 6000;

			
			switch (number){
				
						case 1 : $('#showcase_pic1_click').fadeIn(1500);
									  $('#btn_showcase1_click').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase2_click,#btn_showcase3_click,#btn_showcase4_click,#btn_showcase5_click').attr({src:button_off}).show();
									 
						break;
						
						case 2 : $('#showcase_pic2_click').fadeIn(1500);
								   	  $('#btn_showcase2_click').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase1_click,#btn_showcase3_click,#btn_showcase4_click,#btn_showcase5_click').attr({src:button_off}).show();

									  
						break;
						
						case 3 : $('#showcase_pic3_click').fadeIn(1500);
									  $('#btn_showcase3_click').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase1_click,#btn_showcase2_click,#btn_showcase4_click,#btn_showcase5_click').attr({src:button_off}).show();

						break;
						
						case 4 : $('#showcase_pic4_click').fadeIn(1500);
									  $('#btn_showcase4_click').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase1_click,#btn_showcase2_click,#btn_showcase3_click,#btn_showcase5_click').attr({src:button_off}).show();

						break;
						
						case 5 : $('#showcase_pic5_click').fadeIn(1500);
									  $('#btn_showcase5_click').attr({src:button_on}).fadeIn(700);
									  $('#btn_showcase1_click,#btn_showcase2_click,#btn_showcase3_click,#btn_showcase4_click').attr({src:button_off}).show();

						break;
						
						
				
			}

}






//-------------------------------------------------------------------------- Show & Hide Row packageTour ---------------------------------------------------------------------


function show_row_packageTour(){
	
		$('#row_packageTour,#btn_read_more,#btn_tour,#btn_waterfall').fadeIn(700);
	
}

function hide_row_packageTour(){
	
		$('#row_packageTour,#btn_read_more,#btn_tour,#btn_waterfall').fadeOut(700);
	
}


//-------------------------------------------------------------------------- Image Effect : Tour & Waterfall ---------------------------------------------------------------------

function galleryFadeOut(image){
	
		var picture = "#"+image;
	
		$(picture).fadeTo(400,0.7);
	
}

function galleryFadeIn(image){
	
		var picture = "#"+image;
	
		$(picture).fadeTo(400,1);
	
}


//==========================================================================================
//------------------------------------------------------------------------------  Room Rate Select  -----------------------------------------------------------------------------
//==========================================================================================



function showRoom(type,file){
	
	var room_type = "#"+type;
	
	var room_file  = "<img src='Picture/roomrate/"+type+"/"+file+"'>";
	
	$(room_type).hide().html(room_file).fadeIn(300);
	
	var picRef = file.substr(0,4);
	
	var thumbnail = "#"+type+"_"+picRef;
	
	$(thumbnail).fadeTo(300,0.7);
	
}


function hideRoom(type,file){
	
	var room_type = "#"+type;
	
	var room_file  = "<img src='Picture/roomrate/"+type+"/"+file+"'>";
	
	$(room_type).hide().html(room_file).fadeOut(300);
	
	
	var picRef = file.substr(0,4);
	
	var thumbnail = "#"+type+"_"+picRef;
	
	$(thumbnail).fadeTo(300,1);
	
}



//==========================================================================================
//------------------------------------------------------------------------------------  Contact  -----------------------------------------------------------------------------------
//==========================================================================================

function map_fade(pattern){
	
		switch (pattern){
			
				case "out" : $('#map_hover').fadeIn(400);
				break;
				
				case "in" : $('#map_hover').fadeOut(400);
				break;
			
		}
	
}

//------------------------------------------------------------------------------- Show Date | Time ------------------------------------------------------------------------------


function setDate(){

	$.ajax({
			url : 'class/datetime.php',
			type : 'POST',
			data : {},
			cache : false,
			success : function(data){	
				$('.datetime').html(data);	
			}
	});
}





//------------------------------------------------------------------------- Check Admin Login ----------------------------------------------------------------------------------


function checkAdmin(){
	
	var username = $('#username').val();
	var password = $('#password').val();
	
	if(username == "" || username == null){
	
		$('#alert_check_admin').text('Please insert username !').hide().fadeIn(400);
		$('#username').focus();
		return false;
	}
	
	if(password == "" || password == null){
	
		$('#alert_check_admin').text('Please insert password !').hide().fadeIn(400);
		$('#password').focus();
		return false;
	}
	
	if(username == "username"){
	
		$('#alert_check_admin').text('Username is reserved word !').hide().fadeIn(400);
		return false;
	}
	
	if(password == "password"){
	
		$('#alert_check_admin').text('Password is reserved word !').hide().fadeIn(400);
		return false;
	}
	
	if(username != "" && password != ""){
	
				$.ajax({
							url : 'admin_system.php',
							type : 'POST',
							data : {username:username,password:password},
							cache : false,
							success : function(data){
				
									if(data == "active"){
										
											document.location.href='home.php';
											return false;
										
									}else if(data == "account fail"){

											$('#alert_check_admin').text('Username or Password incorrect !').hide().fadeIn(400);
											return false;
										
									}
						}
				});
			
	}
}


//==========================================================================================
//----------------------------------------------------------------------------- Admin :: Add Showcase  -----------------------------------------------------------------------
//==========================================================================================


function startShowcase(){
	
		$('#ajax1,#alert_addShowcase,#alert_wait').hide();
	
}


function uploadShowcase(){
	
		$('#ajax1').fadeIn(400);
		$('#alert_addShowcase').text('');
	
}

function uploadShowcaseRequest(msg){
	
		if(msg == "Please upload Picture no.1 with type :: jpeg , jpg , png !" || msg == "Please upload Picture no.2 with type :: jpeg , jpg , png !" || msg == "Please upload Picture no.3 with type :: jpeg , jpg , png !" || msg == "Please upload Picture no.4 with type :: jpeg , jpg , png !" || msg == "Please upload Picture no.5 with type :: jpeg , jpg , png !" || msg == "Picture no.1 :: Width != 770 px" || msg == "Picture no.2 :: Width != 770 px" || msg == "Picture no.3 :: Width != 770 px" || msg == "Picture no.4 :: Width != 770 px" || msg == "Picture no.5 :: Width != 770 px" || msg == "Picture no.1 :: Height != 330 px" || msg=="Picture no.2 :: Height != 330 px" || msg=="Picture no.3 :: Height != 330 px" || msg=="Picture no.4 :: Height != 330 px" || msg=="Picture no.5 :: Height != 330 px" || msg=="Please choose picture for Upload"){
				
				$('#ajax1').fadeOut(400);
				$('#alert_addShowcase').text(msg).addClass('alert').hide().fadeIn(400);
				return false;		
		
		}else{
			
				$('#alert_addShowcase').html(msg).removeClass('alert').hide().fadeIn(400);
				$('#ajax1').delay(900).fadeOut(400,function(){
				
				document.formShowcase.reset();
				
				resetPage(1);
														   
				});
				return false;	

		}
	
}

function resetPage(number){
	
			var msg1 = "Reload picture .";
			var msg2 = "Reload picture ..";
			var msg3 = "Reload picture ...";
			var msg4 = "Reload picture ....";
			var msg5 = "Reload picture .....";
			
			switch(number){
					
						case 1 : $('#alert_wait').text(msg1).addClass('promotion_header').show();
						break;
			
						case 2 : $('#alert_wait').text(msg2).addClass('promotion_header').show();
						break;
			
						case 3 : $('#alert_wait').text(msg3).addClass('promotion_header').show();
						break;
						
						case 4: $('#alert_wait').text(msg4).addClass('promotion_header').show();
						break;

						case 5 : $('#alert_wait').text(msg5).addClass('promotion_header').show();
						break;
			
				}
				
				var number = number + 1;
				
				if(number > 5){
					
						document.location.href='index.php';
					
				}
			
			setTimeout(function(){resetPage(number); },1000);
	
	
}






//==========================================================================================
//---------------------------------------------------------------------------- Admin :: Update Promotion  --------------------------------------------------------------------
//==========================================================================================


function startPromotion(){
	
		$('#ajax2,#alert_promotion,#alert_wait2').hide();
	
}


function uploadPromotion(){
	
		$('#ajax2').fadeIn(400);
		$('#alert_promotion').text('');
	
}

function promotionRequest(msg){
	
		if(msg == "Please insert Header" || msg == "Please insert Sub-Detail" || msg == "Start date incorrect !" || msg == "End date incorrect !" || msg == "End date less than or equal Start date !" || msg == "Please insert Detail"){
				
				$('#ajax2').fadeOut(400);
				$('#alert_promotion').text(msg).addClass('alert').hide().fadeIn(400);
				return false;		
		
		}else{
			
				$('#alert_promotion').html(msg).removeClass('alert').hide().fadeIn(400);
				$('#ajax2').delay(900).fadeOut(400,function(){
														   
				});

		}
	
}



