var prev_bundle_id = '';
var prev_article = 0;
var prev_hitfeit;
var prev_bio;
var popup_openTimer;
var popup_closeTimer;
var MyYear;
var MyMonth;
var MyWeek;

String.prototype.capitalize = function(){
    return this.replace(/\w+/g, function(a){
        return a.charAt(0).toUpperCase() + a.slice(1).toLowerCase();
    });
};

function _setGlobals(year, month, week){
	MyYear	= year;
	MyMonth	= month;
	MyWeek	= week;
	if(month == "0"){
		MyMonth = getMonthForWeek(week);
	}
	//return true;
}

function getMonthForWeek(weekNo){
		var d1 = new Date();
		numOfdaysPastSinceLastMonday = eval(d1.getDay()- 1);
		d1.setDate(d1.getDate() - numOfdaysPastSinceLastMonday);
		var weekNoToday = getWeekNr(d1.getFullYear(),d1.getMonth(),d1.getDay());
		var weeksInTheFuture = eval( weekNo - weekNoToday );
		d1.setDate(d1.getDate() + eval( 7 * weeksInTheFuture ));
		return d1.getMonth()+1;
};

function ringtone_hover(rtid){
	document.getElementById("rti"+rtid).style.borderColor='#ff0000';
	document.getElementById("rt"+rtid).style.display='';

}
function ringtone_out(rtid){
	document.getElementById("rti"+rtid).style.borderColor='#cacaca';
	document.getElementById("rt"+rtid).style.display='none';
}
function download_hover(rtid){
	document.getElementById("dli"+rtid).style.borderColor='#ff0000';
	document.getElementById("dl"+rtid).style.display='';
}
function download_out(rtid){
	document.getElementById("dli"+rtid).style.borderColor='#cacaca';
	document.getElementById("dl"+rtid).style.display='none';
}
function bgOver(id){
	document.getElementById(id).style.backgroundImage='url(images/sn_article_hover.png)';
}
function bgOut(id){
	document.getElementById(id).style.backgroundImage='url(images/sn_article.png)';
}

// ----------------------- POPUP SCRIPT -----------------------------
function chart_row_over(idstr)
{
	var obj = document.getElementById(idstr);

	chart_row_highlight(idstr);
	chart_call_popup(idstr);
}
function chart_row_out(idstr)
{
	var obj = document.getElementById(idstr);

	chart_row_unhighlight(idstr);
}

function chart_row_highlight(idstr)
{
	var obj = document.getElementById(idstr);
	
	var cells = obj.getElementsByTagName("td");
	cells[3].style.backgroundImage='url(images/top40_chart_over.jpg)';
	cells[3].style.backgroundPosition='right';
	cells[3].style.backgroundRepeat='repeat-y';
	cells[3].style.backgroundColor='#ff0103';
	cells[2].style.backgroundColor='#ff0103';
	cells[1].style.backgroundColor='#ff0103';
	
	if (cells[0].className.indexOf("_hover") < 0)
		cells[0].className = cells[0].className+"_hover";
	
	cells[0].style.backgroundColor='#ff0103';
}

function chart_row_unhighlight(idstr)
{
	var obj = document.getElementById(idstr);

	var cells = obj.getElementsByTagName("td");
	for(i=1; i<cells.length; i++)
	{
		cells[i].style.backgroundImage='';
		cells[i].style.backgroundColor='';
	}
	
	if (cells[0].className.indexOf("_hover") > 0)
		cells[0].className = cells[0].className.replace("_hover", "");
	
	cells[0].style.backgroundColor='';
}

// Renders and shows popup
function chart_call_popup(idstr) 
{
	// Clear previous operations
	clearTimeout(popup_openTimer);

	var obj = document.getElementById(idstr);

	popup_openTimer = window.setTimeout("chart_show_popup('"+idstr+"');", 300);
}

// Shows popup
function chart_show_popup(idstr)
{
	var obj = document.getElementById(idstr);
	var ol	= document.getElementById('popupLayer');

	// If popup is already rendered, do not render again
	if (ol.getAttribute("curidstr") == null || ol.getAttribute("curidstr") != idstr)
	{
		// Set curidstr so it wont be rendered if not needed
		ol.setAttribute("curidstr", idstr);
		
		var data_div_name = "popup-border-background";
		var data_div = document.getElementById(data_div_name);
		
		// Unmask old row
		var chart_row = ol.getAttribute("linked_chart_row");
		
		if (chart_row != null && chart_row.length > 0 && chart_row != idstr)
			chart_row_unhighlight(chart_row);
		
		// Link the row object to the popup
		ol.setAttribute("linked_chart_row", idstr);
		
		// Highlight the current row
		chart_row_highlight(idstr);
		
		// URL for data for bubble
		var url;
		if(obj.getAttribute("titel_id") == null)
		{
			url	= "data$get.aspx?week="+obj.getAttribute("week")+"&jaar="+obj.getAttribute("jaar")+"&pos="+obj.getAttribute("pos")+"&type="+obj.getAttribute("type");
		} 
		else 
		{
			url	= "data$get.aspx?track_id="+obj.getAttribute("titel_id");
		}
		
		// Render the feed
		showFeed(url, "xsl/bubble.xsl", data_div_name);

		// Set the right position
		var pos = findPos(obj);
		var pX = pos[0]+19;
		var pY = pos[1]-190;
		
		if(obj.getAttribute("direction") == "down"){
				pY = pY+220;
		}

		ol.style.top = pY + "px";
		ol.style.left = pX + "px";	
		
		// Show the popup	
		ol.style.display='';
	}
	chart_popup_suspend_close();
}

// Mouseover on popup itself
function chart_popup_over(obj)
{
	var chart_row = obj.getAttribute("linked_chart_row");
	chart_row_highlight(chart_row);
	chart_popup_suspend_close();
}

// Mouseout on popup itself
function chart_popup_out(obj)
{
	chart_popup_suspend_close();
}

// Suspended close
function chart_popup_suspend_close()
{
	clearTimeout(popup_closeTimer);
	popup_closeTimer = setTimeout("chart_row_hide_popup();",2000);
}

// Close 
function chart_row_hide_popup() {
	var ol	= document.getElementById('popupLayer');
	ol.style.display='none';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
// ------------------------------------------------------------------

function _update_player(bundle_id, sequence_nr, sTitle)
{
	var songurl = "http://download.aim4music.com/shopsupport/download_process/track$prelisten.aspx?media_partner_id=74&bundle_id="+bundle_id+"&sequence_nr="+sequence_nr+"&format=mp3";
	var coverurl = "http://www.top40.nl/artwork.aspx?media_partner_id=74&bundle_id="+bundle_id+"&height=130&width=130";
	
	window.document.flashobject.SetVariable("title", sTitle);
	window.document.flashobject.SetVariable("songurl", songurl);
	window.document.flashobject.SetVariable("cover", coverurl);
}

function _update_timemachine(varName, varValue)
{
	window.document.top40timemachine_sjv_006.SetVariable(varName, varValue);
}

function _setAlarmschijf(cover, artistTxt, songTxt, link){
	var dummy = Math.random();

	var so = new SWFObject("AlarmSchijf.swf", "alarmschijf", "144", "158", "8", "#ffffff");
	so.addVariable("cover", escape(cover));
	so.addVariable("artist", artistTxt.capitalize());
	so.addVariable("title", songTxt.capitalize());
	so.addVariable("link", escape(link));
	so.addParam("wmode", "opaque");

	so.write("alarmschijf");
}

function _setSliderchijf(xmlPath, elmnt){
	var dummy = Math.random();

	var so = new SWFObject("top40_ringtones_sjv_001.swf", elmnt+"swf", "288", "165", "8", "#ffffff");
	so.addVariable("xmlPath", escape(xmlPath));
	so.addParam("wmode", "opaque");
	so.write(elmnt);
}
function _ringtoneSliderInactive(status){
	if(window.document["ringtoneSliderswf"]) window.document["ringtoneSliderswf"].SetVariable("inActive", status);
	else if(document.ringtoneSliderswf) document.ringtoneSliderswf.SetVariable("inActive", status);
	else if(window.document.ringtoneSliderswf) window.document.ringtoneSliderswf.SetVariable("inActive", status);
}
function _downloadSliderInactive(status){
	if(window.document["downloadSliderswf"]) window.document["downloadSliderswf"].SetVariable("inActive", status);
	else if(document.downloadSliderswf) document.downloadSliderswf.SetVariable("inActive", status);
	else if(window.document.downloadSliderswf) window.document.downloadSliderswf.SetVariable("inActive", status);
}

function toggleDiv(ID) {

	if (document.getElementById(ID).style.display == "") {
		document.getElementById(ID).style.display = "none";
	} else {
		document.getElementById(ID).style.display = "";
	}
}

function toggleTrackInfo(ID, num){
	for(i=1; i<num; i++){
		if(document.getElementById(i).style.display == ""){
			document.getElementById(i).style.display = "none";
		}
		
	}
	document.getElementById(ID).style.display = "";
}

function toggle_article(ID) {
	if(prev_article == null){
		prev_article = 0;
	}
	
	if(prev_article != "0"){
		document.getElementById("article"+prev_article).style.display = "";
		document.getElementById("sn"+prev_article).style.display = "none";
	}
	document.getElementById("article"+ID).style.display = "none";
	document.getElementById("sn"+ID).style.display = "";
	
	prev_article = ID;
}
function toggle_hitfeit(ID) {
	if(prev_hitfeit == null){
		prev_hitfeit = 0;
	}
	
	if(prev_hitfeit != "0"){
		document.getElementById("hfarticle"+prev_article).style.display = "";
		document.getElementById("hf"+prev_article).style.display = "none";
	}
	document.getElementById("hfarticle"+ID).style.display = "none";
	document.getElementById("hf"+ID).style.display = "";
	
	prev_hitfeit = ID;
}
function toggle_bio(ID) {
	if(prev_bio == null){
		prev_bio = 0;
	}
	
	if(prev_bio != "0"){
		document.getElementById("bioarticle"+prev_article).style.display = "";
		document.getElementById("bio"+prev_article).style.display = "none";
	}
	document.getElementById("bioarticle"+ID).style.display = "none";
	document.getElementById("bio"+ID).style.display = "";
	
	prev_bio = ID;
}

function _new_rating(bundle_id, sequence_nr, rating)
{
	var image = new Image();
	image.src = "http://catalog.aim4music.com/catalog_rating$insert.dbxml?media_partner_id=74&amp;bundle_id="+bundle_id+"&amp;sequence_nr="+sequence_nr+"&amp;rating="+rating
	
	alert('Je stem is opgeslagen. Het kan even duren voordat je stem wordt verwerkt');
}
function createIframe(sUrl)
{
	// Remove old frame if exists
	var oldframe = document.getElementById("tempframe");
	if (oldframe != null)
		oldframe.removeNode(true);

	// Create new frame
	var nframe = document.createElement("iframe");
	
	nframe.id = "tempframe";
	nframe.src = sUrl;
	nframe.frameBorder = '0';
	nframe.border = '0';
	nframe.style.border = '1px dotted black'
	nframe.style.width = '80px';
	nframe.style.height = '42px';
	nframe.scrolling = 'no';

	var ospan = document.getElementById('playercontainer');

	ospan.appendChild(nframe);
}
function getResponseXml(xmlUrl) {
	var xmlHttp;
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion<=6) {
			xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
		}
		else {
			xmlHttp = new XMLHttpRequest();
		}
	} else {
		xmlHttp = new XMLHttpRequest();
	}
	if(typeof xmlHttp != "undefined"){
		xmlHttp.open("GET", xmlUrl, false);
		var browser=navigator.appName
		if(browser != "Microsoft Internet Explorer"){
			xmlHttp.overrideMimeType('text/xml');
		}
		xmlHttp.send(null);
		return xmlHttp;	
		
	} else {
		
		alert("browser not supportted");
	}
	
}

function showFeed(xmlUrl, xslUrl, fid) {
	var feed = document.getElementById(fid);

	feed.innerHTML = "";

	if(!document.all){
		feed.appendChild(getHtmlFragment(xmlUrl, xslUrl));
	} else {
		feed.innerHTML = getHtmlFragment(xmlUrl, xslUrl);
	}
	
	feed.style.display = '';
}

function getHtmlFragment(xmlUrl, xslUrl) {
	var xmlSource 	= getResponseXml(xmlUrl).responseXML;

	if (typeof XSLTProcessor != "undefined") {   

		var xsltProcessor = new XSLTProcessor(); 
		var xslStylesheet = getResponseXml(xslUrl).responseXML;
		xsltProcessor.importStylesheet(xslStylesheet);
		var fragment = xsltProcessor.transformToFragment(xmlSource,document);
		return(fragment);
		
	} else {
	
		var source = new ActiveXObject("Msxml2.DOMDocument.3.0");
		source.async = false;
		source.load(xmlUrl);
		if (source.parseError.errorCode != 0) {
			var myErr = source.parseError;
			alert("there is an error: " + myErr.reason);
		} else {
			var stylesheet = new ActiveXObject("Msxml2.DOMDocument.3.0");
			stylesheet.async = false
			stylesheet.load(xslUrl);
			if (stylesheet.parseError.errorCode != 0) {
			    var myErr = stylesheet.parseError;
			    alert("You have error " + myErr.reason);
			} else {
			    return source.transformNode(stylesheet);
			}
		}
		
	}

}

function clearDefValue(ref)
{
	if(ref.value == "selecteer datum"){
		ref.value ="";
	}
	else if(ref.value == "Type hier uw zoekterm..."){
		ref.value ="";
	}
	
	if(ref.name == "keyword"){
		document.getElementById("week").value="";
		document.getElementById("jaar").value="";
		document.getElementById("date").value="selecteer datum";
	}
	
}
var naam= 22;
var waar=99;

var button = "dnav-";

function picture_over (welk) {

tmp = welk.id
	if (naam!=welk.id && tmp.toString().indexOf(button.toLowerCase())<0) {
		welk.src="images/"+welk.id+"-aan.jpg";
	}
}

function picture_uit (welk) {


tmp = welk.id

	if (naam!=welk.target && tmp.toString().indexOf(button.toLowerCase())<0) {
	welk.src="images/"+welk.id+"-uit.jpg";
	}
}

function getContent(){

	alert("getContent");

}

function rollover(elmnt) {
	elmnt.setAttribute("id", "searchResultItem_aan");
}

function rollout(elmnt) {
	elmnt.setAttribute("id", "searchResultItem_uit");
}
function expand() {
	var elmnt = document.getElementById("searchExpander");
	elmnt.style.display='';
}
function collapse() {
	var elmnt = document.getElementById("searchExpander");
	elmnt.style.display='none';
}

function getWeekNr(y,m,d)
{
	var today = new Date();
	today.setYear(y);
	today.setMonth(m);
	today.setDate(d);
	Year = takeYear(today);
	Month = today.getMonth();
	Day = today.getDate();
	now = Date.UTC(Year,Month,Day+1,0,0,0);
	var Firstday = new Date();
	Firstday.setYear(Year);
	Firstday.setMonth(0);
	Firstday.setDate(1);
	then = Date.UTC(Year,0,1,0,0,0);
	var Compensation = Firstday.getDay();
	if (Compensation > 3) Compensation -= 4;
	else Compensation += 3;
	NumberOfWeek =  Math.round((((now-then)/86400000)+Compensation)/7);
	return NumberOfWeek;
}

function getWeek(year,month,day){
    //lets calc weeknumber the cruel and hard way :D

    month += 1; //use 1-12

    var a = Math.floor((14-(month))/12);
    var y = year+4800-a;
    var m = (month)+(12*a)-3;
    var jd = day + Math.floor(((153*m)+2)/5) + 
                 (365*y) + Math.floor(y/4) - Math.floor(y/100) + 
                 Math.floor(y/400) - 32045;      // (gregorian calendar)

    //var jd = (day+1)+Math.Round(((153*m)+2)/5)+(365+y) + 

    //                 Math.round(y/4)-32083;    // (julian calendar)

    
    //now calc weeknumber according to JD

    var d4 = (jd+31741-(jd%7))%146097%36524%1461;
    var L = Math.floor(d4/1460);
    var d1 = ((d4-L)%365)+L;
    NumberOfWeek = Math.floor(d1/7) + 1;
    return NumberOfWeek;        
}


function takeYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

function setHome()
{
	if(document.all){
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(window.location.href);
	} else {
		alert("Sleep het pagina icoon naar je Home knop om deze website als je home page in te stellen.");
	}
}
function addfav()
{
	if (document.all)
	{
	window.external.AddFavorite(window.location.href,"Top 40")
	} else {
		alert("Om deze website aan uw Favorieten toe te voegen dient u de toetsencombinatie: Ctrl + D te gebruiken.");
	}
}
function getList(jaar,maand){
	var maandNum;
	var myMonths = new Array( "Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
	var shortMonts = new Array("jan", "feb", "maa", "apr", "mei", "jun", "jul", "aug", "sep", "okt", "nov", "dec");
	for (key in shortMonts){
		if(shortMonts[key] == maand){
			maandNum = key-1+2;
			break;
		}
	}
	document.location.href="index.aspx?maand="+maandNum+"&jaar="+jaar+"&type=maand";

}
function _showChart(jaar, week){
	document.location.href="index.aspx?week="+week+"&jaar="+jaar;
}

function _search(){
	var xmlUrl;
	var xslUrl;
	var fid		= "container";
	if(document.getElementById("keyword").value == "Type hier uw zoekterm..."){
		document.getElementById("keyword").value = "";
	}
	if(document.getElementById("date").value == "selecteer datum"){
		document.getElementById("date").value = "";
	}
	
	if(document.getElementById("date").value != "" && document.getElementById("week").value != "" && document.getElementById("jaar").value != "" && document.getElementById("maand").value != ""){
		document.location.href="index.aspx?week="+document.getElementById("week").value+"&jaar="+document.getElementById("jaar").value+"&maand="+document.getElementById("maand").value;
	} else {
		document.location.href="search.aspx?keyword="+document.getElementById("keyword").value+"&jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
	}
}

function _tipParadeShow(year, maand, week){
	document.location.href="tipparade.aspx?week="+week+"&jaar="+year+"&maand="+maand+"&type=week";
}
function _specialShow(){
	document.location.href="special.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
}

function _bundleShow(bundle_id, tid){
	document.location.href="bundle.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&bundle_id="+bundle_id+"&tid="+tid;
}
function _bundlePlay(bundle_id, tid){
	document.location.href="bundle.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&bundle_id="+bundle_id+"&tid="+tid+"&prelisten=1";
}
function _fullBundleShow(bundle_id){
	document.location.href="bundle.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&bundle_id="+bundle_id;
}

function _artistPageShow(artist_id){
	document.location.href="artist.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&artiest_id="+artist_id;
}

function _newsShow(id){
	document.location.href="nieuws.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&artikel_id="+id;
}

function _trackShow(titel_id){
	document.location.href="track.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&titel_id="+titel_id;
}
function _artistsShow(l){
	if(!l){
		l = "a";
	}
	document.location.href="artists.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&l="+l;
}
function _artistShow(elmnt){
	var l;
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	if(!isIE){
		l = elmnt.textContent;
	} else {
		l = elmnt.innerText;
	}
	if(l == "#"){
		l = 35;
	}
	document.location.href="artists.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&l="+l;
}

function _check_email_value()
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test($("#email_adres").val()))
		return false;
	
	return true;
}

function submitNieuwsbrief()
{
	if (_check_email_value())
	{
		alert("Je hebt geen geldig e-mail adres ingevuld. Voer een geldig e-mail adres in.");
		$("#email_adres").focus();
		return false;
	}

	$.post("nieuwsbrief.aspx?action=new", { email_adres: $("#email_adres").val(), active: "1", todo: "sub" }, function(data){
		var responseTxt = "";
		if(data == "inschrijving succesvol"){
			responseTxt = "Bedankt voor je inschrijving op onze nieuwsbrief. Je ontvangt nu een e-mail om je inschrijving voor de nieuwsbrief te bevestigen.";
		} else {
			responseTxt = "Inschrijving mislukt";
		}
		$("#nieuwsbrief").html(responseTxt);
	});
}

function unsubscribeNieuwsbrief()
{
	if (_check_email_value())
	{
		alert("Je hebt geen geldig e-mail adres ingevuld. Voer een geldig e-mail adres in.");
		$("#email_adres").focus();
		return false;
	}
	$.post("nieuwsbrief.aspx?action=new", { email_adres: $("#email_adres").val(), active: "0", todo: "unsub" }, function(data){
		var responseTxt = "";
		if(data.toLowerCase().indexOf("succesvol")){
			responseTxt = "Je uitschrijving voor de Nederlandse Top 40 nieuwsbrief is ontvangen.<br /> Je ontvangt nu een e-mail waarmee je de uitschrijving kunt bevestigen.<br/> Na je bevestiging ontvang je dan ook niet meer de nieuwsbrief. Mocht je in de toekomst wel weer de Nederlandse Top 40 nieuwsbrief willen ontvangen, dan kan dat natuurlijk door je gewoon weer in te schrijven!";
		} 
		$("#nieuwsbrief").html(responseTxt);
	});
}

function _top40Show(year, maand, week){
	document.location.href="index.aspx?week="+week+"&jaar="+year+"&maand="+maand+"&type=week";
}
function _tb_ringtone_show(caption, id) {
	var url = "ringtone.aspx?bundle_id="+id+"&keepThis=true&TB_iframe=true&width=450&height=360";
	tb_show(caption, url, null);
}
function _tb_artist_show(caption, id) {
	var url = "artist.aspx?artiest_id="+id+"&jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
	document.location.href=url;
}
function _tb_chart_show(caption, id) {
	var url = "chart.aspx?titel_id="+id+"&jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
	//document.location.href=url;
	tb_show(caption.capitalize(), url, null);
}
function _tb_soon(caption) {
	var url = "soon.aspx?keepThis=true&TB_iframe=true&width=450&height=360";
	tb_show(caption, url, null);
}
function _tb_games() {
	_tb_soon('games');
}
function _tb_hitdossier() {
	var url = "hitdossier_update.aspx?keepThis=true&TB_iframe=true&width=450&height=400";
	caption = "Bestel alvast de Top 40 Hitdossier cd-rom update";
	tb_show(caption, url, null);
}
function _tb_shop() {
	var url = "shop.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
	document.location.href = url;
}
function _tb_cart_show(caption) {
	var url = "cart.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek+"&keepThis=true&TB_iframe=true&width=495&height=400";
	tb_show(caption, url, null);
}
function _helpdeskShow() {
	document.location.href="helpdesk.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
}
function _faqShow() {
	document.location.href="faq.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
}
function _disclaimerShow() {
	document.location.href="disclaimer.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
}
function _avShow() {
	document.location.href="av.aspx?jaar="+MyYear+"&maand="+MyMonth+"&week="+MyWeek;
}
function getFlashMovie(movieName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}
function _check_form()
{
	var form = document.getElementById("helpdesk");
	var errorMsg = "";

	var reg = new RegExp("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$","ig");
	
	if (form.naam.value=="")
	{
		errorMsg += "\n\t Naam ontvanger \t\t - Vul het verplichte veld in";
	}
	if (reg.exec(form.email_address.value)==null || form.email_address.value=="")
	{
		errorMsg += "\n\t E-mail adres ontvanger \t - Vul het verplichte veld in";
	}
	
	reg = new RegExp("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$","ig");
	if (reg.exec(form.email_address.value)==null || form.email_address.value=="")
	{
		errorMsg += "\n\t Jouw email adres \t\t - Vul het verplichte veld in";
	}
	
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Het versturen van het formulier leverde een probleem op.\n";
		msg += "Controleer of je alle velden correct hebt ingevuld.\n";
		msg += "______________________________________________________________\n\n";
		msg += "Onderstaande velden leverder een probleem op: -\n";

		errorMsg += alert(msg + errorMsg + "\n\t\t\t");
	}
	if (errorMsg != "") 
	{ 
		return ; 
	}
	document.body.onbeforeunload = "";

	form.submit();			
}

function _check_form_question()
{
	var form = document.getElementById("question")
	var errorMsg = "";

	
	var reg = new RegExp("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$","ig");
	
	if (form.naam.value=="")
	{
		errorMsg += "\n\t Naam ontvanger \t\t - Vul het verplichte veld in";
	}
	if (reg.exec(form.email_address.value)==null || form.email_address.value=="")
	{
		errorMsg += "\n\t E-mail adres ontvanger \t - Vul het verplichte veld in";
	}
	
	reg = new RegExp("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$","ig");
	if (reg.exec(form.email_address.value)==null || form.email_address.value=="")
	{
		errorMsg += "\n\t Jouw email adres \t\t - Vul het verplichte veld in";
	}
	
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Het versturen van het formulier leverde een probleem op.\n";
		msg += "Controleer of je alle velden correct hebt ingevuld.\n";
		msg += "______________________________________________________________\n\n";
		msg += "Onderstaande velden leverder een probleem op: -\n";

		errorMsg += alert(msg + errorMsg + "\n\t\t\t");
	}
	if (errorMsg != "") 
	{ 
		return ; 
	}
	document.body.onbeforeunload = "";

	form.submit();			
}

function toggleMenu(ID) {
	if (ID == "genrelist"){
		document.getElementById(ID).style.display = "none";
		document.getElementById("alfabetlist").style.display = "";
	} 
	if (ID == "alfabetlist"){
		document.getElementById(ID).style.display = "none";
		document.getElementById("genrelist").style.display = "";
	}
}

/* TIME MACHINE FUNCTION */
function _setTimeMachine(){
	var dummy = Math.random();

	var so = new SWFObject("top40timemachine_sjv_006.swf", "mymovie", "692", "160", "8", "#000000");
	so.addVariable("whichYear", MyYear);
	so.addVariable("whichMonth", MyMonth);
	so.addVariable("whichWeek", MyWeek);
	so.addVariable("domain", "http://"+document.domain);
	so.addParam("wmode", "opaque");

	so.write("timemachine");
}

function _getTMYears(){
	var url = "timemachine_data$get.aspx";
	var result = getResponseXml(url).responseText;
	return result;
}
function _getTMMonths(year){
	var url = "timemachine_data$get.aspx?year="+year;
	var result = getResponseXml(url).responseText;
	return result;
}
function _getTMWeeks(year, month){
	
	var url = "timemachine_data$get.aspx?year="+year+"&month="+month;
	var result = getResponseXml(url).responseText;
	return result;
}


