

function conPage(msg,page,target,param) {
	if(!msg)
		msg = "Weet u dit zeker ?";
		
	
    if(!confirm("Let op: "+msg))
		return false;
	
	loadPage(page,target,param)
}

function flash(page,target) {
	
	doMove = 0;
	
	if($('picFrame').visible()) {
		$('picFrame').hide();
		$('fixPic').hide();
		doMove = 1;
	}

	if(!$('videoBlock').visible()) {
		
		Effect.Appear('videoBlock', { duration: 0.8 ,queue: 'front' } );
	}
	
	if(!$('contentBlock').visible()) {
		
		Effect.Appear('contentBlock', { duration: 0.8 ,queue: 'front' } );
	}
	
	
	
	if(!$('flyerBlock').visible()) {
		
		if(page == "dj")
			return false;
			
		Effect.Appear('flyerBlock', { duration: 0.8 ,queue: 'front' } );
		if(firefox)
			new Effect.Morph('contentBlock', { style: "width: 450px;margin-left: 350px;",duration: 1.3, queue : 'front' });
		else
			new Effect.Morph('contentBlock', { style: "width: 450px;margin-left: 380px;",duration: 1.3, queue : 'front' });
	}
	
	if(!$('pictureBlock').visible()) {
		
		Effect.Appear('pictureBlock', { duration: 0.8 ,queue: 'front' } );
	}
	
	if(doMove) {
		new Effect.Move('videoBlock', { x: 415, y: 165, mode: 'absolute' ,queue: 'front' ,duration: 0.1 });
		$('lines').show();
	}
	
	$(target).update('');
	page = "index.php?page="+page;
	loadPage(page,target);
	
	

}


function cropContent() {
	
	new Effect.Move('videoBlock', { x:150, y: 300,mode: 'absolute' ,duration: 0.5 });
	//new Effect.Move('pictureBlock', { x: 50, y: -100, mode: 'relative' });

	$('pictureBlock').hide();
	$('flyerBlock').hide();
	$('lines').hide();
	$('contentBlock').hide();
	//$('siteContent').setOpacity(0);
	//$('siteContent').morph({width: 0+"px"});
	$('picFrame').show();
	//$('siteContent').hide();
	$('fixPic').show();
	
	
}

function djPage() {
	
	Effect.Fade('flyerBlock', { duration: 0.5 ,queue: 'end' } );
	$('main').setStyle({ height: '750px' });
	new Effect.Morph('contentBlock', { style: "width: 780px;margin-left: 20px;height:300px",duration: 1.0,queue: 'end' });
	
	Effect.Appear('djContent', { duration: 0.5 ,queue: 'end' } );
	
}


function yearsPage() {
	
	//Effect.Fade('flyerBlock', { duration: 0.5 ,queue: 'end' } );
	$('main').setStyle({ height: '750px' });
	new Effect.Morph('contentBlock', { style: "width: 780px;margin-left: 80px;height:400px",duration: 1.0,queue: 'end' });
	
	Effect.Appear('yearsContent', { duration: 0.5 ,queue: 'end' } );
	
}

function LightboxDelegate(url,caption) {
	url = domain+url;

	var objLink = document.createElement('a');
	objLink.setAttribute('href',url);
	objLink.setAttribute('rel','lightbox');
	objLink.setAttribute('title','You on the picture? Gratis een Fles Vodka naar keuze, af te halen op de volgende R&B Feelings (zie agenda)');
	Lightbox.prototype.start(objLink);
}



function loadPage(page,target,param) {
	
	loading();

	var url = domain+page;
	var pars = param;
	var target = target;

	var myAjax = new Ajax.Updater({success: target},url, {method: 'get', onComplete : unload, parameters: pars, evalScripts: 'true'});
}

function sendForm(page, id, target){

	loading();

	var page = domain+page;
	var params = Form.serialize($(id));
	new Ajax.Updater(target, page, { method: 'post',onComplete : unload, asynchronous:true, parameters:params,evalScripts: 'true'});
	
} 


function loading(target) {
	
	if($('loading')) {
	
		$('loading').show();
		$('loading').update('<img src="'+domain+'data/images/icons/loading.gif" border="0" style="padding-left:5px;" align="absmiddle">&nbsp;&nbsp;Loading ...');
		
		if(target)
			$(target).update('<img src="'+domain+'data/images/icons/loading.gif" border="0" style="padding-left:5px;" align="absmiddle">&nbsp;&nbsp;Loading ...');
	}
		
}

function updateLoading(target) {
	
	if($(target)) {
		$(target).update('<img src="'+domain+'data/images/icons/indicator_arrows.gif" border="0" style="padding:10px;" align="absmiddle">&nbsp;&nbsp;Loading ...');
	}
}

function unload() {
	$('loading').update('');
	$('loading').hide();
	
}

function checkEnter(e, func){ 
	var characterCode;

	if(e && e.which){ 
		e = e;
		characterCode = e.which;
	}
	else{
		e = event;
		characterCode = e.keyCode;
	}
	
	if(characterCode == 13){ 
		func;
	}

}

function swap(target,id,ani) {
	
	if($(target)) {
		$(target).hide();
		$(target).update(' '+$(id).innerHTML);
		if(ani == "simple")
			$(target).show();	
		else
			Effect.BlindDown(target, ({ duration: 0.3 }));
	}
}

function checkEnterForm(e, page, id, target, show){ 
	
	var characterCode;

	if(e && e.which){ 
		e = e;
		characterCode = e.which;
	}
	else{
		e = event;
		characterCode = e.keyCode;
	}

	if(characterCode == 13){ 
		sendForm(page,id,target,show);
	}

}

 
function moveFocus(e, obj, x, y,maxCol,maxRow,startVal) {
	
	var key;
    if(window.event) {
		key = window.event.keyCode; 
    }
    else if(e.which) {
     	key = e.which;
    }
    var objId;
    if (obj != null) {
    	objId = obj.id;
    } else {
    	objId = this.id;
    }
    var field = document.getElementsByName(x+"_"+y);
	characterCode = key;

	//rechts
	if(characterCode == 39) {
		rowTeller = (x+1);
		
		if(rowTeller>maxCol)
			rowTeller = maxCol;
			
		newRow = rowTeller+'_'+y;
		document.getElementsByName(newRow)[0].focus();
		return;

	}
	// left
	if(characterCode == 37) {
		rowTeller = (x-1);
		
		if(rowTeller<1)
			rowTeller = 1;
			
		newRow = rowTeller+'_'+y;
		document.getElementsByName(newRow)[0].focus();
		return;

	}
	// down
	if(characterCode == 40) {
		rowTeller = (y+1);
		
		if(rowTeller>maxRow)
			rowTeller = maxRow;
			
		newRow = x+'_'+rowTeller;
		document.getElementsByName(newRow)[0].focus();
		return;
	}
	//up
	if(characterCode == 38) {
		rowTeller = (y-1);
		if(rowTeller<1)
			rowTeller = 1;
			
		newRow = x+'_'+rowTeller;
		document.getElementsByName(newRow)[0].focus();
		return;

	}
}


// Some Class
function FCKcheck()
{
        this.doCheck = function()
        {
                for ( i = 0; i < parent.frames.length; ++i )
                        if ( parent.frames[i].FCK )
                                parent.frames[i].FCK.UpdateLinkedField();
        }
}
// instantiate the class
var FCKcheck = new FCKcheck();


Event.observe(window, 'load', function() {
    $$('a[rel="external"]').each(function(link){
        if(link.readAttribute('href') != '' && link.readAttribute('href') != '#'){
            link.writeAttribute('target','_blank');
        }
    });
});