/*fix outline*/
$(function(){$('a').focus(function(){this.blur();})});

//搭建js与flash互通的环境
function getFlashMovie(movieName) {
 var e=document.getElementById(movieName); 
 return (navigator.appName.indexOf("Microsoft") != -1)?e:e.getElementsByTagName("embed")[0];  
}


$(function(){
	$("ul.menu li").hover(function(){
								   
								   if(!$("ul.menu li dl").is(":animated"))
								   {
								   	$(this).addClass("on");													  
									$(this).find("dl").slideDown(130);									
									$(this).sliblings().removeClass("on");
									$(this).sliblings().find("dl").slideUp(0);
								   }
									}, 
									function(){
										$(this).removeClass("on");$(this).find("dl").slideUp(0);
	});
	
	$(".b-box-2 .title .fr img,.upproject").click(function(){
											location.href = 'product_projects.php';		 
										});
	//$("ul.menu li").hover(function(){$(this).find("dl").css({"display":"block"});}, function(){$(this).find("dl").slideUp(200);});	
});

$(function(){
	//alert($("#leftmenu .on").html())	
	if($("#leftmenu .on").prev().hasClass("nb"))
	{
		$("#leftmenu .on").prev().prev().css("border-bottom","none");
		if($.browser.msie && $.browser.version == "6.0")
		{
			$("#leftmenu .on").prev().prev().prev().css({"border-bottom":"none"});
		}
	}
	else
	{
		$("#leftmenu .on").prev().css("border-bottom","none");
		if($.browser.msie && $.browser.version == "6.0")
		{
			$("#leftmenu .on").prev().prev().css({"border-bottom":"none"});
		}
	}
	
});

$(function(){
	/*$(".press_year li").click(function(){
		$(this).addClass("on").siblings().removeClass("on");
		var iIndex = $(this).index();
		$("#presslist ul").eq(iIndex).fadeIn(0).siblings().fadeOut(0);								  
	});*/

	$("#academy_faq_list li").find(".actitle").toggle(function(){
		 $(this).addClass("on");
		 $(this).next().slideDown(300);
		 $(this).parent().siblings().find(".actitle").removeClass("on");
		 $(this).parent().siblings().find(".acct").slideUp(0);
	},function(){
		$(this).removeClass("on");
		 $(this).next().slideUp(300);	
	});
	
	$("#academy_video_control li").click(function(){
		var iIndex = $(this).index();
		$(this).addClass("on").siblings().removeClass("on");
		$("#ac_video_list ul").eq(iIndex).fadeIn(0).siblings().fadeOut(0);
	});
	
	
	$(".ulchk li").click(function(){
		var iIndex = $(this).index();
		$(this).addClass("on").siblings().removeClass("on");
		$(".ulchkdiv>div").eq(iIndex).fadeIn(0).siblings().fadeOut(0);
	});
	
	
	$(".jfck>li").click(function(){
		var iIndex = $(this).index();
		$(this).addClass("on").siblings().removeClass("on");
		$(".jfck>div").eq(iIndex).fadeIn(0).siblings().fadeOut(0);
	});
	
	
	$(".chklist2>li").click(function(){
		var iIndex = $(this).index();
		$(this).addClass("on").siblings().removeClass("on");
		$(".chklist2>div").eq(iIndex).fadeIn(0).siblings().fadeOut(0);
	});
	
	
	$(".drop_down_list").click(function(){
		
		if($(this).next("ul").hasClass("showcosts"))
		{	
			
			var rNumber = /\d{11}/;
			if($(this).parents("tr.tofindp").find(".priceshow").attr("oprice")==null)
			{
				$(this).parents("tr.tofindp").find(".priceshow").text("choose device first");
				return;
			}
			if(!rNumber.test($(this).parents("tr.tofindp").find(".serialnum").val()))
			{
				$(this).parents("tr.tofindp").find(".priceshow").text("Wrong Series No.");
				return;
			}
			
			var ste = $(this).parents("tr.tofindp").find(".priceshow").attr("oprice").split(",");
			
		}
	
		
		var obj = $(this);
		
		$(this).next("ul").slideDown(300);
		$(this).next("ul").hover(function(){$(this).css("display","block");},function(){$(this).slideUp(200);});
		if($(this).next("ul").hasClass("showcosts"))
		{
			if($(this).parents("tr.tofindp").find(".priceshow").attr("oprice")=="182,319")
			{
					$(this).find("li").eq(2).hide();
					$(this).find("li").eq(3).hide();
			}
		}
		
		
		$(this).next("ul").find("li").click(function(){
			
			
							
			var iIndex = $(this).index();
			$("#"+$(this).parent().attr("comment")).val($(this).attr("rel"));	
			obj.text($(this).attr("rel"));
			//$(this).parents("tr.tofindp").find(".priceshow").text($(this).attr("price"));	
			$(this).parent().slideUp(200);
			var osp = $(this).parents("tr.tofindp").find(".priceshow");	
			
			if(typeof $(this).parents("tr.tofindp").find(".priceshow").attr("oprice") !="undefined" && $(this).parents("tr.tofindp").find(".priceshow").attr("oprice") !="182,319")
			{
				$(this).parents("tr.tofindp").find(".showcosts").find("li").css("display","block");
			}
	
			if($(this).parents().hasClass("deviceul"))
			{
				osp.attr("oprice",$(this).attr("price"));
				if(typeof osp.attr("pindex")!="undefined")
				{
					$(this).parents("tr.tofindp").find(".priceshow").text($(this).attr("price").split(",")[osp.attr("pindex")]);
				}
				if($(this).attr("price")=="182,319")
				{					
					$(this).parents("tr.tofindp").find(".showcosts").find("li").eq(0).hide();	
					$(this).parents("tr.tofindp").find(".showcosts").find("li").eq(1).hide();	
					$(this).parents("tr.tofindp").find(".priceshow").text(182);					
				}
			}
			
			if($(this).parents().hasClass("showcosts"))
			{
				osp.attr("pindex",iIndex);
				
				
				if(typeof $(this).parents("tr.tofindp").find(".priceshow").attr("oprice")!="undefined")
				{
					if(typeof osp.attr("pindex")!="undefined")
					{
						$(this).parents("tr.tofindp").find(".priceshow").text($(this).parents("tr.tofindp").find(".priceshow").attr("oprice").split(",")[osp.attr("pindex")]);					
					}
				}
				
				
			}
			
			
			if(typeof ste != "undefined"){
				$(this).parents("tr.tofindp").find(".priceshow").text(ste[iIndex]);
			}
			
			
			$(".allprice").text(function(){
					var temp = 0;
					for(var i=0;i<$(".tofindp .priceshow").length;i++)
					{
						var nowprice = $(".tofindp .priceshow").eq(i).text();
						if(nowprice=="")
						{
							nowprice = 0;
						}
						temp = temp + parseInt(nowprice);	
					}
					temp = temp+temp/10;
					if(String(temp)=="NaN")
					{
						return 0;	
					}
					return temp;
				
			});	
		});
		
		/*setTimeout(function(){
							alert($(this).attr("comment"));
							alert($("#"+$(this).attr("comment")).val());
					$(this).find("li[rel='"+$("#"+$(this).attr("comment")).val()+"']").siblings().slideUp();						
					},2*1000);*/
	});	
	
	
	
	
	
	$(".check_list dd").click(function(){
		$(this).addClass("on").siblings().removeClass("on");
		var rel = $(this).attr("rel");
		$("#"+$(this).parent().attr("comment")).val(rel);
	});
	
	
	$("#leftmenu li[rel='0']").mouseover(function(){	
											  	
		
		
		
		
		if($.browser.msie && $.browser.version == "6.0"){
			$("#leftmenu li:last").css("background","none");
			if($(this).next().next().next().hasClass("nb")){
				$(this).next().next().next().slideDown(100).siblings("li.nb").slideUp(100);			
			}
			else
			{
				$("#leftmenu li.nb").slideUp(100);
			}		
		}
		else
		{
			if($(this).next().hasClass("nb")){
				$(this).next().slideDown(100).siblings("li.nb").slideUp(100);			
			}
			else
			{
				$("#leftmenu li.nb").slideUp(100);
			}	
		}									  
		
		
		
		
		$(this).addClass("on").siblings().removeClass("on");
		
		$("#leftmenu li:eq(0)").css("border-bottom","1px solid #D8D8D8");
		$("#leftmenu li[rel='0']").css("border-bottom","1px solid #D8D8D8");
		
		if($(this).prev().hasClass("nb"))
		{			
			if($.browser.msie && $.browser.version == "6.0"){
				$(this).prev().prev().prev().prev().css("border-bottom","0");
			}else
			{
				$(this).prev().prev().css("border-bottom","none");
			}
		}
		else
		{			
			
			if($.browser.msie && $.browser.version == "6.0"){
					
				
					$(this).prev().css("border-bottom","none");
			}
			else
			{
				$(this).prev().css("border-bottom","none");	
			}
		}
		
		$(this).css("border-bottom","none");		
	});
	
});

/*
	f1
*/

(function($)
{
	$.extend({
		fnCheckForm:function(o){
				var rPhone = /^0*(130|131|132|133|134|135|136|137|138|139|150|153|159|152|182|187|189|188|147)\d{8}$/;
				var rSpace =/^\[ \t]*$/;
				var rNumber = /\d/;
				var rEmail =/^[a-zA-Z0-9-_]+@[a-zA-Z0-9-_]+.[a-zA-Z0-9-_.]+$/;
				var rOwnerNumber = /^\d{5}$/;
				
				$(o.out).find("input").focus(function(){ $(this).removeClass("on") });
				$(".drop_down_list").mouseover(function(){ $(this).removeClass("on") });
				$(o.comment).focus(function(){ $(this).removeClass("on") });
				
				$(o.b).click(function(){
					if(v(o.title) ==" " )
					{
						$(".drop_down_list").addClass("on");
						return false;	
					}
					
					if(v(o.firstname)=="")
					{
						$(o.firstname).addClass("on");
						return false;	
					}
					
					if(v(o.lastname)=="")
					{
						$(o.lastname).addClass("on");
						return false;	
					}
					
					if(!rEmail.test(v(o.email)))
					{
						$(o.email).addClass("on");
						return false;	
					}
					
					if(v(o.comment)=="")
					{
						$(o.comment).addClass("on");
						return false;	
					}
					
					if(v(o.confirmation)=="")
					{
						$(o.confirmation).addClass("on");
						return false;	
					}
					$.ajax({type:'POST',url:o.url,
						   data:{title:v(o.title),firstname:v(o.firstname),lastname:v(o.lastname),companyname:v(o.companyname),
						   	     street:v(o.street),postalcode:v(o.postalcode),city:v(o.city),phone:v(o.phone),
								 fax:v(o.fax),email:v(o.email),comment:v(o.comment),confirmation:v(o.confirmation)
						        },
						   success:function(re){
								  if(re=="Wrong1")
								  {
										$(o.confirmation).addClass("on");  
								  }
								  else if(re=="Wrong")
								  {
									  alert("failed!");
								  }
								  else
								  { alert("success!"); }
								}
							});
					
				});
				
				
				function v(s)
				{
					return $(s).val();	
				}
				
			}		
	});	
})(jQuery);




(function($)
{
	$.extend({
		fnCheckForm2:function(o){
				var rPhone = /^0*(130|131|132|133|134|135|136|137|138|139|150|153|159|152|182|187|189|188|147)\d{8}$/;
				var rSpace =/^\[ \t]*$/;
				var rNumber = /\d/;
				var rEmail =/^[a-zA-Z0-9-_]+@[a-zA-Z0-9-_]+.[a-zA-Z0-9-_.]+$/;
				var rOwnerNumber = /^\d{5}$/;
				
				var $oList = $(o.o).find("input[rule!='']");				
				
				$(o.b).click(function(){
										
					if(v(o.name)=="")
					{
						return false;	
					}
					
					if(v(o.firstname)=="")
					{
						return false;	
					}
					
					if(v(o.companyname)=="")
					{
						return false;	
					}
					
					if(!rEmail.test(v(o.email)))
					{
						return false;	
					}
					
					if(v(o.comment)=="")
					{
						return false;	
					}
					
					if(v(o.confirmation)=="")
					{
						return false;	
					}
					$.ajax({type:'POST',url:'',
						   data:{country:v(o.country),name:v(o.name),firstname:v(o.firstname),companyname:v(o.companyname),
						   	     street:v(o.street),postalcode:v(o.postalcode),city:v(o.city),phone:v(o.phone),
								 fax:v(o.fax),email:v(o.email),comment:v(o.comment),confirmation:v(o.confirmation)
						        },
						   success:function(result){
								alert(result);
								}
							});
					
				});
				
				
				function v(s)
				{
					return $(s).val();	
				}
				
			}		
	});	
})(jQuery);




(function($)
{
	$.extend({
		fnCheckForm3:function(o){
				var rPhone = /^0*(130|131|132|133|134|135|136|137|138|139|150|153|159|152|182|187|189|188|147)\d{8}$/;
				var rSpace =/^\[ \t]*$/;
				var rNumber = /\d/;
				var rEmail =/^[a-zA-Z0-9-_]+@[a-zA-Z0-9-_]+.[a-zA-Z0-9-_.]+$/;
				var rOwnerNumber = /^\d{5}$/;
				var rSn = /^\d{10}$/;
				
				var $oList = $(o.o).find("input[rule!='']");				
				
				$(o.out).find("input").focus(function(){ $(this).removeClass("on") });
				$(o.comment).focus(function(){ $(this).removeClass("on") });
				
				
				$(o.b).click(function(){
										
					if(v(o.snver)=="")
					{
						$(o.snver).addClass("on");
						return false;	
					}
					
					if(!rSn.test(v(o.snver)))
					{
						$(o.snver).addClass("on");
						return false;	
					}
					
					if(v(o.pdate)=="")
					{
						$(o.pdate).addClass("on");
						return false;	
					}
					
					if(v(o.idate)=="")
					{
						$(o.idate).addClass("on");
						return false;	
					}
					
					if(v(o.phone)=="")
					{
						$(o.phone).addClass("on");
						return false;	
					}
					
					if(!rNumber.test(v(o.phone)))
					{
						$(o.phone).addClass("on");
						return false;	
					}
					
					if(!rEmail.test(v(o.email)))
					{
						$(o.email).addClass("on");
						return false;	
					}
					
					
					if(v(o.country)=="")
					{
						$(o.country).addClass("on");
						return false;	
					}
					
					if(v(o.address)=="")
					{
						$(o.address).addClass("on");
						return false;	
					}
					
					if(v(o.comment)=="")
					{
						$(o.comment).addClass("on");
						return false;	
					}
					
					$.ajax({type:'POST',url:o.url,
						   data:{snver:v(o.snver),pdate:v(o.pdate),idate:v(o.idate),phone:v(o.phone),
						   	     email:v(o.email),country:v(o.country),address:v(o.address),comment:v(o.comment)
						        },
						   success:function(re){
								if(re=="Wrong")
								  {
									  alert("failed!");
								  }
								  else
								  { alert("success!"); }
								}
							});
					
				});
				
				
				function v(s)
				{
					return $(s).val();	
				}
				
			}		
	});	
})(jQuery);







(function($)
{
	$.extend({
		fnUpPhoto:function(id){
			$.ajax({type:'POST',url:'project_list.php',data:[pid=id],success:function(data){
				$('#showpro').html(data);
				var lLength = $('.upbox li').length;
				var i = 0;
				var $oMove = $(".upbox ul");
				var bF = false;
				var bS = false;
				var bBool = true;
				$.lightBox(".upbox");
				$(".upbox .left_arrow").click(function(){
					if(!$oMove.is(":animated"))
					{	
						if(bBool)
						{
							i--;
							bBool = false;
						}
						if(bF)
						{
							i= i +2;
							bS = true;
						}
						 if(i>-1 && i < lLength)
						 {
							 $oMove.animate({"margin-left":-i*647},500);
							 i--;
						 }
						 else
						 {
						 	i=lLength-1;
							$oMove.animate({"margin-left":-i*647},500);
							i--;
						 }
					}
				});
				$(".upbox .right_arrow").click(function(){
					if(!$oMove.is(":animated"))
					{
						if(bBool)
						{
							i++;
							bBool = false;
						}
						if(bS)
						{
							i= i -2;
							bF = true;
						}
						 if(i<lLength && i>-1)
						 {
							 $oMove.animate({"margin-left":-i*647},500);	
							 i++; 
						 }
						 else
						 {
						 	i = 0;
							$oMove.animate({"margin-left":-i*647},500);
							i++;
						 }
					}
				});
			}});	
		}		
	});	
})(jQuery);













(function($)
{
	$.extend({
		PicShow:function(o){
			var $box = $(o.id);
			var $list = $box.children("div");
			var iLength = $list.length;
			
			var iIndex = 0;
			var $lbtn = $(o.lbtn);
			var $rbtn = $(o.rbtn);
			var flag = false;
			
			function fnMain(d)
			{
				if(d==1)
				{
					$list.css("z-index","22");					
					if(flag){				
						$list.eq(0).fadeOut(400,function(){ $(this).appendTo($box); Rs();});						
					}			
					
					Rs();
					flag = true;
					/*iIndex++;	
					if(iIndex > iLength)
					{
						iIndex =0;	
					}*/
				}else
				{					
					/*$list.css("z-index","22");					
					if(flag){				
						$list.eq(iLength).fadeOut(400,function(){ $(this).prependTo($box); Ls();});						
					}*/			
					
					Ls();
					flag = true;
				}
			};
			
			
			function Rs()
			{				
					$list = $box.children("div");
					$list.eq(1).css("z-index","23");
					$list.eq(iIndex).animate({left:0,top:45,width:340},{duration:500,complete:function(){	Reflection.remove($box.children("div:first").find("img")[0]);}});
					$list.eq(iIndex).find("img").animate({width:340,left:0},500,function(){});
					$list.eq(iIndex).find("img").attr("width","340");	
					
					$list.eq(iIndex+1).animate({left:160,top:0,'z-index':23},500);
					$list.eq(iIndex+1).find("img").parent().width(420);				
					$list.eq(iIndex+1).find("img").animate({width:420,top:0},{duration:500,complete:function(){Reflection.add(this, { height: 1/7, opacity: 1/6 });}});	
					$list.eq(iIndex+1).find("img").attr("width","420");	
					$list.eq(iIndex+2).css({left:480,top:45}).fadeIn(100);	
			}
			
			function Ls()
			{				
					$list = $box.children("div");
					$list.eq(1).css("z-index","23");
					$list.eq(iIndex).animate({left:0,top:45,width:340},{duration:500,complete:function(){	Reflection.remove($box.children("div:first").find("img")[0]);}});
					$list.eq(iIndex).find("img").animate({width:340,left:0},500,function(){});
					$list.eq(iIndex).find("img").attr("width","340");	
					
					$list.eq(iIndex+1).animate({left:160,top:0,'z-index':23},500);
					$list.eq(iIndex+1).find("img").parent().width(420);				
					$list.eq(iIndex+1).find("img").animate({width:420,top:0},{duration:500,complete:function(){Reflection.add(this, { height: 1/7, opacity: 1/6 });}});	
					$list.eq(iIndex+1).find("img").attr("width","420");	
					$list.eq(iIndex+2).css({left:480,top:45}).fadeIn(100);	
			}
			
			
			$lbtn.click(function(){
				fnMain(1);					 
			});
			$rbtn.click(function(){
				fnMain(1);				 
			});
			
		}		
	});	
})(jQuery);











/*add flash*/

function addSwf(id,W,H,url)
{var swf = "<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0'id="+id+" width="+W+" height="+H+" classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'><param name='movie' value="+url+" /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src="+url+" width="+W+" height="+H+" quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer'type='application/x-shockwave-flash' wmode='transparent'></embed></object>";
return swf;}




