$(document).keypress(function(event){
 
	var keycode = (event.keyCode ? event.keyCode : event.which);
	if(keycode == '13'){
		return false;	
	}
 
});
$(document).ready(function(){
	$("#landing_logo").fadeIn(2000);
	$("#landing_lang").fadeIn(4000);
	$(".sub_nav_holder").hide();
	$(".store_content").hide();
	$("#store_map").show();
	$(".press_result").hide();
	$("#press_all_result").show();
	$(".product_container").hide();
	$("#product_sub_cat_container").show();
	$(".sub_breadcrumb").hide();
	$(".news_info").hide();
	$("#level2").hide();
	$("#new_list").show();
	$(".more").hide();
	
	$("#style_level2").hide();
	
	$('#dock2').Fisheye({
			maxWidth: 70,
			items: 'a',
			container: '.dock-container2',
			itemWidth: 65,
			proximity: 80,
			alignment : 'left',
			valign: 'bottom',
			halign : 'center'
		});			
			$(".button02").mouseover(function(){
				$(".sub_nav_holder").hide();
				$("#SubNav-holder1").show();
			});
			
			$(".button03").mouseover(function(){
					$(".sub_nav_holder").hide();
					$("#SubNav-holder2").show();				
			});
			
			$(".button04").mouseover(function(){
					$(".sub_nav_holder").hide();
					$("#SubNav-holder3").show();
			});
			
			$('#slide_holder').cycle({
					fx:     'fade',				
					speed:   1500,
					timeout: 5000						 			
			});
	
});

function movesubsubmenu(id, lang) {
	var product_type = $("#call_back_sub_sub_menu").val();
	var selected_sub_sub_menu_item = $("#selected_sub_sub_menu_item").val();
	$("#subsubbtn1").removeClass();
	$("#subsubbtn2").removeClass();
	if(id == product_type) {
	$("#subsubbtn"+selected_sub_sub_menu_item).addClass("lock");
	}
	$("#level2").show();
	if(id != 1) {
		var top = 18 * (id - 1);
		$("#level2").css("top", top); 
	} else {
		$("#level2").css("top", 0);
	}

	$('#subsubbtn1').click(function() {
		var new_path = site_path+'index.php?target=product&mode='+id+'&type=1&lang='+lang;

		location.href = new_path;
	});
	$('#subsubbtn2').click(function() {
		var new_path1 = site_path+'index.php?target=product&mode='+sub_sub_id+'&type=2&lang='+lang;

		location.href = new_path1;
	});
}
function showSubSubMenu() {
	$("#style_level2").show();
}
function hideSubSubMenu() {
	$("#style_level2").hide();
}

function subsubmenuback(){
	var sub_sub_id = $("#call_back_sub_sub_menu").val();
	var selected = $("#selected_sub_sub_menu_item").val();

	if(sub_sub_id >= 1) {
		var sub_sub_pos = 18 * (sub_sub_id - 1);
		
	} else {		
		var sub_sub_pos = 0;
			$("#level2").hide();
	}
	$("#level2").css("top", sub_sub_pos);
	 
}
function getLockValue(value){
	var id = $("#sub_menu_lock").val();
	var sub_sub_id = $("#call_back_sub_sub_menu").val();
	if(sub_sub_id > 1) {
		var sub_sub_pos = 18 * (sub_sub_id - 1);
	} else {
		var sub_sub_pos = 0;
	}
	$("#level2").css("top", sub_sub_pos);

	var lang = $("#lang").val();
	if(id == 0) {
		if(value == 1) {
			$("#SubNav-holder"+value).show();
			if(sub_sub_id >= 1) {		
			$("#level2").show();						
			$('#subsubbtn1').click(function() {
				var new_path = site_path+'index.php?target=product&mode='+sub_sub_id+'&type=1&lang='+lang;

				location.href = new_path;
			});
			$('#subsubbtn2').click(function() {
				var new_path1 = site_path+'index.php?target=product&mode='+sub_sub_id+'&type=2&lang='+lang;

				location.href = new_path1;
			});
			} else {
			$("#level2").hide();
			}
		} else {
			$("#SubNav-holder"+value).show();
		}
	} else {
		if(id == 1) {
			$("#SubNav-holder"+id).show();
			if(sub_sub_id >= 1) {		
			$("#level2").show();			 
				$('#subsubbtn1').click(function() {
					var new_path = site_path+'index.php?target=product&mode='+id+'&type=1&lang='+lang;
					location.href = new_path;
				});
				$('#subsubbtn2').click(function() {
					var new_path1 = site_path+'index.php?target=product&mode='+id+'&type=2&lang='+lang;
					location.href = new_path1;
				});
				} else {
				$("#level2").hide();	
				}
		} else {
			$("#SubNav-holder"+id).show();	
		}
	} 
}

function setLockValue(id) {
	$("#sub_menu_lock").val(id);
}
function setsubsubvalue(id) {
	$("#call_back_sub_sub_menu").val(id);
}
function showLandingLogo(){
	$("#landing_logo").fadeIn("fast");
}
function hideSubMenu(){
		$(".sub_nav_holder").hide();	
	subsubmenuback();
}
function change_sc() {
	var current_path = location.href;
	var new_path = current_path.replace('lang=en', 'lang=sc');
	location.href=new_path;
}
function change_en() {
	var current_path = location.href;
	var new_path = current_path.replace('lang=sc', 'lang=en');
	location.href=new_path;
}
function show_hide_map() {
	$(".store_content").fadeOut();
	$("#store_map").fadeIn();
}
function flash_store_result(city_id,lang_id) {

	flash_return_store_result(city_id,lang_id);
}
function flash_return_store_result(city_id,lang_id) {
	
	$.ajax({
		   	  url: site_path+"include/target/store_search.php",
		      type: "POST",
		      data: ({store_type : 5, city : city_id, lang:lang_id} ),
		      success: function(msg){
		         $(".store_content").hide();
				 $("#store_detail").fadeIn();
				 $("#abc").html(msg);
		      },
			  error : function(error) {
				alert("error");
			  }	   	
	 });
}
function return_store_result() {
	var radios = document.getElementsByName("store");
	for (var i=0; i < radios.length; i++) {
		if(radios[i].checked){
			var type = radios[i].id;
		}
	}
	$.ajax({
		   	  url: site_path+"include/target/store_search.php",
		      type: "POST",
		      data: ({store_type : type, city : $("#city").val(), lang:$("#lang").val(), province : $("#province").val()} ),
		      success: function(msg){
		         $(".store_content").hide();
				 $("#store_detail").fadeIn();
				 $("#abc").html(msg);
		      },
			  error : function(error) {
				alert("error");
			  }	   	
	 });
}
function return_press_result() {
	if($("#order").val() == "null"){
		$(".press_result").hide();
		$("#press_all_result").fadeIn();
	} else {
	$.ajax({
		   	  url: site_path+"include/target/press_search.php",
		      type: "POST",
		      data: ({month : $("#order").val(), lang:$("#lang").val()} ),
		      success: function(msg){
		         $(".press_result").hide();
				 $("#press_select_result").fadeIn();
				 $("#press_select_result").html(msg);
		      },
			  error : function(error) {
				alert("error");
			  }	   	
	 });
	}
}
function return_image(id) {
	$.ajax({
		   	  url: site_path+"include/target/get_image.php",
		      type: "POST",
		      data: ({image_id : id} ),
		      success: function(msg){
				 $("#gallery").fadeIn();
				 $("#gallery").html(msg);
		      },
			  error : function(error) {
				alert("error");
			  }	   	
	 });
	
}
function return_video(id) {
	$.ajax({
		   	  url: site_path+"include/target/get_video.php",
		      type: "POST",
		      data: ({video_id : id, lang:$("#lang").val()} ),
		      success: function(msg){
				 $("#video").fadeIn();
				 $("#video").html(msg);
		      },
			  error : function(error) {
				alert("error");
			  }	   	
	 });
	
}

function return_product(id, id1, id2) {
	$.ajax({
		   	  url: site_path+"include/target/get_product.php",
		      type: "POST",
		      data: ({sub_catalog_id : id, lang:$("#lang").val(), cat_id: id1, type_id: id2} ),
		      success: function(msg){
				$("#content").show();			
				 $("#content").html(msg);
		      },
			  error : function(error) {
				alert("error");
			  }	   	
	 });
	
}
function return_search_product(id, id1, id2) {
	$.ajax({
		   	  url: site_path+"include/target/get_search_product.php",
		      type: "POST",
		      data: ({sub_catalog_id : id, lang:$("#lang").val(), cat_id: id1, type_id: id2} ),
		      success: function(msg){
				$("#content").show();			
				 $("#content").html(msg);
		      },
			  error : function(error) {
				alert("error");
			  }	   	
	 });
	
}
function return_news(id) {
	$.ajax({
		   	  url: site_path+"include/target/get_news.php",
		      type: "POST",
		      data: ({news_id : id, lang:$("#lang").val()} ),
		      success: function(msg){
				 $(".news-item").hide();
				 $("#page_number").hide();
				 $("#news_detail").show();		
				 $("#news_detail").html(msg);
		      },
			  error : function(error) {
				alert("error");
			  }	   	
	 });
	
}
function show_month_more(id) {
	$(".more").hide();
	$("#month_more_"+id).show();
}
function show_more(id) {
	$(".more").hide();
	$("#more_"+id).show();
}
function hide_more() {
	$(".more").hide();
}
function hide_news_detail() {
	$(".news_info").hide();
	$("#new_list").show();
	 $(".news-item").show();
	 $("#page_number").show();	 
}

