function layerWrite(id,nestref,text) {
	if (ie4) document.all[id].innerHTML = text;
	if (ns4) {
		var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document;
		lyr.open();
		lyr.write(text);
		lyr.close();
	}
}

function layerShow(id) {
	if (ie4) document.all[id].style.visibility = "visible";
	if (ns4) document.layers[id].visibility = "show";
}

function layerHide(id) {
	if (ie4) document.all[id].style.visibility = "hidden";
	if (ns4) document.layers[id].visibility = "hide";
}

function changeBgColor(id,color){
	if (ie4) document.all[id].style.backgroundColor = color;
	if (ns4) {
		var obj = eval('document.' + id);
		obj.bgColor = color ;
	}
}

function clipValues(obj,which) {
	if (ie4) {
		var clipv = obj.clip.split("rect(")[1].split(")")[0].split("px")
		if (which=="t") return Number(clipv[0])
		if (which=="r") return Number(clipv[1])
		if (which=="b") return Number(clipv[2])
		if (which=="l") return Number(clipv[3])
	}
	if (ns4) {
		if (which=="t") return obj.clip.top
		if (which=="r") return obj.clip.right
		if (which=="b") return obj.clip.bottom
		if (which=="l") return obj.clip.left
	}
}

function clipTo(obj,t,r,b,l) {
	if (ie4) {
		obj.clip = "rect("+t+"px "+r+"px "+b+"px "+l+"px)";
	}
	if (ns4) {
		obj.clip.top = t;
		obj.clip.right = r;
		obj.clip.bottom = b;
		obj.clip.left = l;
	}	
}

function clipBy(obj,t,r,b,l) {
	if (ie4) {
		obj.clip = "rect("+(this.clipValues(obj,'t')+t)+"px "+(this.clipValues(obj,'r')+r)+"px "+Number(this.clipValues(obj,'b')+b)+"px "+Number(this.clipValues(obj,'l')+l)+"px)";
	}
	if (ns4) {
		obj.clip.top = clipValues(obj,'t') + t;
		obj.clip.right = clipValues(obj,'r') + r;
		obj.clip.bottom = clipValues(obj,'b') + b;
		obj.clip.left = clipValues(obj,'l') + l;
	}	
}	

var popWindowH = "";

function popWindow(url,name,width,height,features) {
	var winLeft = (screen.width - width) / 2;
	if (winLeft < 0) winLeft = 0;
	var winTop = (screen.height - height) / 2;
	if (winTop < 0 || winTop <= 55) winTop = 0;
	popWindowH = window.open(url,name,"width=" + width + ",height=" + height + ",top=" + winTop + ",left=" + winLeft + "," + features);
	if (window.focus) setTimeout('popWindowH.focus()',100);
}

function WM_preloadImages() {
  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0; arg<argLength; arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = "images/" + WM_preloadImages.arguments[arg];
    }
  }
}

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 SetCookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}