// JavaScript Document
$(document).ready(function(){


	//---------------------clear search input---------------------
	$("#search_input").focus(function(){
		if($(this).val()=="Site Search"){
			$(this).val("");
		}
	}).blur(function(){
		if($(this).val()==''){
			$(this).val("Site Search");
		}
	});
//	/*Allen Add*/
//	//---------------------clear search input---------------------
//	$("#txtSearchBox").focus(function(){
//		if($(this).val()=="Site Search"){
//			$(this).val("");
//		}
//	}).blur(function(){
//		if($(this).val()==''){
//			$(this).val("Site Search");
//		}
//	});
//	/*Allen Add*/
	
	
	$(".headP").click(function(){
		//var objH=$(".headP").next("div.contentP").height()
		$(".headP").removeClass("headS");
		$(this).addClass("headS"); 
		$(this).mouseout(function(){$(this).addClass("heads")});
		$(".headP").next("div.contentP").animate({opacity:"0"},300).hide(300);
		$(this).next("div.contentP").show(300).animate({opacity:"1"},300);
	});
	
	//table thead style and background color swich on mouseover
	if($(".tdStyle")!=-1){
		$(".tdStyle th").slice(1,$(".tdStyle th").size()).addClass("thLine");
		$(".tdStyle tbody tr").addClass("tr")
		$(".tdStyle tbody tr").hover(function(){
			$(".tdStyle tbody tr").removeClass("trH");
			$(this).addClass("trH");
			//$(this).css("background","url(../image/spacer.gif)");	
		},function(){
			$(".tdStyle tbody tr").removeClass("trH");
		});
	}
	
	//popup master div style
	if($(".pCont2")!=-1){
		$(".pCont2").height($("#pConL").height()-60);
		$(".pCont2").click(function(){
			$(".pCont2").removeClass("selected");
			$(this).addClass("selected");
			return false;
		});
		//product link style
		$(".pLink2").click(function(){
			$(".pLink2").removeClass("selected");
			$(this).addClass("selected");
		})
	};
	//select popup div
	if($("#normalList")!=-1){
		$("#normalList").click(function(){
			$("#lctPop").fadeIn("slow");
			$(this).blur();
		});
		$(".popC a").click(function(){
			$("#normalList").val($(this).text());
			$("#lctPop").fadeOut(500);
			//return false;
		})
		$(".closeBtn").click(function(){
			$("#lctPop").fadeOut(500);
		});
	};
	
	
	//news list select popup div
	if($("#newList")!=-1){
		$("#newList").click(function(){
			$("#lctPop4").fadeIn("slow");
			$(this).blur();
		});
		$("#lctPop4 .popC a").click(function(){
			$("#newList").val($(this).text());
			$("#lctPop4").fadeOut(500);
			//return false;
		})
		$(".closeBtn").click(function(){
			$("#lctPop4").fadeOut(500);
		});
	};
	if($("#newList2")!=-1){
		$("#newList2").click(function(){
			$("#lctPop5").fadeIn("slow");
			$(this).blur();
		});
		$("#lctPop5 .popC a").click(function(){
			$("#newList2").val($(this).text());
			$("#lctPop5").fadeOut(500);
			//return false;
		})
		$(".closeBtn").click(function(){
			$("#lctPop5").fadeOut(500);
		});
	};
	
	//contact list select popup div
	if($("#Profession")!=-1){
		$("#Profession").click(function(){
			$("#lctPop6").fadeIn("slow");
			$(this).blur();
		});
		$("#lctPop6 .popC a").click(function(){
			$("#Profession").val($(this).text());
			$("#lctPop6").fadeOut(500);
			//return false;
		})
		$(".closeBtn").click(function(){
			$("#lctPop6").fadeOut(500);
		});
	};
	if($("#Territory")!=-1){
		$("#Territory").click(function(){
			$("#lctPop8").fadeIn("slow");
			$(this).blur();
		});
		$("#lctPop8 .popC a").click(function(){
			$("#Territory").val($(this).text());
			$("#lctPop8").fadeOut(500);
			//return false;
		})
		$(".closeBtn").click(function(){
			$("#lctPop8").fadeOut(500);
		});
	};
	
	if($("#_ctl0_SubContent_Category")!=-1){
		$("#_ctl0_SubContent_Category").click(function(){
			$("#lctPop9").fadeIn("slow");
			$(this).blur();
		});
		
		
		$("#lctPop9 .ok").click(function(){
			var aa="";
			$("input[@name=Category][@checked]").each(function(){
				aa+=$(this).val()+",";
			})
			$("#_ctl0_SubContent_Category").val(aa);
			$("#lctPop9").fadeOut(500);
			//return false;
		})
	};
	
	if($("#cntLct")!=-1){
		$("#cntLct").click(function(){
			$("#lctPop10").fadeIn("slow");
			$(this).blur();
		});
		$("#lctPop10 .popC a").click(function(){
			$("#cntLct").val($(this).text());
			$("#lctPop10").fadeOut(500);
			return true;
		})
		$(".closeBtn").click(function(){
			$("#lctPop10").fadeOut(500);
		});
	};
	
	//product line by location slide effect
	if($("#proBtnIcon")!=-1){
		$("#proBar").height($("#prolctBoxmain").height()+"px");
		$("#proBtnIcon").mouseover(function(){
			if($(this).attr("class")=="proBtn2"){
				$(this).removeClass("proBtn2").addClass("proBtn");
				$("#proLctR").animate({width:"191px"},350);
				$("#proLctL").animate({width:"383px"},450);
			}
			else{
				$(this).removeClass("proBtn").addClass("proBtn2");
				$("#proLctL").animate({width:"191px"},350);
				$("#proLctR").animate({width:"383px"},450);
			}
		});
		$("#proLctL a").mouseover(function(){
			if($("#proBtnIcon").attr("class")=="proBtn2"){
				$("#proBtnIcon").mouseover();
			}
			return false;
		});
		$("#proLctR a").mouseover(function(){
			if($("#proBtnIcon").attr("class")=="proBtn"){
				$("#proBtnIcon").mouseover();
			}
			return false;
		});
		$(".pCont3 a").click(function(){
			$(".pCont3 a").removeClass("selected");
			$(this).addClass("selected");
		})
		
	}
	
	//popup master effect
	if($("#master")!=-1){
		var w=$("html").width();
		var h=$("body").height();
		$("#master").width(w+"px").height(h+"px");
		$(".linkVideo a").click(function(){
			$('#videoPop').showMsg({autoMiddle:true,coverBody:true,autoClose:false});
			return false;
		})
		$("#btnShowPop").click(function(){
			$('#videoPop').showMsg({autoMiddle:true,coverBody:true,autoClose:false});
			return false;
		})
		$("#closeBtn4").click(function(){
			$("#videoPop").closeMsg()
		});
		$("#design a").click(function(){
			$('#videoPop2').showMsg({autoMiddle:true,coverBody:true,autoClose:false});
			return false;
		})
		$("#closeBtn5").click(function(){
			$("#videoPop2").closeMsg()
		});
		$("#supply a").click(function(){
			$('#videoPop3').showMsg({autoMiddle:true,coverBody:true,autoClose:false});
			return false;
		})
		$("#closeBtn6").click(function(){
			$("#videoPop3").closeMsg()
		});
		
	}
	
	
	// fix menu z-index
	$("#menuBox li").eq(1).children().hover(function(){
		$(".ifrDiv").show();
	},function(){
		$(".ifrDiv").hide();
	});
	
//	//fix search page height
//	if($(".divH").height()<300){
//	    //alert("dfd")
//	    $(".divH").height(300);
//	}

    //fix search page height
	if($(".tab_laytr").height()<300){
	    //alert("dfd")
	    $(".tab_laytr").height(300);
	}


//end
});

 /* jQuery-Plugin menu hover style =============================== */

sfHover = function() {
	var sfEls = document.getElementById("menuBox").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++){
		sfEls[i].onmouseover=function(){
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function(){
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//clear status message on error
function closeErrors(){   
    return true; 
	window.status="";
    }   
window.onerror=closeErrors;


//Allen Add
//if($("#_ctl0_SubContent_Category")!=-1){
//		$("#_ctl0_SubContent_Category").click(function(){
//			$("#lctPop9").fadeIn("slow");
//			$(this).blur();
//		});
//		
//		
//		$("#lctPop9 .ok").click(function(){
//			var aa="";
//			$("input[@name=_ctl0:SubContent:Category][@checked]").each(function(){
//				aa+=$(this).val()+",";
//			})
//			$("#_ctl0_SubContent_Category").val(aa);
//			$("#lctPop9").fadeOut(500);
//			//return false;
//		})
//	};



