$(document).ready(function(){	
	/* control overflow */
	wrapper_w = $('#wrapper').width();
	onresize = overflow;
	overflow();
	
	
	/* accordeon */
	$('.tabs-vertical').accordion({ 
		autoheight:false,
		header: 'h4'
	});	
	
	
	/* popup link */
	$('.jPopup').click(function(){
		var w = getParam(this.href, 'w') || 700;
		var h = getParam(this.href, 'h') || 500;
		var l = ($(window).width())/2 - w/2;
		var t = ($(window).height())/2 - h/2;
		var s = getParam(this.href, 's') || 1;
		window.open(this.href, '','top='+t+', left='+l+', width='+w+',height='+h+', scrollbars='+s+', resizable=1');
		return false;
	});
});


/* parsing of url parameters */
function getParam(url, name){
	var name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( url );
	if( results == null )
		return "";
	else 
		return results[1];
}


function overflow(){
	var document_w = $(this).width();
	if(document_w > wrapper_w){
		$('body').attr('class', 'nooverflow');
	} else {
		$('body').removeAttr('class');
	}	
}