﻿// BEGIN: URLParams holds all URL passed parameters (like ?Param1=Value1&Param2=Value2)
var URLParams = new Object() ;
var aParams = document.location.search.substr(1).split('&');
for (i=0 ; i < aParams.length ; i++)
{
	var aParam = aParams[i].split('=') ;
	URLParams[aParam[0]] = aParam[1] ;
}
// END: URLParams

function GetCookieVal(offset)
//获得Cookie解码後的值
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie(name, value)
//设定Cookie值
{
	var expdate = new Date();
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	//var path = (argc > 3) ? argv[3] : null;
	var path="/";
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
	+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
	+((secure == true) ? "; secure" : "");
}
function DelCookie(name)
//刪除Cookie
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; path=/; expires="+ exp.toGMTString();
}
function GetCookie(name)
//获得Cookie的原始值
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return GetCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
//排序
var rand_arr;
function arrlist(num)
{
	rand_arr=new Array();
	for(var i=1;i<num+1;i++)
  	rand_arr[i-1]=i;//生成一個數組
}
function mysort(a,b){
  var tmp=Math.round(Math.random()); //生成一個隨機數并取整，tmp的值为等于0或1的隨機數。
  return tmp?a-b:b-a;  //根据0或1进行升/降排序
}
//新增窗體
var win=this;
function openWindow(url, name, width, height, features)
{
	var winname="_self";
	if(typeof(name)!= "undefined"&&name!="")winname=name;
	var winfeatures="";
	if(typeof(width)!= "undefined"&&width!="")
	{
		var left=0;
		if(screen.width>width)left=(screen.width-width)/2;
		winfeatures+="left="+left+",screenX="+left+",width="+width+",";
	}
	if(typeof(height)!= "undefined"&&height!="")
	{
		var top=0;
		if(screen.height>height)top=(screen.height-height)/2;
		winfeatures+="top="+top+",screenY="+top+",height="+height+",";
	}
	if(typeof(features)!= "undefined"&&features!="")
	{
		var top=0;
		if(screen.height>height)top=(screen.height-height)/2;
		winfeatures+=features+",";
	}
	winfeatures=winfeatures.substring(0,winfeatures.length-1);
	win=window.open(url,winname,winfeatures);
	if(navigator.appName!= 'Microsoft Internet Explorer'){if(window.focus)win.focus()};
}
//pause
function Pause(obj,iMinSecond){
	if (window.eventList==null) window.eventList=new Array();
	var ind=-1;
	for (var i=0;i<window.eventList.length;i++){
		if (window.eventList[i]==null) {
			window.eventList[i]=obj;
			ind=i;
			break;
		}
	}
	if (ind==-1){
		ind=window.eventList.length;
		window.eventList[ind]=obj;
	}
	setTimeout("GoOn(" + ind + ")",1000);
}
function GoOn(ind){
	var obj=window.eventList[ind];
	window.eventList[ind]=null;
	if (obj.NextStep)
		obj.NextStep();
	else
		obj();
}
function IsConsistent(Str1,Str2)
{
	//例子:"-2-3-5-","-1-4-5-"==>true
	var j = 0;
	for(var i=0;i<Str1.length;i++)
	{
		if (Str1.substring(i, i + 1)=="-")
		{
			if (i != 0)
				if (Str2.indexOf(Str1.substring(j, i + 1)) != -1)
					return true;
			j = i;
		}
	}
	return false;
}
//定义路径警示
function _DefUrl(url,message)
{
	if(url==null)
	{
		url="|";
	}
	{
		var nowurl=document.location;
		nowurl=(nowurl+"").split("http://"+document.location.host)[1];
		url=((url.split("\|")[0]=="")?nowurl:url.split("\|")[0])+"|"+((url.split("\|")[1]=="")?nowurl:url.split("\|")[1]);
	}
	if(message==null)
	{
		message="|";
	}
	SetCookie("NewNowPage",url);
	SetCookie("NewAlertMessage",message);
}
//临时定义路径警示
function _DefTMPUrl()
{
	SetCookie("NewTMPNowPage",GetCookie("NewNowPage"));
	SetCookie("NewTMPAlertMessage",GetCookie("NewAlertMessage"));
	SetCookie("NewNowPage","/css/wc.html|/css/wc.html");
	SetCookie("NewAlertMessage","|");
}
function clickep(_control,_index)
{
	if(_control.innerHTML=="+")
	{
		_control.innerHTML="-";
		_control.parentNode.childNodes[_index].style.display="block";
	}
	else
	{
		_control.innerHTML="+";
		_control.parentNode.childNodes[_index].style.display="none";
	}
}
