/*--------------------------------------------------------------------
Get the elements.
--------------------------------------------------------------------*/
function $(e){ return document.getElementById(e) }



loadstr = "<div style='text-align:center;width:100%;height:100%;'><img src='images/loading.gif' border='0' align='absmiddle'></div>";


/*--------------------------------------------------------------------
Replace space.
--------------------------------------------------------------------*/
function trim(str) 
{ 
	return str.replace(/(^\s*)|(\s*$)/g, ""); 
} 


/*--------------------------------------------------------------------
Get the elements.
--------------------------------------------------------------------*/
function PressKey(k)
{
     var WsShell = new ActiveXObject('WScript.Shell');
     WsShell.SendKeys('{'+k+'}');
}


/*--------------------------------------------------------------------
Chcek all checkbox.
--------------------------------------------------------------------*/
function CheckAll(status,obj)
{
	for(i=0; i<obj.length; i++)
	{
		obj[i].checked=status;
	}
}


/*--------------------------------------------------------------------
Get the client size, x and y.
--------------------------------------------------------------------*/
function WinSize(s)
{
	if(window.innerWidth)
	{
		winWidth = window.innerWidth;
	}
	else if((document.body) && (document.body.clientWidth))
	{
		winWidth = document.body.clientWidth;
	}

	if (window.innerHeight)
	{
		winHeight = window.innerHeight;
	}
	else if((document.body) && (document.body.clientHeight))
	{
		winHeight = document.body.clientHeight;
	}
	
	if(document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
	{
		winHeight = document.documentElement.clientHeight;
		winWidth = document.documentElement.clientWidth;
	}
	
	if( s == "x" ){ return winWidth; }
	if( s == "y" ){ return winHeight; }
}


/*--------------------------------------------------------------------
Turn the turns.
--------------------------------------------------------------------*/
function Turner(obj,cls,siz,spd,sfc,ofc)
{
	if( siz < 0 ){ siz = 0 }
	if( spd == "" ){ spd = 1 }

	if(cls == "width")
	{
		val = parseInt($(obj).style.width);
		if($(obj).name == "Off")
		{
			if((val-spd) < 0)
			{
				$(obj).style.width = "0px";
			}
			else
			{
				$(obj).style.width = val - spd + "px";
			}
			if(parseInt($(obj).style.width) <= spd)
			{
				if( spd < siz ){ clearTimeout(sto); }
				$(obj).style.width = 0 + "px";
				$(obj).name = "On";
				if( ofc != "" ){ eval(ofc) }
				return false;
			}
		}
		else
		{
			$(obj).style.width = val + spd + "px";
			if(parseInt($(obj).style.width) >= siz)
			{
				if( spd < siz ){ clearTimeout(sto); }
				$(obj).style.width = siz + "px";
				$(obj).name = "Off";
				if( sfc != "" ){ eval(sfc) }
				return false;
			}
		}
		
		sto = setTimeout("Turner('"+obj+"','"+cls+"',"+siz+","+spd+",'"+sfc+"','"+ofc+"')",1);
	}
	else
	{
		return false;
	}
}


/*--------------------------------------------------------------------
Nest funciton: $(), WinSize()
Close the Div: $("Cover_Div").innerHTML = "";
--------------------------------------------------------------------*/
function Div(alpha,color,align,valign,style,texts)
{
	PositionY = document.documentElement.scrollTop;
	PositionX = document.documentElement.scrollLeft;
	window.onscroll = function()
	{
		document.documentElement.scrollTop = PositionY;
		document.documentElement.scrollLeft = PositionX;
	}
	
	if(alpha == "")
	{
		alpha = "filter:Alpha(opacity=50);"
	}
	else
	{
		alpha = "filter:Alpha(opacity="+alpha+");"
	}
	if(color == "")
	{
		color = "background-color:#000000;"
	}
	else
	{
		color = "background-color:"+color+";"
	}
	
	if( style.indexOf("width") < 0 ){ style += "width:" + WinSize("x") + ";" }
	if( style.indexOf("height") < 0 ){ style += "height:" + WinSize("y") + ";" }
	
	if(!$("Cover_Div"))
	{
		document.body.innerHTML = "<div id='Cover_Div' style='width:0px;height:0px;margin:0px;padding:0px;'></div>" + document.body.innerHTML;
	}
	
	html = "";
	html += "<table border='0' cellspacing='0' cellpadding='0'><tr><td align='"+align+"' valign='"+valign+"' style='position:absolute;z-index:1000;top:"+PositionY+";left:"+PositionX+";"+alpha+color+style+"'>";
	html += "</td></tr></table>";
	html += "<table border='0' cellspacing='0' cellpadding='0'><tr><td align='"+align+"' valign='"+valign+"' style='position:absolute;z-index:1001;top:"+PositionY+";left:"+PositionX+";"+style+"'>";
	html += texts;
	html += "</td></tr></table>";

	if( $("Cover_Div") ){ $("Cover_Div").innerHTML = html; }
}


/*--------------------------------------------------------------------
Win_Move();
--------------------------------------------------------------------*/
function Win_Move(frame,href,direction,speed)
{
	Win = "Cover_Win";
	FO = $(frame).contentWindow;
	
	direction = direction.toLowerCase();
	Old_Href = $(frame).src;
	New_Href = href;
	
	WSX = parseInt($(frame).style.width);
	WSY = parseInt($(frame).style.height);
	
	if(!FO.document.getElementById(Win))
	{
		html = "";
		html += "<div id='"+Win+"' style='width:"+WSX+";height:"+WSY+";position:absolute;top:0px;left:0px;overflow:visible;display:none;'>";
		html += FO.document.body.innerHTML;
		html += "</div>";
		FO.document.body.innerHTML = html;
	}
	
	switch(direction)
	{
		case "top":
			Win_Old_Stt_X = 0; Win_Old_End_X = 0; Win_Old_Stt_Y = 0; Win_Old_End_Y = -(WSY);
			Win_New_Stt_X = 0; Win_New_End_X = 0; Win_New_Stt_Y = WSY; Win_New_End_Y = 0;

			if(New_Href != Old_Href)
			{
				if(FO.document.getElementById(Win).style.display == "none")
				{
					FO.document.getElementById(Win).style.top = Win_Old_Stt_Y + "px";
					FO.document.getElementById(Win).style.left = Win_Old_Stt_X + "px";
					FO.document.getElementById(Win).style.display = "block";
				}
				
				val = parseInt(FO.document.getElementById(Win).style.top);
				if(val > Win_Old_End_Y)
				{
					FO.document.getElementById(Win).style.top = val - speed;
				}
				else
				{
					FO.document.getElementById(Win).style.top = Win_Old_End_Y + "px";
					FO.document.getElementById(Win).style.left = Win_Old_End_X + "px";
					$(frame).style.filter = "Alpha(opacity=0)";
					$(frame).src = href;
					Load(frame,"Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")");
					clearTimeout(Win_MoveTime);
					return false;
				}
				
				Win_MoveTime = setTimeout("Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")",10);
			}
			else
			{
				if(FO.document.getElementById(Win).style.display == "none")
				{
					FO.document.getElementById(Win).style.top = Win_New_Stt_Y + "px";
					FO.document.getElementById(Win).style.left = Win_New_Stt_X + "px";
					FO.document.getElementById(Win).style.display = "block";
					$(frame).style.filter = "";
				}
				
				val = parseInt(FO.document.getElementById(Win).style.top);
				if(val > Win_New_End_Y)
				{
					FO.document.getElementById(Win).style.top = val - speed;
				}
				else
				{
					FO.document.getElementById(Win).style.top = Win_New_End_Y + "px";
					FO.document.getElementById(Win).style.left = Win_New_End_X + "px";
					FO.document.body.innerHTML = FO.document.getElementById(Win).innerHTML;
					clearTimeout(Win_MoveTime);
					return false;
				}
				
				Win_MoveTime = setTimeout("Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")",10);
			}
			
			break;
			
		case "bottom":
			Win_Old_Stt_X = 0; Win_Old_End_X = 0; Win_Old_Stt_Y = 0; Win_Old_End_Y = WSY;
			Win_New_Stt_X = 0; Win_New_End_X = 0; Win_New_Stt_Y = -(WSY); Win_New_End_Y = 0;
			
			if(New_Href != Old_Href)
			{
				if(FO.document.getElementById(Win).style.display == "none")
				{
					FO.document.getElementById(Win).style.top = Win_Old_Stt_Y + "px";
					FO.document.getElementById(Win).style.left = Win_Old_Stt_X + "px";
					FO.document.getElementById(Win).style.display = "block";
				}
				
				val = parseInt(FO.document.getElementById(Win).style.top);
				if(val < Win_Old_End_Y)
				{
					FO.document.getElementById(Win).style.top = val + speed;
				}
				else
				{
					FO.document.getElementById(Win).style.top = Win_Old_End_Y + "px";
					FO.document.getElementById(Win).style.left = Win_Old_End_X + "px";
					$(frame).style.filter = "Alpha(opacity=0)";
					$(frame).src = href;
					Load(frame,"Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")");
					clearTimeout(Win_MoveTime);
					return false;
				}
				
				Win_MoveTime = setTimeout("Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")",10);
			}
			else
			{
				if(FO.document.getElementById(Win).style.display == "none")
				{
					FO.document.getElementById(Win).style.top = Win_New_Stt_Y + "px";
					FO.document.getElementById(Win).style.left = Win_New_Stt_X + "px";
					FO.document.getElementById(Win).style.display = "block";
					$(frame).style.filter = "";
				}
				
				val = parseInt(FO.document.getElementById(Win).style.top);
				if(val < Win_New_End_Y)
				{
					FO.document.getElementById(Win).style.top = val + speed;
				}
				else
				{
					FO.document.getElementById(Win).style.top = Win_New_End_Y + "px";
					FO.document.getElementById(Win).style.left = Win_New_End_X + "px";
					FO.document.body.innerHTML = FO.document.getElementById(Win).innerHTML;
					clearTimeout(Win_MoveTime);
					return false;
				}
				
				Win_MoveTime = setTimeout("Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")",10);
			}
			
			break;
			
		case "left":
			Win_Old_Stt_X = 0; Win_Old_End_X = -(WSX); Win_Old_Stt_Y = 0; Win_Old_End_Y = 0;
			Win_New_Stt_X = WSX; Win_New_End_X = 0; Win_New_Stt_Y = 0; Win_New_End_Y = 0;
			
			if(New_Href != Old_Href)
			{
				if(FO.document.getElementById(Win).style.display == "none")
				{
					FO.document.getElementById(Win).style.top = Win_Old_Stt_Y + "px";
					FO.document.getElementById(Win).style.left = Win_Old_Stt_X + "px";
					FO.document.getElementById(Win).style.display = "block";
				}
				
				val = parseInt(FO.document.getElementById(Win).style.left);
				if(val > Win_Old_End_X)
				{
					FO.document.getElementById(Win).style.left = val - speed;
				}
				else
				{
					FO.document.getElementById(Win).style.top = Win_Old_End_Y + "px";
					FO.document.getElementById(Win).style.left = Win_Old_End_X + "px";
					$(frame).style.filter = "Alpha(opacity=0)";
					$(frame).src = href;
					Load(frame,"Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")");
					clearTimeout(Win_MoveTime);
					return false;
				}
				
				Win_MoveTime = setTimeout("Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")",10);
			}
			else
			{
				if(FO.document.getElementById(Win).style.display == "none")
				{
					FO.document.getElementById(Win).style.top = Win_New_Stt_Y + "px";
					FO.document.getElementById(Win).style.left = Win_New_Stt_X + "px";
					FO.document.getElementById(Win).style.display = "block";
					$(frame).style.filter = "";
				}
				
				val = parseInt(FO.document.getElementById(Win).style.left);
				if(val > Win_New_End_X)
				{
					FO.document.getElementById(Win).style.left = val - speed;
				}
				else
				{
					FO.document.getElementById(Win).style.top = Win_New_End_Y + "px";
					FO.document.getElementById(Win).style.left = Win_New_End_X + "px";
					FO.document.body.innerHTML = FO.document.getElementById(Win).innerHTML;
					clearTimeout(Win_MoveTime);
					return false;
				}
				
				Win_MoveTime = setTimeout("Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")",10);
			}
			
			break;
			
		default:
			Win_Old_Stt_X = 0; Win_Old_End_X = WSX; Win_Old_Stt_Y = 0; Win_Old_End_Y = 0;
			Win_New_Stt_X = -(WSX); Win_New_End_X = 0; Win_New_Stt_Y = 0; Win_New_End_Y = 0;
			
			if(New_Href != Old_Href)
			{
				if(FO.document.getElementById(Win).style.display == "none")
				{
					FO.document.getElementById(Win).style.top = Win_Old_Stt_Y + "px";
					FO.document.getElementById(Win).style.left = Win_Old_Stt_X + "px";
					FO.document.getElementById(Win).style.display = "block";
				}
				
				val = parseInt(FO.document.getElementById(Win).style.left);
				if(val < Win_Old_End_X)
				{
					FO.document.getElementById(Win).style.left = val + speed;
				}
				else
				{
					FO.document.getElementById(Win).style.top = Win_Old_End_Y + "px";
					FO.document.getElementById(Win).style.left = Win_Old_End_X + "px";
					$(frame).style.filter = "Alpha(opacity=0)";
					$(frame).src = href;
					Load(frame,"Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")");
					clearTimeout(Win_MoveTime);
					return false;
				}
				
				Win_MoveTime = setTimeout("Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")",10);
			}
			else
			{
				if(FO.document.getElementById(Win).style.display == "none")
				{
					FO.document.getElementById(Win).style.top = Win_New_Stt_Y + "px";
					FO.document.getElementById(Win).style.left = Win_New_Stt_X + "px";
					FO.document.getElementById(Win).style.display = "block";
					$(frame).style.filter = "";
				}
				
				val = parseInt(FO.document.getElementById(Win).style.left);
				if(val < Win_New_End_X)
				{
					FO.document.getElementById(Win).style.left = val + speed;
				}
				else
				{
					FO.document.getElementById(Win).style.top = Win_New_End_Y + "px";
					FO.document.getElementById(Win).style.left = Win_New_End_X + "px";
					FO.document.body.innerHTML = FO.document.getElementById(Win).innerHTML;
					clearTimeout(Win_MoveTime);
					return false;
				}
				
				Win_MoveTime = setTimeout("Win_Move('"+frame+"','"+href+"','"+direction+"',"+speed+")",10);
			}
			
			break;
	}
}


/*--------------------------------------------------------------------
Win_Alpha();
--------------------------------------------------------------------*/
function Win_Alpha(frame,href,speed)
{
	val = parseInt($(frame).style.filter.substr(14));
	if(isNaN(val)){val=100}
	
	FO = $(frame).contentWindow;
	Old_Href = $(frame).src;
	New_Href = href;
	Win = "Cover_Win";
	
	WSX = parseInt($(frame).style.width);
	WSY = parseInt($(frame).style.height);

	if(!FO.document.getElementById(Win))
	{
		html = "";
		html += "<div style='width:"+WSX+";height:"+WSY+";overflow:visible;filter:Alpha(opacity=100);'>";
		html += "<div id='"+Win+"' style='position:relative;'>" + FO.document.body.innerHTML + "</div></div>";
		FO.document.body.innerHTML =  html;
	}
	
	if(New_Href != Old_Href)
	{
		if(val < 0)
		{
			$(frame).src = href;
			Load(frame,"Win_Alpha('"+frame+"','"+href+"',"+speed+")");
			clearTimeout(Win_MoveTime);
			return false;
		}
		else
		{
			val -= speed;
			$(frame).style.filter = "Alpha(opacity="+val+")";
			Win_MoveTime = setTimeout("Win_Alpha('"+frame+"','"+href+"',"+speed+")",10);
		}
	}
	else
	{
		if(val > 100)
		{
			$(frame).style.filter = "";
			if( FO.document.getElementById(Win) ){ FO.document.body.innerHTML = FO.document.getElementById(Win).innerHTML }
			clearTimeout(Win_MoveTime);
			return false;
		}
		else
		{
			val += speed;
			$(frame).style.filter = "Alpha(opacity="+val+")";
			Win_MoveTime = setTimeout("Win_Alpha('"+frame+"','"+href+"',"+speed+")",10);
		}
	}
}


/*--------------------------------------------------------------------
When the page loaded and execute the act.
--------------------------------------------------------------------*/
function Load(Loadwin,Loadact)
{
	obj = document.readyState;
	if(Loadwin != "")
	{
		obj = $(Loadwin).contentWindow.document.readyState;
	}
	
	Load_Check = "";
	if (!(obj == "complete"))
	{
		Load_Check = setTimeout("Load(\""+Loadwin+"\",\""+Loadact+"\")",1);
	}
	else
	{
		clearTimeout(Load_Check);
		eval(Loadact);
	}
}


/*--------------------------------------------------------------------
UpdateCSS.
--------------------------------------------------------------------*/
function UpdateCSS(CSSName,element,value)
{
	var cssRules;
	if (document.all)
	{
		cssRules = 'rules';
	}
	else if(document.getElementById)
	{
		cssRules = 'cssRules';
	}
	
	for (var S = 0; S < document.styleSheets.length; S++)
	{
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++)
		{
			if (document.styleSheets[S][cssRules][R].selectorText == CSSName)
			{
				document.styleSheets[S][cssRules][R].style[element] = value;
			}
		}
	}
}


/*--------------------------------------------------------------------
GetURL.
--------------------------------------------------------------------*/
function geturl(loc,con)
{
	var v = "";
	loc != "" ? str = loc.location.href : str = location.href;
	var num = str.indexOf("?") 
	str = str.substr(num+1);
	var arr = str.split("&");

	for(var i = 0; i < arr.length; i++)
	{
		num = arr[i].indexOf("=");
		if(num > 0)
		{ 
			ns = arr[i].substring(0,num);
			if(ns == con){v = arr[i].substr(num+1);}
		} 
	}
	return v;
}


/*--------------------------------------------------------------------
SetURL.
--------------------------------------------------------------------*/
function seturl(loc,str)
{
	loc != "" ? href = loc.location.href : href = location.href;
	if(href.indexOf("?") < 0)
	{
		url = href;
		old_href = "";
	}
	else
	{
		url = href.substr(0,href.indexOf("?"));
		old_href = href.substr(href.indexOf("?")+1);
	}
	
	str = str.split(",");
	new_val = new Array();
	for(i=0; i<str.length; i++)
	{
		Temp = str[i].split("=");
		new_val[i] = Array(Temp[0],Temp[1]);
	}
	
	str = old_href.split("&");
	old_val = new Array();
	for(i=0; i<str.length; i++)
	{
		if(str[i].indexOf("=") >= 0)
		{
			Temp = str[i].split("=");
			old_val[i] = Array(Temp[0],Temp[1]);
		}
	}

	for(i=0; i<old_val.length; i++)
	{
		for(j=0; j<new_val.length; j++)
		{
			if( old_val[i][0] == new_val[j][0] ){ old_val[i] = "" }
		}
	}

	new_href = "";
	for(i=0; i<old_val.length; i++)
	{
		if(old_val[i] != "")
		{
			if(old_val[i][1] != ""){ new_href += "&" + old_val[i][0] + "=" + old_val[i][1] }
		}
	}

	for(i=0; i<new_val.length; i++)
	{
		if(new_val[i] != "")
		{
			if(new_val[i][1] != ""){ new_href += "&" + new_val[i][0] + "=" + new_val[i][1] }
		}
	}
	
	if(new_href != "")
	{
		url = url + "?" + new_href.substr(1);
	}
	
	loc != "" ? loc.location.href = url : location.href = url;
}


/*--------------------------------------------------------------------
SetURL.
--------------------------------------------------------------------*/
function makurl(href,str)
{
	if(href.indexOf("?") < 0)
	{
		url = href;
		old_href = "";
	}
	else
	{
		url = href.substr(0,href.indexOf("?"));
		old_href = href.substr(href.indexOf("?")+1);
	}
	
	str = str.split(",");
	new_val = new Array();
	for(i=0; i<str.length; i++)
	{
		Temp = str[i].split("=");
		new_val[i] = Array(Temp[0],Temp[1]);
	}
	
	str = old_href.split("&");
	old_val = new Array();
	for(i=0; i<str.length; i++)
	{
		if(str[i].indexOf("=") >= 0)
		{
			Temp = str[i].split("=");
			old_val[i] = Array(Temp[0],Temp[1]);
		}
	}

	for(i=0; i<old_val.length; i++)
	{
		for(j=0; j<new_val.length; j++)
		{
			if( old_val[i][0] == new_val[j][0] ){ old_val[i] = "" }
		}
	}

	new_href = "";
	for(i=0; i<old_val.length; i++)
	{
		if(old_val[i] != "")
		{
			if(old_val[i][1] != ""){ new_href += "&" + old_val[i][0] + "=" + old_val[i][1] }
		}
	}

	for(i=0; i<new_val.length; i++)
	{
		if(new_val[i] != "")
		{
			if(new_val[i][1] != ""){ new_href += "&" + new_val[i][0] + "=" + new_val[i][1] }
		}
	}
	
	if(new_href != "")
	{
		url = url + "?" + new_href.substr(1);
	}
	
	return url;
}


/*--------------------------------------------------------------------
Application tags turn.
--------------------------------------------------------------------*/
function Cover_Tag(obj,src,style,target)
{
	tag = obj.id.substr(0,obj.id.length-1);
	for(i=0; i<100; i++)
	{
		if($(tag+i))
		{
			$(tag+i).className = style;
		}
		else
		{
			break;
		}
	}
	obj.className = style+"Selected";
	if( src != "" && $(target).src != src ){ $(target).src = src; }
}


/*--------------------------------------------------------------------
Filter text.
--------------------------------------------------------------------*/
function Filter(text,type,retn)
{
	text = trim(text);
	switch(type)
	{
		case 1:
			str = '"|,|.|(|)|-|_|#|@|!|\'|!';
			break;
		case 2:
			str = '\\|/|*|&|^|%|$|#|@|!|\'|!';
			break;
		default:
			str = '"|\'|<|>';
			break;
	}
	str = str.split("|");
	
	TempText = text;
	for(i=0; i<str.length; i++)
	{
		TempText = TempText.replace(str[i],"");
	}
	
	switch(retn)
	{
		case 'bool':
			TempText == text ? Temp = true : Temp = false;
			return Temp;
			break;
			
		case 'mark':
			TempText = text;
			for(i=0; i<str.length; i++)
			{
				TempText = TempText.replace(str[i],"*");
			}
			return TempText;
			break;
			
		default:
			return TempText;
			break;
	}
}


/*--------------------------------------------------------------------
Drag layer.
--------------------------------------------------------------------*/
function Drag(div,dir)
{
	div = $(div);
	moveable = false;
	
	div.onmousedown = function()
	{
		if(event.button == 1)
		{
			div.style.position = "absolute";
			div.style.top = div.offsetTop;
			div.style.left = div.offsetLeft;
			
			if(dir == "x")
			{
				objX = parseInt(div.style.left);
				winX = event.clientX;
				offX = winX - objX;
			}
			
			if(dir == "y")
			{
				objY = parseInt(div.style.top);
				winY = event.clientY;
				offY = winY - objY;
			}
			
			if(dir != "x" && dir != "y")
			{
				objX = parseInt(div.style.left);
				winX = event.clientX;
				offX = winX - objX;
			
				objY = parseInt(div.style.top);
				winY = event.clientY;
				offY = winY - objY;
			}
			moveable = true;
			div.setCapture();
		}
	};
	
	document.body.onmouseup = function()
	{
		moveable = false;
		div.releaseCapture();
	};
	
	document.body.onmousemove = function()
	{
		if(moveable)
		{
			if(dir == "x")
			{
				div.style.left = event.clientX - offX;
			}
			
			if(dir == "y")
			{
				div.style.top = event.clientY - offY;
			}
			
			if(dir != "x" && dir != "y")
			{
				div.style.left = event.clientX - offX;
				div.style.top = event.clientY - offY;
			}
		}
	};
}



/*--------------------------------------------------------------------
AJAX Create ajax object.
--------------------------------------------------------------------*/
function ajax_create()
{
	var xmlHttp;
	var msXml = new Array(
	"Microsoft.XMLHTTP",
	"MSXML2.XMLHTTP.5.0",
	"MSXML2.XMLHTTP.4.0",
	"MSXML2.XMLHTTP.3.0",
	"MSXML2.XMLHTTP"
	);
	if(window.xmlHttpRequest)
	{
		xmlHttp=new XMLHttpRequest();
	} 
	else
	{
		for(var i=0;i<msXml.length;i++)
		{
			try
			{
				xmlHttp=new ActiveXObject(msXml[i]);
				break;
			}
			catch(e)
			{
				xmlHttp=new xmlHttpRequest();
			}
		}
	}
	return xmlHttp;
}


/*--------------------------------------------------------------------
Ajax interface.
--------------------------------------------------------------------*/
function ajax(act,url)
{
	if(url.indexOf("?") > 0)
	{
		url = url.split("?");
		$ajax = new ajax_create();
		if($ajax)
		{
			try
			{
				if(act == "")
				{
					$ajax.onreadystatechange = ajax_request;
				}
				else
				{
					$ajax.onreadystatechange = act;
				}
				$ajax.open("POST",url[0],true);
				$ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=GB2312"); 
				$ajax.send(url[1]);
				return true;
			} 
			catch(errv)
			{ 
				return false;
			} 
		}
	}
	return false;
}


/*--------------------------------------------------------------------
AJAX Get request.
--------------------------------------------------------------------*/
function ajax_request()
{ 
	if($ajax.readyState==4)
	{
		if($ajax.status==200)
		{
			alert($ajax.responseText);
			//eval($ajax.responseText);
		}
		else
		{ 
			alert($ajax.status); 
			//alert("$ajax error"); 
		} 
	} 
}


/*----------------------------------------------------------------------------------------------------------------------------------------
PHP Framework
----------------------------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------
Parent Function: Cover_Menu
--------------------------------------------------------------------*/
function FoldStatus(obj)
{
	val = obj.innerHTML;
	if(val.indexOf("Fold.png") < 0)
	{
		obj.innerHTML = val.replace("Unfold.png","Fold.png");
	}
	else
	{
		obj.innerHTML = val.replace("Fold.png","Unfold.png");
	}
}

//=========================================
//获得客房端浏览器信息函数
//仅支持IE6 IE7 Firefox
//=========================================
function client()
{
	temp = 0;
	var os = navigator.userAgent.toLowerCase();
	var ostype = "other"
	var osver = "other"
	
	var isie = os.indexOf("msie");
	var isfirefox = os.indexOf("firefox");

	if (isfirefox != -1)
	{
		osver = parseFloat(os.substr(isfirefox + 8));
		ostype = "firefox"
	}

	if (isie != -1)
	{
		osver = parseFloat(os.substr(isie + 5));
		ostype = "msie"
	}
		
	if (ostype == "msie" && osver == 6){temp = 1}
	if (ostype == "msie" && osver == 7){temp = 2}
	if (ostype == "firefox"){temp = 3}
	
	if(temp != 1 && temp != 2)
	{
		alert("本系统仅支持 Microsoft 浏览器访问！");
		top.location.href="about:blank";
	}
}

//========================================================
//show time

function showtime(obj)
{
today=new Date(); 
var year=today.getYear();
var month=today.getMonth()+1;
var day=today.getDate();
var hours = today.getHours(); 
var minutes = today.getMinutes(); 
var seconds = today.getSeconds(); 
var timeValue= hours;//((hours >12) ? hours -12 :hours);
timeValue += ((minutes < 10) ? ":0" : ":") + minutes+""; 
//timeValue += (hours >= 12) ? "PM" : "AM"; 
timeValue+=((seconds < 10) ? ":0" : ":") + seconds+"";
var timetext=year+"-"+month+"-"+day+" "+timeValue
//document.write("<span  onclick=\"document.getElementById('time').value='"+timetext+"'\">"+timetext+"</span>"); 
top.document.getElementById("usertop").innerText = timetext; //div的html是now这个字符串 
setTimeout("showtime()",1000); //设置过1000毫秒就是1秒，调用showtime方法 
}


//========================================================
//选取字符串函数

function right(Str,n){
    return Str.substr(Str.length-n);
}

function left(Str,n){
    return Str.substr(0,n);
}

function mid(Str,Start,End){
    return Str.substring(Start,End);
}



//========================================================
//turn to page

function turnPage(p)
{
	seturl("","p=" + p);
}

//========================================================
//show turn to page for dFrame

function toTurn(val)
{
	if(document.getElementById("ShowTurn"))
	{
		document.getElementById("ShowTurn").innerHTML = val;
	}
}



function addCookie(objName,objValue,objHours)
{
	var str = objName + "=" + escape(objValue);
	if(objHours > 0)
	{
		var date = new Date();
		var ms = objHours*3600*1000;
		date.setTime(date.getTime() + ms);
		str += "; expires=" + date.toGMTString();
	}
	document.cookie = str;
}

function getCookie(objName)
{
	var arrStr = document.cookie.split("; ");
	for(var i = 0;i < arrStr.length;i ++)
	{
		var temp = arrStr[i].split("=");
		if(temp[0] == objName) return unescape(temp[1]);
	}
	return "";
}

function delCookie(name)
{
   var date = new Date();
   date.setTime(date.getTime() - 10000);
   document.cookie = name + "=a; expires=" + date.toGMTString();
}

