 

$(function(){		   
 
$("#navul > li").not(".navhome").hover(function(){$(this).addClass("navmoon")},function(){$(this).removeClass("navmoon")})


var maxwidth = 580;
$(".news_text img").each(function(){
  if ($(this).width() > maxwidth) {
   $(this).width(maxwidth);}
   }); 
}); 
function $tomato(id) {
	return document.getElementById(id);
}
function runCode(obj) {
	var winname = window.open('', "_blank", '');
	winname.document.open('text/html', 'replace');
	winname.document.writeln(obj.value);
	winname.document.close();
}


(function($){
    $.fn.capacityFixed = function(options) {
        var opts = $.extend({},$.fn.capacityFixed.deflunt,options);
        var FixedFun = function(element) {
            var top = opts.top;
            element.css({
                "top":top
            });
            $(window).scroll(function() {
                var scrolls = $(this).scrollTop();
                if (scrolls > top) {

                    if (window.XMLHttpRequest) {
                        element.css({
                            position: "fixed",
                            top: 0							
                        });
                    } else {
                        element.css({
                            top: scrolls
                        });
                    }
                }else {
                    element.css({
                        position: "absolute",
                        top: top
                    });
                }
            });
            element.find(".close-ico").click(function(event){
                element.remove();
                event.preventDefault();
            })
        };
        return $(this).each(function() {
            FixedFun($(this));
        });
    };
    $.fn.capacityFixed.deflunt={
		right : 0,//相对于页面宽度的右边定位
        top:75
	};
})(jQuery);








(function($){
	$.fn.slide=function(options){
		$.fn.slide.deflunt={
		effect : "fade", //效果 || fade：渐显； || top：上滚动；|| left：左滚动；|| topLoop：上循环滚动；|| leftLoop：左循环滚动；|| topMarquee：上无缝循环滚动；|| leftMarquee：左无缝循环滚动；
		autoPlay:false, //自动运行
		delayTime : 500, //效果持续时间
		interTime : 2500,//自动运行间隔。当effect为无缝滚动的时候，相当于运行速度。
		defaultIndex : 0,//默认的当前位置索引。0是第一个
		titCell:".hd li",//导航元素
		mainCell:".bd",//内容元素的父层对象
		trigger: "mouseover",//触发方式 || mouseover：鼠标移过触发；|| click：鼠标点击触发；
		scroll:1,//每次滚动个数。
		vis:1,//visible，可视范围个数，当内容个数少于可视个数的时候，不执行效果。
		titOnClassName:"on",//当前位置自动增加的class名称
		autoPage:false,//系统自动分页，当为true时，titCell则为导航元素父层对象，同时系统会在titCell里面自动插入分页li元素(1.2版本新增)
		prevCell:".prev",//前一个按钮元素。
		nextCell:".next"//后一个按钮元素。
		};
		return this.each(function() {
			var opts = $.extend({},$.fn.slide.deflunt,options);
			var index=opts.defaultIndex;
			var prevBtn = $(opts.prevCell, $(this));
			var nextBtn = $(opts.nextCell, $(this));
			var navObj = $(opts.titCell, $(this));//导航子元素结合
			var navObjSize = navObj.size();
			var conBox = $(opts.mainCell , $(this));//内容元素父层对象
			var conBoxSize=conBox.children().size();
			var slideH=0;
			var slideW=0;
			var selfW=0;
			var selfH=0;
			var autoPlay = opts.autoPlay;
			var inter=null;//setInterval名称 
			var oldIndex = index;
			if(conBoxSize<opts.vis) return; //当内容个数少于可视个数，不执行效果。
			//处理分页
			if( navObjSize==0 )navObjSize=conBoxSize;
			if( opts.autoPage ){
				var tempS = conBoxSize-opts.vis;
				navObjSize=1+parseInt(tempS%opts.scroll!=0?(tempS/opts.scroll+1):(tempS/opts.scroll)); 
				navObj.html(""); 
				for( var i=0; i<navObjSize; i++ ){ navObj.append("<li>"+(i+1)+"</li>") }
				var navObj = $("li", navObj);//重置导航子元素对象
			}

			conBox.children().each(function(){ //取最大值
				if( $(this).width()>selfW ){ selfW=$(this).width(); slideW=$(this).outerWidth(true);  }
				if( $(this).height()>selfH ){ selfH=$(this).height(); slideH=$(this).outerHeight(true);  }
			});

			switch(opts.effect)
			{
				case "top": conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:'+opts.vis*slideH+'px"></div>').css( { "position":"relative","padding":"0","margin":"0"}).children().css( {"height":selfH} ); break;
				case "left": conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:'+opts.vis*slideW+'px"></div>').css( { "width":conBoxSize*slideW,"position":"relative","overflow":"hidden","padding":"0","margin":"0"}).children().css( {"float":"left","width":selfW} ); break;
				case "leftLoop":
				case "leftMarquee":
					conBox.children().clone().appendTo(conBox).clone().prependTo(conBox); 
					conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:'+opts.vis*slideW+'px"></div>').css( { "width":conBoxSize*slideW*3,"position":"relative","overflow":"hidden","padding":"0","margin":"0","left":-conBoxSize*slideW}).children().css( {"float":"left","width":selfW}  ); break;
				case "topLoop":
				case "topMarquee":
					conBox.children().clone().appendTo(conBox).clone().prependTo(conBox); 
					conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:'+opts.vis*slideH+'px"></div>').css( { "height":conBoxSize*slideH*3,"position":"relative","padding":"0","margin":"0","top":-conBoxSize*slideH}).children().css( {"height":selfH} ); break;
			}
			//效果函数
			var doPlay=function(){
				switch(opts.effect)
				{
					case "fade": case "top": case "left": if ( index >= navObjSize) { index = 0; } else if( index < 0) { index = navObjSize-1; } break;
					case "leftMarquee":case "topMarquee": if ( index>= 2) { index=1; } else if( index<0) { index = 0; } break;
					case "leftLoop": case "topLoop":
						var tempNum = index - oldIndex; 
						if( navObjSize>2 && tempNum==-(navObjSize-1) ) tempNum=1;
						if( navObjSize>2 && tempNum==(navObjSize-1) ) tempNum=-1;
						var scrollNum = Math.abs( tempNum*opts.scroll );
						if ( index >= navObjSize) { index = 0; } else if( index < 0) { index = navObjSize-1; }
					break;
				}
				switch (opts.effect)
				{
					case "fade":conBox.children().stop(true,true).eq(index).fadeIn(opts.delayTime).siblings().hide();break;
					case "top":conBox.stop(true,true).animate({"top":-index*opts.scroll*slideH},opts.delayTime);break;
					case "left":conBox.stop(true,true).animate({"left":-index*opts.scroll*slideW},opts.delayTime);break;
					case "leftLoop":
						if(tempNum<0 ){
								conBox.stop(true,true).animate({"left":-(conBoxSize-scrollNum )*slideW},opts.delayTime,function(){
								for(var i=0;i<scrollNum;i++){ conBox.children().last().prependTo(conBox); }
								conBox.css("left",-conBoxSize*slideW);
							});
						}
						else{
							conBox.stop(true,true).animate({"left":-( conBoxSize + scrollNum)*slideW},opts.delayTime,function(){
								for(var i=0;i<scrollNum;i++){ conBox.children().first().appendTo(conBox); }
								conBox.css("left",-conBoxSize*slideW);
							});
						}break;// leftLoop end

					case "topLoop":
						if(tempNum<0 ){
								conBox.stop(true,true).animate({"top":-(conBoxSize-scrollNum )*slideH},opts.delayTime,function(){
								for(var i=0;i<scrollNum;i++){ conBox.children().last().prependTo(conBox); }
								conBox.css("top",-conBoxSize*slideH);
							});
						}
						else{
							conBox.stop(true,true).animate({"top":-( conBoxSize + scrollNum)*slideH},opts.delayTime,function(){
								for(var i=0;i<scrollNum;i++){ conBox.children().first().appendTo(conBox); }
								conBox.css("top",-conBoxSize*slideH);
							});
						}break;//topLoop end

					case "leftMarquee":
						var tempLeft = conBox.css("left").replace("px",""); 

						if(index==0 ){
								conBox.animate({"left":++tempLeft},0,function(){
									if( conBox.css("left").replace("px","")>= 0){ for(var i=0;i<conBoxSize;i++){ conBox.children().last().prependTo(conBox); }conBox.css("left",-conBoxSize*slideW);}
								});
						}
						else{
								conBox.animate({"left":--tempLeft},0,function(){
									if(  conBox.css("left").replace("px","")<= -conBoxSize*slideW*2){ for(var i=0;i<conBoxSize;i++){ conBox.children().first().appendTo(conBox); }conBox.css("left",-conBoxSize*slideW);}
								});
						}break;// leftMarquee end

						case "topMarquee":
						var tempTop = conBox.css("top").replace("px",""); 
							if(index==0 ){
									conBox.animate({"top":++tempTop},0,function(){
										if( conBox.css("top").replace("px","") >= 0){ for(var i=0;i<conBoxSize;i++){ conBox.children().last().prependTo(conBox); }conBox.css("top",-conBoxSize*slideH);}
									});
							}
							else{
									conBox.animate({"top":--tempTop},0,function(){
										if( conBox.css("top").replace("px","")<= -conBoxSize*slideH*2){ for(var i=0;i<conBoxSize;i++){ conBox.children().first().appendTo(conBox); }conBox.css("top",-conBoxSize*slideH);}
									});
							}break;// topMarquee end
				}//switch end
					navObj.removeClass(opts.titOnClassName).eq(index).addClass(opts.titOnClassName);
					oldIndex=index;
			};
			//初始化执行
			doPlay();
			//自动播放
			if (autoPlay) {
					if( opts.effect=="leftMarquee" || opts.effect=="topMarquee"  ){
						index++; inter = setInterval(doPlay, opts.interTime);
						conBox.hover(function(){if(autoPlay){clearInterval(inter); }},function(){if(autoPlay){clearInterval(inter);inter = setInterval(doPlay, opts.interTime);}});
					}else{
						 inter=setInterval(function(){index++; doPlay() }, opts.interTime); 
						$(this).hover(function(){if(autoPlay){clearInterval(inter); }},function(){if(autoPlay){clearInterval(inter); inter=setInterval(function(){index++; doPlay() }, opts.interTime); }});
					}}
			//鼠标事件
			var mst;
			if(opts.trigger=="mouseover"){
				navObj.hover(function(){ clearTimeout(mst); index=navObj.index(this); mst = window.setTimeout(doPlay,200); }, function(){ if(!mst)clearTimeout(mst); });
			}else{ navObj.click(function(){index=navObj.index(this);  doPlay(); })  }
			nextBtn.click(function(){ index++; doPlay(); });
			prevBtn.click(function(){  index--; doPlay(); });
    	});//each End
	};//slide End
})(jQuery);






jQuery.fn.autoZoomLoadImage = function(scaling, width, height, loadPic) {
  if (loadPic == null) loadPic = "/SKCMS/images/loading.gif";
  return this.each(function() {
    var t = $(this);
    var src = $(this).attr("src");
    var img = new Image();
    //alert("Loading")
    img.src = src;
    //自动缩放图片
    var autoScaling = function() {
      if (scaling) {
        if (img.width > 0 && img.height > 0) {
          if (img.width / img.height >= width / height) {
            if (img.width > width) {
              t.width(width);
              t.height((img.height * width) / img.width);
            }
            else {
              t.width(img.width);
              t.height(img.height);
            }
          }
          else {
            if (img.height > height) {
              t.height(height);
              t.width((img.width * height) / img.height);
            }
            else {
              t.width(img.width);
              t.height(img.height);
            }
          }
        }
      }
    }
    //处理ff下会自动读取缓存图片
    if (img.complete) {
      //alert("getToCache!");
      autoScaling();
      return;
    }
    $(this).attr("src", "");
    var loading = $("<img alt=\"Load...\" title=\"Load...\" src=\"" + loadPic + "\" />");
    t.hide();
    t.after(loading);
    $(img).load(function() {
      autoScaling();
      loading.remove();
      t.attr("src", this.src);
      t.show();
      //alert("finally!")
    });
  });
}

 $(document).ready(function(){
 $("ul.menu li:first-child").addClass("current");
 $("div.content").find("div.layout:not(:first-child)").hide();
$("div.content div.layout").attr("id", function(){return idNumber("No")+ $("div.content div.layout").index(this)});
$("ul.menu li").click(function(){
 var c = $("ul.menu li");
 var index = c.index(this);
 var p = idNumber("No");
 show(c,index,p);
});
 
  function show(controlMenu,num,prefix){
var content= prefix + num;
 $('#'+content).siblings().hide();
 $('#'+content).show();
 controlMenu.eq(num).addClass("current").siblings().removeClass("current");
 };

 function idNumber(prefix){
 var idNum = prefix;
 return idNum;
 };
 });
 
 
 
 
 //收藏本站
function addFavorite(url,title){var d=url;var c=title;if(document.all){window.external.AddFavorite(d,c)}else{if(window.sidebar){window.sidebar.addPanel(c,d,"")}else{alert("对不起，您的浏览器不支持此操作!\n请您使用菜单栏或Ctrl+D收藏本站。")}}}

  
 jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
            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(); // use expires attribute, max-age is not supported by IE
        }
        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 { // only name given, get cookie
        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]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
 
 //暂存箱 SKCMS 作品
function floatingBox(box,options,index){this.targetX=-250;this.targetY=140;this.interval=50;this.menu=box;this.index=index;this.options=options;this.hasInner=typeof(window.innerWidth)=='number';this.hasElement=document.documentElement&&document.documentElement.clientWidth;this.move=function(){jQuery(this.menu).css('left',this.nextX+'px').css('top',this.nextY+'px')};this.computeShifts=function(){var de=document.documentElement;this.shiftX=this.hasInner?pageXOffset:this.hasElement?de.scrollLeft:document.body.scrollLeft;if(this.targetX<0){if(this.hasElement&&this.hasInner){this.shiftX+=de.clientWidth>window.innerWidth?window.innerWidth:de.clientWidth}else{this.shiftX+=this.hasElement?de.clientWidth:this.hasInner?window.innerWidth:document.body.clientWidth}};this.shiftY=this.hasInner?pageYOffset:this.hasElement?de.scrollTop:document.body.scrollTop;if(this.targetY<0){if(this.hasElement&&this.hasInner){this.shiftY+=de.clientHeight>window.innerHeight?window.innerHeight:de.clientHeight}else{this.shiftY+=this.hasElement?document.documentElement.clientHeight:this.hasInner?window.innerHeight:document.body.clientHeight}}};this.doFloat=function(){var stepX,stepY;this.computeShifts();stepX=(this.shiftX+this.targetX-this.nextX)*.07;if(Math.abs(stepX)<.5){stepX=this.shiftX+this.targetX-this.nextX};stepY=(this.shiftY+this.targetY-this.nextY)*.07;if(Math.abs(stepY)<.5){stepY=this.shiftY+this.targetY-this.nextY};if(Math.abs(stepX)>0||Math.abs(stepY)>0){this.nextX+=stepX;this.nextY+=stepY;this.move()};setTimeout('funcFloating['+this.index+'].func()',this.interval)};this.initSecondary=function(){this.computeShifts();this.nextX=this.shiftX+this.targetX;this.nextY=this.shiftY+this.targetY;this.move()};this.position=function(targetX,targetY){if(typeof(targetX)=='number'){this.targetX=targetX}else if(typeof(targetX)=='string'){switch(targetX){case'left':this.targetX=5;break;case'right':this.targetX=-((jQuery(this.menu).outerWidth())+5);break}};if(typeof(targetY)=='number'){this.targetY=targetY}else if(typeof(targetY)=='string'){switch(targetY){case'top':this.targetY=5;break;case'bottom':this.targetY=-((jQuery(this.menu).outerHeight()+5));break}}};this.init=function(){jQuery(this.menu).css('position','absolute');if(typeof(this.options)=='object'){for(var i in this.options){switch(i){case'targetX':case'targetY':if(typeof(this.options[i])=='number'){this[i]=this.options[i]}else if(typeof(this.options[i])=='string'){switch(this.options[i]){case'top':this.targetY=5;break;case'bottom':this.targetY=-((jQuery(this.menu).outerHeight()+5));break;case'left':this.targetX=5;break;case'right':this.targetX=-((jQuery(this.menu).outerWidth())+5);break}};break;default:this[i]=this.options[i]}}};this.initSecondary();this.doFloat()}};var funcFloating={};jQuery.fn.floating=function(options){return jQuery(this).each(function(i){var nextIndex=0;for(var index in funcFloating){nextIndex=parseInt(index)};funcFloating[nextIndex+1]={};funcFloating[nextIndex+1].box=this;funcFloating[nextIndex+1].obj=new floatingBox(this,options,(nextIndex+1));funcFloating[nextIndex+1].func=function(){funcFloating[nextIndex+1].obj.doFloat()};if(document.layers){funcFloating[nextIndex+1].obj.init()}else{funcFloating[nextIndex+1].obj.init();funcFloating[nextIndex+1].obj.initSecondary()}})};jQuery.fn.floatingPosition=function(targetX,targetY){return jQuery(this).each(function(i){for(var j in funcFloating){if(funcFloating[j].box==this){funcFloating[j].obj.position(targetX,targetY)}}})};

$(document).ready(function(){
	$('#ComparBox').floating({targetX:'right', targetY:'middle'});
	$("#ComparList").html($.cookie('cookiesHtml'));
	$("#cookiesHtml").html($.cookie('cookiesHtml'));//cookies演示
	  if($.cookie('cookiesHtml')==null) {
	  $('#ComparBox').hide();
	  };
	bindListener();
	Adds_mun();
}); 
function Adds_mun(){
	if($.cookie('ms')){
	  return _n = $.cookie('ms');
	}else{
	  return _n = 0;
	}}
function bindListener(){
	$("#ComparList a[name=dels]").unbind().click(function(){ 
		$(this).parent().remove();_n--;
		$.cookie('cookiesHtml', $("#ComparList").html());
		$.cookie('ms',_n);
		$("#cookiesHtml").html($.cookie('cookiesHtml'));//cookies演示
	})
}
function Adds(urls,ids,titles,imgurl){
        Adds_mun();
	if($("#ComparList input[value="+ids+"]").length>0){
	  alert("已经在您的询盘篮了");
	}else{
	  if(_n<12){//可以添加对比的最大数为4个
		  _n++;
		  var htmls="<li><input name=\"pid\" type=\"hidden\" value=\""+ids+"\" /><a href=\""+urls+"\"><img  src=\""+imgurl+"\" class=\"imgphoto\" width=\"40\" height=\"40\" >"+titles+"</a> <a href=\"javascript:\" title=\"Delete\" class=\"delbast\" name=\"dels\">[ X ]</a></li>"
		   $("#ComparList").append(htmls);
		   $.cookie('cookiesHtml', $("#ComparList").html());
		   $("#cookiesHtml").html($.cookie('cookiesHtml'));//cookies演示
		   bindListener();
		   $.cookie('ms',_n);
		    $('#ComparBox').show();
	  }else{
		  alert("询盘篮已经满了");  
	  }
	}
}
function delcookie(){
	$.cookie('cookiesHtml',null);
	$.cookie('ms',null);
	 $('#ComparBox').hide();
	$("#ComparList").html('');}
function postbest(){
	  if($.cookie('cookiesHtml')=='') {
	    alert("询盘篮是空的");
	  } else{
	  document.jqshop.submit()
}}
function hidebest(){
  $('#ComparBox').hide();
}