//=base structure effect ==========
	//select、checkbox style
	$(document).ready(function() {  
		if (jQuery.browser.msie && jQuery.browser.version<7){
		}else{
		  $("#location-select").jLook({selectHeight: '128'}); 
		  $("#search-select").jLook({selectHeight: '128'});  
		  $(".welcome-page h2").jLook();  
		  $(".product-selector").jLook({});
		  $(".product-select").jLook({}); 
		  $(".mem-select").jLook({});
		  $(".regist-select").jLook({});
		  $(".dlagreement-select").jLook({});
		  /*$(".sort").jLook({selectHeight: '128'});
		  $(".page-select").jLook({selectHeight: '127'});
		  $(".select192").jLook({selectHeight: '180'});  
		  $(".select135").jLook({selectHeight: '126'}); 
		  $(".select95").jLook({selectHeight: '125'}); 
		  $(".select115").jLook({selectHeight: '126'}); 
		  $(".select200").jLook({selectHeight: '180'}); */
  		 //alert($(".select192 ul").size());
		 //alert($(".select192 ul:eq(1) > li").size());
			$(".select192 ul").each(function(i){										 
			   if($(".select192 ul:eq("+i+") > li").size() <10)
				{
					$(".select192 .optionsWrapper:eq("+i+")").height($(".select192 ul:eq("+i+") > li").size()*20+10);
			 	$(".select192 .optionsWrapper:eq("+i+") > ul ").height($(".select192 ul:eq("+i+") > li").size()*20);
				}
 			});
			
		}
	});
	
	$(function(){
	//butterfly (background color menu switch)
	$(".butterfly-btn").toggle(
		function() {
			$(".choose-bg").css("visibility","visible");
			$(".choose-bg-wrapper").css("visibility","visible");
	  	},
		function() {
			$(".choose-bg").css("visibility","hidden");
			$(".choose-bg-wrapper").css("visibility","hidden");
	});
	
	//butterfly (background color switch)
	$("#graybg-btn").click(function(){
		$("body").removeClass('purple-bg');
		$("body").addClass('gray-bg');
	});
	$("#purplebg-btn").click(function(){
		$("body").removeClass('gray-bg');
		$("body").addClass('purple-bg');
	});

	//recently viewed switch
	$("#recently-viewed .recently-viewed-close").click(function(){
		$("#recently-viewed .recently-viewed-close").hide();
		$("#recently-viewed .recently-viewed-open").show();
		$("#recently-viewed").css({'z-index':'20'});
	});
	$("#recently-viewed .recently-viewed-open .title").click(function(){
		$("#recently-viewed .recently-viewed-open").hide()
		$("#recently-viewed .recently-viewed-close").show();
		$("#recently-viewed").css({'z-index':''});
	});
	});


//=common effect ==========
/*	$(function(){
	$('.closebox').click(function(){
	    $('.boxcontent',$(($(this).parent()).parent())).css({display:"block"});
        $('.openbox',$(this).parent()).css({display:""});
        $(this).css({display:"none"});
		$('.boxcontent',$(($(this).parent()).parent())).toggle('slow');
		$($($(this).parent()).parent()).attr('class','');
	});
	$('.openbox').click(function(){	
		$('.boxcontent',$(($(this).parent()).parent())).css({display:"none"});
		$(this).css({display:"none"});
		$('.closebox',$(this).parent()).css({display:""});
		$('.boxcontent',$(($(this).parent()).parent())).toggle('slow');
		
		if ($($($($($(this).parent()).parent()).parent()).parent()).attr('id') == 'links' || $($($($($(this).parent()).parent()).parent()).parent()).attr('id') == 'comparison'){
		    $($($(this).parent()).parent()).attr('class','now');
		}else{
		    $($($(this).parent()).parent()).attr('class','scroll');
		}
	});
	})*/

	$(function(){
	//sidenav animation
	$("#sidenav .boxtitle").hover(function(){
		$(this).find(".boxtitle-top-bg").addClass("boxtitle-top-bg-over");
		$(this).removeClass("boxtitle-top-bg");
		$(this).find(".boxtitle-body-bg").addClass("boxtitle-body-bg-over");
		$(this).removeClass("boxtitle-body-bg");
		$(this).find(".boxtitle-btm-bg").addClass("boxtitle-btm-bg-over");
		$(this).removeClass("boxtitle-btm-bg");
	},
	function(){
		$(this).find(".boxtitle-top-bg-over").addClass("boxtitle-top-bg");
		$(this).removeClass("boxtitle-top-bg-over");
		$(this).find(".boxtitle-body-bg-over").addClass("boxtitle-body-bg");
		$(this).removeClass("boxtitle-body-bg-over");
		$(this).find(".boxtitle-btm-bg-over").addClass("boxtitle-btm-bg");
		$(this).removeClass("boxtitle-btm-bg-over");
	});
	
   //detail content tab switch
	$("#detail-nav li").each(function(i){
		$(this).click(function(e){
			if ($(this).hasClass("select")){
			}else{
				$("#detail-nav .select").removeClass("select");
				$(this).addClass("select");
				$("#detail-content .contentblock").hide();
				$("#detail-content .contentblock").eq(i).fadeIn('fast');
			}
		})
	});

	//list item link
/*	$("#list ul").click(function(){								 		
		window.location=$(this).find("a").attr("href"); 
		return false;
	});	*/
	$("#list ul .list-pic,.list-name,.list-descibe").click(function(){								 		
		window.location=$(this).parent().find("a").attr("href"); 
		return false;
	});		
	
	//	alert($("#list ul .list-select").find("select").size());	
	$("#list ul .list-select").find("select").change(function()
	{
	//	alert($('#list ul .list-select option:selected').attr("id"));
	//	alert($(this).find("option:selected").attr("id"));
		window.location=$(this).find("option:selected").attr("id");
		return false;
	});

	
	//expand-all
/*	$(function(){
		$(".expand-btn").click(function(){
			$(this).css({display:"none"});
			$(".contract-btn").css({display:""});
			$(".boxcontent").slideDown();
			$(".openbox").css({display:"none"});	
			$(".closebox").css({display:""});	
		});
	});
	
	//contract-all
	$(function(){
		$(".contract-btn").click(function(){
			$(this).css({display:"none"});
			$(".expand-btn").css({display:""});
			$(".boxcontent").slideUp();
			$(".openbox").css({display:""});	
			$(".closebox").css({display:"none"});	
		});
	});*/

	});

/*	//lightbox - jqModal http://dev.iceburg.net/jquery/jqModal/
	$(function(){
		// overall
		$('.lookingreat-video-pop').jqm({modal: true,overlay:70});
		$('#article .open-lookingreat a').click(function(){
			$('.lookingreat-video-pop').jqmShow();
			setTimeout("playVideo();", 1000);
														 })
		$('.lookingreat-video-pop .closepop-btn').click(function(){stopVideo();$('.lookingreat-video-pop').jqmHide(); })

		$('.mailto-pop').jqm({modal: true,overlay:70, trigger: '.open-mailbox a'});
		$('.mailto-pop .closepop-btn').click(function(){$('.mailto-pop').jqmHide(); })
		
		$('.login-pop').jqm({modal: true,overlay:70, trigger: '.open-login a'});
		$('.login-pop .closepop-btn').click(function(){$('.login-pop').jqmHide(); })
		
		$('.forgotpw-pop').jqm({modal: true,overlay:70, trigger: '.open-forgotpw a'});
		$('.forgotpw-pop .closepop-btn').click(function(){$('.forgotpw-pop').jqmHide(); })
		
		$('.dlagreement-pop').jqm({modal: true,overlay:70, trigger: '.open-dlagreement a'});
		$('.dlagreement-pop .closepop-btn').click(function(){$('.dlagreement-pop').jqmHide(); })

		$('.pjtlamp-pop').jqm({modal: true,overlay:70, trigger: '.open-pjtlamp a'});
		$('.pjtlamp-pop .closepop-btn').click(function(){$('.pjtlamp-pop').jqmHide(); })

		$('.wheretobuy-pop').jqm({modal: true,overlay:70, trigger: '.open-wheretobuy a'});
		$('.wheretobuy-pop .closepop-btn').click(function(){$('.wheretobuy-pop').jqmHide(); })

		$('.popspic-pop').jqm({modal: true,overlay:70, trigger: '.open-popspic a'});
		$('.popspic-pop .closepop-btn').click(function(){$('.popspic-pop').jqmHide(); })
});*/


//=/products/product_list.asp ==========
	$(function(){
	//choose your product first open
	setTimeout(function(){
		$(".selector-content-close").slideDown();
		$(".selector-content-open").slideUp();
		$("#close-selector").css({display:"none"});
		$("#expand-selector").css({display:""});
		$(".intro-content-close").slideDown();
		$(".intro-content-open").slideUp();
		$("#close-intro").css({display:"none"});
		$("#expand-intro").css({display:""});
	}, 3000);	
	
	//choose your product switch
	$("#expand-selector").click(function(){
		$(".selector-content-open").css({display:""});
		$(".selector-content-close").css({display:"none"});
		$("#expand-selector").css({display:"none"});
		$("#close-selector").css({display:""});
	});
	$("#close-selector").click(function(){
		$(".selector-content-close").css({display:""});
		$(".selector-content-open").css({display:"none"});
		$("#close-selector").css({display:"none"});
		$("#expand-selector").css({display:""});
	});
	
	//=/products/demo/product_list_pjtlamp.asp ==========
	//BenQ Lamp Introduction switch
	$("#expand-intro").click(function(){
		$(".intro-content-open").css({display:""});
		$(".intro-content-close").css({display:"none"});
		$("#expand-intro").css({display:"none"});
		$("#close-intro").css({display:""});
	});
	$("#close-intro").click(function(){
		$(".intro-content-close").css({display:""});
		$(".intro-content-open").css({display:"none"});
		$("#close-intro").css({display:"none"});
		$("#expand-intro").css({display:""});
	});

		//product attribute tab switch
		$(".selector-nav-container li a").each(function(i){
			$(this).click(function(e){
				if ($(".selector-nav-container li ").eq(i).hasClass("select")){
				}else{
					$(".selector-nav-container li ").removeClass("select");
					$(".selector-nav-container li ").eq(i).addClass("select");
					$(".selector-content-item p").hide();
					$(".selector-content-item p").eq(i).fadeIn("fast");
				}
			})
		});
	
	//add to compare
	$("#article .product-list .product-select a").each(function(){
		$(this).click(function(){
			if($(this).parent().hasClass('add-to-compare')){
				$(this).parent().removeClass('add-to-compare');			
			}else{
				$(this).parent().addClass('add-to-compare');			
			}
		});
	});
	
	//show product detail(mouse over)
	$(".product-list .product-pic").each(function(){
		var _this = $(this);
		var _thisdetail = $(this).parent().parent().parent().parent().find(".float-product-detail");
		_this.hover(function(){
			_thisdetail.css("display","block");
		}, function(){
			_thisdetail.css("display","none");
		});
		_thisdetail.hover(function(){
			_thisdetail.css("display","block");
		}, function(){
			_thisdetail.css("display","none");
		});
	});
	
	
	});
	
	//go to url
	function MM_goToURL() { //v3.0
	   var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	   for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}

//=/products/product_detail.asp ==========
	$(function(){
	//vedio demo switch
	$(".vediodemo-closebtn").click(function(){
		$(".vediodemo-closebtn").css({display:"none"});
		$(".vediodemo-openbtn").css({display:""});
		$(".vediodemo-flv").fadeOut();
	});
	$(".vediodemo-openbtn").click(function(){
		$(".vediodemo-closebtn").css({display:""});
		$(".vediodemo-openbtn").css({display:"none"});
		$(".vediodemo-flv").fadeIn();
	});
	});


//=/about/hr.asp ==========
	$(function(){	   
	//hr detail content switch
	$(".job .openbox").each(function(){
		var _thisdetail = $(this).parent().parent().parent().parent().parent().parent().find(".hr-jobdetail");
		$(this).click(function(){
			_thisdetail.css("display","block");
		});	
	});
	$(".job .closebox").each(function(){
		var _thisdetail = $(this).parent().parent().parent().parent().parent().parent().find(".hr-jobdetail");
		$(this).click(function(){
			_thisdetail.css("display","none");
		});	
	});
	});


//=/products/comparison.asp ==========
/*	function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
	}*/
	
	$(function(){
	//set column equal height
	equalHeight($(".compare-list .product-pic"));
	equalHeight($(".compare-list .product-name"));
	equalHeight($(".compare-list .platform"));
	equalHeight($(".compare-list .operating-sys"));
	equalHeight($(".compare-list .chipset"));
	equalHeight($(".compare-list .graphics"));
	equalHeight($(".compare-list .memory"));
	equalHeight($(".compare-list .hdd"));
	equalHeight($(".compare-list .drive"));
	equalHeight($(".compare-list .display"));
	equalHeight($(".compare-list .webcam"));
	equalHeight($(".compare-list .battery"));
	
	//init column height
/*	 var atscccc =  jQuery.makeArray($('ul.compare-product:first li'));
	 var liClassName = new Array();
	 for (var i = 0; i <atscccc.length; i ++){
	 	var eKey = $(atscccc[i]).attr('class');
	    var eValue = $(atscccc[i]).css('height');
	    liClassName[eKey] = eValue;
	 }
	 $('.compare-list span').click(function(){	   
	    var liid = $($(this).parent()).attr('class');
	    if ($(this).attr('class').toLowerCase()=='open'){
	        $('ul.compare-product li.' + liid).css('height',liClassName[liid]);
	        $('ul.compare-product-btn li.' + liid).css('height',liClassName[liid]);
	        $('.compare-product .'+liid + ' .speci-content').css('display','');
	        $(this).attr('class','close');
	        $(this).html('close');
	    }else{
	        $('ul.compare-product .' + liid).attr('style','');
	        $('ul.compare-product-btn li.' + liid).attr('style','');
	        $('.compare-product .'+liid + ' .speci-content').css('display','none');
	        $(this).attr('class','open');
	        $(this).html('open');
	    }
	});*/
	 
	//close one column product 
	$(".compare-del-btn").click(function(){
		$(this).parents(".compare-product").animate({ opacity: 'hide' }, "slow");
	});
	});

//===Relayout==== 0615 Productline Menu Slide
	//Productline Menu Slide
	function wbSlide (targetBox, showAtOnce, animateSpeed){
	$(document).ready(function(){
		var _this = $(targetBox);
		var itemNum = $('.sidenav2-Item>div', _this).length;
		var itemWidth = $('.sidenav2-Item>div', _this).width();
		var slideWidth = itemNum * (itemWidth + 56);
		var maxId =-( Math.ceil(itemNum / showAtOnce)) + 1;
		var rowSlide = $('.sidenav2-Panel').outerWidth(true);
		$('.sidenav2-Item', _this).css({width : slideWidth + "px"});
		var cId = 0;
		$('.sidenav2-Left>a', _this).click(function () {
			cId ++;
			sliding (cId);
		});
		$('.sidenav2-Right>a', _this).click(function () {
			cId --;
			sliding (cId);
		});
		function sliding (cId){
			if(cId == maxId) {$('.sidenav2-Right>a', _this).hide();};
			if(cId == 0) {$('.sidenav2-Left>a', _this).hide();};
			//var marginNum = itemWidth * cId;
			var marginNum = rowSlide * cId;
			$(".sidenav2-Item", _this).animate( { marginLeft: marginNum + "px" }, {duration:animateSpeed} );
			if(cId > maxId) {$('.sidenav2-Right>a', _this).show();};
			if(cId < 0) {$('.sidenav2-Left>a', _this).show();}
		};
		if (itemNum <= showAtOnce){
			$('.sidenav2-Left>a', _this).hide();
			$('.sidenav2-Right>a', _this).hide();
			$('.sidenav2-Item').css({margin:'0 auto'});
		} else {
			$('.sidenav2-Left>a', _this).hide();
		};
	});
	};
	wbSlide('.sidenav2', 6, 1000);
	
  	//Productline Menu Picture Hover Effect
	function picHover (picBox){
	$(document).ready(function(){
		var _thisPic=$('a',picBox);
		$('img',_thisPic).css('opacity',0.33);
		_thisPic.each(function(){
			$(this).hover(function(){
			$(this).parent('div').css('position','relative');
			$('img',this).css('opacity',1);
				}, function(){
			$(this).parent('div').css('position','');
			$('img',this).css('opacity',0.33);
		});
	});
	});
	};
	picHover('.sidenav2-Item');


