// JavaScript Document by vitrum.zhu 2010.02.01


	function GetUrlParam(url, paramName ) {
	    var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
	    //var oMatch = oRegex.exec( window.top.location.search ) ; //获取当前窗口的URL
	    var oMatch = oRegex.exec( url ) ;
	    if ( oMatch && oMatch.length > 1 )
	        return oMatch[1] ;  //返回值
	    else
	        return '' ;
    }
	function GetQueryString(name) {

       var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|jQuery)","i");

       var r = window.location.search.substr(1).match(reg);

       if (r!=null) return unescape(r[2]); return null;

    }





	function addMega(){
		var spanhover = jQuery(this).parents("li").find("span.hover").length;
		//jQuery(this).parents("ul.topnav").find("ul.subnav").stop();
		jQuery(this).parents("ul.topnav").find(".subnav").hide();
		//jQuery(this).parents("ul.topnav").find("span.hover").stop();
		if ( spanhover >0 ) {
				jQuery(this).parents("li").find(".subnav").slideDown('6');
				jQuery(this).parents("li").find("span.hover").fadeIn("10",function(){
					//jQuery(this).parents("li").find("ul").slideDown('6');
				});
			} else {
				jQuery(this).parents("li").find(".subnav").slideDown('6');
			}
	}

	function removeMega(){


		//jQuery(this).parents("li").find("div.teb").removeClass("active");
		jQuery(this).parents("li").find("span.hover").fadeOut("10");
		jQuery(this).parents("ul").find("li").removeClass("active");
		//jQuery(this).find("ul").slideToggle('10');
		//jQuery(this).find("ul").slideUp("2");
		jQuery(this).find(".subnav").hide();

	}
	function addBottom(){
		//jQuery(this).find("span").hide();
		jQuery(this).find("span.hover").fadeIn('10');
	}
	function removeBottom(){
		//jQuery(this).find("span").show();
		jQuery(this).find("span.hover").fadeOut("10");
	}
	function file_name_only(str) {
		 var slash = "/";
		 if (str.match(/\\/)) {
			 slash = "\\";
		 }
		 var filename;
		 if (str.lastIndexOf("/")+1==str.length) {filename ="";} else {filename = str.substring(str.lastIndexOf(slash) + 1, str.lastIndexOf('.'));}

		 var prestring = str.substring(0,str.lastIndexOf(slash));
		 var foldername = prestring.substring(prestring.lastIndexOf(slash)+1,prestring.length);
		 if (foldername == "images/product") {foldername="";}
		return (filename)
	}

	function ReplacePicName(ss, newss){
	   var r, re;                    // 声明变量。
	   re = /-s/g;             // 创建正则表达式模式。
	   r = ss.replace(re,newss);    // 用 "A" 替换 "The"。
	   return(r);                   // 返回替换后的字符串。
	}

	function PopTimeShow(ss, newss){
		jQuery("#poptime img.bg").animate({
				width: "178px",
				height: "103px",
				opacity: 0.9
			  }, 400 );
		jQuery("#poptime").fadeIn(350,function(){
		   jQuery("div.poptimebox").show();
		 });

	}
    function WidthCheck(str, maxLen){

        var w = 0;
        var tempCount = 0;
        for (var i=0; i<str.value.length; i++) {
           var c = str.value.charCodeAt(i);
           //单字节加1
           if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) {
            w++;

           }else {
            w+=2;

           }

           if (w > maxLen) {
           str.value = str.value.substr(0,i);

           break;
           }
        }
    }
	jQuery(document).ready(function(){

		var megaConfig = {
			 interval: 30,
			 sensitivity: 1,
			 over: addMega,
			 timeout: 30,
			 out: removeMega
		};
	    if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
        {
             jQuery("#footbox").css("position", "static");
        };
		jQuery("ul.topnav .teb").hoverIntent(megaConfig);
		jQuery("ul.topnav").hover(
			function () {
			  },
			  function () {
				jQuery("ul.topnav ul.subnav").hide();
			  }
		);

		var bottomConfig = {
			 interval: 30,
			 sensitivity: 1,
			 over: addBottom,
			 timeout: 30,
			 out: removeBottom
		};
		jQuery("a.btn_def").hoverIntent(bottomConfig);
		jQuery("a.btn_sm").hoverIntent(bottomConfig);

		jQuery(".subnav li").mouseover(function(){
			jQuery(this).parents("ul").find("li").removeClass("active");
			jQuery(this).addClass("active");
		});

		//jQuery("#poptime").fadeIn("10");


		//PopTimeShow();
		jQuery("#poptime").click( function () {
			jQuery("#poptime div.poptimebox").hide();
			jQuery("#poptime img.bg").animate({
				width: "10px",
				height: "5px",
				fontSize: "0em",
				opacity: 0,
				left:"160px"
			  }, 200 );
			//jQuery("#poptime").hide();
			jQuery("#poptime").fadeOut("10");
		 });

		//btn_def align center
		 if (jQuery('.brandinfo .btn_video').text().length == 0) {
		 	if ( jQuery.browser.msie && jQuery.browser.version == '6.0') {
		 		jQuery('.brandinfo .btn_def').css('margin-left','33px');
			}else{
		 		jQuery('.brandinfo .btn_def').css('margin-left','66px');
		 	}
		 };
	});


