/* <![CDATA[ */



var AjaxContent;
var myScroll=null;
var Animate=null;
var HistoryManager=null;
var pagi=null;


var teaserwindow=function () {
	var newsWin=window.open("news.php","News","toolbar=no,scrollbars=yes,location=no,resizable=yes,width=440,height=600");
}

var loadScroll=function(){
	
	
	//iAnzahl=$('scrollOuter').getScrollHeight().toInt()/(40*1.33);
	
	if($('fullimg')==null){
		iAnzahl=$('scrollOuter').getScrollHeight().toInt()/(40*1.33);
		iAnzahl=iAnzahl.round();
		iAnzahl=(iAnzahl-1);
	}
	
	if($('fullimg')!=null){
		iAnzahl=$('scrollOuter').getScrollHeight().toInt()/42;
		iAnzahl=iAnzahl.round();
	}
	
	
	
		myScroll = new Fx.Scroll('scrollOuter',{
			duration:300,
			anzahlElements:iAnzahl,
			elementWidth:60,
			anzeigeBreite:370,
			slideArea:'SlideNavigatorArea',
			slideKnob:'SlideNavigator',
			scrollDir:'vertical',
			showControls:false
		});
		
		myScroll.toTop();
	
}


var PaginationClass = new Class({

	initialize: function(el, max, startpage) {
		this.element = $(el);
		this.max = max;
        this.startPage=startpage;
		this.historyKey ='-p';
		this.history = HistoryManager.register(
			this.historyKey,
			[1],
			function(values) {
				//alert(values[0]);
				if(values[0]==1) values[0]=this.startPage;
				this.to(parseInt(values[0]));
			}.bind(this),
			function(values) {
				return [this.historyKey, '(', values[0], ')'].join('');
			}.bind(this),
			this.historyKey + '\\((\\d+)\\)');
	},

	by: function(dir) {
		this.to(this.page + dir);
	},

	to: function(page) {
		
		page = Math.max(Math.min(this.max, page), 1);
		this.page = page;
		slideInOut(this.page);
		//this.element.set('html','Page '+this.page);
		//alert(this.page);
		this.history.setValue(0, this.page);
	}

});
  

var slideInOut=function(CID){
	
	
	$$('#naviTop a').each(function(el){el.removeClass('current')});
	
	//$$('title').set('html','Moderatorin & Journalistin Anja Viktoria Novak - Offizielle Homepage {'+$('seite_'+CID).getProperty('title')+'}');
	
	var newWidth=845;
	if(CID==9 || CID==10 || CID==12 || CID==11 || CID==4){
		newWidth=640;
	}
	
   
	Animate.start({
		opacity:[1,0]
		
		
	}).wait(200).chain(function(){
		
		Animate.start({
			opacity:[0,1],
			width:[$('innerMain').getCoordinates().width,newWidth]
		});
		$('contentRight').set('html','&nbsp;');
		
		if(newWidth==640){
			$('nameNovak1').setStyle('left','101px');
		}else{
			$('nameNovak1').setStyle('left','0px');
		}
		
		AjaxContent.send('ajaxaction=0&cId='+CID);
		
		if(CID!=12){
			EL='seite_'+CID;
			if($(EL)!=null){
				if($(EL).getParent('ul').getProperty('id')=='sub1_1'){
					$('sub1').addClass('current')
				}
				else if($(EL).getParent('ul').getProperty('id')=='sub2_1'){
					$('sub2').addClass('current')
				}
				
				$(EL).addClass('current');
			}
		}
	});
}



var SubmitForm = function(FormId,FIELD,VALUE) {

//if(getFehlerCheck(FormId)==false){
	$(FormId).getElement('input[name='+FIELD+']').set('value',VALUE);
	AjaxContent.send($(FormId));
	
	
//}

}

var galerieLoad=function(){
	

	var imgPreload =new ownPreload('',{
		itemsClass:'.item',
		 onReadyLoad:function(){
			
		var imgSlider = new ownSlide('scrollInner','fullimg', {
				SlideMode:'galerie',
				offset: {'x': 0, 'y': 0},
				loop:true,
				processing:true,
				showControls:false,			
				elementWidth:79,
				anzeigeBreite:248,
				addButtons:{'previousLink':null,'nextLink':null,'stopLink':null,'playLink':null,'loopLink':null},
				itemsClass:'.item',
				itemsAnimationClass:'.thumb',
				SlideAnimation:{'opacity':[0,1]},
				SlideAnimationOut:{'opacity':[1,0]},
				animation:{'opacity':'0.3'},
			    animationOut:{'opacity':'1'},
				transition: Fx.Transitions.Cubic.easeOut	
		}).toLeft();
			imgSlider.startAnimManuell(0);
	    }	
	});
	
	
	
	


}


var StableAjaxInstanz=function(){
	
	AjaxContent=new Request.HTML({url:'control.inc.php', method: 'post',update: $('contentRight'),evalScripts:true,
			onRequest:function(){
				
			},
			onComplete:function(){
				if($('fullimg')!=null){
					
					galerieLoad();
				}
				if($('contentHeader')!=null){
					$('contentHeader').setStyle('opacity',1);
				}
				if($('scrollOuter')!=null){
					
					loadScroll();
				}
			}
		});
	

	
}

window.addEvent('domready', function(){
	
     HistoryManager = new HistoryManagerX();
	 Animate=new Fx.Morph('innerMain', {duration:500,transition: Fx.Transitions.linear, wait: false});
	 StableAjaxInstanz();
	
	
	if (Browser.Engine.trident){
		//alert(Browser.Engine.version);
		$('TopLayout').setStyles({'z-index':3000});
		$('MainLayout').setStyles({'opacity':1});
		
	}
	$('bgTop').setStyle('left',$('MainLayout').getCoordinates().left+'px')
	

    
	pagi = new PaginationClass('navTop',13,2);
	
	HistoryManager.start();
		 
});//ENDE DOMONLOAD

/* ]]> */
