$(document).ready(function(){ 
	$(".Slide-content").hide();
	$("#Slide-overlay").hide();
	$("#cat_index").hide();
	$("#cat_01").hide();
	$("#cat_02").hide();
	$("#cat_03").hide();
	$(".product-content").hide();
	$("#fragrances_photo_0").addClass("lock");
	$("#elecronics_photo_0").addClass("lock");
	$("#watchesnjewelry_photo_0").addClass("lock");


	
// Add class to Menu    

	$(".head_btn").click(function() {
		$(".head_btn").removeClass("lock");
		$(this).addClass("lock");			
	});	
	 
// Slide Down Page Button 

	$("#about_btn").click(function() {  
        open_content("about-slider", "download-slider", "contact-slider", "news-slider");	 			
	});
	$("#download_btn").click(function() { 
		open_content("download-slider", "about-slider", "contact-slider", "news-slider");					
	});
	$("#contact_btn").click(function() {  
        open_content("contact-slider", "about-slider", "download-slider", "news-slider"); 	  			
	});
	$("#news_btn").click(function() {  
		open_content("news-slider", "about-slider", "download-slider", "contact-slider");					
	});
	
// Product Page Button  
  
	$("#product_btn").click(function() {
		add_default_class();
        close_content();		
		$("#Slide-show").hide();
		$(".slide-pic").hide(); 
		$(".cat_content").hide();
		$(".slide-pic").cycle("pause");   
		$("#cat_index").fadeIn("slow");
		$("#cat_01").hide();
		$("#cat_02").hide();
		$("#cat_03").hide();
		$(".product-content").hide();
				
	});

// Home Page Button 
      
	$("#home_btn").click(function() {
		add_default_class();
	 	close_content();
		show_home_slide_show(); 

	});    
   
//Slide Down Page Close Button   

	$(".btn_close").click(function() {  
	   	resume_slide();   
		$(".head_btn").removeClass("lock"); 		  	
	}); 
	 
	$("#Slide-overlay").click(function() {  
	   	resume_slide(); 		   	
	});
	
// Product Select 
		$(".photo").click(function() {
			$(".photo").removeClass("lock");
			
			$(this).addClass("lock");	
	
			$(".product-content").hide();
			var thisID = $(this).attr("id");
	        var product_content = thisID.replace('photo','content');
			$("#"+product_content).fadeIn("slow");			
		});
	
	        
});    

//------------------------------------------------------Function----------------------------------------------//     

// Show Slide Show

function show_home_slide_show(){
   	  $("#cat_index").hide();
		$("#Slide-show").fadeIn("slow"); 
		$(".slide-pic").show();
		$(".slide-pic").cycle("resume"); 
}
function close_content(){
	$(".Slide-content").hide();			
		$("#Slide-overlay").fadeOut("slow");
		$(".Slide-content").animate({top:'-452px'}, 800);  
		
}  
function resume_slide() {
		$(".Slide-content").animate({top:'-452px'}, 800);
		$('#Slide-show').cycle('resume');  
		$("#Slide-overlay").fadeOut("slow");
}               

 // Hide Flash
function hide_flash(){
	$(".slide-pic").show();
	$("#menu").fadeIn("slow"); 
	$('.slide-pic').cycle({
		fx:     'scrollHorz',
		speed:   2000,
		timeout: 5000,
		next:   '#Slide-show', 
		pager:  '.slide-point',
		pagerAnchorBuilder: function(idx, slide) {
			return '<a href="javascript:void(0);" class="pointer"><span><img src="site_image/share/blank.gif" width="10" height="10" /></span></a>  ';
		} 
	}); 

	$("#flash-holder").addClass('hidden');	
	
	var url = location.href;
	// Pass an empty string as argument
	var breakurl =  url.split("#");
	var target = breakurl[1];
	switch (target) {
		case "about" :			
			open_content("about-slider", "download-slider", "news-slider", "contact-slider");
			add_menu_class("about_btn");
			$('#flash-holder').remove();									
		break; 
		case "download" :
			open_content("download-slider", "about-slider", "news-slider", "contact-slider");
			add_menu_class("download_btn");
			$('#flash-holder').remove();			
		break;
		case "news" :
	   		open_content("news-slider", "download-slider", "about-slider", "contact-slider");
	   		add_menu_class("news_btn"); 
			$('#flash-holder').remove();		
		break;
		case "contact" :
			open_content("contact-slider", "news-slider", "download-slider", "about-slider");
			add_menu_class("contact_btn");
			$('#flash-holder').remove();		
		break;   
        case "product" :
			close_content();
			add_menu_class("product_btn");		
			$("#Slide-show").hide();
			$(".slide-pic").hide(); 
			$(".cat_content").hide();
			$(".slide-pic").cycle("pause");   
			$("#cat_index").fadeIn("slow"); 
			 
		break;
	    case "Fragrances" : 
			show_cat01();
			$("#fragrances_content_0").show();
			add_menu_class("product_btn");   
		break;
		case "Elecronics" : 
			show_cat02();
			$("#elecronics_content_0").show();
			add_menu_class("product_btn");   
		break;
		case "WatchesNjewelry" : 
			show_cat03();
			$("#watchesnjewelry_content_0").show();
			add_menu_class("product_btn");   
		break;
		// default : 					var menu_div = ' <div id="menu" class="normal">'; break;
	}
}  

// Show Slide Down Content 

function open_content(content_id, content_id_1, content_id_2, content_id_3){
	$(".Slide-content").hide();
	$("#Slide-overlay").fadeIn("slow"); 				
	$("#"+content_id).show();



	if ($("#"+content_id).css('top') == '0px') {
			$("#Slide-overlay").fadeOut("slow"); 
			$('.slide-pic').cycle('resume');
			$(".head_btn").removeClass("lock");
			$("#"+content_id).animate({top:'-452px'}, 800);		  
	} else {
		if($("#"+content_id_1).css('top') == '-452px' && $("#"+content_id_2).css('top') == '-452px' && $("#"+content_id_3).css('top') == '-452px') {
		$("#"+content_id).animate({top:'0px'}, 800);
		$('.slide-pic').cycle('pause'); 
		} else {
			if($("#"+content_id_1).css('top') != '-452px') {
				$("#"+content_id).hide();
				$("#"+content_id_1).show();
				$('.slide-pic').cycle('pause');	
				$("#"+content_id_1).animate({top:'-452px'}, 800, function(){
							$("#"+content_id).show();
							$("#"+content_id).animate({top:'0px'}, 800);						
				});
		
		
		}
				if($("#"+content_id_2).css('top') != '-452px') {
							$("#"+content_id).hide();
							$("#"+content_id_2).show();
							$('.slide-pic').cycle('pause');	
							$("#"+content_id_2).animate({top:'-452px'}, 800, function(){
										$("#"+content_id).show();
										$("#"+content_id).animate({top:'0px'}, 800);						
							});
			}
					if($("#"+content_id_3).css('top') != '-452px') {
								$("#"+content_id).hide();
								$("#"+content_id_3).show();
								$('.slide-pic').cycle('pause');	
								$("#"+content_id_3).animate({top:'-452px'}, 800, function(){
											$("#"+content_id).show();
											$("#"+content_id).animate({top:'0px'}, 800);						
								});
				}
	}

}
} 
// Add Default Class

function add_default_class(){
   $("#menu").removeClass();
   $("#menu").addClass('normal');
}  
// Add Menu Class 

function add_menu_class(target) {
	$(".head_btn").removeClass("lock");
	$("#"+target).addClass("lock");
} 

// Add Product Menu Color  

function chang_menu_color(color_id, target_id) {
	$("#menu").removeClass(); 
	$("#Slide-show").hide();
   	$("#cat_index").hide(); 
	$(".cat_content").hide(); 
	$("#"+target_id).fadeIn("slow"); 
	$("#menu").addClass(""+color_id); 
}     

function show_cat01() {
  chang_menu_color("cat01", "cat_01");   
	$("#fragrances_content_0").fadeIn("slow");
} 
function show_cat02() {
  chang_menu_color("cat02", "cat_02");
	$("#elecronics_content_0").fadeIn("slow");
}
function show_cat03() {
  chang_menu_color("cat03", "cat_03"); 
	$("#watchesnjewelry_content_0").fadeIn("slow");
}
function chk_page() {
		var url1 = location.href; 
		var chk_page = url1.indexOf("#"); 
		if(chk_page > 0) {
		   hide_flash();         
		} 		
}
function login_check() {		
	$.ajax({
	      url: "include/target/download.inc.php",
	      type: "POST",
	      data: ({username : $("#username").val(), password : $("#password").val()} ),
	      success: function(msg){
	         $('#download-slider').html(msg);
	      },
		  error : function(error) {
			alert("error");
		  }		
	   });
}

