// JavaScript Document

$(document).ready(function(){

		
	/* set menu */
	$('.sub_hot_flower').corner("round 5px");
	$('.promotion').corner("round 7px");
	$('.payment_wrap').corner("round 7px");
	$(' #sub_hot_flower_img img').corner("round top 7px");
	
	$(".menu_first").mouseenter(function(){
		$(".menu_third").css("position","relative");
		$(".menu_third").css("z-index","-2");
	});
	$(".menu_first").mouseleave(function(){
		$(".menu_third").css("z-index","0");
	});
	/* set menu */		
	var isSelected=getCookie("menu");
	

	$("#menu_left_top").mouseenter(function()
	{
		$("#menu_sub_left").show();
	});
	$("#menu_sub_left").mouseleave(function()
	{
		$("#menu_sub_left").hide();
	});
	
	$(".menu_bar").mouseenter(function()
	{
		var id=$(this).attr('id');
		$(".menu_bar ul").css("display","none");
		$("#"+id+" ul").css("display","block");
	});
	$(".menu_bar ul").mouseleave(function()
	{
		$(".menu_bar ul").css("display","none");
	});

	$("body").click(function()
	{
		$("#menu_sub_left").hide();
		$(".menu_bar ul").css("display","none");
	});

	/* main left */
	$(".product_filter_list ul li").click(function()
	{
		var current_pos=$(this).index();
		$(".product_filter_list ul li ul").removeClass("active");
		$(this).children("ul").addClass("active");
	});
	
	/*exp & video control */
	var set_pos=0;
	$("#promotion_nav_back,#promotion_nav_next").click(function()
	{
		var control_id=$(this).index();
		control_id==0 ? set_pos=-1 : set_pos=1;
		//alert(control_id)
		play_hot_flower();		
		window.clearInterval(play_hot_flower);
		
	});
	function play_hot_flower()
	{

		var content_wrap="promotion";
		var content_active="promotion_active";
		var number_content=$("#"+content_wrap+" ul li").length;		
		var cur_pos=$("#"+content_wrap+" ul li."+content_active).index();
		//(set_pos==0) ? set_pos=1 : set_pos=0;
		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) : '';
		
		if(number_content<=1) window.clearInterval(timer_play_adv_banner);
		
		$("#"+content_wrap+" ul li").removeClass(content_active);
		$("#"+content_wrap+" ul li").eq(cur_pos).addClass(content_active);
		
	}
	
	//get payment medthod
	$("#payment_direct,#payment_baokim,#payment_nganluong").click(function(){
		var getval=$(this).attr('value');
		setCookie('payment_medthod',getval,3600);
		//alert(getCookie('payment_medthod'));
	});
	
	
	//clear text search
	$("#input_search").focus(function(){
		this.value='';
	});
	
	
	//load image product silder
	//$('ul#basic_config').carouFredSel();
	$('#carousel').carouFredSel({
		auto: true,
		prev: "#prev",
		next: "#next",
		items               : 6,
		direction           : "left",
		scroll : {
			items           : 1,
			effect          : "easeOutBounce",
			duration        : 500,                        
			pauseOnHover    : false
		}  				
				
	});	
	
	//lightbox
	function show_lightbox(show_lighbox_id,content_lighbox)
	{
		$(show_lighbox_id).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)
			containerBorderSize:	10,
			fixedNavigation:		true,		// (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:					'/',
			content_image:			content_lighbox
		});	
		
	}
	
	//main content popup img
	//load lightbox 
	//var timer_play_main_product=window.setInterval(play_main_product,5000);
	var play_hot_flower_id=document.getElementById('promotion');
	if(play_hot_flower_id !=null)
	{
		set_pos=1;
		var timer_play_hot_flower=window.setInterval(play_hot_flower,3000);
	}else
		window.clearInterval(timer_play_hot_flower);

});
	




