// 1k DHTML API - standards version
d=document;l=d.layers;op=navigator.userAgent.indexOf('Opera')!=-1;px='px';
function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
function sE(e){l?e.visibility='show':e.style.visibility='visible';}
function hE(e){l?e.visibility='hide':e.style.visibility='hidden';}
function dsE(e){l?e.display='block':e.style.display='block';}
function dhE(e){l?e.display='none':e.style.display='none';}
function sZ(e,z){l?e.zIndex=z:e.style.zIndex=z;}
function sX(e,x){l?e.left=x:op?e.style.pixelLeft=x:e.style.left=x+px;}
function sY(e,y){l?e.top=y:op?e.style.pixelTop=y:e.style.top=y+px;}
function sW(e,w){l?e.clip.width=w:op?e.style.pixelWidth=w:e.style.width=w+px;}
function sH(e,h){l?e.clip.height=h:op?e.style.pixelHeight=h:e.style.height=h+px;}
function sC(e,t,r,b,x){l?(X=e.clip,X.top=t,X.right=r,X.bottom=b,X.left=x):e.style.clip='rect('+t+' '+r+' '+b+' '+x+')';}
function wH(e,h){if(l){Y=e.document;Y.open();Y.write(h);Y.close();}if(e.innerHTML)e.innerHTML=h;}

function getElem(e, f) { return gE(e,f) }
function showElem(e) { return e?sE(e):false } // visibility
function hideElem(e) { return e?hE(e):false }
function showDisplayElem(e) { return e?dsE(e):false } // display
function hideDisplayElem(e) { return e?dhE(e):false }
function showMultiDisplayElem(commaSepIds) { 
         var itemList = commaSepIds.split(","); 
         for (i=0; i<itemList.length; i++) { 
                 showDisplayElem(getElem(itemList[i])); 
         } 
  
 } 
 function hideMultiDisplayElem(commaSepIds) { 
         var itemList = commaSepIds.split(","); 
         for (i=0; i<itemList.length; i++) { 
                 hideDisplayElem(getElem(itemList[i])); 
         } 
  
 }
function scrollToDivTop(dividName) {
	var scrollobj = getElem(dividName);
	if (scrollobj) { 
		scrollobj.scrollTop = 0;
	}
	else {
		scrollobj.scrollLeft = 0;
	}
}

function setZ(e, z) { return sZ(e,z) }
function setLeft(e, x) { return sX(e,x) }
function setTop(e, y) { return sY(e,y) }
function setWidth(e, w) { return sW(e,w) }
function setHeight(e, h) { return sH(e,h) }
function setClip(e,t,r,b,x) { return sC(e,t,r,b,x) }
function writeHTML(e, h) { return wH(e,h) }
function setClass(e, n) {
    e.className=n
}
function disableElem(e) {
    e.disabled=true
    e.style.visibility='hidden';
}
function enableElem(e) {
    e.disabled=false
    e.style.visibility='visible'
}
function isClass(object, className) {
	return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1);
}
function doAHrefClick(id) {
    var a=getElem(id)
    if (a && a.href)

    // stop click thru propagation
    // would result in 'double' clicking
    if (!e) var e = window.event;
    if (e) {
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();
    }

    window.location=a.href

}
function GetElementsWithClassName(elementName,className,obj) {
    var allElements = null
    if (obj) {
        allElements = obj.getElementsByTagName(elementName);
    } else {
    	allElements = document.getElementsByTagName(elementName);
    }
	var elemColl = new Array();
	for (i = 0; i< allElements.length; i++) {
		if (isClass(allElements[i], className)) {
			elemColl[elemColl.length] = allElements[i];
		}
	}
	return elemColl;
}
function DOM_insertAfter(newChild,refChild)
//Post condition: if childNodes[n] is refChild, than childNodes[n+1] is newChild.
{
  var parent=refChild.parentNode;
  if(parent.lastChild==refChild) return parent.appendChild(newChild);
  else return parent.insertBefore(newChild,refChild.nextSibling);
}


// expires is in days
function setCookie( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function deleteCookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

clearDefault = function(obj) {
    if (obj.defaultValue == obj.value) obj.value = ''
}
function doDropDown(obj) {
    var url = obj.options[obj.selectedIndex].value
    if (url != "null") {
    window.location = url
    }
}
function silas_randomizeClass(id, className, limit) {
    var div = getElem(id);
    if (div) {
        var rand = parseInt(Math.random()*parseInt(limit));
        div.className += " " + className + rand
    }
}