/* <![CDATA[ */


var bSwitchFA=false;


var myWysiwyg;




	

function BilderVorladen(){
    document.Vorladen = new Array();

    if(document.images){
        for(var i = 0; i < BilderVorladen.arguments.length; i++)
        {
            document.Vorladen[i] = new Image();
            document.Vorladen[i].src = BilderVorladen.arguments[i];
        }
    }
}




var resizeIt=function(ID,WIDTH,HEIGHT){

        saveHeight=HEIGHT.toInt();
        saveWidth=WIDTH.toInt();
        saveBotHeight=$(ID+'_bot').getCoordinates().height.toInt();
        saveTopHeight=$(ID+'_dragToolArea').getCoordinates().height.toInt();

         var myEffect = new Fx.Morph(ID+'_main', {duration: 2000, transition: Fx.Transitions.linear});
         var myEffectBody = new Fx.Morph(ID+'_toolBody', {duration: 2000, transition: Fx.Transitions.linear});

        $(ID+'_ajaxcontent').setStyles({
              'opacity':0
        });

        myEffect.start({
				'width':[$(ID+'_main').getCoordinates().width,saveWidth],
				'height':[$(ID+'_main').getCoordinates().height,saveHeight]
		    });

        myEffectBody.start({
				'height':[$(ID+'_main').getCoordinates().width-180,(saveHeight-saveTopHeight)]
		}).chain(function(){

		        $(ID+'_ajaxcontent').setStyles({
		              'height':(saveHeight-(saveBotHeight+saveTopHeight+10))+'px',
		              'width':(saveWidth-16)+'px',
		              'opacity':1
		        });
       });
}



var editContentText=function(AJAX,MAIN_ID,BASEURL,FOLDER){

	
	if(document.id('Maintitle')!=null){
	    var temp=document.id('Maintitle').get('text');
	    document.id('Maintitle').set('text','');
	
		input = new Element("input").setProperties({'id':'temp_Maintitle','class':'textField','size':40});
		input.set('value',temp);
		input.inject(document.id('Maintitle'),'before');
	}

var ELEMENT='Maintext';
var vier;
var pathLocate=BASEURL;
var pathUpload=FOLDER;

var cssFile='style2.css';
var breite=document.id(ELEMENT).getCoordinates().width;


var LoadInhalt=new Request.HTML({url:'control.php', method: 'post',data:'ajaxaction=25&ID='+MAIN_ID,update: document.id(ELEMENT),
	           onComplete:function(){
					vier=new HtmlArea(document.id(ELEMENT),pathLocate,{inlineEdit:true,resizeLimit:{y: [300, 600],x:[300,breite]},width:breite,CssFile:cssFile,initfactor:1,height:'500px',picupload:true,uploadfolder:pathUpload,
					      onReadyLoad:function(){
								   document.id('editlinkText').set('text','speichern');
								   document.id('editlinkText').onclick=function(){
								   if(vier.saveCheck()){
								      var SaveTitle='';
									   if(document.id('temp_Maintitle')!=null) {
										   SaveTitle=document.id('temp_Maintitle').get('value');
								       } 
									   saveContent(vier.saveContentHTMLAREA(),SaveTitle,AJAX,MAIN_ID,ELEMENT,BASEURL,FOLDER);
								        
								     }
								   }
					             }
					   });
				}
	
				}).send();


 
}


var editMeta=function(CONID,MODUS){
	var saveMetaDescription=$$('meta[name=description]').get('content');
	var saveMetaKeywords=$$('meta[name=keywords]').get('content');
	
	textarea1 = new Element("textarea").setProperties({'id':'metaDescr','class':'metaDescrArea'});
	textarea1.set('value',saveMetaDescription);
	textarea2 = new Element("textarea").setProperties({'id':'metaKey','class':'metaKeyArea'});
	textarea2.set('value',saveMetaKeywords);
	textarea1.inject($('editmetalink'),'before');
	textarea2.inject($('editmetalink'),'before');

	$('editmetalink').onclick=function(){
	       saveMeta($('metaDescr').value,$('metaKey').value,CONID,MODUS);
	}
}
var saveMeta=function(DESCR,KEYS,CONID,MODUS){
	
	$$('meta[name=description]').set('content',DESCR);
	$$('meta[name=keywords]').set('content',KEYS);

	new Request.HTML({url:'control.php', method: 'post',data: 'ajaxaction=1901&DESCR='+DESCR+'&KEYS='+KEYS+'&CONID='+CONID+'&MODUS='+MODUS,
		onComplete:function(){
		    $('metaDescr').destroy();
		    $('metaKey').destroy();
		    $('editmetalink').onclick=function(){
		    	editMeta(CONID,MODUS);
			}
		}
	}).send();

}


var saveContent = function(HTML,TITLE,AJAX,ID,ELEMENT,BASEURL,FOLDER) {
	
	if(document.id('temp_Maintitle')!=null){
		var temp=document.id('temp_Maintitle').get('value');
		document.id('temp_Maintitle').destroy();
		document.id('Maintitle').set('html',temp);
	}
	new Request.HTML({url:'control.php', method: 'post',data: 'ajaxaction='+AJAX+'&title='+encodeURIComponent(TITLE)+'&txt='+encodeURIComponent(HTML)+'&ID='+ID,
		onFailure:function(){
		
			},
				onComplete:function(){
				     document.id('editlinkText').set('text','bearbeiten');
					 document.id('editlinkText').onclick=function(){
				         editContentText(AJAX,ID,BASEURL,FOLDER);
				     }
				
				}}).send();
}


var markAll=function(KLASSE,SWITCH){
	var SwitchKlasse=$$('.'+KLASSE);
		SwitchKlasse.each(function(el){
			el.checked=SWITCH;
		});
}


var loadWYSIWYG=function(PATH,FORM,TEXTAREA){
	var mySel=[{'bold':true,'underline':true,'italic':true,'forecolor':true,'backcolor':true,'Smilies':true,'help':true}];
	if($('jsHTMLAREA')==null){
		myAsset=  new Asset.javascript('./htmlarea/loadhtmlarea.php', {id: 'jsHTMLAREA',
  		onload: function() {
		myWysiwyg=new HtmlArea(TEXTAREA,PATH,{form:FORM,CssFile:'style2.css',ViewSource:false,toolbar:mySel,width:'450px',height:'180px'});
	   }
  		});
	}else{
		myWysiwyg=new HtmlArea(TEXTAREA,PATH,{form:FORM,CssFile:'style2.css',ViewSource:false,toolbar:mySel,width:'450px',height:'180px'});
	}
}



var showPages=function(){
if($('showAllPages').getPosition().height < 1)
$('showAllPages').setStyles({'display':'inline','top':'10px','left':'10px'});
else{
$('showAllPages').setStyles({'display':'none','top':'10px','left':'10px'});
}
}


var loadSpecial=function(ChangeID,ACTION,UPDID){

		if(ChangeID==''){
			$(UPDID).set('html','');
		}else{
			loadAjaxContent(ACTION,UPDID,ChangeID);
		}
	}



var loadAjaxContent = function(action,what,more) {new Request.HTML({url:'control.php',method: 'post',data: 'ajaxaction='+action+'&more='+more,update: $(what),evalScripts:true,
		onRequest:function(){
			$(what).set('html','<br /><table align="center" style="background-color:#fff; border:1px solid #333; height:100px; width:100px;"><tr><td align="center"><img src="images/loading.gif" border="0" title="loading" /></td></tr></table>');
		},
		onComplete:function(){

		}
	}).send();
}




var myShowWindow=function(UPDATEFIELD,TITLE,WIDTH,HEIGHT,MODAL,AJAXAKTIV,AJAXDATA,TXT){
	
	myWindoo=new OwnWindoo(null,{
    width:WIDTH,
	height:HEIGHT,
	modal:MODAL,
	updateField:UPDATEFIELD,
	title:TITLE,
	text:TXT,
	elemPos:document.id('mainBody'),
	ajaxAktiv:AJAXAKTIV,
	ajaxFile:'control.php',
	ajaxData:AJAXDATA,
	onAjaxComplete: function(){
 		
       
	}.bind(this)

    });
	myWindoo.show();
	
  
}



var myAjaxSearch=null;
var myAnimSearch;

var closeSearch=function(){
	myAnimSearch.start({
		 'top':[0,-450]          
		  }).chain(function(){
				document.id('searchAusgabe').addClass('isHidden').set('html','');

		  });  
}

var prepareLiveSearch=function(){
	
	myAnimSearch=new Fx.Morph('searchAusgabe',{duration:800,transition:Fx.Transition.Linear});
	
	if(document.id('liveSearch')!=null){
		
		var searchtxt = document.id('liveSearch');
		document.id('liveSearch').addEvents({
				'focus': function() {
			
		document.id('searchAusgabe').removeClass('isHidden').setStyles({'opacity':0.9,'z-index':150});
		var topMove=document.id('liveSearch').getCoordinates().bottom;
			myAnimSearch.start({
						 'top':[-450,topMove],
						 'left':0
						  }).chain(function(){
								document.id('searchAusgabe').set('html','<br /><a href="javascript:;" style="float:right; margin-right:10px;" class="linkButton" onclick="closeSearch();">schliessen</a><br class="clearing" /><br /><div class="MenuSetting" style="background:#fff;"><br />&nbsp;&nbsp;Geben Sie bitte Ihren Suchbegriff ein! <br /><br /></div>');
 
						  });      
			      searchtxt.set('value','');
				},
				'keyup': function() {
				  
					if(searchtxt.get('value').length >= '3'){
						window.setTimeout("myAjaxSearch.send('ajaxaction=26&Search="+encodeURIComponent(searchtxt.get('value'))+"')", 1000);
					  
	     			}
				}
		});
	}
}

var ajaxContent=function(which,more){

	loadAjaxContent(which,'showFenster_ajaxcontent',more);

}

//Content
var loadAjaxPag = function(action,UPDATE,Param,entries) {new Request.HTML({url:'control.php', method: 'post',data: 'ajaxaction='+action+'&Param='+Param+'&entries='+entries,update: $(UPDATE+'_ajaxcontent'),evalScripts: true,
		onFailure:function(){
		alert('Problem');
		},
		onRequest:function(){
			$(UPDATE+'_ajaxcontent').set('html','<img src="images/loading.gif" border="0" title="loading" />');
		},
		onSuccess:function(){

		}
}).send();}



var SubmitForm = function(FIELD,VALUE,FormId,UPDATEAREA) {
	$(FormId).getElement('input[name='+FIELD+']').set('value',VALUE);
    myWysiwyg.getSubmitHtml();

//if(getFehlerCheck(FormId)==false){

	new Request.HTML({url:'control.php', method: 'post',update: $(UPDATEAREA),evalScripts: true,
		onFailure:function(){
		alert('Problem');
		},
		onRequest:function(){
			$(UPDATEAREA).set('html','<img src="images/loading.gif" border="0" title="loading" />');
		},
		onSuccess:function(){

		}
	}).send($(FormId));
//}

}
var SubmitForm1 = function(FIELD,VALUE,FormId,UPDATEAREA) {
   $(FormId).getElement('input[name='+FIELD+']').set('value',VALUE);

  //  myWysiwyg.getSubmitHtml();

//if(getFehlerCheck(FormId)==false){

	new Request.HTML({url:'control.php', method:'post',update: $(UPDATEAREA),evalScripts: true,
		onFailure:function(){
		alert('Problem');
		},
		onRequest:function(){
			$(UPDATEAREA).set('html','<img src="images/loading.gif" border="0" title="loading" />');
		},
		onSuccess:function(){

		}
	}).send($(FormId));
//}

}

var SubmitFormRate = function(FormId,UPDATEAREA) {

	new Request.HTML({url:'control.php', method:'post',update: $(UPDATEAREA),evalScripts: true,
		onFailure:function(){
		alert('Problem');
		},
		onRequest:function(){
			$(UPDATEAREA).set('html','<img src="images/loading.gif" border="0" title="loading" />');
		},
		onSuccess:function(){
			
		}
	}).send($(FormId));

}

var slidingtabsNav;
var slidingtabsStart;

var prepareTeam=function(){
	
	$$('.team').each(function(elem){
		elem.addEvent('mouseenter',function(){
		
			document.id('teamBg').addClass('teamHover');
			
			elem.addClass(elem.id+'_hover');
			
		});
       elem.addEvent('mouseleave',function(){
    	   document.id('teamBg').removeClass('teamHover');
    	   elem.removeClass(elem.id+'_hover');
    	  
		});
      elem.addEvent('click',function(){
			//teamMember
    	    var person=elem.get('text');
    		 showTeamMember(person);
    	 
		});
	});
}

var showTeamMember=function(ID){
	   
	   loadAjaxContent('1','teamMember',ID);
	   document.id('teamMember').removeClass('isHidden');
	   //document.id('teamMember').set('html',TXT);
	   var leftMove=(window.getWidth()/2)-360;
	   var myMeldungFx=new Fx.Morph('teamMember',{duration:3000,transition:Fx.Transitions.Bounce.easeOut});
	   myMeldungFx.start({
	   	top:[-550,100],
		left:[leftMove,leftMove]
	   });
	   
	   document.id('teamMember').addEvent('click',function(){
		  
		   document.id('teamMember').set('morph',{duration:700});
		   document.id('teamMember').get('morph').start({
		   		top:[100,-750]
		   }).chain(function(){
		   		document.id('teamMember').addClass('isHidden');
			    document.id('teamMember').set('html','');
		   });
   });
		   
	   
}

window.addEvent('domready', function(){

	
	//	loadItemFunc();
		
	/*	
	$$('#nav ul li').each(function(el){
		//el.setStyles({'opacity':0.9});
		alert(el.getStyle('z-index'));
	});*/
	
	if(document.id('showRoom')!=null){
		
		var data1 = {
				'room0.jpg': {'caption':'Raum'},
				'room1.jpg': {'caption':'Raum'},
				'room070.jpg': {'caption':'Raum'},
				'room029.jpg': {'caption':'Raum'},
				'room107.jpg': {'caption':'Raum'},
				'room095.jpg': {'caption':'Raum'},
				'room090.jpg': {'caption':'Raum'},
				'room083.jpg': {'caption':'Raum'},
				'room080.jpg': {'caption':'Raum'},
				'room073.jpg': {'caption':'Raum'},
				'room065.jpg': {'caption':'Raum'},
				'room056.jpg': {'caption':'Raum'},
				'room001.jpg': {'caption':'Raum'}
				};
		new Slideshow.KenBurns('showRoom', data1, {delay: 5000, duration: 4000, height: 500, hu: './images/pics', width: 710,direction:'top' });
			
		
	}
	
	
	if ($$('.team').length >0) {
		prepareTeam();
	}
	
	myAjaxSearch =new Request.HTML({url:'control.php', method:'post',update: document.id('searchAusgabe'),evalScripts:true,
		onRequest:function(){
			
		},
		onComplete:function(){
		}
	});
	prepareLiveSearch();

new NS.Placeholder({cssClass: 'my-placeholder'});


if($$('.toolTipContent').length > 0){
   new Tips($$('.toolTipContent'),{showDelay:300,className:'tooltipEvent',text:''});
}
if($$('.tooltip').length > 0){
	   new Tips($$('.tooltip'),{showDelay:300,className:'tooltipEvent',text:''});
	}

});//ENDE DOMONLOAD
/* ]]> */
