	function GetObject(id)
	{
			var object = null;
			
			object =  document.getElementById(id);

			if(IsNull(object ) || object == "undefined")
			{
				var elementNum = document.all.length;
				var elementIndex;
				for(elementIndex=0;elementIndex<elementNum-1;elementIndex++)
				{
					if(document.all(elementIndex).id.indexOf(id) != -1)
					{
						object = document.all(document.all(elementIndex).id);
						break;
					}
				}
			}

			return object ;
	}
	
	function GetValue(id)
	{
		var object = null;
		object = GetObject(id);
		if(object != null)
		{
			if(object.canHaveHTML == true)
			{
				return object.innerText
			}
			else
			{
				return object.value;
			}
		}
	}
	
	function SetValue(id,value)
	{
		var object = GetObject(id);
		if(object != null)
		{
			if(object.canHaveHTML == true)
			{
				object.innerHTML = value;
			}
			else
			{
				object.value = value;
			}
		}
	}
	
	
	function IsCurrency(value)
	{
		var isCurrency= /^\d+(\.\d+)?$/;
		var reg = new RegExp(isCurrency);
		reg.ignoreCase = true;
		var b = reg.test(value);

		if(b == false)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	
	function IsNumeric(value)
	{
		var i;
		for(i=0;i<Len(value);i++)
		{
			if(value.charCodeAt(i) < 48 || value.charCodeAt(i)>57)
			{
				return false;
			}
		}
		return true;
	}
	
	function IsNull(object)
	{
		if(object == null)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	function Len(string)
	{
		return string.length;
	}
	
	function Left(string,length)
	{
		if(Len(string) <= length)
			return string;
		else
			return string.substring(0,length);
	}
	


	function Right(string,length)
	{
		if(Len(string) <= length)
		{
			return string;
		}
		else
		{
			return string.substring(Len(string) - length);
		}
	}

	function Mid(string,start,end)
	{
		if(start<Len(string))
		{
			string = string.substring(start);
			string = Left(string,end);
		}	
		return string;
	}
	
	

	function ToUpper(string)
	{	
		return string.toUpperCase();
	}
	

	function ToLower(string)
	{
		return string.toLowerCase();
	}
	

	function CharCode(aChar)
	{
		return aChar.charCodeAt(0);
	}

	function RedirectToUrl(url)
	{
		location.replace(url);
	}
	

	function SetIsDisabled(id,bool)
	{
		GetObject(id).disabled = bool;
	}
	

	function SetIsDisplay(id,type)
	{
			GetObject(id).style.display= type;
	}

	function CompareDate(DateOne,DateTwo)
	{
		try
		{		
			var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ("-"));
			var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ("-")+1);
			var OneYear = DateOne.substring(0,DateOne.indexOf ("-"));
		
			var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ("-"));
			var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ("-")+1);
			var TwoYear = DateTwo.substring(0,DateTwo.indexOf ("-"));

			var i = Date.parse(OneMonth+"/"+OneDay+"/"+OneYear) - Date.parse(TwoMonth+"/"+TwoDay+"/"+TwoYear);
			
			if(i>0)
				return 1;
			else if(i == 0)
				return 0;
			else
				return -1;
		}
		catch(e)
		{
					alert(e.description+ ",code=" + (e.number & 0xFFFF));
		}
	}
	
	function CloseWindow(showConfirm)
	{
		if(showConfirm)
			window.close();
		else
		{
			window.opener = null;
			window.close();
		}	
	}
	
	function SetbgColor(id,color)
	{
		GetObject(id).style.backgroundColor=color;
	}
	
	function SetFontColor(id,color)
	{
		GetObject(id).style.color = color;
	}
	
	function Trim(value)
	{
		//var length = Len(string);
		//var index = 0;
		//var charCode = 0;
		
		//while(index <=length)
		//{
		//	charCode = string.charCodeAt(index );
		//	if(charCode != 32)
		//	{
		//		string = Mid(string,index ,length-index );
		//		break;
		//	}
		//	else
		//		index++;
		//}
		
		//length = Len(string)-1;
		
		//while(length>=0)
		//{
		//	charCode = string.charCodeAt(length);
			
		//	if(charCode != 32)
		//	{
		//		string = Mid(string,0,length+1);
		//		break;
		//	}
		//	else
		//		length--;
		//}
	 
 		var re = /\s*(\S[^\0]*\S)\s*/; 
		re.exec(value); 
 		return RegExp.$1; 
	}
	
	function ExecScript(code)
	{
		try
		{
			return window.execScript(code);
		}
		catch(ex)
		{
			return eval(code);
		}
	}

	function ShowDialog(url,vArguments,dialogWidth,dialogHeight,isModal)
	{
		var returnValue = "";
		if(isModal)
		{
			returnValue = window.showModalDialog(url,vArguments,"dialogWidth:" + dialogWidth + "px;dialogHeight=" + dialogHeight + "px;status:no;resizable:no;unadorned:no;scroll:no;center:yes;");
			return returnValue;
		}
		else
			returnValue = window.showModelessDialog(url,vArguments,"dialogWidth:" + dialogWidth + "px;dialogHeight=" + dialogHeight + "px;status:no;resizable:no;unadorned:no;scroll:no;center:yes;");
	}
	

	function ShowWindow(url,width,height)
	{
	    
	  var screenWidth,screenHeight;
	  screenWidth = screen.availWidth;
	  screenHeight = screen.availHeight;
	  var left = (screenWidth - width) * 0.5;
	  var top = (screen.Height - height) * 0.5; 
	  var newWin = window.open(url,null,"height=" + height + "px,width=" + width + "px,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,menubar=no,");
      newWin.moveTo(left,top);
      newWin.focus();
	}
		
	function ForbidGoBack()
	{
		history.forward();
	}
	
	function OnlyNumberic(id)
	{
		var object = GetObject(id);
		if(!IsNull(object))
		{
			var handler = function OnHandler(){return (event.keyCode>=48&&event.keyCode<=57)};
			object.attachEvent("onkeypress",handler);
		}
	}

		function OffsetLeft(id)
	    {
		var left = 0;
		var oElementParent = null;
		var oElement = document.getElementById(id);
		if(oElement != null)
		{
			left = oElement.offsetLeft;
			while(true)
			{
				oElementParent = oElement.offsetParent;
				if(oElementParent != null)
				{
					left += oElementParent.offsetLeft;
					oElement = oElementParent;
				}
				else
				{
					break;
				}
			}
		}
		return left;
	}
	
	function OffsetTop(id)
	{
	    
		var top = 0;
		var oElementParent = null;
		var oElement = document.getElementById(id);
		if(oElement != null)
		{
			left = oElement.offsetTop;
			while(true)
			{
				oElementParent = oElement.offsetParent;
				if(oElementParent != null)
				{
					top += oElementParent.offsetTop;
					oElement = oElementParent;
				}
				else
				{
					break;
				}
			}
		}
		return top;
	}
	
	
		function DisplayDateTime(id)
	{
		var curDate = new Date();
		var year 	= curDate.getFullYear();
		var month   = ((curDate.getMonth()+1)<10)?"0"+(curDate.getMonth()+1):(curDate.getMonth()+1);
		var day		= (curDate.getDate()<10)?"0"+curDate.getDate():curDate.getDate();
		var hour 	= (curDate.getHours()<10)?"0"+curDate.getHours():curDate.getHours();
		var minuter = (curDate.getMinutes()<10)?"0"+curDate.getMinutes():curDate.getMinutes();
		var second  = (curDate.getSeconds()<10)?"0"+curDate.getSeconds():curDate.getSeconds();
		SetValue(id,year + "-" + month + "-" + day + " " +  hour + ":" + minuter + ":" + second); 
		setTimeout("DisplayDateTime('" + id + "')",1000);
	}
	

	
        function TabClick(tab)
        {
            GetObject(tab).style.display = "block";
            
            switch(tab)
            {
                case "Tab1":
                {
                    GetObject("Tabs").style.background = 'url(images/rank_tab01.gif) no-repeat';
                    GetObject("Tab2").style.display = "none";
                    GetObject("Tab3").style.display = "none";
                    break;
                }
                case "Tab2":
                {
                    GetObject("Tabs").style.background = 'url(images/rank_tab02.gif)  no-repeat';
                    GetObject("Tab1").style.display = "none";
                    GetObject("Tab3").style.display = "none";

                    break;
                }               
                 case "Tab3":
                {
                    GetObject("Tabs").style.background = 'url(images/rank_tab03.gif)  no-repeat';
                    GetObject("Tab1").style.display = "none";
                    GetObject("Tab2").style.display = "none";
                    break;
                }            
           }
        }
        
        
        function Refresh(imageId)
        {
             var randomnum = Math.random();
             var img = GetObject(imageId);
             if(img != null)
             {
                img.src = img.src + "?" + randomnum;
             }
        }
        
        
     window.load = DisplayDateTime("timer");

