var url_helper = {
	
	qs:		false,
	
	get:	function(key) {
		var qs = this.qs;
		if(qs === false) {
			qs = {};
			q = window.location+'';
			q = q.split('?');
			if(q[1]) {
				$.each(q[1].split('&'), function(i, value) {
					v = value.split('=');
					qs[v[0]] = v[1];
				});
				this.qs = qs;
			}
		}
		
		if(qs[key]) return qs[key];
		return false;
	}
	
};





function switch_tab(eq) {
	$('#meniu_c a').removeClass('active');
	$('div#meniu_c a:eq(' + eq + ')').addClass('active');
	//$('#tabs_content > p.titlu1').slideUp('fast');
	$('#tabs_content > div.tab_content').slideUp('fast');
	//$('#tabs_content > p.titlu1:eq(' + eq + ')').slideDown('fast');
	$('#tabs_content > div.tab_content:eq(' + eq + ')').slideDown('fast');
	height1=$('#tabs_content > div.tab_content:eq(' + eq + ') > .tekst').innerHeight();
	height2=$('#tabs_content > div.tab_content:eq(' + eq + ')').innerHeight();
	//if(height2>height1 && height2>1) {
		//verschil=height2-height1;
	//} else {
		verschil=239-height1;
	//}
	//alert(height2+"-"+height1+"="+verschil);
	$('#tabs_content > div.tab_content:eq(' + eq + ') > .tekst').css("margin-top",verschil+"px");
	$('#tabs_content > div.tab_content:eq(' + eq + ') > .tekstbg').css("margin-top",verschil+"px");
	$('#tabs_content > div.tab_content:eq(' + eq + ') > .tekstbg').css("height",height1+"px");
}

function OnLoad() {
	
	
	jQuery.fn.hover = function(attr) {
		var el = $(this);
		var old_attr = {};
		$.each(attr, function(i) {
			old_attr[i] = el.css(i);
		});
		
		el.mouseenter(function() {
			$(this).css(attr);
		}).mouseleave(function() {
			$(this).css(old_attr);
		});
		
	}
	/* external links */
	$('a.ext').attr('target', '_blank');

	
	
	
	var selected_tab = url_helper.get('tab') || 0;
	$('#tabs_content > div.tab_content').hide();
	$('#tabs_content > div.tab_content:eq(' + selected_tab + ')').show();
	$('#meniu_c ul li a[rel=' + selected_tab + ']').addClass('active');
	
	$('#meniu_c a[rel]').click(function() {
		
		switch_tab($(this).attr('rel'));
		return false;
	});
	switch_tab(selected_tab);
	checkselectie();
	
	
}

