﻿$(function(){
	$('#index_nav li').hover(
	function()
	{
		$(this).find('.s2').css({opacity:'0'}).css({display:'block'}).stop().animate({opacity:'1'});
		$(this).find('.s1').stop().animate({top:'28px',opacity:'0'});
	},
	function()
	{
		$(this).find('.s1').stop().animate({top:'0px',opacity:'1'});
		$(this).find('.s2').stop().animate({opacity:'0'});
	});
	//导航效果
	$('#index_nav li').click(Body);
	//点击加载所有页面
	
	
});

function Body()
{
	
	var id=$(this).attr('id');
	if(id=='case')
	{
		return ;
		
	}
	var id_Body=$('<div id="'+id+'_Body"></div>');
	var id_Container=$('<div id="'+id+'_container"></div>');
	$('#index_body').append(id_Body);
	$('#'+id+'_Body').css({width:$(document.body).width(),height:$(document.body).height(),top:-$(document.body).height()});
	$('#'+id+'_Body').append(id_Container);
	
	switch(id)
	{
		case 'about':$('#'+id+'_Body').animate({top:'0px'},{duration:800,complete:function (){Body_End(id)}}); break;
		case 'service':$('#'+id+'_Body').animate({top:'0px'},{duration:800,complete:function (){Body_End(id)}}); break;
		case 'flow':$('#'+id+'_Body').animate({top:'0px'},{duration:800,complete:function (){Body_End(id)}}); break;
		case 'advantage':$('#'+id+'_Body').animate({top:'0px'},{duration:800,complete:function (){Body_End(id)}}); break;
		case 'news':$('#'+id+'_Body').animate({top:'0px'},{duration:800,complete:function (){Body_End(id)}}); break;
		case 'contact':$('#'+id+'_Body').animate({top:'0px'},{duration:800,complete:function (){Body_End(id)}}); break;
		default://alert('没有');break;;
	}
}


function Body_End(id)
{
	//alert(id);
	$(window).resize(
	function()
	{
		//alert(id);
		$('#'+id+'_Body').css({width:$(document.body).width(),height:$(document.body).height()});
	});

	$('#' + id + '_container').load(id + '.html',
	function(responseText, textStatus, XMLHttpRequest) {
	    //alert(responseText);
	    alert
	    $('#' + id + '_close div').hover(
		function() {
		    $(this).find('span').stop().animate({ opacity: '0' });
		},
		function() {
		    $(this).find('span').stop().animate({ opacity: '1' });
		});
	    $('#' + id + '_close div').click(
		function() {
		    $('#' + id + '_Body').animate({ top: -$(document.body).height() }, { duration: 800, complete: index_body_End });
		});
	    if (id == 'service') {
	        $('#' + id + '_Tab li').mouseover(
			function() {
			    var index = $('#' + id + '_Tab li').index(this);
			    $(this).attr('class', 'hover').siblings().attr('class', '');
			    $('#' + id + '_Cont ul').stop().animate({ left: -(index) * 748 });
			});
	    }

	    if (id == 'advantage') {
	        $('#' + id + '_Tab li').mouseover(
			function() {
			    var index = $('#' + id + '_Tab li').index(this);
			    $(this).attr('class', 'hover').siblings().attr('class', '');
			    $('#' + id + '_Cont ul').stop().animate({ left: -(index) * 748 });
			});
	    }

	    if (id == 'news') {


	        $.post("/ajax/ajaxNewsInfo.ashx", function(data) {


	            var html = '';
	            html = data;
	            $('#news_Cont').append('<ul id="news_list">' + html + '</ul>');
	            $('#news_list li').css({ backgroundPosition: "-360px 0px" }).mouseover(news_Cont).mouseout(news_Cont).click(news_Cont);

	        });

	      

	    }
	});
}



function news_Cont(event)
{
	if(event.type=="mouseover")
	{
		$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:800,easing:"easeInOutBack"});
	}
	if(event.type=="mouseout")
	{
		$(this).stop().animate({backgroundPosition:"(-360px 0px)"}, {duration:800,easing:"easeInOutBack"});
	}
	if(event.type=="click")
	{
		var id=$(this).attr('id');
		var h1=$(this).attr('title');
		var date=$(this).find('span').text();
		var title=$(this).find('div').html();
		var news_Title='<div id="news_title"><div id="news_title_close"></div><h1>'+h1+'</h1><div class="time">'+date+'</div><div class="news_title">'+title+'</div></div>';
		$('#news_title_end').append(news_Title);
		$('#news_title').animate({left:'0px'}, {duration:500,easing:"easeInOutCirc"});
		$('#news_title_close').click(news_title_close);
	}
	
}

function news_title_close()
{
	$('#news_title').animate({left:'-748px'}, {duration:500,easing:"easeInOutCirc",complete:news_title_End});
}

function news_title_End()
{
	//alert(this);
	$('#news_title_end').empty('#news_title');
}
//所有页面效果

function index_body_End()
{
	$('#index_body').empty();
}
//清空所有页面代码

