var d=new Date();
dag = (d.getDay());
maand = (d.getMonth());
jaar = (d.getYear());
var today = dag+"-"+maand+"-"+jaar;

function swap(file,txt){  
	plaatje = new Image()
	plaatje.src = file;
    document.images.fotoGroot.src = plaatje.src;
	document.getElementById('bijschrift').innerHTML = txt;
}

function thumbWidth(count){
	breedte = 127 * count;
	document.getElementById('thumbsInside').style.width = breedte + "px";
}

function isValdid() {

check = 1;
var formArray = new Array();
formArray[0] = "name";
formArray[1] = "email";


	for(i=0;i<formArray.length;i++){
	itemid = formArray[i];
		if(document.formulier[itemid].value.length == 0){
			document.getElementById(itemid).style.border = "2px solid #E3001B";
			check = 0;
		}
		else{
			document.getElementById(itemid).style.border = "1px solid #4D4B61";
		}
	}

if(check==1){
	document.formulier.submit();
}
}

function mailLink(adres,subject){
	domein = "carchannel.tv";
	mailadres = adres + "@" + domein;
	document.write('<a href="mailto:' + mailadres + '?subject=' + subject + '">' + mailadres + '</a>');
}

function carUpdate(){
	//prevent caching
	var datum = new Date();
	dag = datum.getDate();
	jaar = datum.getFullYear();
	maand = datum.getMonth();
	today = dag+'-'+maand+'-'+jaar;
	document.write('<a href="http://www.carchannel.tv/media/carupdate/Car%20Update.mpg?'+today+'" target="_blank">Bekijk de laatste Car Update <strong>hier!!!</strong></a><br /><br />');
}

function firstVisitToday(){
	cookieRes = readCookie('carupdate');
	if(cookieRes==null){
		writeCarUpdate('true');
	}
	else if(today==cookieRes){
		writeCarUpdate('false');		
	}
	else{
		writeCarUpdate('true');	
	}
}

function firstVisitTodayNew(){
	cookieRes = readCookie('carupdate');
	if(cookieRes==null){
		writeCarUpdateNew('true');
	}
	else if(today==cookieRes){
		writeCarUpdateNew('false');		
	}
	else{
		writeCarUpdateNew('true');	
	}
}

function writeCarUpdate(status) {
	createCookie('carupdate',today,1);
	var FO = { movie:"http://www.carchannel.nl/player/flvplayer.swf", width:"344", height:"189", id:"mediaplayer",name:"mediaplayer",majorversion:"8",build:"0",bgcolor:"#FFF", wmode:"opaque", flashvars:"&displayheight=189&file=http://www.carchannel.tv/media/carupdate/Car%20Update.flv&height=189&image=http://www.carchannel.tv/player/preview.jpg&width=344&frontcolor=0x022346&backcolor=0xe6f3f9&lightcolor=0xcde6f0&usefullscreen=false&autostart="+status };
UFO.create(FO, "videoCarUpdate");
}

function writeCarUpdateNew(status) {
	createCookie('carupdate',today,1);
	var FO = { movie:"http://www.carchannel.nl/player/flvplayer.swf", width:"468", height:"256", id:"mediaplayer",name:"mediaplayer",majorversion:"8",build:"0",bgcolor:"#FFF", wmode:"opaque", flashvars:"&displayheight=256&file=http://www.carchannel.tv/media/carupdate/Car%20Update.flv&height=256&image=http://www.carchannel.tv/player/preview.jpg&width=468&frontcolor=0x022346&backcolor=0xe6f3f9&lightcolor=0xcde6f0&usefullscreen=false&autostart="+status };
UFO.create(FO, "videoCarUpdate");
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}