$(window).resize(function(){
	});

$(document).ready(function(){		
	menu();
	popup();
	tabtext();
	product_detail();
	sel_model();
        if($(".rotator.rt1").length) {
            rotate_show($(".rotator.rt1 #q1"));
      	 }
        if($(".rotator.rt2").length) {
            rotate_show($(".rotator.rt2 #q1"));
      	 }
	$.updnWatermark.attachAll();
 });

function product_detail(){
	 if($(".product_detail").length) {
		 $(".banner_order").css("display","none");
		 }	
	}

function sel_model(){
	$("select.sel_model").change(function(){
		window.location = $(this).val();
		});
	}

function menu(){
	$(".menutab td").hover(function(){
			$(this).toggleClass("hover");			
		},function(){
			$(this).removeClass("hover");
		});	
	}
	
 function popup(){
	 	$(".layer .popup .close").click(function(){
				if($.browser.msie&&$.browser.version==6) $(this).parents(".layer").css("display","none");			
				else $(this).parents(".layer").fadeOut("2000");
				$(".layer.l_nobg").removeClass("l_nobg");
			});
		$(".catalogtab .prodc .pointer").click(function(){														
				$(".layer.l_prod .popup .tit").html($(this).parents(".prodc").find(".tit").html());
				$(".layer.l_prod .popup .preview").html($(this).parents(".prodc").find(".detail_picture").html());
				$(".layer.l_prod .popup .links a").attr("href",$(this).parents(".prodc").find(".links a.order").attr("href"));
				$(".layer.l_prod .popup .detail_text").html($(this).parents(".prodc").find(".detail_text").html());
				$(".layer.l_prod .popup .tech").html($(this).parents(".prodc").find(".tech").html());
				popupcent($(".layer.l_prod"));
			});
		$(".catalogtab .prodc .links .link").click(function(){
				$(".layer.l_prod .popup .tit").html($(this).parents(".prodc").find(".tit").html());
				$(".layer.l_prod .popup .preview").html($(this).parents(".prodc").find(".detail_picture").html());
				$(".layer.l_prod .popup .links a").attr("href",$(this).parents(".prodc").find(".links a.order").attr("href"));
				$(".layer.l_prod .popup .detail_text").html($(this).parents(".prodc").find(".detail_text").html());
				$(".layer.l_prod .popup .tech").html($(this).parents(".prodc").find(".tech").html());
				popupcent($(".layer.l_prod"));
			});		
		$(".banner_order").click(function(){														
				popupcent($(".layer.l_order"));
			});
		
		if($(".layer.l_order .popup .errortext").length) {
				popupcent($(".layer.l_order"));
			}
		if($(".layer.l_order .popup .succ").length) {
				$(".layer.l_order .formdiv").css("display","none");
				popupcent($(".layer.l_order"));
			}
		if($(".product_detail .pd_right .succ").length) {
				popupcent($(".layer.l_succ"));
			}
	 }
 
   function popupcent(lyr){	
			//w = $(window).width();
			w = 999;
			//if(w<$(".container").width()) w = $(".container").width();
			h = $(document).height();
			$(lyr).css("height",h+"px");
			$(lyr).css("width",w+"px");			
			if($.browser.msie&&$.browser.version==6) $(lyr).css("display","block");			
			else $(lyr).fadeIn("2000");
		 	t = ($(window).height()-$(lyr).find(".popup").height())/2+$(window).scrollTop();			
			$(lyr).find(".layerpadd").css("padding-top",t+"px");	
	 } 
	 
	 function center(){
			//w = $(window).width();
			w=999;
			//if(w<$(".container").width()) w = $(".container").width();
			h = $(document).height();
			$(".layer").css("height",h+"px");
			$(".layer").css("width",w+"px");
			t = ($(window).height()-$(".layer .popup").height())/2+$(window).scrollTop();
			$(".layer .layerpadd").css("padding-top",t+"px");
		}	
		
		function tabtext(){
			$(".table.t_link .link").click(function(){
				$(".tabtext").html($(this).parents("td").find(".text").html());
				});
			}
			
		function rotate_next(obj){	
				ids = $(obj).attr("id");
				ids = ids.replace("q","")*1;
				//alert(ids);
				
				if(ids<$(obj).parents(".rotator").find("img").length) {
					idn = ids+1;
					//rotate_show(".rotator #q"+idn);
					rotate_show($(obj).parents(".rotator").find("#q"+idn));			
					}
				else {
					rotate_show($(obj).parents(".rotator").find("#q1"));
					}
			}
			
		function rotate_close(obj){	
			setTimeout(function() { $(obj).fadeOut(700, function(){rotate_next(obj);} ); }, 4000);
			}
			
		function rotate_show(obj){		
			$(obj).fadeIn(700,rotate_close(obj));		
			}
