// JavaScript Document
/// Start Nav
$(document).ready(function(){
	$(".Nav li").hover(function(){
		$(this).children("a").not(".hor").animate({opacity:0.01},600);
	},function(){
		$(this).children("a").not(".hor").animate({opacity:1},600);
	});
});
/// End Nav




///****************************************** Start fouct ***********************************************
	var mCount,iExist;//////移动位置1为起始位置
	var imgWidth;//////图片宽度
	var liLength;//////图片个数
	var startIndex=0;/////起始位置
	var sequence;
$(document).ready(function(){
	mCount=1;//////移动位置1为起始位置
	iExist=0;
	imgWidth=$("#focusContent").width();//////图片宽度
	liLength=$("#focusContent ul li").length;//////图片个数

	$(".focusBtnL,.focusBtnR,.linkPage").css({"opacity":0.01, "cursor":"pointer"});
	$("#focusContent ul").css("width",$("#focusContent li").length*$("#focusContent").width());
	$("#focus").hover(
		function(){$(".focusBtnL,.focusBtnR,.linkPage").animate({opacity:0.9},600);},
		function(){$(".focusBtnL,.focusBtnR,.linkPage").animate({opacity:0.01},600);}
	);
	linkpage(liLength);
});

	function imagesMoveCount(i){
		clearInterval(sequence);
		if($(".linkPage .blue").attr("title")!=$(".linkPage span[title="+i+"]").attr("title")){
		$(".focusBtnL,.focusBtnR,.linkPage").css("display","none");
		var t=0,  d=250;
		$(".linkPage span.blue").removeClass("blue").addClass("white");
		$(".linkPage span[title="+i+"]").toggleClass("blue");
		clearTimeout(imagesMoveCount._t1);
		function _run(){
			if(t<d){
				t++;
				actionStart(t,-(mCount-1)*imgWidth,(mCount-i)*imgWidth,d);
				imagesMoveCount._t1 = setTimeout(_run, 10);
			}else{
				$(".focusBtnL,.focusBtnR,.linkPage").fadeIn(600);	
				mCount=i;
			}
		}
		_run();
		}
		//moveStart=i;
	}
	function moveImages(iCount){
		$(".focusBtnL,.focusBtnR,.linkPage").css("display","none");
		mCount+=iCount;
		var t=0,  d=250;
		clearTimeout(moveImages._t1);
		clearInterval(sequence);
		function _run(){
			if(t<d){
				t++;
				if(mCount<=liLength&&mCount>=1){
					if(iCount==1){
						actionStart(t,-(mCount-2)*imgWidth,-imgWidth,d);
					}else{
						actionStart(t,-(mCount)*imgWidth,imgWidth,d);
					}
				}
				else if(mCount>liLength){
					actionStart(t,-(liLength-1)*imgWidth,(liLength-1)*imgWidth,d);
				}else if(mCount<1){
					actionStart(t,0,-(liLength-1)*imgWidth,d);
				}
				moveImages._t1 = setTimeout(_run, 10);
			}else{
				if(mCount>liLength){
					mCount=1;
				}else if(mCount<1){
					mCount=liLength;
				}
				$(".linkPage span.blue").removeClass("blue").addClass("white");
				$(".linkPage span[title="+(mCount)+"]").toggleClass("blue");

				$(".focusBtnL,.focusBtnR,.linkPage").fadeIn(600);
				
				sequence=setInterval("moveImages(1)",6000);
			}
		}
		_run();
	}
	function actionStart(t,s,e,d){
		$("#focusContent ul").css({"left":Math.ceil(shake(t,s,e,d)) + "px"});
	}
	function shake(t,b,c,d){
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	}
	function linkpage(liLength){
		var count=liLength
		for(var i=1;i<=count;i++){
			$(".linkPage").append('<span class="white" onclick="imagesMoveCount('+i+')" title="'+i+'">&bull;</span>');
		}
		$(".linkPage span:first").addClass("blue")
	}
	
sequence=setInterval("moveImages(1)",6000);

///*********************************** End fouct***********************************************


///***************************************** Start service******************************************
$(document).ready(function(){
	$(".serviceInfo ul li span").each(function(i){$(this).css({backgroundPosition:-93*(i)+"px -465px"});});
	$(".serviceInfo ul li span:not(:animated)").parents("li").hover(function(){
		$(this).children("span").not($(".hor")).animate({opacity: 0.01},200);
	},function(){
		$(this).children("span").not($(".hor")).animate({opacity: 1},200);
	});
	function hideServerItem(){
	$(".serviceInfo ul li span").each(function(){
		$(this).animate({opacity:1},200);
	})
	}
	$(".serviceInfo ul li span").not(".last").click(function(){
		var $_Id=$(this);
		var $_Text="."+$(this).html();
		hideServerItem();
		$(".serviceInfo ul li span[class=hor]").removeClass("hor");
		$_Id.addClass("hor");
		$("#serverImg").fadeOut(200,function(){
			$("#serverImg").attr("src",$($_Text).children("code").text());
			$("#serverImg").attr("alt",$($_Text).children("h2").attr("title"));
			$("#serverImg").attr("title",$($_Text).children("h2").attr("title"));
			$("#serverImg").fadeIn(200);
		});
		$(".serviceInfo div.show:not(:animated)").fadeOut(200,function(){
			$(this).removeClass("show");
			$($_Text).addClass("show");
			$($_Text).fadeIn(200);
		});
		
		$("a#more").attr("href",$($_Text).children("em").html());
	});
});
///***************************************** End service *******************************************

///***************************************** Start faq******************************************
$(document).ready(function(){
	$("#faq .faqContent li:first").addClass("faqItem");
	$("#faq .faqContent li .q").click(function(){
		if(!$(".faqContent *").is(":animated")){
		$(".faqItem .a").slideToggle("slow"); 
		$(".faqItem").animate({opacity:0.01},600,function(){
			$(this).removeClass();
			$(this).animate({opacity:1},600);
		});
		$(this).animate({opacity:0.01},600,function(){
			$(this).parents("li").children(".a").slideToggle("slow"); 
			$(this).parents("li").addClass("faqItem");
			$(this).animate({opacity:1},600);
		});
		}
	});
	
	
	var $content = $("#txtAsk");
	var $str  =  $('#str');
	var time;
	var limit_str = 100;
	$content.css("color","#999");
	$content.val("在此填写问题");
	$content.focus(function(){
		time = window.setInterval( substring,100 );
	});	
	$content.blur(function(){
		if($content.val()==""){
			$content.val("在此填写问题");
			$content.css("color","#999");
		}
		window.clearInterval(time);
		substring();
	});
	$content.click(function(){
		if($content.val()=="在此填写问题"){
			$content.val("");
			$content.css("color","#000");
		}
	});
	function substring() {
		var val = $content.val();
		var length = val.length;
		if(length > limit_str){
			$content.val( $content.val().substring(0 , limit_str) );
		}
		if( $str.html() != (limit_str-length ) ){ //跳出循环
			$str.html( "你还可以输入"+((limit_str-length<=0)?'0':limit_str-length )+"字");
		}
	}
});
///***************************************** End faq******************************************

///***************************************** Start news******************************************
$(document).ready(function(){
	$(".newsItem em").each(function(i){
		$(this).css({backgroundPosition:"-640px "+((-i*10)-379)+"px"});
	});
});
///***************************************** End news******************************************




$(document).ready(function(){
  $('.TipTop.floatR').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')&& location.hostname == this.hostname) {
      var $target = $(this.hash);
      $target = $target.length && $target 
      || $('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        $('html,body').animate({scrollTop: targetOffset}, 400);
       return false;
      }
    }
  });
 
});

/********************************* Start .qq**************************************/
$(document).ready(function(){
var strqq="<div class=\"strqq\"><a href=\" http://sighttp.qq.com/cgi-bin/check?sigkey=0d071d2e33da349f00029a825d9d38b7f4f16709d17dd2251a76ff36846473624ce4c919140721173bbc6efdff156e72\"; target=_blank; onclick=\"var tempSrc=' http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=0d071d2e33da349f00029a825d9d38b7f4f16709d17dd2251a76ff36846473624ce4c919140721173bbc6efdff156e72';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;\"><img border=\"0\" SRC=' http://wpa.qq.com/pa?p=1:909917980:3' alt=\"点击这里给我发消息\"></a></div>";
var strqq1="<div class=\"strqq\"><a href=\" http://sighttp.qq.com/cgi-bin/check?sigkey=0d071d2e33da349f00029a825d9d38b7f4f16709d17dd2251a76ff36846473624ce4c919140721173bbc6efdff156e72\"; target=_blank; onclick=\"var tempSrc=' http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=0d071d2e33da349f00029a825d9d38b7f4f16709d17dd2251a76ff36846473624ce4c919140721173bbc6efdff156e72';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;\"><img border=\"0\" SRC=' http://wpa.qq.com/pa?p=1:909917980:3' alt=\"点击这里给我发消息\"></a></div>";
var strqq2="<div class=\"strqq\"><a href=\" http://sighttp.qq.com/cgi-bin/check?sigkey=97365e5d48706ecd14ebd37f2413585ef2f1bba9e00f2866a6124ecf8dc918324ad6198f662096c4941eb5064158ef14\"; target=_blank; onclick=\"var tempSrc=' http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=97365e5d48706ecd14ebd37f2413585ef2f1bba9e00f2866a6124ecf8dc918324ad6198f662096c4941eb5064158ef14';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;\"><img border=\"0\" SRC=' http://wpa.qq.com/pa?p=1:420311783:3' alt=\" 您好，有什么可以帮到您！\"></a></div>"
var strqq3="<div class=\"strqq\"><a href=\" http://sighttp.qq.com/cgi-bin/check?sigkey=0d071d2e33da349f00029a825d9d38b7f4f16709d17dd2251a76ff36846473624ce4c919140721173bbc6efdff156e72\"; target=_blank; onclick=\"var tempSrc=' http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=0d071d2e33da349f00029a825d9d38b7f4f16709d17dd2251a76ff36846473624ce4c919140721173bbc6efdff156e72';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;\"><img border=\"0\" SRC=' http://wpa.qq.com/pa?p=1:909917980:3' alt=\"点击这里给我发消息\"></a></div>";
var strqq4="<div class=\"strqq\"><a href=\" http://sighttp.qq.com/cgi-bin/check?sigkey=0d071d2e33da349f00029a825d9d38b7f4f16709d17dd2251a76ff36846473624ce4c919140721173bbc6efdff156e72\"; target=_blank; onclick=\"var tempSrc=' http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=0d071d2e33da349f00029a825d9d38b7f4f16709d17dd2251a76ff36846473624ce4c919140721173bbc6efdff156e72';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;\"><img border=\"0\" SRC=' http://wpa.qq.com/pa?p=1:909917980:3' alt=\"点击这里给我发消息\"></a></div>";
$("#qq").html(strqq4+strqq1+strqq2+strqq3);
$("#faqqq").html(strqq4+strqq1+strqq2+strqq3);
});
/********************************* End .qq**************************************/

/********************************* Start .map**************************************/
(function($) {
jQuery.fn.backgroundPosition = function() {
  var bgPosition = $(this).css('background-position');
  if(typeof(bgPosition) == 'undefined') {
	  return $(this).css('background-positionX') + ' ' + $(this).css('background-positionY');
  }else{
	  return bgPosition;
  }
};
})(jQuery);
$(document).ready(function(){
	$(".map").mousedown(function(m){
		var offs = $(".map").offset();
		var StartMapX = m.clientX - offs.left;
		var StartMapY = m.clientY + document.documentElement.scrollTop - offs.top;
		var startX=parseInt($('.map').backgroundPosition().split(" ")[0].split("p")[0]);
		var startY=parseInt($('.map').backgroundPosition().split(" ")[1].split("p")[0]);
		$(document).mousemove(function(e) {
			var mapX = e.clientX - offs.left-StartMapX+startX;
			var mapY = e.clientY + document.documentElement.scrollTop - offs.top-StartMapY+startY;
			mapX=(mapX>=0)?mapX=0:mapX;
			mapY=(mapY>=0)?mapY=0:mapY;
			mapX=(mapX<=-196)?mapX=-196:mapX;
			mapY=(mapY<=-154)?mapY=-154:mapY;
			$(".map").css({"background-position":mapX+"px "+mapY+"px"});
		});
	});
	$(document).mouseup(function(){
		$(document).unbind("mousemove");
	});
});
/********************************* End .map**************************************/




