/*

http://closure-compiler.appspot.com/home


// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name default.js
// @code_url http://www.produki.de/js/myScripts.js
// @code_url http://www.produki.de/js/prototype.js
// @code_url http://www.produki.de/js/scriptaculous.js
// @code_url http://www.produki.de/js/effects.js
// @code_url http://www.produki.de/js/builder.js
// @code_url http://www.produki.de/js/controls.js


// ==/ClosureCompiler==


*/
var ie = document.all?1:0;
var w3c = document.getElementById?1:0;
var ns4 = document.layers?1:0;
var counter=0;
var block=1;
var qs_pos=0; /* Quicksearch position*/
var active;
/* Preload Images */






Bild01 = new Image();
Bild01.src = "/img/menuBgLeft_blueOver.jpg";

Bild02 = new Image();
Bild02.src = "/img/quicksearchBackground2.png";



 function keyPressHandler(e) {
      var kC  = (window.event) ?    // MSIE or Firefox?
                 event.keyCode : e.keyCode;
      var Esc = (window.event) ?
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox
      if(kC==Esc){
         //alert("Esc pressed")
       	if($("authBlock").style.display=="block"){
       		hideAuthBlock();

       	}
       	if($("alert").style.display=="block"){
       		hideAlert();

       	}

       }
   }





function getWinSize(){
   var size = {w:0 ,h:0}
   var win = window;

   size.w = win.innerWidth ? win.innerWidth : win.document.body.clientWidth;
   size.h = win.innerHeight ? win.innerHeight : win.document.body.clientHeight;

   return size;
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1)
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }


  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

  function showTeaser(teaserName){

  	$("einfuehrung").className="";
  	$("tipps").className="";
  	$("hilfe").className="";
  	$("neue").className="";

  	$(teaserName).className="current";
  	return false;

  }



function resetFUAMenu(){
	var c= $("fragenMenu").childElements();

	for( var i =0;i<c.length;i++){
	    c[i].className=""
	}
}

function activateMainBoxLink(div){
	resetFUAMenu();
	div.className='current';

}

function toggleById(id){

	if(document.getElementById(id).style.display==''){
		hideById(id);
	}else{
		showById(id);
	}
}

function  hideById(id){
	document.getElementById(id).style.display='none';
}

function showById(id){
	document.getElementById(id).style.display='';

}

function checkAddProductForm(checkFirst){
	var ret=true;



	if( $("hersteller").value=="" && $("produkt").value=="" ){
		$("hersteller").value="";
		$("hersteller").focus();
		ret=false;
	}


	if( $("hersteller").value!="" && $("produkt").value=="" ){

		$("produkt").value="";
		$("produkt").focus();
		ret=false;
	}


 	return ret;
 }


function ungreyProdukt(){

	$("reg2NoImg").src="/img/n_two_blue_30x30.png";
	$("reg2Submit").src="/img/button_prod_anlegen_blue.gif";
	$("reg2Titel").className="biggerBlack";
	$("reg2Text").className="biggerBlack";
	$("reg2Titel2").className="biggerBlack";

}


function greyProdukt(){

	$("reg2NoImg").src="/img/n_two_gray_30x30.png";
	$("reg2Submit").src="/img/button_prod_anlegen_gray.gif";
	$("reg2Titel").className="biggerGrey";
	$("reg2Text").className="biggerGrey";
	$("reg2Titel2").className="biggerGrey";

}


 function setActiveMenu(element){
	var link =document.getElementsByName("topLink");
 	for(var i=0;i<link.length;i++){

    	if(link[i]==element){
    		link[i].className='menuActive'
    	}else{
    		link[i].className='menuInactive'
    	}
	}
}

function setActiveSubMenu(element){
	var link =document.getElementsByName("subLink");
 	for(var i=0;i<link.length;i++){

    	if(link[i]==element){
    		link[i].className='menuLinkActive'
    	}else{
    		link[i].className='menuLink'
    	}
	}
}


function positioniereDetails(){


	var offset= getScrollPos();
	if(offset<130){
		var myOffset=130;
	}else{
		var myOffset=offset+10;
	}
	var size=getWinSize();
	var offset= getScrollPos()
	document.getElementById('detail').style.left=findPosX(document.getElementById('companyLogo'))+40+'px';
	document.getElementById('detail').style.height=size.h-200+'px';
	document.getElementById('detail').style.top=myOffset+'px';



}

function positioniereFooter(){
	var f=$("footer");
	var breite=f.getDimensions().width;

	var left=(getWinSize().w-breite)/2;
	f.style.left=left+"px"



	var mainBottom=findPosY($("main"))+$("main").getDimensions().height;
	var windowHoehe=getWinSize().h;


	if(windowHoehe<mainBottom){
		$("footer").style.top=mainBottom+50+"px"

	}else{
		f.style.bottom="0px";
	}

}


function posToCorner(id_trashImage,id_image){
var p=$(id_image);
var t=$(id_trashImage);

t.style.left=findPosX(p)+p.getDimensions().width-t.getDimensions().width+"px";t.style.top=findPosY(p)+p.getDimensions().height-t.getDimensions().height+"px";

}

function setFooter(){
	var mainBottom=findPosY($("main"))+$("main").getDimensions().height;
	var windowHoehe=getWinSize().h;


	if(windowHoehe>mainBottom){

			$("footer").style.marginTop=windowHoehe-mainBottom+"px";

	}

	$("footer").style.bottom="0px";
	$("footer").style.marginBottom="-50px";

}






function getScrollPos(){
	var scrollPos;
	if (typeof window.pageYOffset != 'undefined') {
	   scrollPos = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' &&  document.compatMode != 'BackCompat') {
	   scrollPos = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined') {
	   scrollPos = document.body.scrollTop;
	}

	return scrollPos;
}

function setLoginDivPos(){
	var mm=$("mainmenu");
	$("loginFormDiv").style.left=mm.getDimensions().width+findPosX(mm)-$("loginFormDiv").getDimensions().width+"px";
	$("loginFormDiv").style.top="70px"
}


function setAuthBlockPos(){
	var mm=$("mainmenu");
	$("authBlock").style.left=mm.getDimensions().width+findPosX(mm)-$("authBlock").getDimensions().width+"px";
	$("authBlock").style.top="70px"
}

function setAlertPos(){
	var mm=$("mainmenu");
	$("alert").style.left=mm.getDimensions().width+findPosX(mm)-$("alert").getDimensions().width+"px";
	$("alert").style.top="70px"
}


function setSearchResultsDivPos(){
	/*var mm=$("mainmenu");
	$("searchResults").style.left=mm.getDimensions().width+findPosX(mm)-$("searchResults").getDimensions().width+25+"px";
	$("searchResults").style.top="66px"

	*/


	var x = findPosX($("search_field"));
	var y =	findPosY($("search_field"))+2;

	//$("searchResults").style.left=x+-159+"px";
	$("searchResults").style.left=x+-174+"px";
	$("searchResults").style.top=y+"px";


	//var bottom=$("searchResultsBottom");
	//var x= findPosX($("searchResults"));
	//var y = findPosY($("searchResults"))+$("searchResults").getDimensions().height;;
	//bottom.style.top=y+"px";
	//bottom.style.left=x+"px";






}

function getPageHeight(){
	var height;
	if (typeof window.pageYOffset != 'undefined') {
	   //scrollPos = window.pageYOffset;
	   height = document.height
	}
	else if (typeof document.compatMode != 'undefined' &&  document.compatMode != 'BackCompat') {
	   //scrollPos = document.documentElement.scrollTop;
	    height = document.documentElement.scrollHeight;

	}
	else if (typeof document.body != 'undefined') {
	   height = document.body.scrollHeight;
	}

	return height;
}



function getScrollPos(){
	var scrollPos;
	if (typeof window.pageYOffset != 'undefined') {
	   scrollPos = window.pageYOffset;
	}
	else if (typeof document.compatMode != 'undefined' &&
	     document.compatMode != 'BackCompat') {
	   scrollPos = document.documentElement.scrollTop;
	}
	else if (typeof document.body != 'undefined') {
	   scrollPos = document.body.scrollTop;
	}

	return scrollPos;
}


function showBBox(id){

 	$('bb1').hide();
 	$('bb2').hide();
 	$('bb3').hide();
 	$('bb4').hide();
 	$('teaserBtn1').style.backgroundImage='none';
 	$('teaserBtn2').style.backgroundImage='none';
 	$('teaserBtn3').style.backgroundImage='none';
 	$('teaserBtn4').style.backgroundImage='none';
 	$('teaserBtn1').className='blueBoxButton ';
 	$('teaserBtn2').className='blueBoxButton ';
 	$('teaserBtn3').className='blueBoxButton ';
 	$('teaserBtn4').className='blueBoxButton ';
 	$('bb'+id).show();
	$('teaserBtn'+id).style.backgroundImage='url(/img/teaserBoxBackground.gif)';
	$('teaserBtn'+id).className='blueBoxButton blueBoxButtonBlack';
}

function showAuthBlock(nummer){


	var schonda=$("gesamtOverlay").style.display=="block";

	if(!schonda){
		$('gesamtOverlay').show().setStyle({opacity: 0});
	}
	$("gesamtOverlay").style.display="block";
	$("gesamtOverlay").style.height="100%";
	$("gesamtOverlay").style.height=getPageHeight()+"px";
	$("gesamtOverlay").style.width="100%";



	if(!schonda){
		$('gesamtOverlay').show().setStyle({opacity: 0.4});

	}else{
		Effect.Fade("gesamtOverlay",{duration: 0.1, from: 0, to:0.4})
	}

	$("authBlock").style.top=getScrollPos()+20+"px";
	$("authBlock").style.left=findPosX($("header"))+200+"px";
	$("authBlock").style.display="block";

	/*
	if($("loginUsername")){
		window.setTimeout('$("authBlock").style.display="block";$("loginUsername").focus();', 100);
	}
	*/

	/*	$("authBlockTop").style.top=findPosY($("authBlock"))-15+"px";
	$("authBlockTop").style.left=findPosX($("authBlock"))+"px";

	$("authBlockBottom").style.top=findPosY($("authBlock"))+$('authBlock').getDimensions().height+"px";
	$("authBlockBottom").style.left=findPosX($("authBlock"))+"px";

	$("authBlockTop").style.display="block";
	$("authBlockBottom").style.display="block";
	*/


	setAuthFrame();

	if(nummer==undefined){
		showLoginReiter(2)
	}else{
		showLoginReiter(nummer)
	}


	/*
	if(USE_FACEBOOK){
		FB.init(FB_API_KEY,"xd_receiver.htm");
	}
	*/
}


function setAuthFrame(){
	if($("authBlock").style.display=="") return;
	$("authBlockTop").style.top=findPosY($("authBlock"))-15+"px";
	$("authBlockTop").style.left=findPosX($("authBlock"))+"px";

	$("authBlockBottom").style.top=findPosY($("authBlock"))+$('authBlock').getDimensions().height+"px";
	$("authBlockBottom").style.left=findPosX($("authBlock"))+"px";

	$("authBlockTop").style.display="block";
	$("authBlockBottom").style.display="block";


}


function ausgrauen(){

	var schonda=$("gesamtOverlay").style.display=="block";

	if(!schonda){
		$('gesamtOverlay').show().setStyle({opacity: 0});
	}
	$("gesamtOverlay").style.display="block";
	$("gesamtOverlay").style.height="100%";
	$("gesamtOverlay").style.height=getPageHeight()+"px";
	$("gesamtOverlay").style.width="100%";


	/*Effect.Fade("gesamtOverlay",{duration: 0.3, from: 0, to:0.9})*/

	if(!schonda){
		$('gesamtOverlay').show().setStyle({opacity: 0.4});

	}else{
		//Effect.Fade("gesamtOverlay",{duration: 0.1, from: 0, to:0.4})
	}


}

/*
* JS-Funktion loggt FB User ein.
*/
function fb_login() {

return true;
  	var user_box = document.getElementById("login");
	hideAuthBlock();

	var api = FB.Facebook.apiClient;
    var fb_uid = api.get_session().uid;

   	xajax_loginFB_User();

  // add in some XFBML. note that we set useyou=false so it doesn't display "you"
  	user_box.innerHTML =
      "<span>"
    //+ "<fb:profile-pic uid='loggedinuser' facebook-logo='true'></fb:profile-pic>"
    + "Eingeloggt als: FB <fb:name uid='loggedinuser' useyou='false'></fb:name>."

    + "</span>";

  // because this is XFBML, we need to tell Facebook to re-process the document
  FB.XFBML.Host.parseDomTree();
}


function FB_test_perm(api_key, xd_receiver, permission, callback)
{
	FB.Bootstrap.requireFeatures(["Connect"], function()
	{
		FB.Facebook.init(api_key, xd_receiver);
		FB.Connect.requireSession(function()
		{
			FB.Facebook.apiClient.users_hasAppPermission(permission, function(result)
			{
				if (result != 0)
					return callback(true);

				FB.Connect.showPermissionDialog(permission, function(result)
				{
					return callback(result == null ? false : (result.indexOf(permission) != -1));
				}, true, null);
			});
		});
	});
}


function hideAuthBlock(){

	Effect.Fade("gesamtOverlay",{duration: 0.3, from: 0.4, to:0})

	if($("authBlock")){
		$("authBlock").style.display="none";
		$("authBlockTop").style.display="none";
		$("authBlockBottom").style.display="none";
	}
}

function showLoginReiter(no){

	if($("auth_r1"))
		$("auth_r1").hide();

	if($("auth_r2"))
		$("auth_r2").hide();

	if($("auth_r3"))
		$("auth_r3").hide();

	if($("auth_r4"))
		$("auth_r4").hide();

	$("auth_r"+no).show();

	setAuthFrame();
}

function showFB_Forms(){
	showAuthBlock(3);

}


function showPicLayer(){

	var opacity = $('gesamtOverlay').style.opacity;


	if(opacity!='0.9' || $("picLayer").style.display=="none"){
	$('gesamtOverlay').show().setStyle({opacity: 0});
	$("gesamtOverlay").style.display="block";
	$("gesamtOverlay").style.height="100%";
	$("gesamtOverlay").style.height=getPageHeight()+"px";
	$("gesamtOverlay").style.width="100%";
	Effect.Fade("gesamtOverlay",{duration: 0.3, from: 0, to:0.9})
}

	$("picLayer").style.top=getScrollPos()+10+"px";
	$("picLayer").style.left=findPosX($("header"))+200+"px";
	$("picLayer").style.display="block";


	positionPicLayer()


}

function positionPicLayer(){
	var pl=$("picLayer");
	var offset= ($("mainmenu").getDimensions().width-pl.getDimensions().width)/2;
	pl.style.left=findPosX($("mainmenu"))+offset+"px";
}



function hidePicLayer(){

	Effect.Fade("gesamtOverlay",{duration: 0.3, from: 0.7, to:0})

	$("picLayer").style.display="none";
	$("picContainer").innerHTML="";

	//$('gesamtOverlay').show().setStyle({opacity: 0});
	//alert($('gesamtOverlay').style.opacity);
}


function showAlert(text){



	showCatcher2();




	$("alert").style.top=getScrollPos()+20+"px";
	$("alert").style.left=findPosX($("header"))+100+"px";
	/*
	Effect.Fade("alert",{duration: 0.1, from: 0, to:1.0})
	*/

	$("alert").style.display="block";
	$("alertSubmit").focus()
	$("alertContent").innerHTML=text;

}


function hideAlert(){
	/*
	Effect.Fade("alert",{duration: 0.3, from: 0.7, to:0})
	*/
	$("alert").style.display="none";
	hideCatcher2();

}

function showInfo(text){



	showCatcher2();




	$("info").style.top=getScrollPos()+20+"px";
	$("info").style.left=findPosX($("header"))+200+"px";
	/*
	Effect.Fade("alert",{duration: 0.1, from: 0, to:1.0})
	*/

	$("info").style.display="block";
	$("infoSubmit").focus()
	$("infoContent").innerHTML=text;

}

function hideInfo(){
	/*
	Effect.Fade("alert",{duration: 0.3, from: 0.7, to:0})
	*/
	$("info").style.display="none";
	hideCatcher2();

}
function showCatcher(){
	$("catcher").style.display="block";
	$("catcher").style.height=getPageHeight()+"px";
	$("catcher").style.width="100%";
}


function hideCatcher(){
	$("catcher").style.display="none";
}

function showCatcher2(){
	$("catcher2").style.display="block";
	$("catcher2").style.height=getPageHeight()+"px";
	$("catcher2").style.width="100%";
}


function hideCatcher2(){
	$("catcher2").style.display="none";
}

function showHelp(Ereignis,text){




	$('gesamtOverlay').show().setStyle({opacity: 0});
	$("gesamtOverlay").style.display="block";
	$("gesamtOverlay").style.height="100%";
	$("gesamtOverlay").style.height=getPageHeight()+"px";
	$("gesamtOverlay").style.width="100%";

	Effect.Fade("gesamtOverlay",{duration: 0.3, from: 0, to:0.6})

	$("authBlock").style.top=getScrollPos()+140+"px";
	$("authBlock").style.left=findPosX($("header"))+200+"px";
	$("authBlock").style.display="block";
	$("authBlock").style.padding="20px"
	$("authBlock").innerHTML="<div style=\"padding:10px;width:570px;\">"+text+"<p /><p /><center><img src='/img/btn_ok.png' onclick='hideHelp()' /></center></div>";;

	if($("loginUsername")){
		window.setTimeout('$("authBlock").style.display="block";$("loginUsername").focus();', 100);
	}



	return;
	if (!Ereignis)
		Ereignis = window.event;
	mouseX = ((ns4)?Ereignis.pageX:Ereignis.clientX);
	mouseY = ((ns4)?Ereignis.pageY:Ereignis.clientY);
	myYoffSet=document.body.scrollTop;

	X = Math.round(mouseX); // Umrechnen der Mausposition
	Y = Math.round(mouseY+myYoffSet); // auf grosse Grafik

	var d=getWinSize();

	if(d.w-X>500){
		posX=X-20;
 	}else{
 		posX=X-420;
	}



	if(d.h-200>Y){
		posY=Y;
 	}else{
 		posY=Y+205;
	}


	document.getElementById('helpContent').innerHTML=text;
	document.getElementById('bgIframe').width=document.getElementById('help').style.width;
 	document.getElementById('help').style.top=posY+"px";
	document.getElementById('help').style.left=posX+"px";
	document.getElementById('help').style.display='';

}


 function showHelps(Ereignis,text){
	if (!Ereignis)
		Ereignis = window.event;
	mouseX = ((ns4)?Ereignis.pageX:Ereignis.clientX);
	mouseY = ((ns4)?Ereignis.pageY:Ereignis.clientY);

	myYoffSet=document.body.scrollTop;

	X = Math.round(mouseX); // Umrechnen der Mausposition
	Y = Math.round(mouseY+myYoffSet); // auf grosse Grafik



// links von der Maus
	if(X>450){
		posX=X+20-460;
	}else{
	 	posX=X+20;
	}



	h=$("help")
	h.style.position="absolute"
	h.style.width="400px"
	h.style.height="200px"
	h.style.backgroundColor="#f8ffc1"
	h.style.border="1px solid #aaaaaa"
	h.style.zIndex="9999999"
	h.style.left=posX
	h.style.top=Y
	h.style.overflow="auto"
	$("helpContent").innerHTML=text;//"fsdf"
	h.show();


}



function hideHelp(){

	hideAuthBlock();
	return;
	document.getElementById('help').style.display='none';
	document.getElementById('helpContent').innerHTML='';

}


function checkImageName(form){

	var x=form.match("\\.(jpg|JPG|jpeg|JPEG)$");
	if(x==null){
		alert("Bitte nur JPEGs hochladen");
		return false;
	}

	return true;


}



function toggleTagBox(){


	$('newTagContainer').toggle();
	if($('tagTag')){
		//$('tagTag').focus();
	//$('tagTag').select();
	}


	var x= $$('.tagButton_X');
	x.length;
	for(var i=0;i<x.length;i++){
		x[i].style.display=$('newTagContainer').style.display;
	}
}

function toggleBeta(){
	var beta=$("beta");
	//beta.style.height="20px";

	var height=beta.getDimensions().height;
	if(height==48){
		// gross machen
		new Effect.Morph('beta', { style: 'height:350px;margin-top:-20px', duration: 0.3});
		$('beta').setAttribute("onclick", "");
		$('betaClose').show();
		$('betaFormular').show();

		if(ie){
			$('beta').style.backgroundPosition="right 310px";
		}

	}else{
		// klein machen
		new Effect.Morph('beta', { style: 'height:48px;margin-top:0px', duration: 0.3});

		if(ie){
			$('beta').onclick= function (){ toggleBeta() };
		}else{
			$('beta').setAttribute('onclick', 'toggleBeta()');
		}
		$('betaClose').hide();
		$('betaFormular').hide();
		if(ie){
			$('beta').style.backgroundPosition="right 1px";
		}

	}


}





function toggleAdmin(){
	var admin=$("admin");
	//beta.style.height="20px";

	var width=admin.getDimensions().width;
	if(width<100){
		// gross machen
		new Effect.Morph('admin', { style: 'width:800px;', duration: 0.3});
		$("adminToggler").src="/img/negative.png";
		$("adminMenu").show();
		$("adminContent").show();


	}else{
		// klein machen
		new Effect.Morph('admin', { style: 'width:30px;', duration: 0.3});
		$("adminToggler").src="/img/openAdmin.png";
		$("adminMenu").hide();
		$("adminContent").hide();


	}



}

function removeDublicate(feld,wert){
	var Teil = feld.value.substring(0, 14);
	if(Teil=='http://http://'){
		feld.value=feld.value.substring(7, feld.value.length);;
	}

}


function getBrowserName() {
	var browserName = "";

	var ua = navigator.userAgent.toLowerCase();
	if ( ua.indexOf( "opera" ) != -1 ) {
	browserName = "opera";
	} else if ( ua.indexOf( "msie" ) != -1 ) {
	browserName = "msie";
	} else if ( ua.indexOf( "safari" ) != -1 ) {
	browserName = "safari";
	} else if ( ua.indexOf( "mozilla" ) != -1 ) {
	if ( ua.indexOf( "firefox" ) != -1 ) {
	browserName = "firefox";
	} else {
	browserName = "mozilla";
	}
	}

	return browserName;
	};

function hideByName(name){
	var x=document.getElementsByName(name);
	for(var i =0 ; i <x.length;i++){
    	x[i].style.display="none";
	}
}

function showByName(name){
	var x=document.getElementsByName(name);
	for(var i =0 ; i <x.length;i++){
    	x[i].style.display="";
	}
}

function toggleByName(name){
	var x=document.getElementsByName(name);
	if(x[0].style.display==''){
		hideByName(name);
	}else{
		showByName(name);
	}
}

/**
* Funtion zum Updaten der Vor- und Nachteile
* Funktion ersetzt den textinhalt eines td oder divs durch ein inputFeld und schreibt den Text in diesen. Beim Verlassen des INPUT Feldes wird der Inhalt in der DB gespeichert
*/
function editPro(obj,id){

	var text=obj.innerHTML;
	text=text.replace(/\"/g,'&quot;');

	obj.innerHTML='<input id="tmpInput" class="inPlayEdit" type="text" style="width:505px" value="'+text+'" onBlur="xajax_updateVorteil(\''+id+'\',this.value);this.parentNode.innerHTML=this.value;">';
	obj.childNodes[0].focus();

	obj.onclick='';

}


/**
* Funtion zum Updaten von Links
* Funktion ersetzt den textinhalt eines td oder divs durch ein inputFeld und schreibt den Text in diesen. Beim Verlassen des INPUT Feldes wird der Inhalt in der DB gespeichert
*/
function editLink(obj,id){

	var text=obj.innerHTML;
	text=text.replace(/\"/g,'&quot;');
	text=text.replace(/\'/g,'&quot;');

	obj.innerHTML='<input id="tmpInput" class="inPlayEdit" type="text" style="width:505px" value="'+text+'" onBlur="xajax_updateLink(\''+id+'\',this.value);this.parentNode.innerHTML=this.value;">';
	obj.childNodes[0].focus();

	obj.onclick='';

}

function replaceMissingUserImages(){
  for (var i=0; i<document.images.length; i++){
    img = new Image();
    img.src = document.images[i].src;
    if (img.height == 0)
      document.images[i].src = '/img/no_profile_pic_48x48.png';
  }
}



function addLinkEditRow(rowNo,id_link){

	if($("editRow")){
		//alert("besetzt");
		$("editRow").remove();
	}
	var table=$("pLinks");
	var row = table.insertRow(rowNo);
	var cell = row.insertCell(-1);

	cell.setAttribute("colspan","2");
	cell.id=  'cell'+rowNo;
	row.id=  'editRow';
	xajax_getLinkEditForm('cell'+rowNo,id_link);


}


function startAutoSearch(string){
	alert(counter++);
	xajax_getSearchResultsFor(string)
}


function getEndung( str ) {
	var pos = str.lastIndexOf( "." );
	return str.substring( pos+1, str.length );
}


function checkFotoName(name){

	var endung=getEndung(name)

	if(endung.toLowerCase()=="jpg") return true;
	if(endung.toLowerCase()=="jpeg") return true;
	if(endung.toLowerCase()=="png") return true;
	if(endung.toLowerCase()=="gif") return true;

	showAlert('Bitte nur JPG, GIF oder PNG hochlanden.');
	return false;
}


function showAllPros(pro){
	var e=$("main").getElementsByClassName("hiddenPros"+pro);

	for(var i=0;i<e.length;i++){
	    e[i].style.display=""
	}

	$("moreProsBox"+pro).hide();
}


function showAllAngebote(){
	var e=$("main").getElementsByClassName("hiddenAngebot");

	for(var i=0;i<e.length;i++){
	    e[i].style.display=""
	}

	$("moreAngeboteBox").hide();
}

function showAllLinks(){
	var e=$("main").getElementsByClassName("hiddenLinks");

	for(var i=0;i<e.length;i++){
	    e[i].style.display=""
	}

	$("moreLinksBox").hide();
}


function showNextBlock(){

	var x =document.getElementsByClassName("block"+block)

	for (var i=0;i<x.length;i++){
   		x[i].style.display="";
	}

	block++;

}




function hideByClass(cla) {
	var elements = document.getElementsByClassName(cla);

	for(var i = 0; i < elements.length; i++) {
		elements[i].style.display = "none";
	}
}

function showByClass(cla) {
	var elements = document.getElementsByClassName(cla);

	for(var i = 0; i < elements.length; i++) {
		elements[i].style.display = "";
	}
}

function toggleByClass(cla) {
	var elements = document.getElementsByClassName(cla);

	for(var i = 0; i < elements.length; i++) {
 		if (elements[i].style.display == "none") {
			elements[i].style.display = "";
		} else {
			elements[i].style.display = "none";
		}
	}
}


var quickSearchString="";
function doQuicksearch(e){







	/*
	40 = runter
	38 = hoch
	13 = Enter
	*/

	var kC  = (window.event) ?    // MSIE or Firefox?
                 	event.keyCode : e.keyCode;
	var Esc = (window.event) ?
                27 : e.DOM_VK_ESCAPE // MSIE : Firefox


	qs_pos=(qs_pos%6);
	if(e.keyCode==40){
		hoverSuchzeile(qs_pos+1);
		qs_pos++;

		if(qs_pos==0){

		}
		return false;
	}else if(e.keyCode==38){

		if(qs_pos==0){
			qs_pos=6;
		}

		qs_pos--;

		hoverSuchzeile(qs_pos);
		return false;

	}else if(e.keyCode==13){

		if($("suchzeile_"+qs_pos)){
			$("suchzeile_"+qs_pos).onclick();
		}else{
			return true;
		}

		return false;
	}


	window.clearTimeout(active);
	if($('search_field').value.length>0 && quickSearchString!=$('search_field').value){


		active = window.setTimeout('xajax_getSearchResultsFor($("search_field").value)', 300);

		quickSearchString=$('search_field').value;
		qs_pos=0;
	}

	if($('search_field').value.length==0){
		$('searchResults').hide();
		hideCatcher();
	}

/* $("productSearch").value=qs_pos;*/

}


function hoverSuchzeile(nummer){





	for(var i=1;i<7;i++){

		if($("suchzeile_"+i)){
			$("suchzeile_"+i).className="suchzeile"
		}

		if($("suchzeile_"+nummer)){
			$("suchzeile_"+nummer).className="suchzeileHover"
		}

	}
	/* Variante 2 (ohne ids)

	var marked=1;
	var x = $("suchzeile_1");

	for(var i=0;i<5;i++){
    	x.className="suchzeile";

    	x = x.nextSibling.nextSibling.nextSibling.nextSibling;
	}

	*/
}




function siblings(element, onlyTags, remove/*0=none, 1=previous, 2=next, 3=all*/){
if(typeof element=="string"){element=document.getElementById(element);};
if(!element){return null;};
var previous=[];
var next=[];
var elementcopy=element;
while(elementcopy.previousSibling){
	if(!onlyTags){
	previous.unshift(elementcopy.previousSibling);
	}
	else if(elementcopy.previousSibling.nodeType==1){
	previous.unshift(elementcopy.previousSibling);
	};
elementcopy=elementcopy.previousSibling;
}
elementcopy=element;
while(elementcopy.nextSibling){
	if(!onlyTags){
	next.push(elementcopy.nextSibling);
	}
	else if(elementcopy.nextSibling.nodeType==1){
	next.push(elementcopy.nextSibling);
	};
elementcopy=elementcopy.nextSibling;
}
remove=parseInt(remove)||0;
if(remove==1 || remove==3){
	for(var i=0; i<previous.length; i++){
	element.parentNode.removeChild(previous[i]);
	}
};//not else
if(remove==2 || remove==3){
	for(var i=0; i<next.length; i++){
	element.parentNode.removeChild(next[i]);
	}
};
return [previous, next];
/*keep this comment to reuse freely:
http://www.fullposter.com/?1 */}


/*
 *  md5.js 1.0b 27/06/96
 *
 * Javascript implementation of the RSA Data Security, Inc. MD5
 * Message-Digest Algorithm.
 *
 * Copyright (c) 1996 Henri Torgemane. All Rights Reserved.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentation for any purposes and without
 * fee is hereby granted provided that this copyright notice
 * appears in all copies.
 *
 * Of course, this soft is provided "as is" without express or implied
 * warranty of any kind.
 *
 *
 * Modified with german comments and some information about collisions.
 * (Ralf Mieke, ralf@miekenet.de, http://mieke.home.pages.de)
 */



function array(n) {
  for(i=0;i<n;i++) this[i]=0;
  this.length=n;
}



/* Einige grundlegenden Funktionen müssen wegen
 * Javascript Fehlern umgeschrieben werden.
 * Man versuche z.B. 0xffffffff >> 4 zu berechnen..
 * Die nun verwendeten Funktionen sind zwar langsamer als die Originale,
 * aber sie funktionieren.
 */

function integer(n) { return n%(0xffffffff+1); }

function shr(a,b) {
  a=integer(a);
  b=integer(b);
  if (a-0x80000000>=0) {
    a=a%0x80000000;
    a>>=b;
    a+=0x40000000>>(b-1);
  } else
    a>>=b;
  return a;
}

function shl1(a) {
  a=a%0x80000000;
  if (a&0x40000000==0x40000000)
  {
    a-=0x40000000;
    a*=2;
    a+=0x80000000;
  } else
    a*=2;
  return a;
}

function shl(a,b) {
  a=integer(a);
  b=integer(b);
  for (var i=0;i<b;i++) a=shl1(a);
  return a;
}

function and(a,b) {
  a=integer(a);
  b=integer(b);
  var t1=(a-0x80000000);
  var t2=(b-0x80000000);
  if (t1>=0)
    if (t2>=0)
      return ((t1&t2)+0x80000000);
    else
      return (t1&b);
  else
    if (t2>=0)
      return (a&t2);
    else
      return (a&b);
}

function or(a,b) {
  a=integer(a);
  b=integer(b);
  var t1=(a-0x80000000);
  var t2=(b-0x80000000);
  if (t1>=0)
    if (t2>=0)
      return ((t1|t2)+0x80000000);
    else
      return ((t1|b)+0x80000000);
  else
    if (t2>=0)
      return ((a|t2)+0x80000000);
    else
      return (a|b);
}

function xor(a,b) {
  a=integer(a);
  b=integer(b);
  var t1=(a-0x80000000);
  var t2=(b-0x80000000);
  if (t1>=0)
    if (t2>=0)
      return (t1^t2);
    else
      return ((t1^b)+0x80000000);
  else
    if (t2>=0)
      return ((a^t2)+0x80000000);
    else
      return (a^b);
}

function not(a) {
  a=integer(a);
  return (0xffffffff-a);
}

/* Beginn des Algorithmus */

    var state = new array(4);
    var count = new array(2);
        count[0] = 0;
        count[1] = 0;
    var buffer = new array(64);
    var transformBuffer = new array(16);
    var digestBits = new array(16);

    var S11 = 7;
    var S12 = 12;
    var S13 = 17;
    var S14 = 22;
    var S21 = 5;
    var S22 = 9;
    var S23 = 14;
    var S24 = 20;
    var S31 = 4;
    var S32 = 11;
    var S33 = 16;
    var S34 = 23;
    var S41 = 6;
    var S42 = 10;
    var S43 = 15;
    var S44 = 21;

    function F(x,y,z) {
        return or(and(x,y),and(not(x),z));
    }

    function G(x,y,z) {
        return or(and(x,z),and(y,not(z)));
    }

    function H(x,y,z) {
        return xor(xor(x,y),z);
    }

    function I(x,y,z) {
        return xor(y ,or(x , not(z)));
    }

    function rotateLeft(a,n) {
        return or(shl(a, n),(shr(a,(32 - n))));
    }

    function FF(a,b,c,d,x,s,ac) {
        a = a+F(b, c, d) + x + ac;
        a = rotateLeft(a, s);
        a = a+b;
        return a;
    }

    function GG(a,b,c,d,x,s,ac) {
        a = a+G(b, c, d) +x + ac;
        a = rotateLeft(a, s);
        a = a+b;
        return a;
    }

    function HH(a,b,c,d,x,s,ac) {
        a = a+H(b, c, d) + x + ac;
        a = rotateLeft(a, s);
        a = a+b;
        return a;
    }

    function II(a,b,c,d,x,s,ac) {
        a = a+I(b, c, d) + x + ac;
        a = rotateLeft(a, s);
        a = a+b;
        return a;
    }

    function transform(buf,offset) {
        var a=0, b=0, c=0, d=0;
        var x = transformBuffer;

        a = state[0];
        b = state[1];
        c = state[2];
        d = state[3];

        for (i = 0; i < 16; i++) {
            x[i] = and(buf[i*4+offset],0xff);
            for (j = 1; j < 4; j++) {
                x[i]+=shl(and(buf[i*4+j+offset] ,0xff), j * 8);
            }
        }

        /* Runde 1 */
        a = FF ( a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
        d = FF ( d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
        c = FF ( c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
        b = FF ( b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
        a = FF ( a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
        d = FF ( d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
        c = FF ( c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
        b = FF ( b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
        a = FF ( a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
        d = FF ( d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
        c = FF ( c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
        b = FF ( b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
        a = FF ( a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
        d = FF ( d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
        c = FF ( c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
        b = FF ( b, c, d, a, x[15], S14, 0x49b40821); /* 16 */

        /* Runde 2 */
        a = GG ( a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
        d = GG ( d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
        c = GG ( c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
        b = GG ( b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
        a = GG ( a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
        d = GG ( d, a, b, c, x[10], S22,  0x2441453); /* 22 */
        c = GG ( c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
        b = GG ( b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
        a = GG ( a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
        d = GG ( d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
        c = GG ( c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
        b = GG ( b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
        a = GG ( a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
        d = GG ( d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
        c = GG ( c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
        b = GG ( b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */

        /* Runde 3 */
        a = HH ( a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
        d = HH ( d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
        c = HH ( c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
        b = HH ( b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
        a = HH ( a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
        d = HH ( d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
        c = HH ( c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
        b = HH ( b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
        a = HH ( a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
        d = HH ( d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
        c = HH ( c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
        b = HH ( b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
        a = HH ( a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
        d = HH ( d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
        c = HH ( c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
        b = HH ( b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */

        /* Runde 4 */
        a = II ( a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
        d = II ( d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
        c = II ( c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
        b = II ( b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
        a = II ( a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
        d = II ( d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
        c = II ( c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
        b = II ( b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
        a = II ( a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
        d = II ( d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
        c = II ( c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
        b = II ( b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
        a = II ( a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
        d = II ( d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
        c = II ( c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
        b = II ( b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */

        state[0] +=a;
        state[1] +=b;
        state[2] +=c;
        state[3] +=d;

    }
    /* Mit der Initialisierung von Dobbertin:
       state[0] = 0x12ac2375;
       state[1] = 0x3b341042;
       state[2] = 0x5f62b97c;
       state[3] = 0x4ba763ed;
       gibt es eine Kollision:

       begin 644 Message1
       M7MH=JO6_>MG!X?!51$)W,CXV!A"=(!AR71,<X`Y-IIT9^Z&8L$2N'Y*Y:R.;
       39GIK9>TF$W()/MEHR%C4:G1R:Q"=
       `
       end

       begin 644 Message2
       M7MH=JO6_>MG!X?!51$)W,CXV!A"=(!AR71,<X`Y-IIT9^Z&8L$2N'Y*Y:R.;
       39GIK9>TF$W()/MEHREC4:G1R:Q"=
       `
       end
    */
    function init() {
        count[0]=count[1] = 0;
        state[0] = 0x67452301;
        state[1] = 0xefcdab89;
        state[2] = 0x98badcfe;
        state[3] = 0x10325476;
        for (i = 0; i < digestBits.length; i++)
            digestBits[i] = 0;
    }

    function update(b) {
        var index,i;

        index = and(shr(count[0],3) , 0x3f);
        if (count[0]<0xffffffff-7)
          count[0] += 8;
        else {
          count[1]++;
          count[0]-=0xffffffff+1;
          count[0]+=8;
        }
        buffer[index] = and(b,0xff);
        if (index  >= 63) {
            transform(buffer, 0);
        }
    }

    function finish() {
        var bits = new array(8);
        var        padding;
        var        i=0, index=0, padLen=0;

        for (i = 0; i < 4; i++) {
            bits[i] = and(shr(count[0],(i * 8)), 0xff);
        }
        for (i = 0; i < 4; i++) {
            bits[i+4]=and(shr(count[1],(i * 8)), 0xff);
        }
        index = and(shr(count[0], 3) ,0x3f);
        padLen = (index < 56) ? (56 - index) : (120 - index);
        padding = new array(64);
        padding[0] = 0x80;
        for (i=0;i<padLen;i++)
          update(padding[i]);
        for (i=0;i<8;i++)
          update(bits[i]);

        for (i = 0; i < 4; i++) {
            for (j = 0; j < 4; j++) {
                digestBits[i*4+j] = and(shr(state[i], (j * 8)) , 0xff);
            }
        }
    }

/* Ende des MD5 Algorithmus */

function hexa(n) {
 var hexa_h = "0123456789abcdef";
 var hexa_c="";
 var hexa_m=n;
 for (hexa_i=0;hexa_i<8;hexa_i++) {
   hexa_c=hexa_h.charAt(Math.abs(hexa_m)%16)+hexa_c;
   hexa_m=Math.floor(hexa_m/16);
 }
 return hexa_c;
}


var ascii="01234567890123456789012345678901" +
          " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
          "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";

function MD5(nachricht)
{
 var l,s,k,ka,kb,kc,kd;

 init();
 for (k=0;k<nachricht.length;k++) {
   l=nachricht.charAt(k);
   update(ascii.lastIndexOf(l));
 }
 finish();
 ka=kb=kc=kd=0;
 for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*8));
 for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*8));
 for (i=8;i<12;i++) kc+=shl(digestBits[15-i], ((i-8)*8));
 for (i=12;i<16;i++) kd+=shl(digestBits[15-i], ((i-12)*8));
 s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
 return s;
}


function logout_fb(){

	FB.Connect.logoutAndRedirect('/fblogout');
}


function FB_test_perm(api_key, xd_receiver, permission, callback)
{
	FB.Bootstrap.requireFeatures(["Connect"], function()
	{
		FB.Facebook.init(api_key, xd_receiver);
		FB.Connect.requireSession(function()
		{
			FB.Facebook.apiClient.users_hasAppPermission(permission, function(result)
			{
				if (result != 0)
					return callback(true);

				FB.Connect.showPermissionDialog(permission, function(result)
				{
					return callback(result == null ? false : (result.indexOf(permission) != -1));
				}, true, null);
			});
		});
	});
}
