﻿$(function() {
	//banner
    $('#banner').bxSlider({
        infiniteLoop: true,
        auto: true,
        pager: true
    });
		   
	//IE6 PNG透明
	$(document).pngFix(); 
	
	//返回页面顶部按纽跟随
	$('.goTop').scrollFollow({offset:200});
	$('.goTop').click(function(){
		$('html,body').animate({scrollTop: '0px'}, 600);
		return false;
	});
	
	//tab选项卡
	$("a.tabs").click(function () {
		$(this).parent().find("a.selected").removeClass("selected");
		$(this).addClass("selected");
		for(var i=0;i<$(this).parent().find("a").length;i++){
			$("#"+$(this).parent().find("a:eq("+i+")").attr("rel")).hide();
		}
		$("#"+$(this).attr("rel")).show();
		return false;
	});
	
	
		
	//留言和其他信息定位到左下位置
	
	$('#pageLeft .guestBook #name').focus(function(){
		var content=$(this).val();
		if(content=="Name")
		$(this).val('');							  
	})
	$('#pageLeft .guestBook #name').blur(function(){
		var content=$(this).val();
		if(content=="")
		$(this).val('Name');							  
	})
	$('#pageLeft .guestBook #email').focus(function(){
		var content=$(this).val();
		if(content=="E-mail")
		$(this).val('');							  
	})
	$('#pageLeft .guestBook #email').blur(function(){
		var content=$(this).val();
		if(content=="")
		$(this).val('E-mail');							  
	})
	$('#pageLeft .guestBook #title').focus(function(){
		var content=$(this).val();
		if(content=="Title")
		$(this).val('');							  
	})
	$('#pageLeft .guestBook #title').blur(function(){
		var content=$(this).val();
		if(content=="")
		$(this).val('Title');							  
	})
	//
	//$('#pageLeft .guestBook textarea').focus(function(){
		//var content=$(this).html();
		//if(content=="请输入咨询内容")
		//$(this).html('');							  
//	})
	//$('#pageLeft .guestBook textarea').blur(function(){
		//var content=$(this).html();
		//if(content=="")
		//$(this).html('请输入咨询内容');							  
	//})
	//$('#pageLeft .guestBook button').hover(function(){
		//$(this).addClass("hover");
	//},function(){
	//	$(this).removeClass("hover");
	//})

	//服务列表渐变效果	
	initServiceList();	
	
	//案例列表渐变效果	
	initCaseList();	
	
	//客户滚动
	var speed=24;
	var demo = $(".client .list");
	var demo1 = $("#demo1");
	var demo2 = $("#demo2");
	demo2.html(demo1.html());
	function Marquee(){ 
		if(demo.scrollLeft()>=demo1.width())
			demo.scrollLeft(0); 
		else{
			demo.scrollLeft(demo.scrollLeft()+1);
		}
	} 	
	var MyMar=setInterval(Marquee,speed);
	
})

function toggleLight(){
    if (!this.cover) {
        this.cover = $(this.lightTag, this).css({opacity:0});
		this.speed1=this.speed1||400;
		this.speed2=this.speed2||200;
		if($.browser.msie && $.browser.version=="6.0")
		{
			this.speed1=this.speed2=1;
		}
    }
    if (this.onLight) {
        this.cover.stop(true).fadeTo(this.speed1, 0);
        this.onLight = false;
    }
    else {
        this.cover.stop(true).fadeTo(this.speed2, 1);
        this.onLight = true;
    }
}

function initServiceList()
{	
	var item=$("#index .service .list li");
	item.each(function(){
		this.lightTag="div";
		var that=$(this);
		var div=$(document.createElement("div"));
		div.html(that.html());
		that.append(div).hover(toggleLight,toggleLight);
	})
}

function initCaseList()
{	
	var item=$("#index .case .list li,#case .list li");
	item.each(function(){
		this.lightTag="div";
		var that=$(this);
		var div=$(document.createElement("div"));
		div.html(that.html());
		that.append(div).hover(toggleLight,toggleLight);
	})
}

