/*
##############################################################################
# UCC User Created Content Version
# 2007-2010 (c) J3S GmbH, info@j3s.de
##############################################################################
# copying prohibited, do not use without written permission of J3S GmbH
##############################################################################
*/

function lite(o,col) {
  /*if (typeof(col) == 'undefined') {
    //col = '#F0E070';
    //col = '#eee';
  }
  o.style.backgroundColor = col;*/
  o.style.border = 'solid 1px #666';
  o.style.cursor='hand';o.style.cursor='pointer';
}
function dark(o) {
    o.style.border = 'none';
	//o.style.backgroundColor = '';
}

function high(el) {
  el.className = 'result_high';
}

function low(el) {
  el.className = 'result';
}

function openlink(link, name, width, height,toolbar) {
 if (typeof (name)   =='undefined') { name='popup';}
 if (typeof (width)  =='undefined') { width=800;}
 if (typeof (height) =='undefined') { height=600;}

 // pass additional hoverwidth information =)
 if(typeof(current_hover_width) != 'undefined' && current_hover_width != -1) {
   var hoverwidth= current_hover_width;
   link+= "&hoverwidth="+hoverwidth;
 }
 if (typeof (toolbar)=='undefined') { toolbar='status=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height;}
 var posx= Math.round((screen.availWidth -width )/2);
 var posy= Math.round((screen.availHeight-height)/2);
 toolbar += ",left="+posx+",top="+posy;
 var popup = window.open(link,name,toolbar);
 popup.focus();
 return false;
}

function Demystify(data) {
  var chars=data.split(",");
  for (var c in chars){
    document.write(String.fromCharCode(chars[c]-37));
  }
}

/*****************************************************************************
 * getHeight
 * retrieves inner height of the body
 ****************************************************************************/

function getHeight() {
  var y;
  if (self.innerHeight) // all except Explorer
  {
  	y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  	// Explorer 6 Strict Mode
  {
  	y = document.documentElement.clientHeight;
  }
  else if (document.body) // other Explorers
  {
  	y = document.body.clientHeight;
  }
  return y;
}

/*****************************************************************************
 * getWidth
 * retrieves inner width of the body
 ****************************************************************************/

function getWidth() {
  var x;
  if (self.innerHeight) // all except Explorer
  {
  	y = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  	// Explorer 6 Strict Mode
  {
  	x = document.documentElement.clientWidth;
  }
  else if (document.body) // other Explorers
  {
  	x = document.body.clientWidth;
  }
  return x;
}

/*****************************************************************************
 * getScrollX
 * retrieves x scroll position
 ****************************************************************************/

function getScrollX() {
  var x;
  if (self.pageXOffset) // all except Explorer
  {
  	x = self.pageXOffset;
  }
  else if (document.documentElement && document.documentElement.scrollLeft)
  	// Explorer 6 Strict
  {
  	x = document.documentElement.scrollLeft;
  }
  else if (document.body) // all other Explorers
  {
  	x = document.body.scrollLeft;
  }
  return x;
}

/*****************************************************************************
 * getScrollY
 * retrieves y scroll position
 ****************************************************************************/

function getScrollY() {
  var y;
  if (self.pageYOffset) // all except Explorer
  {
  	y = self.pageYOffset;
  }
  else if (document.documentElement && document.documentElement.scrollTop)
  	// Explorer 6 Strict
  {
  	y = document.documentElement.scrollTop;
  }
  else if (document.body) // all other Explorers
  {
  	y = document.body.scrollTop;
  }
  return y;
}

/*****************************************************************************
 * getx
 * retrieves x position of element specified by id
 * NOTE: the object has to be rendered *before* this function is called
 *
 * Parameters
 *   id:     id of object
 *
 * returns x position
 ****************************************************************************/

function getx(imgID,node) {
 var tempEl;
  if (imgID!='') tempEl = document.getElementById(imgID);
  else           tempEl = node;

  var xPos = tempEl.offsetLeft;
  tempEl = tempEl.offsetParent;
  while (tempEl != null) {
    xPos += tempEl.offsetLeft;
    tempEl = tempEl.offsetParent;
  }
  return xPos;
}

/*****************************************************************************
 * gety
 * retrieves y position of element specified by id
 * NOTE: the object has to be rendered *before* this function is called
 *
 * Parameters
 *   id:     id of object
 *
 * returns y position
 ****************************************************************************/

function gety(imgID,node) {
  var tempEl;
  if (imgID!='') tempEl = document.getElementById(imgID);
  else           tempEl = node;

  var yPos = tempEl.offsetTop;
  tempEl = tempEl.offsetParent;
  while (tempEl != null) {
    yPos += tempEl.offsetTop;
    tempEl = tempEl.offsetParent;
  }
  return yPos;
}

/**********************************************************************************
 * RandomParameter
 * creates a random parameter to force relad of pages.. sigh =(
 *********************************************************************************/

 function RandomParameter() {
   var d=new Date();
   var res = 'rnd='+d.getDate()+d.getMonth()+d.getYear()+d.getHours()+d.getMinutes()+d.getSeconds()+d.getMilliseconds()+Math.random()*10000000;
   res = res.replace('.','');
   return res;
 }

 /**********************************************************************************
 * AddRandomParameter
 * creates a random parameter to force relad of pages.. sigh =(
 *********************************************************************************/

 function AddRandom(url) {
   url = url.replace(/rnd=\d+/,'');
   if (url.indexOf('?') == -1) url+= '?';
   url+= "&"+RandomParameter();
   url = url.replace('?&','?');

   return url;
 }



/*****************************************************************************
 * GetXMLHttp
 * returns xhmtl object
 ****************************************************************************/

function GetXMLHttp() {
  var xmlHttp = null;
  if (typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
  }
  if (!xmlHttp) {
    try {        xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e) {
      try {      xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch(e) { xmlHttp  = null; }
    }
  }
  return xmlHttp;
}

/*****************************************************************************
 * flip
 * flips state of item in detail view
 ****************************************************************************/
function flip(which){
	var undefined;
	if (document.getElementById('det' + which) == undefined) {
		return;
	}
	var s = document.getElementById('det' + which).style;
	if (s.display == 'none' || s.display == '' || typeof(s.display) == 'undefined') {
	  unflipAll(which);
	  s.display = 'block';
	  document.getElementById('tab' + which).className = 'tab-active';
	} else {
	  s.display = 'none';
	  document.getElementById('tab' + which).className = 'tab';
	}
}
/*****************************************************************************
 * unflipAll
 * Unflips al tabs.
 ****************************************************************************/
function unflipAll(which) {
	for (var i = 0; i < 10; i++) {
		if (i != which) {
			document.getElementById('det' + i).style.display = 'none';
			document.getElementById('tab' + i).className = 'tab';
		}
	}
}
/*****************************************************************************
 * toggleCheckbox
 * Toggles a checkbox widget
 ****************************************************************************/
function toggleCheckbox(id, type) {
	var el = document.getElementById(id);
	var checked = el.checked;
	if (checked) {
		el.checked = false;
		el.parentNode.className = type + 'checkbox0';
	} else {
		el.checked = true;
		el.parentNode.className = type + 'checkbox1';
	}
}

/*****************************************************************************
 * silentreq
 * performs a background request and ignores the result
 ****************************************************************************/

function silentreq(url){
  var xml = GetXMLHttp();

  xml.open('GET', url, true);
  xml.onreadystatechange = function () {
    if (xml.readyState == 4) {
      //alert(xml.responseText);
    }
  }
  xml.send(null);
}
/*****************************************************************************
 * countpic
 * counts view/click on panoramio pic
 ****************************************************************************/

function countpic(p){
  silentreq(AddRandom('/cgi-bin/rev%2epl?template=ecamp/w2/panoramio%2ehtm&amp;id=' + p));
}

/*****************************************************************************
 * checkpic
 * checks if thumbnail url is reachable
 ****************************************************************************/

function checkpic(p){
  silentreq(AddRandom('/cgi-bin/rev%2epl?template=ecamp/w2/checkpic%2ehtm&amp;pid=' + p));
}

/*****************************************************************************
 * blockpic
 * counts view/click on panoramio pic
 ****************************************************************************/

function blockpic(p){
  if (!confirm('Sind Sie sicher, dass Sie dieses Bild löschen möchten?')) return false;
  silentreq(AddRandom('/cgi-bin/rev%2epl?template=ecamp/popups/blockpic.htm&amp;pid=' + p));
}

/********************************************************************************
 * Header functions
 ********************************************************************************/
function toggleHead() {
  var el = document.getElementById('headerbox');
  if (el.style.display == 'none') {
    showHead();
  } else {
    hideHead();
  }
}
function showHead() {
    var el = document.getElementById('headerbox');
    el.style.display='block';
    document.getElementById('run-out').style.display='none';
    document.getElementById('run-in').style.display='block';
    document.cookie = 'head=block; path=/';
}
function hideHead() {
    var el = document.getElementById('headerbox');
    el.style.display='none';
    document.getElementById('run-out').style.display='block';
    document.getElementById('run-in').style.display='none';
    document.cookie = 'head=none; path=/';
}
function isHeadVisible() {
  var c = '' + document.cookie;
  if (c.indexOf('head=none') == -1) {
    return true;
  }
  return false;
}
function initHead() {
  if (!isHeadVisible()) {
    hideHead();
  }
}
function handleSelect(select) {
  var text = select.options[select.options.selectedIndex].text;
  var el = document.getElementById(select.id).parentNode;
  el.firstChild.firstChild.nodeValue = text;
}
 function handleSmallSelect(select) {
	  var text = select.options[select.options.selectedIndex].text;
	  var el = document.getElementById(select.id).parentNode;
	  el.firstChild.firstChild.nodeValue = text;
}
 function toggleMoreLang() {
	var el = document.getElementById('more-lang');
	if (el.style.display == 'block') {
		el.style.display = 'none';
	} else {
		el.style.display = 'block';
	}	  
 }
 function hideMoreLang(e) {
	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	if (tg.nodeName != 'DIV') return;
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg != tg && reltg.nodeName != 'BODY')
		reltg= reltg.parentNode
	if (reltg== tg) return;
	// Mouseout took place when mouse actually left layer
	// Handle event
	var el = document.getElementById('more-lang');
	el.style.display = 'none';
 }

/********************************************************************************
 * End of header functions
 ********************************************************************************/

 
