// JavaScript Document

function popupWindow(url,dimensions) {

  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,screenX=150,screenY=150,top=150,left=150,' + dimensions);

}



function makeArray(str){

	str = str.split(',');

	return str;

}





function rollOver(id){

	id = 'ref' + id;

	document.getElementById(id).style.backgroundImage='url(fileadmin/01/img/level4/ro.png)';

}



function rollOut(id, imgStr){

	/* check to see if the current background image of the text div

	matches that associated with the current element

	if it does, then cancel rollout effect, else continue

	*/

	var imageArray = makeArray(imgStr);

	t=xGetElementById('text');

	d=xGetElementById('ref' + id);

	id++;

	if(t.style.backgroundImage != 'url(uploads/pics/' + imageArray[id] +')'){

		d.style.backgroundImage='url(fileadmin/01/img/level4/no.png)';

		

	}

}







function pwLoadImg(pos,imgStr){

		var imageArray = makeArray(imgStr);

		

		var active = pos;

		pos++;

		var currentImage = 'uploads/pics/' + imageArray[pos];

		// reset all divs to the default background

		

		for(i = 0; i< 20; i++){

			var docId = 'ref' + i;

			if(e=xGetElementById(docId)){

				document.getElementById(docId).style.backgroundImage='url(fileadmin/01/img/level4/no.png)';

			}

		}

		

		// set the clicked div to the active background

		rollOver(active);

		//document.getElementById('ref' + active).style.backgroundImage='url(fileadmin/01/img/level4/ro.png)';

		

		// replace the background of the main content

		document.getElementById('text').style.backgroundImage='url('+currentImage+')';



}





function adjust3ColLayout(col1,col2,col3,layerToMove,offset){

	xHide(layerToMove);

	

	var	suffix = 'Wrap';

		

	var cHeight = xHeight(col2 + suffix);

	var lHeight = xHeight(col1 + suffix);

	var rHeight = xHeight(col3 + suffix);

	

	var maxHeight = Math.max(cHeight, Math.max(lHeight, rHeight));

	

	// get top of layers

	

	xHeight(col1, maxHeight);

	xHeight(col2, maxHeight );

	xHeight(col3, maxHeight);

	

	xTop(layerToMove, (maxHeight + offset));

	xShow(layerToMove);

}



function adjustHeight(col1,col2,col3){

	var	suffix = 'Wrap';

		

	var cHeight = xHeight(col2 + suffix);

	var lHeight = xHeight(col1 + suffix);

	var rHeight = xHeight(col3 + suffix);

	

	var maxHeight = Math.max(cHeight, Math.max(lHeight, rHeight));

	

	xHeight(col1, maxHeight);

	xHeight(col2, maxHeight );

	xHeight(col3, maxHeight);

}





function adjustLayout(){

	adjust3ColLayout('colLeft','colCenter','colRight','footer',10 + 254);

/*	

	var cHeight = xHeight('colLeft');

	var lHeight = xHeight('colCenter');

	var rHeight = xHeight('colRight');

	var maxHeight = Math.max(cHeight, Math.max(lHeight, rHeight));

	xHeight('footer',maxHeight);

	adjust3ColLayout('footerRecent','footerHelp','footerAlso','footerStrip',-25);

*/

}	



var objMyImg = null;

function init(){

}



function xMenu1(triggerId, menuId, mouseMargin, openEvent)

{

  var isOpen = false;

  var trg = xGetElementById(triggerId);

  var mnu = xGetElementById(menuId);

  if (trg && mnu) {

    xAddEventListener(trg, openEvent, onOpen, false);

  }

  function onOpen()

  {

    if (!isOpen) {

      xMoveTo(mnu, xPageX(trg), xPageY(trg) + xHeight(trg));

      xShow(mnu);

      xAddEventListener(document, 'mousemove', onMousemove, false);

      isOpen = true;

    }

  }

  function onMousemove(ev)

  {

    var e = new xEvent(ev);

    if (!xHasPoint(mnu, e.pageX, e.pageY, -mouseMargin) &&

        !xHasPoint(trg, e.pageX, e.pageY, -mouseMargin))

    {

      xHide(mnu);



      xRemoveEventListener(document, 'mousemove', onMousemove, false);

      isOpen = false;

    }

  }

} // end xMenu1





/*

show & hide selects

*/

function hideSelects()

{

var selNodes = document.getElementsByTagName('select')

var i=0;

if (!selNodes.item(0))

	{

	return false;

	}

else

	{

	do{selNodes.item(i).style.visibility = 'hidden';}

	while(++i < selNodes.length);

	}

}



function showSelects()

{

var selNodes = document.getElementsByTagName('select')

var i=0;

if (!selNodes.item(0))

	{

	return false;

	}

else

	{

	do{selNodes.item(i).style.visibility = 'visible';}

	while(++i < selNodes.length);

	}

}



function getArgs() {

     var args = new Object();

     var query = location.search.substring(1).toLowerCase();

     var pairs = query.split("&");

     for(var i = 0; i < pairs.length; i++) {

          var pos = pairs[i].indexOf('=');

          if (pos == -1) continue;

          var argname = pairs[i].substring(0,pos);

          var value = pairs[i].substring(pos+1);

          args[argname] = unescape(value);

     }

     return args;

}





window.onload = function()

{	

	//init();

	//xAddEventListener(window,"resize", adjustLayout, false);

	//adjustLayout();

}
