var MAX_CYCLES=2;
function Hashtable(){
	this.hash = new Array();
	this.keys = new Array();

	this.location = 0;
}

Hashtable.prototype.get = function (key)
{
	return this.hash[key];
}

Hashtable.prototype.put = function (key, value)
{
	if (value == null)
		return null;

	if (this.hash[key] == null)
		this.keys[this.keys.length] = key;

	this.hash[key] = value;
}

function showmenu(elmnt)
{
	document.getElementById(elmnt).style.display="block";
}
function hidemenu(elmnt)
{
	document.getElementById(elmnt).style.display="none";
}

var tid;
function messageTurn(sid,s)
{
	var obj=document.getElementById(sid);
	if (obj)
	{
		var str = s;
		if(!s || s.length==0)
		{
			str=obj.innerHTML;
		}
		var swidth=obj.style.width;
		var nwidth = eval(swidth.substring(0,swidth.length-2));
		var nMax=Math.round(nwidth/5.5);
		for (var i=0;i<nMax;i++)
		{ 
			str=" "+str;
		}
		messageForward(sid,nMax,str,nMax,MAX_CYCLES);
	}
}

function messageForward(sid,idx,str,nMax, ncycle)
{
	var obj=document.getElementById(sid);
	var mbanner = document.getElementById("mbanner");
	if (obj)
	{
		var ncycle2 = ncycle;
		if (idx>=str.length)
		{
			idx=0;
			ncycle2--;
		}
		if ((str.length-idx)<=nMax)
		{
			var idx2=nMax-str.length+idx;
		    obj.innerHTML=(str.substring(idx)+str.substring(0,idx2)).replace(/\s/g,'&nbsp;');
		}
		else
		{
		    obj.innerHTML=str.substring(idx,(idx+nMax)).replace(/\s/g,'&nbsp;');
		}
		/*mbanner.style.backgroundPosition=Math.round(100-idx*100/str.length)+"% 50%"; */
		if (ncycle2<=0) return;
		idx+=5;
	    tid=setTimeout("messageForward('"+sid+"',"+idx+",'"+str+"',"+nMax+","+ncycle2+");", 500);
	}
}

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 setCookie(c_name,value,expiredays)
{
  var exdate=new Date();
  exdate.setDate(exdate.getDate()+expiredays);
  document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}

function getComputedStyleForId(elementId, cssPropertyName) {
	return getComputedStyleForElement(document.getElementById(elementId), cssPropertyName);
}

function getComputedStyleForElement(element, cssPropertyName) {
    if (element) {
        if (window.getComputedStyle) {
			return window.getComputedStyle(element,'').getPropertyValue(cssPropertyName.replace(/([A-Z])/g, "-$1").toLowerCase());
        } else if (element.currentStyle) {
			return element.currentStyle[cssPropertyName]; 
        } else {
			return null;
        }
    } else {
        return null;
    }
}

function setStyleForElement(element, cssPropertyName, value) {
    element.style[cssPropertyName]=value;
}

function setStyleForId(elementId, cssPropertyName, value) {
	var elem=document.getElementById(elementId);
	if (elem) elem.style[cssPropertyName]=value;
}

function getRealValue(input) 
{
    var attr = input.getAttributeNode("value");
    return (attr && attr.specified) ? input.getAttribute("value") : null;
}

function openwindow(shtml)
{
    var myWindow=window.open('','','width=600,height=400,resizable=yes');
    myWindow.document.write(shtml);
    myWindow.focus();
}

function clearDivs(divs) {
	for (var i=0; i<divs.length;i++) {
		var elem = document.getElementById(divs[i]);
		if (elem) elem.innerHTML='';
	}
}

