// JavaScript Document

$(document).ready(function(){
	//show clock time
	ShowToday();StartTime();
	//round conner
	/*	$('.infoBoxHeading').corner("round 6px");
	$('#addcart a').corner("round 6px");
	$('#moredetail a').corner("round 6px");
	if(!$.browser.msie)// && $.browser.version < 8)
	{
		//$('.search').corner("round 12px");
	}*/
	$('#product_title').corner("round 3px");
	$('.answer_faq').corner("round 5px");
	
	//set active sub navigation
	$(".categories li").click(function () {
		var pos=$(this).index();
		var sid=$(this).children('ul').attr('id');
		//alert(pos);
		//$(this).children('a').addClass('infoBoxContents_active');
		$('#'+sid).fadeToggle("fast", "linear");
		$(this).children('a').children('span').toggleClass('plus_icon','sub_icon');
		$(this).children('a').toggleClass('lighting_nav','losing_nav');
		
	});	
	
	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);
		
	});
	
	$("#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_skype_wrap").hide();
	});
	$("#skype_block").mouseenter(function(){
		$("#support_skype_wrap").show();
		$("#support_yahoo_wrap").hide();
	});
	$("#support_yahoo_wrap").mouseleave(function(){
		$("#support_yahoo_wrap").hide();
	});
	$("#support_skype_wrap").mouseleave(function(){
		$("#support_skype_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
	$('#product_detail_left a').lightBox({ 
		imageLoading:			'images/lightbox/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
		imageBtnPrev:			'images/lightbox/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
		imageBtnNext:			'images/lightbox/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
		imageBtnClose:			'images/lightbox/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
		imageBlank:				'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');
	getLastestNewsData();
	window.setInterval(showLastestNewsAjax, 5000);
	getRandomImgProduct();
	window.setInterval(showRandomImgProductAjax, 5000);
	
});





