function show_card( url ){

  var myX = window.screenX + 50;
  var myY = window.screenY + 100;
  var w = "dependent=yes,resize=yes,height=240,width=360,screenX="+myX+",screenY="+myY;
  user_w = open( url, "UserInfo", w );
}


function open_window( url, title, w, h ){

  var myX = window.screenX + 50;
  var myY = window.screenY + 100;

  var w = "dependent=yes,resize=yes,height="+h+",width="+w+",screenX="+myX+",screenY="+myY;
  new_w = open( url, title, w );
}


function set_lang(baseurl){
    var lang = document.getElementsByName("langsel")[0].value;
    
    var re = /\?/;
    var sep = "?";
    if( re.test(location) ){
	sep = "&";
    }
    var newurl = location + sep + "langset="+lang;

    location.replace( newurl );
}


function toggleHidden( id ){
    var toggle = document.getElementById("toggle"+id);
    var hidden = document.getElementById("hidden"+id);
    var nonhidden = document.getElementById("nonhidden"+id);

    if( hidden.style.display != "block" ){
	toggle.src = "images/arrow-down.png";
	if( hidden ){
	  hidden.style.display = "block"; }
	if( nonhidden ){
	  nonhidden.style.display = "none"; }
    } else {
	toggle.src = "images/arrow-right.png";
	if( hidden ){
	  hidden.style.display = "none"; }
	if( nonhidden ){
	  nonhidden.style.display = "block"; }
    }
}

	
function progressWindow( url ) {

  var myX = window.screenX + 150;
  var myY = window.screenY + 200;

  var opt = "dependent=yes,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,height=120,width=280,screenX="+myX+",screenY="+myY;
	
  theUniqueID = (new Date()).getTime() % 1000000000;
  window.open( url, theUniqueID , opt );

  document.uf.uniq.value = theUniqueID;
  document.uf.submit();  
}


function user_window(obj, uid){
  x = findPosX(obj);
  y = findPosY(obj);

  var w = $("windowdiv");
  if( w ){
    if( y>50 ){
      w.style.top = (y-30)+"px";
    } else {
      w.style.top = "10px";
    }
    if( x>500 ){
      w.style.left = (x-340)+"px";
    } else {
      w.style.left = (x+100)+"px";
    }
    w.style.display = "block";
    $("windowdiv-body").innerHTML = "loading ... ";

    var myAjax = new Ajax.Request(
      "index.php",
      {method: 'post', parameters: "q=user/card/"+uid+"&plain=1", onComplete: userwindow_ajaxR}
    );    

  } else {
    alert("HH");
  }
}

function userwindow_ajaxR(o){
  $("windowdiv-body").innerHTML = o.responseText;
}

function windowdiv_hide(){
  $("windowdiv").style.display = "none";
}


function findPosX(obj){
  var curleft = 0;
  if (obj.offsetParent)
    {
      while (obj.offsetParent)
	{
	  curleft += obj.offsetLeft
	    obj = obj.offsetParent;
	}
    }
  else if (obj.x)
    curleft += obj.x;
  return curleft;
}

function findPosY(obj){
  var curtop = 0;
  if (obj.offsetParent)
    {
      while (obj.offsetParent)
	{
	  curtop += obj.offsetTop
	    obj = obj.offsetParent;
	}
	}
  else if (obj.y)
    curtop += obj.y;
  return curtop;
}


function canAjax(){
  xmlHttp = false;
  if (typeof XMLHttpRequest != 'undefined') {
    xmlHttp = true;
  }
  if (!xmlHttp) {
    // Internet Explorer 6 und älter
    try {
      xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
	xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
	xmlHttp  = false;
      }
    }
  }
  if (xmlHttp) {
    return true;
  }
  return false;
}
