browserName=navigator.appName;browserVer=parseInt(navigator.appVersion);condition=!(((browserName.indexOf("Explorer")>=0)&&(browserVer<4))||((browserName.indexOf("Netscape")>=0)&&(browserVer<2)));if(condition==true)CanAnimate=true;else CanAnimate=false;function trans(pt){page_pth=document.location.href;actualpth=pt+"?"+page_pth;window.open(actualpth)}function translator(pattern){var open_in_same_window=0;var my_location=unescape(document.location.toString());var new_location='';var new_pattern='';if(my_location.indexOf('translate_c?')!=-1){var indexof_u=my_location.indexOf('u=');if(indexof_u==-1){new_location=document.location}else{var subs=my_location.substring(indexof_u,my_location.length);var ss=subs.split('&');new_location=ss[0].substring(2,ss[0].length)}}else{new_location=document.location}indexof_p=pattern.indexOf('|');var isen='';if(indexof_p==-1){indexof_p1=pattern.indexOf('><');if(indexof_p1==-1){new_pattern=pattern;if(pattern=='en'){isen=1}}else{var psplit=pattern.split('><');new_pattern=psplit[0]+'|'+psplit[1];if(psplit[1]=='en'){isen=1}}}else{var psplit=pattern.split('|');new_pattern=psplit[0]+'|'+psplit[1];if(psplit[1]=='en'){isen=1}}var thisurl='';if(isen==1){thisurl=new_location}else{thisurl='http://translate.google.com/translate_c?langpair='+new_pattern+"&u="+new_location}if(open_in_same_window==1){window.location.href=thisurl}else{if(CanAnimate){msgWindow=window.open('','subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0');msgWindow.focus();msgWindow.location.href=thisurl}else{msgWindow=window.open(thisurl,'subwindow','toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,menubar=yes,resizable=yes,left=0,top=0')}}}
function sendInquiry(){if($("form input[name=fSubject]").val().length==0){alert("Please fill Subject");$("form input[name=fSubject]").get(0).focus();return false}if($("form textarea[name=fMessage]").val().length==0){alert("Please fill Message");$("form textarea[name=fMessage]").get(0).focus();return false};if($("form input[name=fCompany]").val().length==0){alert("Please fill Your Company");$("form input[name=fCompany]").get(0).focus();return false};if($("form input[name=fName]").val().length==0){alert("Please fill Your Name");$("form input[name=fName]").get(0).focus();return false};if(!(new RegExp(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/)).test($("form input[name=fEmail]").val())){alert("Correctly filled out email");$("form input[name=fEmail]").get(0).focus();return false};return true}
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires='; expires='+date.toUTCString()}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('')}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}return cookieValue}};


$(document).ready(function(){
	if($("#indexProduct img.basket").size() > 0){
		$("#indexProduct img.basket").bind("click", function(){
			if(window.confirm('Add to the basket,Are you sure?')){
				var rel =$(this).next("a").attr("rel");
				if ($("#Basket ul li[rel="+rel+"]").size() == 0){
					$addHtml = "<li rel=\""+rel+"\">";
					$addHtml+= "<span class=\"floatRight remove\">x</span>";
					$addHtml+= "<a href=\""+$(this).next().attr("href")+"\" ";
					$addHtml+= "title=\""+$(this).next().attr("title")+"\"> ";
					$addHtml+= $(this).next().attr("title")+"</a></li>";
					$("#Basket ul").append($addHtml);
					$("#Basket span.remove").unbind("click").unbind("mouseout").unbind("mouseover");
					$("#Basket span.remove").bind("click", function(){
						delBasketObj($(this).parent());
					}).bind("mouseover", function(){
						$(this).css({"fontWeight":"bold", "color":"#f60", "cursor":"pointer"});
					}).bind("mouseout", function(){
						$(this).css({"fontWeight":"normal", "color":"#000", "cursor":"pointer"});
					});
					
					var cookieValue = rel+", "+$(this).next().attr("href")+", "+$(this).next().attr("title")+", "+$(this).next().attr("alt");

					if ($.cookie('basket') == null || $.cookie('basket').length == 0){
						$.cookie('basket', escape(cookieValue));
					}else{
						$.cookie('basket', escape(unescape($.cookie('basket'))+"||"+cookieValue));
					}


				}else{
					$("#Basket ul li[rel="+rel+"]").slideUp(600).slideDown(600);
				}
			}
		}).bind("mouseover", function(){
			$(this).attr("src", $(this).attr("src").replace("basket.bak", "basket"));
		}).bind("mouseout", function(){
			$(this).attr("src", $(this).attr("src").replace("basket", "basket.bak"));
		});;
	}

	if ($("a.iconBasket").size() > 0){
		$("a.iconBasket").bind("mouseout", function(){
			$(this).css("backgroundColor", "transparent");
		}).bind("click", function(e){
			if ($("#Basket").size() > 0){
				if ($("#Basket").is(":hidden")){
					openBasket($(this));
					$(this).css("backgroundColor", "transparent");
				}else{
					closeBasket($(this));
					$(this).css("backgroundColor", "#73ACCA");
				}
			}
		});

		$("#Basket .remove").bind("click", function(){
			delBasketObj($(this).parent());
		}).bind("mouseover", function(){
			$(this).css({"fontWeight":"bold", "color":"#f60", "cursor":"pointer"});
		}).bind("mouseout", function(){
			$(this).css({"fontWeight":"normal", "color":"#000", "cursor":"pointer"});
		});
	}

	loadBasket();

	makeViewState();

	$(".hiddenNextDiv").bind("click", function(){
		$(this).next().toggle();
	}).css("cursor", "pointer");

	// Select All
	$("#indexProductOpBar input[name=selectAll]").bind("click", function(){
		$("#indexProduct input[type=checkbox]").attr("checked", $(this).attr("checked"));
	});

	// translate
	$("a.trans").bind("click", function(e){
		if ($("#transDiv").size() > 0){
			$("#transDiv").toggle();
		}else{
			$html = "<div id='transDiv'>";
			$html+= "<div><a href='javascript:void(0);'>en_fr</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_de</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_it</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_nl</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_ja</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_ko</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_pt</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_ru</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_es</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_zh</a></div>";
			$html+= "<div><a href='javascript:void(0);'>en_zt</a></div>";
			$html+= "</div>";
			$("body").append($html);
			$("#transDiv").css({"top":$(this).offset().top + 18 +"px", "left":$(this).offset().left + "px"});
			$("#transDiv a").bind("click", function(){
				window.open("http://fanyi.cn.yahoo.com/translate_url?fr=forexporter&lp="+$(this).html()+"&trurl="+escape(window.location), "_blank", "");
			}).focus(function(){this.blur()});
		}
		
		if(e.preventDefault) {   
			// Firefox   
			e.preventDefault();
			e.stopPropagation();
		} else {   
			// IE   
			e.cancelBubble=true;
			e.returnValue = false;
		}
	});
	$(document).bind("click", function(e){
		$("#transDiv").hide();
	});

	$("#proList li").bind("click", function(){
		//$("#proList li.ol").hide();
		//$(this).next(".ol").show();
		//return false;
	});

	if ($.cookie("viewStyle")){
		setStyle($.cookie("viewStyle"));
	}

	$(".jMyCarousel").jMyCarousel({
		visible: '100%'
	});
});

function loadBasket(){

	if ($.cookie("basket") != null && $.cookie("basket")){
		re = /\|\|$/ig;
		var jBasket = unescape($.cookie("basket")).replace(re, "");

		var Item = jBasket.split("||");
		var ul = "";
		if (Item.length > 0){
			ul = "<ul>";
			for(i=0;i<Item.length;i++){
				try{
					lit = Item[i].split(", ");
					ul+= "<li rel=\""+lit[0]+"\"><span class=\"floatRight remove\">x</span><a href=\""+lit[1]+"\" title=\""+lit[2]+"\">"+lit[2]+"</a></li>";
				}catch(e){
				}
			}
			ul+= "</ul>";

			$("#Basket .BasketInner").html(ul);
			$("#Basket span.remove").bind("click", function(){
				delBasketObj($(this).parent());
			}).bind("mouseover", function(){
				$(this).css({"fontWeight":"bold", "color":"#f60", "cursor":"pointer"});
			}).bind("mouseout", function(){
				$(this).css({"fontWeight":"normal", "color":"#000", "cursor":"pointer"});
			});			
		}
	}
}
function openBasket(obj){
	var myTop  = obj.offset().top;
	var myLeft = obj.offset().left - $("#Basket").width();
	$("#Basket").css({top:myTop+"px",left:myLeft+"px"}).slideDown();
}

function closeBasket(){
	$("#Basket").slideUp();
}

function delBasketObj(obj){
	if(window.confirm("Are You Delete it!")){
		var rel = obj.attr("rel") || 0;
		re = new RegExp("("+rel+", [^\|\|]+)", "i");

		var cookieNow = unescape($.cookie("basket")).replace(re, "");
		cookieNow = cookieNow.replace(/^\|\||\|\|$/, "");
		$.cookie("basket", escape(cookieNow.replace(/\|{2,}/g, "||")));
		obj.css({backgroundColor:"#FFBE7D"}).animate({opacity:.0}, 600, function(){obj.remove();});
	}
}

function addToBasket(){
	if (window.confirm('Add to the basket,Are you sure?')){
		if ($("#indexProduct input:checked[type=checkbox]").size() > 0){
			$("#indexProduct input:checked[type=checkbox]").each(function(i){

				var rel =$(this).next("a").attr("rel");
				if ($("#Basket ul li[rel="+rel+"]").size() == 0){
					$addHtml = "<li rel=\""+rel+"\">";
					$addHtml+= "<span class=\"floatRight remove\">x</span>";
					$addHtml+= "<a href=\""+$(this).next().attr("href")+"\" ";
					$addHtml+= "title=\""+$(this).next().attr("title")+"\"> ";
					$addHtml+= $(this).next().attr("title")+"</a></li>";
					$("#Basket ul").append($addHtml);
					$("#Basket span.remove").unbind("click").unbind("mouseout").unbind("mouseover");
					$("#Basket span.remove").bind("click", function(){
						delBasketObj($(this).parent());
					}).bind("mouseover", function(){
						$(this).css({"fontWeight":"bold", "color":"#f60", "cursor":"pointer"});
					}).bind("mouseout", function(){
						$(this).css({"fontWeight":"normal", "color":"#000", "cursor":"pointer"});
					});
					
					var cookieValue = rel+", "+$(this).next().attr("href")+", "+$(this).next().attr("title")+", "+$(this).next().attr("alt");

					if ($.cookie('basket') == null || $.cookie('basket').length == 0){
						$.cookie('basket', escape(cookieValue));
					}else{
						$.cookie('basket', escape(unescape($.cookie('basket'))+"||"+cookieValue));
					}


				}else{
					$("#Basket ul li[rel="+rel+"]").slideUp(600).slideDown(600);
				}

			});
		}
		
	}
}

function makeViewState(){
	if ($(".iconViewgallery").size() >0 && $.cookie("viewState")){
		if ($.cookie('viewState') == "Gallery"){
			$("#indexProduct ul").removeClass("viewlist");
		}else if (!$("#indexProduct ul").hasClass("viewlist")){
			$("#indexProduct ul").addClass("viewlist");
		}
	}
}

function setView(name){
	$.cookie('viewState', name);
	if (name == "Gallery"){
		$("#indexProduct ul").removeClass("viewlist");
	}else if (!$("#indexProduct ul").hasClass("viewlist")){
		$("#indexProduct ul").addClass("viewlist");
	}
}

function doSearch(){
	$varSearchKey = $.trim($("input[name=searchKey]").val());
	if ($varSearchKey){
		$("form[name=searchForm]:eq(0)").attr("action", "search_"+$varSearchKey.replace(/\s{1,}/, " ").replace(/\s{1,}/ig, "+")+".htm").submit();
	}else{
		alert("What are you looking for ?");
		$("input[name=searchKey]").get(0).focus();
	}

	return false;
}

function setStyle(title) {

   //预定义变量
   var i, links;

   //用DOM方法获得所有的link元素
   links = document.getElementsByTagName("link");
   for(i=0; links[i]; i++) {
     //判断此link元素的rel属性中是否有style关键字
     //即此link元素是否为样式表link
     //同时判断此link元素是否含有title属性
     if(links[i].getAttribute("rel").indexOf("style") != -1 && links[i].getAttribute("title")) {
       //先不管三七二十一把它设为disabled
       links[i].disabled = true;
       //再判断它的title中是否有我们指定的关键字
       if(links[i].getAttribute("title").indexOf(title) != -1)
         //如果有则将其激活
         links[i].disabled = false;
     }
   }
   if (!$.cookie("viewStyle") || $.cookie("viewStyle") != title){
	   $.cookie("viewStyle", title);
   }
}




(function($){$.fn.jMyCarousel=function(o){o=$.extend({btnPrev:null,btnNext:null,mouseWheel:true,auto:false,speed:500,easing:'linear',vertical:false,circular:true,visible:'4',start:0,scroll:1,step:50,eltByElt:false,evtStart:'mouseover',evtStop:'mouseout',beforeStart:null,afterEnd:null},o||{});return this.each(function(){var running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var div=$(this),ul=$("ul",div),tLi=$("li",ul),tl=tLi.size(),v=o.visible;var mousewheelN=0;var defaultBtn=(o.btnNext===null&&o.btnPrev===null)?true:false;var cssU=(v.toString().indexOf("%")!=-1?'%':(v.toString().indexOf("px")!=-1)?'px':'el');var direction=null;if(o.circular){var imgSet=tLi.clone();ul.prepend(imgSet).append(imgSet.clone());}
var li=$("li",ul);div.css("visibility","visible");li.css("overflow","hidden").css("float",o.vertical?"none":"left").children().css("overflow","hidden");if(!o.vertical){li.css("display","inline");}
if(li.children().get(0).tagName.toLowerCase()=='a'&&!o.vertical){li.children().css('float','left');}
if(o.vertical&&jQuery.browser.msie){li.css('line-height','4px').children().css('margin-bottom','-4px');}
ul.css("margin","0").css("padding","0").css("position","relative").css("list-style-type","none").css("z-index","1");div.css("overflow","hidden").css("position","relative").css("z-index","2").css("left","0px");var liSize=o.vertical?height(li):width(li);var liSizeV=o.vertical?elHeight(li):height(li);var curr=o.start;var nbAllElts=li.size();var ulSize=liSize*nbAllElts;var nbElts=tl;var eltsSize=nbElts*liSize;var allEltsSize=nbAllElts*liSize;var step=o.step=='default'?liSize:o.step;o.btnPrev=defaultBtn?$('<input type="button" class="'+(o.vertical?'up':'prev')+'" />'):$(o.btnPrev);o.btnNext=defaultBtn?$('<input type="button" class="'+(o.vertical?'down':'next')+'" />'):$(o.btnNext);var prev=o.btnPrev;var next=o.btnNext;if(defaultBtn&&o.auto!==true){prev.css({'opacity':'0.6'});next.css({'opacity':'0.6'});div.prepend(prev);div.prepend(next);o.btnPrev=prev;o.btnNext=next;}
if(o.eltByElt){step=liSize;if(o.start%liSize!==0){var imgStart=parseInt(o.start/liSize);curr=o.start=(imgStart*liSize);}}
if(o.circular){o.start+=(liSize*tl);curr+=(liSize*tl);}
var divSize,cssSize,cssUnity;if(cssU=='%'){divSize=0;cssSize=parseInt(v);cssUnity="%";}
else if(cssU=='px'){divSize=parseInt(v);cssSize=parseInt(v);cssUnity="px";}
else{divSize=liSize*parseInt(v);cssSize=liSize*parseInt(v);cssUnity="px";}
ul.css(sizeCss,ulSize+"px").css(animCss,-(o.start));div.css(sizeCss,cssSize+cssUnity);if(o.vertical&&cssUnity=='%'){var pxsize=((liSize*nbElts)*(parseInt(v)/100));div.css(sizeCss,pxsize+'px');}
if(divSize===0){divSize=div.width();}
if(o.vertical){div.css("width",liSizeV+'px');ul.css("width",liSizeV+'px');li.css('margin-bottom',(parseInt(li.css('margin-bottom'))*2)+'px');li.eq(li.size()-1).css('margin-bottom',li.css('margin-top'));}else{div.css('height',liSizeV+'px');ul.css('height',liSizeV+'px');}
if(cssU=='%'){v=divSize/li.width();if(v%1!==0){v+=1;}
v=parseInt(v);}
var divVSize=div.height();if(defaultBtn){next.css({'z-index':200,'position':'absolute'});prev.css({'z-index':200,'position':'absolute'});if(o.vertical){prev.css({'width':prev.width(),'height':prev.height(),'top':'0px','left':parseInt(liSizeV/2)-parseInt(prev.width()/2)+'px'});next.css({'width':prev.width(),'height':prev.height(),'top':(divVSize-prev.height())+'px','left':parseInt(liSizeV/2)-parseInt(prev.width()/2)+'px'});}
else{prev.css({'left':'0px','top':parseInt(liSizeV/2)-parseInt(prev.height()/2)+'px'});next.css({'right':'0px','top':parseInt(liSizeV/2)-parseInt(prev.height()/2)+'px'});}}
if(o.btnPrev){$(o.btnPrev).bind(o.evtStart,function(){if(defaultBtn){o.btnPrev.css('opacity',0.9);}
running=true;direction='backward';return backward();});$(o.btnPrev).bind(o.evtStop,function(){if(defaultBtn){o.btnPrev.css('opacity',0.6);}
running=false;direction=null;return stop();});}
if(o.btnNext){$(o.btnNext).bind(o.evtStart,function(){if(defaultBtn){o.btnNext.css('opacity',0.9);}
running=true;direction='forward';return forward();});$(o.btnNext).bind(o.evtStop,function(){if(defaultBtn){o.btnNext.css('opacity',0.6);}
running=false;direction=null;return stop();});}
if(o.auto===true){running=true;forward();}
if(o.mouseWheel&&div.mousewheel){div.mousewheel(function(e,d){if(!o.circular&&(d>0?(curr+divSize<ulSize):(curr>0))||o.circular){mousewheelN+=1;if(running===false){if(d>0){forward(step,true);}
else{backward(step,true);}
running=true;}}});}
function forward(stepsize,once){var s=(stepsize?stepsize:step);if(running===true&&direction==="backward"){return;}
if(!o.circular){if(curr+s+(o.vertical?divVSize:divSize)>eltsSize){s=eltsSize-(curr+(o.vertical?divVSize:divSize));}}
ul.animate(animCss=="left"?{left:-(curr+s)}:{top:-(curr+s)},o.speed,o.easing,function(){curr+=s;if(o.circular){if(curr+(o.vertical?divVSize:divSize)+liSize>=allEltsSize){ul.css(o.vertical?'top':'left',-curr+eltsSize);curr-=eltsSize;}}
if(!once&&running){forward();}
else if(once){if(--mousewheelN>0){this.forward(step,true);}
else{running=false;direction=null;}}});}
function backward(stepsize,once){var s=(stepsize?stepsize:step);if(running===true&&direction==="forward"){return;}
if(!o.circular){if(curr-s<0){s=curr-0;}}
ul.animate(animCss=="left"?{left:-(curr-s)}:{top:-(curr-s)},o.speed,o.easing,function(){curr-=s;if(o.circular){if(curr<=liSize){ul.css(o.vertical?'top':'left',-(curr+eltsSize));curr+=eltsSize;}}
if(!once&&running){backward();}
else if(once){if(--mousewheelN>0){backward(step,true);}
else{running=false;direction=null;}}});}
function stop(){if(!o.eltByElt){ul.stop();curr=0-parseInt(ul.css(animCss));}
running=false;direction=null;}
function imgSize(el,dimension){if(dimension=='width'){return el.find('img').width();}
else{return el.find('img').height();}}
function elHeight(el){var elImg=el.find('img');if(o.vertical){return parseInt(el.css('margin-left'))+parseInt(el.css('margin-right'))+parseInt(elImg.width())+parseInt(el.css('border-left-width'))+parseInt(el.css('border-right-width'))+parseInt(el.css('padding-right'))+parseInt(el.css('padding-left'));}
else{return parseInt(el.css('margin-top'))+parseInt(el.css('margin-bottom'))+parseInt(elImg.width())+parseInt(el.css('border-top-height'))+parseInt(el.css('border-bottom-height'))+parseInt(el.css('padding-top'))+parseInt(el.css('padding-bottom'));}}
function debug(html){$('#debug').html($('#debug').html()+html+"<br/>");}});};function css(el,prop){return parseInt($.css(el[0],prop))||0;}
function width(el){return el[0].offsetWidth+css(el,'marginLeft')+css(el,'marginRight');}
function height(el){return 130/*el[0].offsetHeight+css(el,'marginTop')+css(el,'marginBottom')*/;}})(jQuery);
