var sponsorCountTotal = 1;
var sponsorCount = 1;
var klikOpAutoLink = '';
function laadFuncties(sponsor,foto)
{
	sponsorAuto();
	fotoBanner(1);
	sponsorBanner(0,sponsor);
	fotoBanner2(0,foto);
	sponsorCountTotal = sponsor;
}
function sponsorAuto()
{
	sponsorAutoTekst();
	$("#autoSponsorNavText").css( { marginLeft : "70px" } );
	$("#autoSponsorNav").css( { marginLeft : "1102px", "background-image" : "url(assets/images/auto-marcel-dekker-racing.png)" } );
	$("#autoSponsorNav").animate( { marginLeft : "-301px" }, 18000 );
	setTimeout("sponsorAutoTerug()", 18000);
}
function sponsorAutoTerug()
{
	sponsorAutoTekst();
	$("#autoSponsorNavText").css( { marginLeft : "45px" } );
	$("#autoSponsorNav").css( { marginLeft : "-201px", "background-image" : "url(assets/images/auto-marcel-dekker-racing2.png)" } );
	$("#autoSponsorNav").animate( { marginLeft : "1102px" }, 18000 );
	setTimeout("sponsorAuto()", 18000);
}
function sponsorAutoKlik()
{
	if( klikOpAutoLink != '' )
	{
		window.open(klikOpAutoLink);
	}
}
function sponsorAutoTekst()
{
	if( sponsorCount > sponsorCountTotal )
	{
		sponsorCount = 1;
	}
	
	if( sponsorLinkArray[sponsorCount] != '' )
	{
		$("#autoSponsorNav").css( { cursor : "pointer" } );
		klikOpAutoLink = sponsorLinkArray[sponsorCount];
		sponsorLink = sponsorNameArray[sponsorCount];
	}
	else
	{
		$("#autoSponsorNav").css( { cursor : "auto" } );
		klikOpAutoLink = '';
		sponsorLink = sponsorNameArray[sponsorCount];
	}
	
	document.getElementById("autoSponsorNavText").innerHTML = sponsorLink;
	sponsorCount++;
}

function menu(status,id)
{
	if( status == 'over' )
	{
		$(".menuActive").css( { "background-image" : "none" } );
		$(".menu").css( { "background-image" : "none" } );
		$("#menu-"+id).css( { "background-image" : "url(assets/images/bg-menu-active.png)" } );
	}
	else
	{
		$(".menuActive").css( { "background-image" : "url(assets/images/bg-menu-active.png)" } );
		$(".menu").css( { "background-image" : "none" } );
	}
}

function fotoBanner(nummer)
{
	Max = 6;
	vorige = nummer - 1;
	if( nummer > Max ) { nummer = 1; vorige = Max }
	$("#bannerImg-"+vorige).animate( { opacity : "0.0" }, 1000 );
	$("#bannerImg-"+nummer).animate( { opacity : "1.0" }, 1000 );
	nummer++;
	setTimeout("fotoBanner("+nummer+")", 9000);
}

function sponsorBanner(nummer, Max)
{
	if( nummer > (Max-1) ) { nummer = 0 }
	positie = nummer * 211;
	$("#sponsorFrameHolder").animate( { marginLeft : "-"+positie+"px" }, 1000 );
	nummer++;
	setTimeout("sponsorBanner("+nummer+","+Max+")", 4500);
}
function fotoBanner2(nummer, Max)
{
	if( nummer > (Max-1) ) { nummer = 0 }
	positie = nummer * 214;
	$("#fotoFrameHolder").animate( { marginLeft : "-"+positie+"px" }, 1000 );
	nummer++;
	setTimeout("fotoBanner2("+nummer+","+Max+")", 2000);
}

function randomString(length) {
  var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
  var str = '';
  for (var i = 0; i < length; i++) {
	str += chars[Math.floor(Math.random() * chars.length)];
  }
  return str;
}
var rnd = randomString(8);

function loadTwitter() {
  $(".tweet").tweet({
	join_text: "auto",
	username: "dekkerRacing",
	count: 3,
	auto_join_text_default: "", 
	auto_join_text_ed: "we",
	auto_join_text_ing: "waren we",
	auto_join_text_reply: "antwoorden we",
	auto_join_text_url: "bekeken we",
	loading_text: "tweets laden..."
  });
}

function switchFoto(foto,id)
{
	$(".thumbFoto").animate( { opacity : "0.5" }, 1 );
	$(".thumbFoto#thumbFoto-"+id).animate( { opacity : "1.0" }, 1 );
	
	setTimeout("document.getElementById('grotoFotoImg').src = '"+foto+"'", 1);
}

function sendBericht()
{
	if( document.getElementById("naam").value != "" && document.getElementById("naam").value != "Naam" && document.getElementById("bericht").value != "" && document.getElementById("bericht").value != "Bericht" )
	{
		$("#gastenboekDiv").animate( { height: "0px" },400 );
		setTimeout('document.getElementById("gastenboekForm").submit()',400);
	}
	else
	{
		$("#gastenboekDiv").animate( { marginLeft: "0px" },50 );
		$("#gastenboekDiv").animate( { marginLeft: "-5px" },50 );
		$("#gastenboekDiv").animate( { marginLeft: "0px" },50 );
		$("#gastenboekDiv").animate( { marginLeft: "-5px" },50 );
	}
}

function sendContact()
{
	if( document.getElementById("contactpersoon").value != "" && document.getElementById("contactpersoon").value != "Contactpersoon" && document.getElementById("email").value != "" && document.getElementById("email").value != "E-mail"
	 && document.getElementById("onderwerp").value != "" && document.getElementById("onderwerp").value != "Onderwerp" && document.getElementById("bericht").value != "" && document.getElementById("bericht").value != "Bericht" )
	{
		$("#contactDiv").animate( { height: "0px" },400 );
		setTimeout('document.getElementById("contactForm").submit()',400);
	}
	else
	{
		$("#contactDiv").animate( { marginLeft: "5px" },50 );
		$("#contactDiv").animate( { marginLeft: "0px" },50 );
		$("#contactDiv").animate( { marginLeft: "5px" },50 );
		$("#contactDiv").animate( { marginLeft: "0px" },50 );
	}
}
