﻿/*
Compatibility:	jQuery JavaScript Library v1.4.2
Version:		1.1.0
Date:		14:24 2010-5-14
Author:		Dolors.Yong
Email:		Dolors.Yong@hotmail.com
*/
var _hoverDelay = 500;

function SetCookie(c_name, value, expiredays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";path=/;expires=" + exdate.toUTCString());
}

function GetCookie(c_name)
{
	if (document.cookie.length > 0)
	{
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1)
		{
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1) c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return "";
}

function TextLimit(expr, limitLength)
{
	$(expr).each(function()
	{
		var objString = $(this).text();
		if (objString.replace(/[^\x00-\xff]/g, "rr").length > limitLength)
		{
			var cutLength = 0;
			for (var i = 0; i < objString.length; i++)
			{
				cutLength++;
				if (/[^\x00-\xff]/g.test(objString.charAt(i)))
					cutLength++;
				if (cutLength > limitLength)
				{
					$(this).attr("title", objString);
					$(this).text(objString.substring(0, i) + "...");
					break;
				}
			}
		}
	});
}

function LastListItemMark(exprList, exprItem, col)
{
	var itemLength = $(exprList).find(exprItem).length;
	if (itemLength <= col)
	{
		var lastItem = $(exprList + " " + exprItem);
		lastItem.attr("class", (lastItem.attr("class") == null || lastItem.attr("class") == "") ? "last" : lastItem.attr("class") + " last");
	}
	else
	{
		$(exprList + " " + exprItem + ":gt(" + (Math.ceil(itemLength / col) * col - col - 1) + ")").each(function()
		{
			$(this).attr("class", (this.className == null || this.className == "") ? "last" : this.className + " last");
		});
	}
}

function Tab_Show(tabName)
{
	$("#Tab_" + tabName).parent("ul.bar").parent("div.module").attr("id", "TabArea_" + tabName);
	document.getElementById("Tab_" + tabName).className = "green";
	$("#Div_" + tabName).show();
}

function TabArea_Switch(tabArea)
{
	$("#" + tabArea.id).parent("ul.bar").children("li[id]").each(function()
	{
		this.className = "";
		$("#" + this.id.replace("Tab_", "Div_")).hide();
	});
	Tab_Show(tabArea.id.replace("Tab_", ""));
}

function TabArea_Initialization()
{
	$(".module ul.bar li:not(.tab_shandow,.tab_end)").hover(
		function()
		{
			var e = $(this);
			e.bind("click", function()
			{
				TabArea_Switch(this);
			});
			setTimeout(function() { e.click(); }, _hoverDelay);
		},
		function()
		{
			$(this).unbind("click");
		}
	);
}

function AutoScrollUp(obj, scrollHeight)
{
	$(obj).find("ul:first").animate({ marginTop: scrollHeight }, "slow", function()
	{
		$(this).css({ marginTop: "0px" }).find("li:first").appendTo(this);
	});
}

function Slide_Show(slideName, index)
{
	if ($("#" + slideName + " ul li:eq(" + index + ")").attr("class") != "current")
	{
		var a = $("#" + slideName + " ol li:eq(" + index + ") a");
		$("#" + slideName + ">a:last img").attr({ src: $("#" + slideName + " ol li:eq(" + index + ") span").text(), title: a.text() }).stop().fadeTo(0, 1);
		$("#" + slideName + ">a:last").attr("href", a.attr("href")).insertBefore($("#" + slideName + ">a:first"));
		$("#" + slideName + ">a:last img").fadeOut("normal");
		$("#" + slideName + " ul li").each(function()
		{
			if ($(this).attr("class") == "current")
				$(this).attr("class", "");
		});
		$("#" + slideName + " ul li:eq(" + index + ")").attr("class", "current");}
}

function Slide_AutoPlay(slideName)
{
	if ($("#" + slideName + " ul li.current").text() == $("#" + slideName + " ul li").length)
		Slide_Show(slideName, 0);
	else
		Slide_Show(slideName, parseInt($("#" + slideName + " ul li.current").text()));
}

function FunctionIcons_Initialization()
{
	$(".fun_icon").each(function()
	{
		this.src = "/images/space.gif";
		switch (this.className.replace("fun_icon ", ""))
		{
			case "wan3":
				this.alt = this.title = fun_icon.wan3;
				break;
			case "wan4":
				this.alt = this.title = fun_icon.wan4;
				break;
			case "wan5":
				this.alt = this.title = fun_icon.wan5;
				break;
			case "qos":
				this.alt = this.title = fun_icon.qos;
				break;
			case "vpn":
				this.alt = this.title = fun_icon.vpn;
				break;
			case "eoip":
				this.alt = this.title = fun_icon.eoip;
				break;
			case "online400":
				this.alt = this.title = fun_icon.online400;
				break;
			case "online700":
				this.alt = this.title = fun_icon.online700;
				break;
			case "mbps700":
				this.alt = this.title = fun_icon.mbps700;
				break;
			case "pppoe":
				this.alt = this.title = fun_icon.pppoe;
				break;
			case "hotspot":
				this.alt = this.title = fun_icon.hotspot;
				break;
			case "wifi":
				this.alt = this.title = fun_icon.wifi;
				break;
			case "radius":
				this.alt = this.title = fun_icon.radius;
				break;
		}
	});
}

$(document).ready(function()
{
});
