/***Fold out***/
function get_object(o)
{
	if(document.getElementById && document.getElementById(o))
   {
      return document.getElementById(o);
   }
	else if(document.all && document.all[o])
	{
		return document.all[o];
	}
	else
		return false;
}

function trswap(trid) {
	var tr = get_object(trid);

	if(tr.style.display == "none") {
		tr.style.display = navigator.appName == "Microsoft Internet Explorer" ? "block" : "table-row";
	} else {
		tr.style.display = "none";
	}
}

function trhide(trid) {
	var tr = get_object(trid);

	if(tr.style.display != "none") {
		tr.style.display = "none";
	}
}


function trshow(trid) {
	var tr = get_object(trid);

	if(tr.style.display == "none") {
		tr.style.display = navigator.appName == "Microsoft Internet Explorer" ? "block" : "table-row";
	} 
}

/* Hide div if visible, Show div if hidden */
function divswapone(id, hideshow) {

	var obj = get_object(id);

	if (hideshow) {
		if (obj && obj.style.display) {
	   	obj.style.display = (hideshow == 'show') ? 'block' : 'none';
		} else {
	   	obj.style.visibility = (hideshow == 'show') ? 'visible' : 'hidden';
		}
		obj.style.height = (hideshow != 'show') ? '0px' : 'auto';
		obj.style.overflow = (hideshow != 'show') ? 'hidden' : 'visible';
	} else {
		if (obj && obj.style.display) {
	   	obj.style.display = obj.style.display == 'none' ? 'block' : 'none';
		} else {
	   	obj.style.visibility = obj.style.visibility == 'hidden' ? 'visible' : 'hidden';
		} 
	   obj.style.height = obj.style.height == '0px' ? 'auto' : '0px';
	   obj.style.overflow = obj.style.overflow == 'hidden' ? 'visible' : 'hidden';
	}
   return obj.style.height;
}
function divswaptwo(id, hideshow) {
	var obj = get_object(id);
	obj.style.display = (hideshow == 'show') ? 'block' : 'none';
	obj.style.visibility = (hideshow == 'show') ? 'visible' : 'hidden';
	obj.style.height = (hideshow != 'show') ? '0px' : 'auto';
	obj.style.overflow = (hideshow != 'show') ? 'hidden' : 'visible';
   return obj.style.height;
}

function divswap(id, arr) {
	for(x=0; x<arr.length; x++) {
			if(divswapone(arr[x]) != '0px')
				divswapone(arr[x]);
		}
	divswapone(id);
}

/* Set inner html */
function settext(id, content) {
   var obj = get_object(id);
   obj.innerHTML = content;
}

function expand(id, buttonid, opentxt, closetxt)
{
   if(! opentxt || opentxt == '')     opentxt = '&nbsp;Open&nbsp;';
   if(! closetxt || closetxt == '')   closetxt = 'Close';

   var height = divswapone(id);
   //alert(height);

	if (height == '0px' && buttonid)
      settext(buttonid, opentxt);
   else if(buttonid)
   	settext(buttonid, closetxt);
}

function popupDiv(msg, heading, width, top, left)
{
	if(!msg || msg == false)
		return false;
	
	divswapone('popupdiv');
	get_object('popupdiv').style.width = (!width || width == false) ? '400px' : width+'px';
	get_object('popupdiv').style.top = (!top || top == false) ? '100px' : top+'px';
	get_object('popupdiv').style.left = (!left || left == false) ? '300px' : left+'px';
	settext('popupdivheader', heading);
	settext('popupdivcontent', msg);
	/*'<a href="javascript:;" onClick="divswapone(\'popupdiv\')" style="float:right; background: #D9016E; color: white;padding: 3px;">St&auml;ng</a>'+msg);	*/
}

function hlig(i, c) {
	if(!c)	c = 'pink';
	if (typeof(i) == 'string')
		document.getElementById(i).style.background = c;
	else
		i.style.background = c;
}

function popupUrl(url, heading, width, top, left)
{
		width = (!width || width == false) ? '200' : width;
		top = (!top || top == false) ? '200' : top;
		left = (!left || left == false) ? '200' : left;
		msg = 'left:  '+left; /*+'top '+top+'W: '+width+'<iframe src="'+url+'" frameborder="0" style="width: '+(width-15)+'px; overflow-x: hidden; height: auto;"></iframe>';*/
		popupDiv(msg, heading, width, top, left);
}
