//chk if an object is an array or not.
function isArray(obj)
{
	//returns true is it is an array
	if (obj.constructor.toString().indexOf("Array") == -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

var showthis = "";
var hidethis = "";
var prev = "";
function showHide(showthis, hidethis)
{
	//alert(showthis +"|"+ hidethis);
	if(showthis!='')
	{
		document.getElementById(showthis).style.display = 'block';
	}
	if(hidethis!='')
	{
		if(isArray(hidethis))
		{
			for(i in hidethis)
			{
				document.getElementById(hidethis[i]).style.display = 'none';
			}
		}
		else
		{
			document.getElementById(hidethis).style.display = 'none';
		}
	}
	else if(prev != false)
	{
		//alert("prev="+prev);
		if(prev != showthis)
		{
			document.getElementById(prev).style.display = 'none';
			prev = showthis;
		}
	}
	else
	{
		//alert("prev 1st time="+prev);
		prev = showthis;
	}
}

function switchtab(newtab, oldtab, tabon, taboff, tabstyleOn, tabstyleOff){
	if(newtab!=''){
		document.getElementById(newtab).style.display = 'block';
		document.getElementById(tabon).className = tabstyleOn;
	}
	if(oldtab!=''){
		document.getElementById(oldtab).style.display = 'none';
		document.getElementById(taboff).className = tabstyleOff;
	}
	
}

function changeClass(Elem, myClass) {
	//alert("changeClass called with "+Elem+" | "+myClass);
	var elem;
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	elem.className = myClass;
}


function callajax(url,val,next){
	loadXMLDoc(url+'?refid='+val, next);
}

function getURL(url){
	window.location = url;
}

function setPos(moveThis, toThis, shiftX, shiftY)
{
  var relPos;
  var getPosArr;

  getPosArr = getPos(toThis);
  //alert(getPosArr[0]);

  document.getElementById(moveThis).style.left = (getPosArr[0] + shiftX) + "px";
  document.getElementById(moveThis).style.top = (getPosArr[1] + shiftY) + "px";
  document.getElementById(moveThis).style.display = 'block';
}

function getPos(oElement)
{
  var posX = 0;
  var posY = 0;
  while( oElement != null ) {
    posX += oElement.offsetLeft;
    posY += oElement.offsetTop;
    oElement = oElement.offsetParent;
  }
  //alert(posX+"|"+posY);
  var arrPos = Array(posX, posY);
  return arrPos;
}
