var WindowSheetList = new Array();
var bw ="";

function verifyCompatibleBrowser()
{
    this.ver=navigator.appVersion;
    this.dom=document.getElementById?1:0
    this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0; 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
    this.Mac=(navigator.platform.indexOf("MacPPC")>-1)?1:0;
    this.PC=(navigator.platform.indexOf("Win")>-1)?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
    return this;
} 

function NewWindowSheet(Name,LayerWindow,LayerContent)
{
	if(!bw)
		bw = new verifyCompatibleBrowser();

	WindowSheetList[WindowSheetList.length] = new ClassWindowSheet(LayerWindow,LayerContent);
	WindowSheetList[WindowSheetList.length-1].Name = Name;
	return WindowSheet(Name);
}

function ClassWindowSheet(LayerWindow,LayerContent)
{
	this.Window = new SheetWindow(LayerWindow) ;
	this.Content = new SheetWindow(LayerContent,LayerWindow);
	this.Content.parent = this.Window;
	this.Content.MoveArea(0,(0 - this.Content.scrollHeight));
	this.Name = "";
	this.Content.css.visibility = 'hidden';
	this.Window.css.visibility = 'hidden';
}

function SheetWindow(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.';
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight;
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight;
    this.width=bw.ns4?this.css.document.width:this.el.offsetWidth;
    this.height=bw.ns4?this.css.document.height:this.el.offsetHeight;
    this.Document = bw.ns5?document:this.el.document;
    this.open=MoveAreaUp;
    this.close=MoveAreaDown;
    this.MoveArea=MoveArea;
    this.parent = "";
    this.IsClose = true;
    this.x = 0;
    this.y = 0;
    this.move = 5;
    this.obj = obj + "Object";
    this.endAction = "";
    this.openAction = "";
    eval(this.obj + "=this");
    this.speed = 0;
    return this;
} 

SheetWindow.prototype.SetSpeed = function (value)
{
	this.speed = value;
}

SheetWindow.prototype.SetMove = function (value)
{
	this.move = value;
}

SheetWindow.prototype.Show = function (Action,Execute)
{
	this.openAction = Action;
	
	if (Execute)
	{
		eval(this.openAction);
		this.openAction = '';
	}
	
	this.open();
}

SheetWindow.prototype.Hide = function (Action,Execute)
{
	this.endAction = Action;

	if (Execute)
	{
		eval(this.endAction);
		this.endAction = '';
	}
	
	this.close();
}


SheetWindow.prototype.Center = function ()
{
	if(document.all) 
    	{
		 dw = document.body.clientWidth;
		 dh = document.body.clientHeight;
	}
	else 
	{
		 dw = innerWidth;
		 dh = innerHeight;
	}
		this.css.left = (dw/2)-(this.width/2);
}

function MoveArea(x,y){ 
    this.x=x;
    this.y=y;
    this.css.left=this.y;
    this.css.top=this.x;
} 
 
function MoveAreaDown()
{ 
	if (!this.IsClose)
	{
		if(this.y>-335) //Use "this.scrollHeight)" or simply replace the number with the width of the window.
		{
	    		this.MoveArea(0,this.y-this.move)
	    		setTimeout(this.obj+'.close()',this.speed)
		}
		else
		{
			if (this.endAction != '')
			{	
				eval(this.endAction);	
				this.endAction = "";
			}

			this.css.visibility = 'hidden';
			this.parent.css.visibility = 'hidden';
			this.IsClose = true;
		}
	}
}

function MoveAreaUp()
{ 
	if (this.IsClose)
	{
		if(this.y-(this.move * -1)< 0)
		{
			this.css.visibility = 'visible';
			this.parent.css.visibility = 'visible';
 	   		this.MoveArea(0,this.y-(this.move * -1))
 	   		setTimeout(this.obj+".open()",this.speed)
		}
		else
		{
			if (this.openAction != '')
			{	
				eval(this.openAction);	
				this.openAction = "";
			}
			
			this.IsClose = false;
			this.MoveArea(0,0);
		}
	}
}

function WindowSheet(ID)
{
	var i;
	
	if ( typeof(ID) == "number")
		return WindowSheetList[ID].Content;

	for ( i = 0; i < WindowSheetList.length; i++)
	{
		if(WindowSheetList[i].Name == ID)
			return WindowSheetList[i].Content;
	}
}


function WindowSheetWindow(ID)
{
	var i;

	if ( typeof(ID) == "number")

		return WindowSheetList[ID].Window;

	for ( i = 0; i < WindowSheetList.length; i++)
	{
		if(WindowSheetList[i].Name == ID)
			return WindowSheetList[i].Window;
	}
}

function QueryString(Properties)
{
	if (document.location.href.indexOf("?") != -1)
	{
		var arrg = document.location.href.split("?");
		var list = arrg[1].split("&");
		var pro ;
		for(i = 0; i < list.length; i++)
		{
			pro = list[i].split("=")
			if (pro[0] == Properties)
				return pro[1].replace('%20' , ' ');
			pro = ""
		}
	}
	else
	{
		return null;
	}
}
