href = "";
$(document).ready(function(){
	//odds
	$.ajax({
	  url: "/templates/tippspiel/odds.php",
	});
	if(!$.browser.msie){
		$(document).bind('submit',function(e){
			submitForm(e);
			return;
		});
		
		$(document).bind('click',function(e){
			if(e.button != 0)
				return;
			var target = $(e.target);
			if(target.val() == 'Login' || target.attr('noajax') == 'true'){
				return;
			}
			if (target.attr('nodeName')!=='A'){
				target = target.parent('a');
			}
			if(target.attr('noajax') == 'true'){
				return;
			}
			if(target.attr("onclick") != undefined){
			
				e.preventDefault();
				return;
			}
			href = target.attr("href");
			if(href.match(/^http.*/))
				return;
			if(href != undefined){
				e.preventDefault();
				$.ajax({
				  url: href,
				  success: sucess
				});
			}
		});
	}

});

function submitForm(e){
            var jQueryform = $(e.target);
			if(jQueryform.attr('action').match(/nutbb.*/)){
				return;
			}
			e.preventDefault();
            if (jQueryform.length && jQueryform.attr('action')) {
				href = jQueryform.attr('action');
                $.ajax({
					url: href, 
                    data: jQueryform.serialize()+"&submit=3",
                    type: jQueryform.attr('method') || "POST",
                    success: sucess,
					cache: false
                });
            }
}

function sucess(data,status,xhdr){
	$('.nav').each(function(){
		var img = $($(this).find('img')[0]);
		if($(this).attr("href") == href){
			aktive_page = img.attr('id');
			img.attr('src','images/navi_new/'+img.attr('id')+'_active.png');
		}else
			img.attr('src',img.attr('src').replace(/_active/,''));
	});
	 var data = $(data);
	 var snip = data.attr('snipped');
	 $(window).trigger('load');
	 
	 if(snip != undefined){
		$('*[snipped='+snip+'] > *').fadeOut('fast',function(){
			$(this).remove();
			//extract js	
			data.each(function(){
				var node = $(this);
				if(node.attr('nodeName') == "SCRIPT"){
			
					if(node.attr("src") == undefined){
						
						eval(node.html());
					}else{
						var script = $(document.createElement("script"));
						script.attr("type","text/javascript");
						script.attr("language","javascript");
						script.attr('src',node.attr('src'));
						$('body').append(script.get(0));
					}
				}
			});
			data.find('*:first').css("display","none");
			$('*[snipped='+snip+']').append(data.find('*:first'));
			$('*[snipped='+snip+'] > *').fadeIn('fast');

			$(document).trigger('ready');
		});
	 }			
}

function openimagewindow(window_url,width_window,height_window)
{
	imgwindow = window.open(window_url,"a","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width="+width_window+",height="+height_window+",left=20,top=20");
}
function rollover(id,flag)
{
	if(document.getElementById(id))
	{

		if(id==aktive_page || id == '')
		{
			document.getElementById(aktive_page).src="images/navi_new/"+aktive_page+"_active.png";
		}else{

			if(flag)
			{
				document.getElementById(id).src="images/navi_new/"+id.replace(/[0-9]$/,'')+".png";
			}else{
				document.getElementById(id).src="images/navi_new/"+id.replace(/[0-9]$/,'')+"_over.png";
			}
		}
	}
}

function addtofavorites(){
	title = 'Burning Nuts FCA Fanclub';
	url = 'http://www.burning-nuts.de';
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}

function minimize(){
	
	if(document.getElementById('minitab').style.display == "none"){
		document.getElementById('minitab').style.display = "block";
	}else{
		document.getElementById('minitab').style.display = "none";
	}
}

function closeTable(){
		document.getElementById('table').style.display = "none";
}

function showLayer(){
	var hinweis = $('.hinweis');
	hinweis.css('display','inline-block');
	hinweis.css('left',($(window).width()/2-hinweis.width()/2)+'px');
	hinweis.css('top',($(window).height()/2-hinweis.height()/2)+'px');
	return false;
}
