function load_script()
{
    set_navigation();
}

/* 设置导航栏 */
function set_navigation()
{
    var lis = document.getElementById("nav").getElementsByTagName("a");
    for (var i = 0; i < lis.length; i++)
    {
        if (lis[i].href == document.URL)
        {
            lis[i].className = "cur";
        }
    }
}

// 动态页面过渡效果
var current_frame = null;
var frame_one = null;
var frame_two = null;
var current_url = null; 
$(function()
{
	// 设置是否使用这种页面机制
	var using_page_case = false;
	
	// 只在火狐使用这种效果
	if (!$.browser.mozilla && !($.browser.msie && $.browser.version == "8.0") || !using_page_case)
	{
		return;
	}
	
	// 因为用框架的, 所以要动态设置标题
	window.parent.document.title = window.document.title;
	
	// 绑定页面中的任何一个超链接处理, 一个都不放过
	$("a").click(function()
	{
		// 不是在当前页打开的链接, 以及执行javascript代码的链接, 都不是使用页面效果
		if (this.target  == "" && !this.href.match(/^javascript:.*$/))
		{
			// 点击本页的链接,  比较的时候需要把#后面的去掉, 因为加#是链接到本页的锚点
			var target_url = this.href.replace(/#\w*$/, "");
			if (document.URL.replace(/#\w*$/, "") == target_url)
			{
				// 锚点
				var target_id = this.href.replace(/^(.*)#(\w*)$/, "$2");
				if (target_id != target_url)
				{
					// 滚动到锚点处
					$(document.body).scrollTo($("#" + target_id), 400, {queue:true} );
				}
				
				return false;
			}
			
			// 滚动到最上面
			$(window.parent.document.body).scrollTo( 0, 800, {queue:true} );

			// 第一次点击超链接, 创建框架
			if (current_frame == null && window.parent.current_frame == null)
			{
				// 第一个
				$("html").append("<iframe id='the_page_frame_one' /><iframe id='the_page_frame_two' />");
				frame_one = $("#the_page_frame_one");
				frame_two = $("#the_page_frame_two");
				current_frame = frame_one;
			}
			else if (window.parent.current_frame.attr("id") == "the_page_frame_one")
			{
				// 第二个
				window.parent.current_frame.css("z-index", 100);
				window.parent.current_frame = current_frame = window.parent.frame_two;
			}
			else if (window.parent.current_frame.attr("id") == "the_page_frame_two")
			{
				// 第三个
				window.parent.current_frame.css("z-index", 100);
				window.parent.current_frame = current_frame = window.parent.frame_one;
			}
			
			// 几个新的页面动画切换
			if (target_url != window.parent.document.location)
			{
				// 使用iframe里的滚动条
				$(window.parent.document.body).css("overflow", "hidden");
				
				// 调整布局
				current_frame.css("z-index", 101);
				current_frame.css("display", "block");
				current_frame.css("left", "100%");
				
				
				// 动态切换, 切换完之后再显示内容
				current_url  =this.href;
				current_frame.animate({left : "0px"}, 400, "swing", function(){$(this).attr("src", current_url);});
			}
			else // 返回第一个打开的页面
			{
				// 使用浏览器自带的滚动条
				$(window.parent.document.body).css("overflow", "auto");
				
				// 选择最上面的那个iframe页面作为滚动收缩效果
				if (window.parent.frame_one.css("z-index") == 100)
				{
					window.parent.frame_one.css("left", "0px");
					window.parent.frame_one.animate({left:"100%"}, 400, "swing", function(){$(this).css("display", "none");});
					
					window.parent.frame_two.css("display", "none");
				}
				else
				{
					window.parent.frame_two.css("left", "0px");
					window.parent.frame_two.animate({left:"100%"}, 400, "swing", function(){$(this).css("display", "none");});
					
					window.parent.frame_one.css("display", "none");
				}
			}
			
			return false;
		}
	});
});

document.writeln("<style type='text/css'>");
document.writeln("#the_page_frame_one, #the_page_frame_two { border:none; position:absolute; top:0; height:100%; width:100%; display:none;background-color:#151600;}");
document.writeln("</style>");
