
var current_blog_post = 0;
var current_blog_scrolldirection = 0;
var myWindow, youtubePopup;

/**/ 
/**		Begin main menu rollover script 
/**/
/* OFF images */
buttonThuis_off 		= new Image();
buttonOverBW_off 		= new Image();
buttonRedactie_off 		= new Image();
buttonProgramma_off		= new Image();
buttonKaarten_off 		= new Image();
buttonKaarten_off 		= new Image();
buttonContact_off 		= new Image();
buttonMailing_off 		= new Image();
buttonPers_off 			= new Image();
buttonEducatie_off		= new Image();
buttonEnglish_off 		= new Image();
buttonThuis_off.src 		= "/assets/templates/breakin-walls-09/images/buttons/thuis.gif";
buttonOverBW_off.src 		= "/assets/templates/breakin-walls-09/images/buttons/over_bw.gif";
buttonRedactie_off.src 		= "/assets/templates/breakin-walls-09/images/buttons/redactie.gif";
buttonProgramma_off.src		= "/assets/templates/breakin-walls-09/images/buttons/programma.gif";
buttonKaarten_off.src 		= "/assets/templates/breakin-walls-09/images/buttons/kaarten.gif";
buttonContact_off.src 		= "/assets/templates/breakin-walls-09/images/buttons/contact.gif";
buttonMailing_off.src 		= "/assets/templates/breakin-walls-09/images/buttons/mailing.gif";
buttonPers_off.src 			= "/assets/templates/breakin-walls-09/images/buttons/pers.gif";
buttonEducatie_off.src		= "/assets/templates/breakin-walls-09/images/buttons/educatie.gif";
buttonEnglish_off.src 		= "/assets/templates/breakin-walls-09/images/buttons/english.gif";
/* ON images */
buttonThuis_on 			= new Image();
buttonOverBW_on 		= new Image();
buttonRedactie_on 		= new Image();
buttonProgramma_on		= new Image();
buttonKaarten_on 		= new Image();
buttonKaarten_on 		= new Image();
buttonContact_on 		= new Image();
buttonMailing_on	 	= new Image();
buttonPers_on 			= new Image();
buttonEducatie_on		= new Image();
buttonEnglish_on 		= new Image();
buttonThuis_on.src 			= "/assets/templates/breakin-walls-09/images/buttons/thuis_on.gif";
buttonOverBW_on.src			= "/assets/templates/breakin-walls-09/images/buttons/over_bw_on.gif";
buttonRedactie_on.src 		= "/assets/templates/breakin-walls-09/images/buttons/redactie_on.gif";
buttonProgramma_on.src		= "/assets/templates/breakin-walls-09/images/buttons/programma_on.gif";
buttonKaarten_on.src 		= "/assets/templates/breakin-walls-09/images/buttons/kaarten_on.gif";
buttonContact_on.src 		= "/assets/templates/breakin-walls-09/images/buttons/contact_on.gif";
buttonMailing_on.src 		= "/assets/templates/breakin-walls-09/images/buttons/mailing_on.gif";
buttonPers_on.src 			= "/assets/templates/breakin-walls-09/images/buttons/pers_on.gif";
buttonEducatie_on.src		= "/assets/templates/breakin-walls-09/images/buttons/educatie_on.gif";
buttonEnglish_on.src 		= "/assets/templates/breakin-walls-09/images/buttons/english_on.gif";
/**/ 
/**		Einde main menu rollover script 
/**/

/**/
/**		Begin Submenu rollover script
/**/
// off images
submenu_redactie_off 				= new Image();
submenu_redactie_off.src			= "/assets/templates/breakin-walls-09/images/subtitles/redactie.gif";
submenu_jij_in_de_redactie_off 		= new Image();
submenu_jij_in_de_redactie_off.src	= "/assets/templates/breakin-walls-09/images/subtitles/jij_in_de_redactie.gif";
submenu_organisatie_off 			= new Image();
submenu_organisatie_off.src			= "/assets/templates/breakin-walls-09/images/subtitles/organisatie.gif";
submenu_bw_producties_off 			= new Image();
submenu_bw_producties_off.src		= "/assets/templates/breakin-walls-09/images/subtitles/bw_producties";
submenu_about_breakinwalls_off		= new Image();
submenu_about_breakinwalls_off.src	= "/assets/templates/breakin-walls-09/images/subtitles/about_breakinwalls.gif";
submenu_language_no_problem_off		= new Image();
submenu_language_no_problem_off.src	= "/assets/templates/breakin-walls-09/images/subtitles/language_no_problem.gif";
// on images
submenu_redactie_on 				= new Image();
submenu_redactie_on.src				= "/assets/templates/breakin-walls-09/images/subtitles/redactie_on.gif";
submenu_jij_in_de_redactie_on		= new Image();
submenu_jij_in_de_redactie_on.src	= "/assets/templates/breakin-walls-09/images/subtitles/jij_in_de_redactie_on.gif";
submenu_organisatie_on				= new Image();
submenu_organisatie_on.src			= "/assets/templates/breakin-walls-09/images/subtitles/organisatie_on.gif";
submenu_bw_producties_on			= new Image();
submenu_bw_producties_on.src		= "/assets/templates/breakin-walls-09/images/subtitles/bw_producties_on.gif";
submenu_about_breakinwalls_on		= new Image();
submenu_about_breakinwalls_on.src	= "/assets/templates/breakin-walls-09/images/subtitles/about_breakinwalls_on.gif";
submenu_language_no_problem_on		= new Image();
submenu_language_no_problem_on.src	= "/assets/templates/breakin-walls-09/images/subtitles/language_no_problem_on.gif";


function rollSubmenu(stage, name)
{
	if(stage == 1)
	{
		document[name].src = eval(name + '_on.src');
	}
	else
	{
		document[name].src = eval(name + '_off.src');
	}
}
/**/
/**		Einde Submenu rollover script
/**/


bg_voorstelling_mouseover		= new Image();
bg_voorstelling_mouseover.src 	= "/assets/templates/breakin-walls-09/images/bg_voorstelling_mouseover.jpg";

function changeBG(stage, id)
{
	if(stage == 1)
	{
		document.getElementById(id).style.backgroundImage=('url('+bg_voorstelling_mouseover.src+')');
	}
	else
	{
		document.getElementById(id).style.backgroundImage=('url(/assets/templates/breakin-walls-09/images/bg_voorstelling.jpg)');
	}
}

function openCenteredWindow(url) {
    var width = 600;
    var height = 320;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));

    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "Breakin_Walls", windowFeatures);
}

function programmaPopup(url) {
    var width = 900;
    var height = 525;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));

    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ", scrollbars=1, screenY=" + top;
    myWindow = window.open(url, "Breakin_Walls", windowFeatures);
}

function youtubepop(url) {
    var width = 670;
    var height = 400;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, "Breakin_Walls", windowFeatures);
}

function rollover(action, name) {
	if(action == 'on')
	{
		document.images[name].src = eval(name + '_on.src');
	} else 
	{
		document.images[name].src = eval(name + '_off.src');
	}
}

function scrollblog(){
	var tmp = current_blog_post + current_blog_scrolldirection;
	var p = $('posts').getElementsByClassName('post');
	if(tmp>=0&&tmp<p.length){
		current_blog_post += current_blog_scrolldirection;
		blogToCurrent();
		if(current_blog_scrolldirection!=0)document.blogscrollTimeoutID = setTimeout("scrollblog()", 500);
	}
}
var blogScrollTweener = 0;

function blogToCurrent(){
	if(blogScrollTweener)blogScrollTweener.stop();
	blogScrollTweener = new Tween($('posts'),"scrollTop",Tween.strongEaseOut,$('posts').scrollTop, Position.positionedOffset($('posts').getElementsByClassName('post')[current_blog_post])[1]-20,0.3);
	blogScrollTweener.start();
}

function blogFromBottomToCurrent(){
	if(blogScrollTweener.stop)blogScrollTweener.stop();
	var p = $('posts').getHeight() - $('posts').getElementsByClassName('post')[current_blog_post].getHeight();
	var t = Position.positionedOffset($('posts').getElementsByClassName('post')[current_blog_post])[1]-p
	blogScrollTweener = new Tween($('posts'),"scrollTop",Tween.strongEaseOut,$('posts').scrollTop, t,0.3);
	blogScrollTweener.start();
}

function startscroll(direction){
	current_blog_scrolldirection = direction;
	scrollblog();
}
function endscroll(){
	current_blog_scrolldirection = 0;
	if(document.blogscrollTimeoutID) clearTimeout(document.blogscrollTimeoutID);
}
function showBlogPost(lmn){
	Element.extend(lmn);
	$('posts').setStyle({height:postsHeight+'px'});
	var myPos = 0;
	lmn.up().immediateDescendants().each(function(s){
		if(s!=lmn){
			if(s.getElementsByClassName('more').length>0) s.getElementsByClassName('more')[0].setStyle({display:'none'});
			if(s.getElementsByClassName('less').length>0) s.getElementsByClassName('less')[0].setStyle({display:''});
		}else{
			if(s.getElementsByClassName('more').length>0) s.getElementsByClassName('more')[0].setStyle({display:''});
			if(s.getElementsByClassName('less').length>0) s.getElementsByClassName('less')[0].setStyle({display:'none'});
			if(s.getHeight() > postsHeight){
				$('posts').setStyle({height:(s.getHeight()+40)+'px'});
			}
			if(current_blog_post!=myPos){
				var t = current_blog_post < myPos;
				current_blog_post = myPos;
				if(t)
					blogFromBottomToCurrent();
				else
					blogToCurrent();
			}
			
		}
		myPos++;
	});
}

function programInit(w,h){
	var hw = hw ? hw : 200;
	var hh = hh ? hh : 140;
	var t = $('content').getElementsByClassName('programma')[0].getElementsByTagName('td');
	for(var n in t){
		s = t[n];
		s.onmouseover = function(){
			document.over = this;
			if(this.innerHTML.strip()=='')return;
			if($('myHilited'))$('myHilited').remove();
			Element.extend(this);
			var e = document.createElement('div');
			e.id = 'myHilited';
			Element.extend(e);
			e.addClassName('hilited');
			$('content').appendChild(e);
			Position.absolutize(e);
			Position.clone(this,e);
			var w = parseInt(this.getStyle('width'),10)
			var h = parseInt(this.getStyle('height'),10)
			var ml = parseInt((hw-w)/2);
			var mt = parseInt((hh-h)/2);
			
			e.addClassName('hilited');
			new Tween(e.style,'width',Tween.strongEaseOut,w,hw,0.2,'px').start();
			new Tween(e.style,'height',Tween.strongEaseOut,h,hh,0.2,'px').start();
			new Tween(e.style,'marginLeft',Tween.strongEaseOut,0,-ml,0.2,'px').start();
			var t = new Tween(e.style,'marginTop',Tween.strongEaseOut,0,-mt,0.2,'px');
			t['targetContent'] = this.innerHTML;
			t['target'] = e;
			t.onMotionFinished = function(obj){
				this.target.innerHTML = this.targetContent;
				if(parseInt(this.target.scrollTop,10)>0)this.target.style.height='auto';
			}
			t.start();
		}
	}
	
	Event.observe(document,'mousemove',function(evnt){
			if($('myHilited')&&document.over&&!Position.within(document.over,Event.pointerX(evnt),Event.pointerY(evnt))){
				$('myHilited').remove();
				document.over=false;
			}
		}
	)
}
var postsHeight=0;
Event.observe(window,'load',function(){
	$$('.mov').each(function(i){
		if(i.innerHTML.indexOf('http://www.youtube.com/v')==-1){
			if(i.hasClassName('shoutout')){
				new Flash('http://www.youtube.com/v/'+i.innerHTML,{width:150,height:128,wmode:'transparent'}).embed(i);
			}else{
				new Flash('http://www.youtube.com/v/'+i.innerHTML,{width:236,height:195,wmode:'transparent'}).embed(i);
			}
		}
	})
	if($('mov')
		&&$('mov').innerHTML
		&&$('mov').innerHTML!=''
		&&$('mov').innerHTML.indexOf('http://www.youtube.com/v')==-1){
			new Flash('http://www.youtube.com/v/'+$('mov').innerHTML,{width:236,height:195,wmode:'transparent'}).embed('mov');
		}

	if($('content').getElementsByClassName('programma').length>0) programInit();
	postsHeight = $('posts').getHeight();
})
