var isOpera = (typeof window.opera!='undefined');
var isIE = (typeof document.all!='undefined');
var msie = isIE;

window.onclick = function() {
	if (typeof popLink != 'undefined' && popLink.close) popLink.close();
}

function getScrollPos(win) {
	var x,y;
	if (win.pageYOffset) // all except Explorer
	{
		x = win.pageXOffset;
		y = win.pageYOffset;
	}
	else if (win.document.documentElement && win.document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		x = win.document.documentElement.scrollLeft;
		y = win.document.documentElement.scrollTop;
	}
	else if (win.document.body) // all other Explorers
	{
		x = win.document.body.scrollLeft;
		y = win.document.body.scrollTop;
	}
	return Array(x,y);
}

function getOffset(obj) { // get the right position
  otop = 0; oleft = 0;
  ctop = 0; cleft = 0;
  if (obj) {
    ctop = obj.offsetTop; cleft = obj.offsetLeft;
    otop = ctop; oleft = cleft;
    p = obj.offsetParent;
    while (p) {
      ctop += p.offsetTop; cleft += p.offsetLeft;
      p = p.offsetParent;
    }
    return Array(ctop,cleft,otop,oleft);
  }
}

function removeObj(obj) { // remove any object or element
  if (obj) if (pn = obj.parentNode) {
	  pn.removeChild(obj);
  	obj = null;
	}
	return obj;
}

function is_set() {
	if (arguments.length) {
		obj = arguments[0];
		if (typeof obj != 'undefined') return true;
	}
	return false;
}

function openDownDiv() {
	var downdiv = document.getElementById('downdiv')
	if (downdiv && downdiv.style.visibility) {
		downdiv.style.visibility="visible";
		window.setTimeout("closeDownDiv()",5000);
	}
}

function closeDownDiv() {
	var downdiv = document.getElementById('downdiv')
	if (downdiv && downdiv.style.visibility) downdiv.style.visibility="hidden";
}

function str_repeat(text,iterations) {
	var t = '';
	if (text) for (i=1; i<=iterations; i++) {
		t += text;
	}
	return t;
}

function expose(obj) {
	deli = '\n';
	var level = 0;
	if (arguments[1]) deli = arguments[1];
	if (arguments[2]) {
		level = parseInt(arguments[2]);
  	if (level > 4) return '';
	}
  if (obj) {
    var text = "";
  	to = (typeof obj);
    if (to.indexOf('string')>=0) {
			text += (to+' '+obj+'\n');
		}
		else {
			for (prop in obj) {
	  		to = (typeof obj[prop]);
        text += (str_repeat('\t',level)+to+' '+prop+'='+obj[prop]+deli);
				nextlevel = level+1;
		  	if (to.indexOf('object')>=0) text += expose(obj[prop],deli,nextlevel);
		  }
    }
    //if (text) alert(text);
  }
	return text+'\n';
}

