﻿jQuery.noConflict();
jQuery(document).ready(function($){
/////////////////////////////////////////////////// sidebar SNS
$('#sidebar-sns a').hover(function() {
	$(this).stop().animate({'top': '-5px','opacity': '1'}, 50);
	var pos = $(this).position();
	$('#sns_text').html($(this).attr('title'));
	$('#sns_text').css({"left": pos.left - 13 + "px","display":"block"});
	$('#sns_text_icon').css({"left": pos.left + 13 + "px","display":"block"});
}, function() {
	$(this).stop().animate({'top': '0px','opacity': '0.5'}, 'fast');
	$('#sns_text').html('');
	$('#sns_text').css({"display":"none"});
	$('#sns_text_icon').css({"display":"none"});
});
/////////////////////////////////////////////////// JQ Form
//$(function(){
//	$('.jqform form').jqTransform({imgPath:'../images/form/'});
//});
/////////////////////////////////////////////////// IE6 Update
$(function(){
	var name = $('.ie6update');
	$('#close').click(function(){
		$(name).hide();
	});
});
$(document).ready(function() {
$(".ie6update_con").hover(function() {
	$(this).addClass("ie6update_con_cur");
	},function() {
		$(this).removeClass("ie6update_con_cur");
	});
});
/////////////////////////////////////////////////// js Scroll
	  $(function() {

		//cache the ticker
		var ticker = $("#ticker");

		//wrap dt:dd pairs in divs
		ticker.children().filter("ul").each(function() {

		  var dt = $(this),
		    container = $("<div>");

		  dt.next().appendTo(container);
		  dt.prependTo(container);

		  container.appendTo(ticker);
		});

		//hide the scrollbar
		ticker.css("overflow", "hidden");

		//animator function
		function animator(currentItem) {

		  //work out new anim duration
		  var distance = currentItem.height();
			duration = (distance + parseInt(currentItem.css("marginTop"))) / 0.025;

		  //animate the first child of the ticker
		  currentItem.animate({ marginTop: -distance }, duration, "linear", function() {

			//move current item to the bottom
			currentItem.appendTo(currentItem.parent()).css("marginTop", 0);

			//recurse
			animator(currentItem.parent().children(":first"));
		  });
		};

		//start the ticker
		animator(ticker.children(":first"));

		//set mouseenter
		ticker.mouseenter(function() {

		  //stop current animation
		  ticker.children().stop();

		});

		//set mouseleave
		ticker.mouseleave(function() {

          //resume animation
		  animator(ticker.children(":first"));

		});
	  });
/////////////////////////////////////////////////// TABS

$(document).ready(function() {
$(".tabproducts span:first").addClass("current");
$(".tabproducts ul:not(:first)").hide();
$(".tabproducts span.tabna").mouseover(function() {
$(".tabproducts span.tabna").removeClass("current");
$(this).addClass("current");
$(".tabproducts ul").hide();
$("." + $(this).attr("id")).show();
});
});
/////////////////////////////////////////////////// :hover
$(document).ready(function() {
$(".sidebar-pro ul li,.sidebar-tags ul li,.v_content ul li,.v_content0 ul li").hover(function() {
	// $("#orderedlist li:last").hover(function() {
		$(this).addClass("bghover");
	}, function() {
		$(this).removeClass("bghover");
	});
});
$(document).ready(function() {
$(".gridlist ul").hover(function() {
	// $("#orderedlist li:last").hover(function() {
		$(this).addClass("bghover_g");
	}, function() {
		$(this).removeClass("bghover_g");
	});
});
$(document).ready(function() {
$(".listlist ul.line").hover(function() {
	// $("#orderedlist li:last").hover(function() {
		$(this).addClass("bghover_l");
	}, function() {
		$(this).removeClass("bghover_l");
	});
});
/////////////////////////////////////////////////// LIVE CHAT
jQuery.fn.float= function(settings){
	if(typeof settings == "object"){
		settings = jQuery.extend({
			//延迟
			delay : 500,
			//位置偏移
			offset : {
				left : 0,
				right : 0,
				top : 0,
				bottom : 0
			},
			style : null, //样式
			width:100,  //宽度
			height:200, //高度
			position:"rm" //位置
		}, settings || {});	
		var winW = $(window).width();
		var winH = $(window).height();
		
		 //根据参数获取位置数值
		function getPosition($applyTo,position){
			var _pos = null;
			switch(position){
				case "rm" :
					$applyTo.data("offset","right");
					$applyTo.data("offsetPostion",settings.offset.right);
					_pos = {right:settings.offset.right,top:winH/2-$applyTo.innerHeight()/2};
				break;
				case "lm" :
					$applyTo.data("offset","left");
					$applyTo.data("offsetPostion",settings.offset.left);
					_pos = {left:settings.offset.left,top:winH/2-$applyTo.innerHeight()/2};
				break;
				case "rb" :
					_pos = {right:settings.offset.right,top:winH - $applyTo.innerHeight()};
				break;
				case "lb" :
					_pos = {left:settings.offset.left,top:winH - $applyTo.innerHeight()};
				break;
				case "l" :
					_pos = {left:settings.offset.left,top:settings.offset.top};
				break;
				case "r" :
					_pos = {right:settings.offset.right,top:settings.offset.top};
				break;
				case "t" :
					$applyTo.data("offset","top");
					$applyTo.data("offsetPostion",settings.offset.top);
					_pos = {left:settings.offset.left,top:settings.offset.top};
				break;
				case "b" :
					$applyTo.data("offset","bottom");
					$applyTo.data("offsetPostion",settings.offset.bottom);
					_pos = {left:settings.offset.left,top:winH - $applyTo.innerHeight()};
				break;
			}
			return _pos;
		}
		//设置容器位置
		function setPosition($applyTo,position,isUseAnimate){
			var scrollTop = $(window).scrollTop();
			var scrollLeft = $(window).scrollLeft();
			var _pos = getPosition($applyTo,position);
			_pos.top += scrollTop;
			isUseAnimate && $applyTo.stop().animate(_pos,settings.delay) || $applyTo.css(_pos);
		}
		return this.each(function(){
			var $this =  $(this);
			$this.css("position","absolute");
			settings.style && $this.css(settings.style);
			setPosition($this,settings.position);
			$(this).data("isAllowScroll",true);
			$(window).scroll(function(){
				$this.data("isAllowScroll") && setPosition($this,settings.position,true);
			});
		})
	}else{
		var speed = arguments.length > 1 && arguments[1] || "fast";
		this.each(function(){
			if(settings == "clearOffset"){
					var _c = {};
					if($(this).data("offset")){
						 _c[$(this).data("offset")] = 0;
						 $(this).data("isAllowScroll",false);
						 $(this).stop().animate(_c,speed);
					}
			}else if(settings == "addOffset"){
					var _c = {};
					if($(this).data("offset") && $(this).data("offsetPostion")){
						 _c[$(this).data("offset")] = $(this).data("offsetPostion");
						 $(this).stop().animate(_c,speed);
						 $(this).data("isAllowScroll",true);
					}

			}else if(settings == "setScrollDisable"){
				$(this).data("isAllowScroll",false);
			}else if(settings == "setScrollUsable"){
				$(this).data("isAllowScroll",true);
			}
		})
	}
};

});

////////////////////////////////////////////////////////////////
//                                                            //
//      以下为非Jquery代码 请勿使用                              //
//      jQuery.noConflict();                                  //
//      jQuery(document).ready(function($){                   //
//      });                                                   //
//                                                            //
////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////// topmenu
var NTS = NTS || {};
	NTS.Header = function() {
    var g = function(v) {
        return typeof(v) != "string" ? v: document.getElementById(v)
    },
    s = navigator.userAgent.toLowerCase(),
    o = /msie/.test(s) && !/opera/.test(s),
    l = o && !/msie 7/.test(s) && !/msie 8/.test(s);
    var i = {
        getCookie: function(w) {
            var v = document.cookie.match("(?:^|;)\\s*" + w + "=([^;]*)");
            return (v && v[1]) ? decodeURIComponent(v[1]) : ""
        },
        parseQueryParams: function(B) {
            var y = {};
            var w = B.split("&");
            for (var z = 0,
            A = w.length; z < A; ++z) {
                var x = w[z],
                C = x.search("=");
                var D = x.substring(0, C);
                var v = x.substring(C + 1, x.length);
                y[decodeURIComponent(D)] = decodeURIComponent(v)
            }
            return y
        },
        trim: function(v) {
            return v.replace(/^\s+|\s+$/g, "")
        },
        hasClass: function(w, v) {
            w = g(w);
            if (!w || !v || !w.className) {
                return false
            }
            return (" " + w.className + " ").indexOf(" " + v + " ") > -1
        },
        addClass: function(w, v) {
            w = g(w);
            if (!w || !v) {
                return
            }
            if (this.hasClass(w, v)) {
                return
            }
            w.className += " " + v
        },
        removeClass: function(w, v) {
            w = g(w);
            if (!this.hasClass(w, v)) {
                return
            }
            w.className = w.className.replace(new RegExp(v, "g"), "");
            if (!this.trim(w.className)) {
                w.removeAttribute(o ? "className": "class")
            }
        },
        addEvent: function(x, w, v) {
            x = g(x);
            if (!x || !w || typeof(v) != "function") {
                return
            }
            if (x.addEventListener) {
                x.addEventListener(w, v, false)
            } else {
                if (x.attachEvent) {
                    x.attachEvent("on" + w, v)
                }
            }
        },
        stopEvent: function(v) {
            if (v.stopPropagation) {
                v.stopPropagation()
            } else {
                v.cancelBubble = true
            }
            if (v.preventDefault) {
                v.preventDefault()
            } else {
                v.returnValue = false
            }
        },
        getElementsByClassName: function(w, B, v, A) {
            if (!g(v)) {
                return
            }
            var x = [],
            z = g(v).getElementsByTagName(B),
            y = 0;
            for (; y < z.length; y++) {
                if (i.hasClass(z[y], w)) {
                    x[x.length] = z[y];
                    arguments[3] && arguments[3].call(z[y])
                }
            }
            return x
        },
        escapeHTML: function(w) {
            var x = document.createElement("div");
            var v = document.createTextNode(w);
            x.appendChild(v);
            return x.innerHTML
        }
    };
    var e = i.getCookie("tracknick"),
    r = (document.location.href.indexOf("https://") === 0);
    function a(x) {
        var w = i.getElementsByClassName("menu-bd", "div", x)[0];
        if (!w) {
            return
        }
        if (!r) {
            var v = document.createElement("iframe");
            v.src = "about: blank";
            v.className = "menu-bd";
            x.insertBefore(v, w);
            x.iframe = v
        }
        x.menulist = w;
        x.onmouseenter = function() {
            i.addClass(this.parentNode, "hover");
            if (r) {
                return
            }
            this.iframe.style.height = parseInt(this.menulist.offsetHeight) + 25 + "px";
            this.iframe.style.width = parseInt(this.menulist.offsetWidth) + 1 + "px"
        };
        x.onmouseleave = function() {
            i.removeClass(this.parentNode, "hover")
        }
    }

    return {
        init: function(w) {
            if (l) {
                var v = i.getElementsByClassName("menu", "div", "site-nav",
                function() {
                    a(this)
                })
            }
        },
        writeLoginInfo: function(z) {
        }
    }
} ();

/////////////////////////////////////////////////// switch
var moveing = false;
function nts(id) { return document.getElementById(id); }
function moveElement(elementID,final_x,final_y,interval) {
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  if (elem.movement) {
    clearTimeout(elem.movement);
  }
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  if (!elem.style.top) {
    elem.style.top = "0px";
  }

  var xpos = parseInt(elem.style.left);
  var ypos = parseInt(elem.style.top);
  if (xpos == final_x && ypos == final_y) {
 moveing=false;
    return true;
  }
  if (xpos < final_x) {
    var dist = Math.ceil((final_x - xpos)/10);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = Math.ceil((xpos - final_x)/10);
    xpos = xpos - dist;
  }
  if (ypos < final_y) {
    var dist = Math.ceil((final_y - ypos)/10);
    ypos = ypos + dist;
  }
  if (ypos > final_y) {
    var dist = Math.ceil((ypos - final_y)/10);
    ypos = ypos - dist;
  }
  elem.style.left = xpos + "px";
  elem.style.top = ypos + "px";
  var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
  elem.movement = setTimeout(repeat,interval);
}
function next(previousBtn,nextBtn,scrollID,highlightID) {
 if(moveing) return;
 moveing = true;
 var vTop = parseInt(nts(scrollID).style.top);
 var vLeft = parseInt(nts(scrollID).style.left);
 if (vLeft <= -1776) return moveing=false;
 if(vLeft == -1184) {
  nts(nextBtn).className = 'last_btn';
 }
 var finalLeft = vLeft - 700;
 moveElement(scrollID,finalLeft,vTop,5);
 nts(previousBtn).className = 'previous';
 var highLightList = nts(highlightID).getElementsByTagName('span');
 for (var i=0; i<highLightList.length; i++) {
  if (highLightList[i].className == 'current') {
    var currentNum = i;
  }
 }
 highLightList[currentNum].className = '';
 highLightList[currentNum+1].className = 'current';
}
function previous(previousBtn,nextBtn,scrollID,highlightID) {
 if(moveing) return;
 moveing = true;
 var vTop = parseInt(nts(scrollID).style.top);
 var vLeft = parseInt(nts(scrollID).style.left);
 if (vLeft >= 0) return moveing=false;
 if(vLeft == -700) {
  nts(previousBtn).className = 'first_btn';
 }
 var finalLeft = vLeft + 700;
 moveElement(scrollID,finalLeft,vTop,5);
 nts(nextBtn).className = 'next';
 var highLightList = nts(highlightID).getElementsByTagName('span');
 for (var i=0; i<highLightList.length; i++) {
  if (highLightList[i].className == 'current') {
    var currentNum = i;
  }
 }
 highLightList[currentNum].className = '';
 highLightList[currentNum-1].className = 'current';
}
//show system message
function showSysMessage(){
	if(jQuery('#nts_dialog').length>0){
		var html = jQuery('#nts_dialog').html();
		if(html) mywx.load({title:'Message',width:400,height:'auto'}).text(html);
		//setTimeout(function(){mywx.closes()},8000);
	}	
}
jQuery(document).ready(function(){
	showSysMessage();
	

})
