var pageloaded = 0, onloadlist = "";
var InNetscape, InNS4 = 0, InNS6 = 0;
var InIE, InOldIE = 0;
var InOpera;
var DOMCompatible;
var BrowserVersion;
var BrowserVerMajor = parseInt(navigator.appVersion), BrowserVerMinor = parseFloat(navigator.appVersion);
var useragent = navigator.userAgent.toLowerCase();

InNetscape = ((useragent.indexOf('mozilla') != -1) && (useragent.indexOf('spoofer') == -1) && (useragent.indexOf('compatible') == -1) &&
	(useragent.indexOf('opera') == -1) && (useragent.indexOf('webtv') == -1)) ? 1 : 0;
InOpera = (useragent.indexOf('opera') != -1) ? 1 : 0;
InIE = document.all ? 1 : 0;
DOMCompatible = document.getElementById ? 1 : 0;

if (InNetscape) {
	BrowserVersion = BrowserVerMajor;
	InNS4 = document.layers ? 1 : 0;
	if (BrowserVerMajor >= 5) {
		InNS6 = 1;
		if (useragent.indexOf('netscape6') != -1) {
			BrowserVersion = 6;
		} else {
			q = useragent.indexOf('netscape');
			if (q != -1)
				BrowserVersion = parseInt(useragent.substring(q + 9, q + 10));
		}

	} else {
		InNS6 = 0;

	}

} else if (InIE) {
	if (BrowserVerMajor < 4) {
		BrowserVersion = BrowserVerMajor;
		InIE = 0;
		InOldIE = 1;

	} else if (BrowserVerMajor >= 4) {
		q = useragent.indexOf('msie');
		if (q != -1) {
			BrowserVersion = parseInt(useragent.substring(q + 5, q + 6));
		} else {
			BrowserVersion = BrowserVerMajor;
		}

	}

} else {
	BrowserVersion = BrowserVerMajor;

}

if (InOpera) {
	q = useragent.indexOf('opera');
	if (q != -1) {
		BrowserVersion = parseInt(useragent.substring(q + 6, q + 7));
	}
}

var InMacOS, InUnix, InWindows;
var useros = navigator.platform.toLowerCase();
InMacOS = (useros.indexOf("mac") != -1) ? 1 : 0;
InWindows = (useros.indexOf("win") != -1) ? 1 : 0;
InUnix = ((useros.indexOf("unix") != -1) || (useros.indexOf("solaris") != -1) || (useros.indexOf("linux") != -1) || (useros.indexOf("sun") != -1) ||
	(useros.indexOf("hp") != -1) || (useros.indexOf("bsd") != -1)) ? 1 : 0;

Randomize();

var C_NUM = 0;
var C_DBL = 1;
var C_STRING = 2;
function nullwrap(somevar, newtype) {
	var curval;
	switch (newtype) {
	case 0:
		if (typeof(somevar) == 'number')
			return Math.floor(somevar);
		if (typeof(somevar) == 'string') {
			curval = isNaN(somevar) ? 0 : parseInt(somevar);
			if (isNaN(curval))
				curval = 0;
			return curval;
		}
		return 0;

	case 1:
		if (typeof(somevar) == 'number')
			return somevar;
		if (typeof(somevar) == 'string') {
			curval = isNaN(somevar) ? 0.0 : parseFloat(somevar);
			if (isNaN(curval))
				curval = 0.0;
			return curval;
		}
		return 0;

	case 2:
		if (typeof(somevar) == 'number')
			return somevar.toString;
		if (typeof(somevar) == 'string')
			return somevar;
		return '';
	}
}



var MeMSO_RandSeed = 0;
function Randomize() {
  var now = new Date();
  MeMSO_RandSeed = now.getTime() % 0xffffffff;
}



function Random(n) {
  MeMSO_RandSeed = (0x015a4e35 * MeMSO_RandSeed + 1) % 0x7fffffff;
  return (MeMSO_RandSeed >> 16) % n;
}



function OnLoadMainFunction() {
	if (onloadlist!="")
		eval(onloadlist);
	pageloaded = 1;
}



function AreYouSure(popuptext, someurl) {
	if (confirm(popuptext))
		window.location = someurl;
}



function DisplayMiniWindow(windowpage, popupwidth, popupheight) {
	window.open(windowpage, '', 'width=' + popupwidth + ',height=' + popupheight +
		',location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
}



function DisplayMiniWindow2(windowpage, popupwidth, popupheight) {
	window.open(windowpage, '', 'width=' + popupwidth + ',height=' + popupheight +
		',location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no');
}



function DisplayMiniWindow3(windowpage, targetwindow, popupwidth, popupheight) {
	window.open(windowpage, targetwindow, 'width=' + popupwidth + ',height=' + popupheight +
		',location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
}



function DisplayMiniWindow4(windowpage, targetwindow, popupwidth, popupheight) {
	window.open(windowpage, targetwindow, 'width=' + popupwidth + ',height=' + popupheight +
		',location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no');
}



function DisplayMiniWindowX(windowpage, targetwindow, popupwidth, popupheight, options) {
	window.open(windowpage,
		targetwindow,
		'width=' + popupwidth +
		',height=' + popupheight +
		',location=' + (options & 0x01 ? 'yes' : 'no') +
		',toolbar=' + (options & 0x02 ? 'yes' : 'no') +
		',menubar=' + (options & 0x04 ? 'yes' : 'no') +
		',scrollbars=' + (options & 0x08 ? 'yes' : 'no') +
		',resizable=' + (options & 0x10 ? 'yes' : 'no'));
}



function DisplayMessageAndGo(displaymessage, newlocation) {
	DisplayMiniWindow2('/popup-message.asp?message=' + escape(displaymessage), 400, 250);
	window.location = newlocation;
}



function PreloadImages(imagelist) {
	var imagearray = imagelist.split(",");
	var imagearraydata = new Array(imagearray.length);

	for (var q = 0; q < imagearray.length; q++) {
		imagearraydata[q] = new Image;
		imagearraydata[q].src = imagearray[q];
	}
}



function DisplayBrowserAndOSData() {
	alert('useragent = ' + useragent + '\n' +
		'InNetscape = ' + InNetscape + '\n' +
		'InNS4 = ' + InNS4 + '\n' +
		'InNS6 = ' + InNS6 + '\n' +
		'InIE = ' + InIE + '\n' +
		'InOldIE = ' + InOldIE + '\n' +
		'InOpera = ' + InOpera + '\n' +
		'DOMCompatible = ' + DOMCompatible + '\n' +
		'BrowserVersion = ' + BrowserVersion + '\n' +
		'BrowserVerMajor = ' + BrowserVerMajor + '\n' +
		'BrowserVerMinor = ' + BrowserVerMinor + '\n' +
		'\nuseros = ' + useros + '\n' +
		'InMacOS = ' + InMacOS + '\n' +
		'InWindows = ' + InWindows + '\n' +
		'InUnix = ' + InUnix + '\n');
}



function CheckForFlash2() {
	navigator.plugins.refresh();
	if (navigator.plugins["Shockwave Flash"]){ 
		parent.location.reload();

	} else {
		setTimeout("CheckForFlash2();", 1000);

	}
}



function CheckForFlash() {
	var ShockMode = 0;

	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] &&
		navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
		if (navigator.plugins && navigator.plugins["Shockwave Flash"])
			ShockMode = 1;
	}

	if (!ShockMode && navigator.appName && navigator.appName.indexOf("Netscape") != - 1 && navigator.appVersion.indexOf("4.") != - 1 &&
		navigator.javaEnabled() && netscape.softupdate.Trigger.UpdateEnabled() && document.cookie.indexOf("StartedShockwaveInstall") == -1) {
		var jarPath = new String("");
		if (navigator.platform.indexOf("Win32") >= 0)
			jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflash32.jar"
		else if (navigator.platform.indexOf("Win16") >= 0)
			jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflash16.jar"
		else if (navigator.platform.indexOf("MacPPC") >= 0)
			jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflashppc.jar"

		if (jarPath.length) {
			netscape.softupdate.Trigger.StartSoftwareUpdate (jarPath, netscape.softupdate.Trigger.FORCE_MODE);
			document.cookie = 'StartedShockwaveInstall;path=/;'
			setTimeout("CheckForFlash2();", 1000);
		}
	}
}



function CloseCurrentWindow() {
	if (InIE)
		self.close();
	else
		window.close();
}


function MeMSOAddEvent(eventname, eventfunction) {
	if (!InIE && !DOMCompatible && !InNS6 && !InNS4)
		return 0;
	if (InNS6)
		document.addEventListener(eventname, eventfunction, false);

	switch (eventname) {
	case 'mousemove':
		if (InNS4)
			document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = eventfunction;
		break;

	case 'mousedown':
		if (InNS4)
			document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown = eventfunction;
		break;

	case 'mouseup':
		if (InNS4)
			document.captureEvents(Event.MOUSEUP);
		document.onmouseup = eventfunction;

	}
	return 1;
}


function MeMSOObjectCreate(objectname) {
	var newhtml, newobject;
	if (!InNS4) {
		newhtml = '<div id="' + objectname + '" style="position: absolute;">&nbsp;</div>';
		if (typeof(document.createElement) != 'undefined') {
			newobject = document.createElement("DIV");
			if (newobject) {
				newobject.id = objectname;
				newobject.style.position = "absolute";
				document.body.appendChild(newobject);
			}

		} else if (typeof(document.body.insertAdjacentHTML) != 'undefined') {
			document.body.insertAdjacentHTML("BeforeEnd", newhtml);

		}

	} else {
		document.layers[objectname] = new Layer(0);
		eval('document.' + objectname + ' = document.layers[objectname];');

	}
}



function MeMSOObjectStyleChange(objectname, styletochange, newvalue) {
	var stylename = '', q, flag, curval;
	if (DOMCompatible || InNS4) {
		switch (styletochange) {
		case 'opacity':
			if (InNS6)
				document.getElementById(objectname).style.MozOpacity = (newvalue / 100);
			else if (InIE && !InMacOS)
				document.getElementById(objectname).filters.alpha.opacity = newvalue;
			break;

		default:
			if (styletochange=='background-image')
				newvalue = "url(" + newvalue + ")";
			for (q=0; q<styletochange.length; q++) {
				curval = styletochange.substring(q, q+1);
				if (curval=='-') {
					flag = 1;

				} else {
					if (flag) {
						stylename += curval.toUpperCase();
						flag = 0;
					} else {
						stylename += curval;
					}
				}
			}

			if (!InNS4) {
				eval('document.getElementById(objectname).style.' + stylename + ' = newvalue;');
			} else {
				eval('GetElementPointer(objectname, 0).' + stylename + ' = newvalue;');
			}
			break;
		}

	} else if (InIE) {
		switch (styletochange) {
		case 'background-color':
			stylename = 'bgColor';
			break;

		case 'background-image':
			stylename = 'bgImage';
			break;

		default:
			stylename = styletochange;

		}
		eval('document.all.' + objectname + '.' + stylename + ' = newvalue;');
	}
}



function MeMSOObjectMove(objectname, newx, newy) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);

	if (InIE || DOMCompatible) {
		if (!InOpera) {
			ourpointer.style.left = newx.toString() + 'px';
			ourpointer.style.top = newy.toString() + 'px';
		} else {
			ourpointer.style.pixelLeft = newx;
			ourpointer.style.pixelTop = newy;
		}

	} else if (InNS4) {
		ourpointer.left = newx;
		ourpointer.top = newy;

	}
}



function MeMSOObjectUpdate(objectname, newcontent) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
	if (InIE || DOMCompatible) {
		if (typeof(ourpointer.innerHTML) != 'undefined') {
			ourpointer.innerHTML = newcontent;

		} else {
			ourpointer.firstChild.nodeValue = newcontent;

		}

	} else if (InNS4) {
		ourpointer.document.open();
		ourpointer.document.write(newcontent);
		ourpointer.document.close();

	}
}



function MeMSOObjectSetVisible(objectname, turniton) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
  if (InIE || DOMCompatible) {
    ourpointer.style.visibility = turniton ? 'visible' : 'hidden';

  } else if (InNS4) {
    ourpointer.visibility = turniton ? 'show' : 'hide';

  }
}



function MeMSOObjectGetVisible(objectname) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
  if (InIE || DOMCompatible) {
    return ourpointer.style.visibility == 'hidden' ? 0 : 1;

  } else if (InNS4) {
		return ourpointer.visibility == 'hide' ? 0 : 1;

  }
}



function MeMSOObjectSetZIndex(objectname, newindex) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
  if (InIE || DOMCompatible) {
    ourpointer.style.zIndex == newindex;

  } else if (InNS4) {
		ourpointer.zIndex == newindex;

  }
}



function MeMSOObjectGetZIndex(objectname) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
  if (InIE || DOMCompatible) {
    return ourpointer.style.zIndex;

  } else if (InNS4) {
		return ourpointer.zIndex;

  }
}



function MeMSOObjectGetPosition(objectname) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
	var coordinates = new Object();
	var x = 0, y = 0;


	if (InIE || InNS6) {
		x = MeMSO_IEGetPageOffsetLeft(ourpointer);
		y = MeMSO_IEGetPageOffsetTop(ourpointer);

	} else if (InOpera) {
		x = ourpointer.style.pixelLeft;
		y = ourpointer.style.pixelTop;

	} else if (DOMCompatible) {
		x = parseInt(ourpointer.style.left);
		y = parseInt(ourpointer.style.top);

	} else if (InNetscape) {
		x = ourpointer.left;
		y = ourpointer.top;

	}

	coordinates.x = x;
	coordinates.y = y;
	return coordinates;
}



function MeMSOObjectGetScreenPosition(objectname) {
	var coordinates = MeMSOObjectGetPosition(anchorname);
	var x = 0;
	var y = 0;
	if (InIE) {
		x = coordinates.x - document.body.scrollLeft + window.screenLeft;
		y = coordinates.y - document.body.scrollTop + window.screenTop;

	} else if (DOMCompatible) {
		if (isNaN(window.screenX)) {
			x = coordinates.x - document.body.scrollLeft + window.screenLeft;
			y = coordinates.y - document.body.scrollTop + window.screenTop;

		} else {
			x = coordinates.x + window.screenX + (window.outerWidth - window.innerWidth) - window.pageXOffset;
			y = coordinates.y + window.screenY + (window.outerHeight - 24 - window.innerHeight) - window.pageYOffset;

		}

	}	else if (InNetscape) {
		x = coordinates.x + window.screenX + (window.outerWidth - window.innerWidth) - window.pageXOffset;
		y = coordinates.y + window.screenY + (window.outerHeight - 24 - window.innerHeight) - window.pageYOffset;

	}
	coordinates.x = x;
	coordinates.y = y;
	return coordinates;
}



function MeMSOObjectGetSize(objectname) {
	var coordinates = new Object();
	var curwidth = 0, curheight = 0;
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
	if (InIE || InOpera) {
		if (ourpointer.style.pixelWidth) {
			curwidth = ourpointer.style.pixelWidth;
			curheight = ourpointer.style.pixelHeight;

		} else {
			curwidth = ourpointer.clientWidth;
			curheight = ourpointer.clientHeight;

		}

	} else if (DOMCompatible) {
		if (ourpointer.style.width) {
			curwidth = parseInt(ourpointer.style.width);
			curheight = parseInt(ourpointer.style.height);

		} else if (document.defaultView) {
			curwidth = parseInt(document.defaultView.getComputedStyle(document.getElementById(objectname), "").getPropertyValue("width"));
			curheight = parseInt(document.defaultView.getComputedStyle(document.getElementById(objectname), "").getPropertyValue("height"));

		} else {
			curwidth = object.offsetWidth;
			curheight = object.offsetHeight;

		}

	} else if (InNS4) {
		if (ourpointer.height) {
			curwidth = ourpointer.width;
			curheight = ourpointer.height;

		} else {
			curwidth = ourpointer.clip.right - ourpointer.clip.left + 1;
			curheight = ourpointer.clip.bottom - ourpointer.clip.top + 1;

		}

	}
	coordinates.width = curwidth;
	coordinates.height = curheight;
	return coordinates;
}



function MeMSOObjectSetSize(objectname, newwidth, newheight) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
	if (InOpera) {
		ourpointer.style.pixelWidth = newwidth;
		ourpointer.style.pixelHeight = newheight;		

	} else if (InIE || DOMCompatible) {
		ourpointer.style.width = newwidth;
		ourpointer.style.height = newheight;

	} else if (InNS4) {
		ourpointer.offsetWidth = newwidth;
		ourpointer.offsetHeight = newheight;

	}
}



function MeMSOObjectGetClipping(objectname) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
	var coordinates = new Object();
	var t = 0, b = 0, l = 0, r = 0;
	var curpos = 0, q, curval, curchar, curstring;
	if (!InNS4) {
		curstring = ourpointer.style.clip;
		for (q = 0; q < 3; q++) {
			curchar = curstring.charCodeAt(curpos);
			while (curchar < 48 || curchar > 57) {
				curchar = curstring.charCodeAt(++curpos);
			}
			curval = 0;
			while (curchar >= 48 && curchar <= 57 && curpos<curstring.length) {
				curval = (curval * 10) + (curchar - 48);
				curchar = curstring.charCodeAt(++curpos);
			}

			switch (q) {
			case 0:
				t = curval;
				break;
			case 1:
				r = curval;
				break;
			case 2:
				b = curval;
				break;
			case 3:
				l = curval;
				break;
			}
		}

	} else {
		t = ourpointer.clip.top;
		b = ourpointer.clip.bottom;
		l = ourpointer.clip.left
		r = ourpointer.clip.right;

	}
	coordinates.top = t;
	coordinates.bottom = b;
	coordinates.right = r;
	coordinates.left = l;
	return coordinates;
}



function MeMSOObjectSetClipping(objectname, newleft, newtop, newright, newbottom) {
	var ourpointer = MeMSOObjectGetPointer(objectname, 0);
	if (!InNS4) {
		ourpointer.style.clip = 'rect(' + newtop + ' ' + newright + ' ' + newbottom + ' ' + newleft + ')';

	} else {
		ourpointer.clip.top = newtop;
		ourpointer.clip.bottom = newbottom;
		ourpointer.clip.left = newleft;
		ourpointer.clip.right = newright;
	}
}


function MeMSOGetWindowSize() {
  var coordinates = new Object();
	var curwidth = 0, curheight = 0;

  if (typeof(window.innerWidth) == 'number') {
    curwidth = window.innerWidth;
    curheight = window.innerHeight;

  } else {
    if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {

      curwidth = document.documentElement.clientWidth;
      curheight = document.documentElement.clientHeight;

    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {

      curwidth = document.body.clientWidth;
      curheight = document.body.clientHeight;

    }

  }

  coordinates.width = curwidth;
  coordinates.height = curheight;
	return coordinates;
}


function MeMSOGetScrollPosition() {
  var coordinates = new Object();
	var curposx = 0, curposy = 0;

  if (typeof(window.pageXOffset) == 'number') {

    curposx = window.pageXOffset;
    curposy = window.pageYOffset;

  } else {
    if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {

      curposx = document.body.scrollLeft;
      curposy = document.body.scrollTop;

    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {

      curposx = document.documentElement.scrollLeft;
      curposy = document.documentElement.scrollTop;

    }

  }

  coordinates.x = curposx;
  coordinates.y = curposy;
	return coordinates;
}


function MeMSOObjectGetPointer(objectname, parentlayer) {
	var layerarray;
	if (DOMCompatible)
		return document.getElementById(objectname);
	if (InIE)
		return document.all[objectname];
	if (InNS4) {
		layerarray = (parentlayer ? parentlayer : self).document.layers;
		if (layerarray[objectname])
			return layerarray[objectname];
		for (i = 0; i < layerarray.length; i++)
			return MeMSOObjectGetPointer(objectname, layerarray[i]);
	}
	return 0;
}



function MeMSO_IEGetPageOffsetLeft(curobject) {
	var curpos = curobject.offsetLeft;
	while ((curobject = curobject.offsetParent)!=null) {
		curpos += curobject.offsetLeft;
	}
	return curpos;
}



function MeMSO_IEGetPageOffsetTop(curobject) {
	var curpos = curobject.offsetTop;
	while ((curobject = curobject.offsetParent)!=null) {
		curpos += curobject.offsetTop;
	}
	return curpos;
}




