// JavaScript Document
/*=====================================================*/
/* Surfmaatje functies en dergelijke, nu netjes in */
/* de templates verwerkt met grappige interactieve */
/* AJAX functionaliteiten etcetera */
/*=====================================================*/

function ws_Activator(tID,fID) {
	
	if(parseInt(tID) > 0 && parseInt(fID) > 0)
	{		
		if(fID == 20)
		{			
			document.getElementById('surfMaatje').innerHTML = '<div style=\"padding-bottom:5px;padding-left:1px;font-weight:bold;\">Schrijf je in voor surfmaatje zodat je surfmaatjes kunnen zien dat jij er ook bij bent!</div><div style=\"padding-bottom:3px;padding-left:24px;\"><img src=\"/styles/opperhoofd/custom/surfmaatje.gif\" border=\"0\" alt=\"\" align=\"absbottom\"><a onclick=\"aanMelden(' + tID + ')\" onmouseover=\"menu_over(this)\" onmouseout=\"menu_out(this)\" title=\"Klik hier om je aan te geven dat je deze surfdag er bij bent.\">Ik ben er ook bij</a>&nbsp;&nbsp;&nbsp;<img src=\"/styles/opperhoofd/custom/no_surfmaatje2.gif\" border=\"0\" alt=\"\" align=\"absbottom\"><font style=\"color:#92cae3;\">Ik meld me af</font></div>';
	
			wieAangemeld(tID);
		}
	} 
}

function wieAangemeld(tID) {

	if(parseInt(tID) > 0)
	{
		var reqUrl = "/windsurfing.php?dW=w&t=" + tID + "&rand=" + Math.round(Math.random()*987654321);
		var xmlhttp = false;

		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		 try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
		   xmlhttp = false;
		  }
		 }
		@end @*/

		if (!xmlhttp && typeof XMLHttpRequest!='undefined')
		{
			xmlhttp = new XMLHttpRequest();
		}
			
		xmlhttp.open("GET", reqUrl, true);
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState == 4)
			{
				eval(xmlhttp.responseText);

				if(document.getElementById('aanMeldingen'))
				{
					var divSM = document.getElementById('surfMaatje');
					var sMb = document.getElementById('aanMeldingen');
					var bOn = false;
					var bPast = false;

					sMb.innerHTML = "<div style=\"line-height:18px;padding-left:1px;\"><strong>Er zijn nog geen surfmaatjes.</strong></div>";
					
					if(alAanmeldingen)
					{
						var sSM = "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"77%\"><tr><td style=\"line-height:18px;padding-left:1px;\"><strong>" + alAanmeldingen[0] + "</strong></td></tr><tr><td style=\"line-height:18px;width:100%;padding-left:25px;\">";
						for(var i=1; i < alAanmeldingen.length; i++)
						{	
							var description = (alAanmeldingen[i][2]=='') ? alAanmeldingen[i][1] : '<font style=\"font-weight:bold;color:#' + alAanmeldingen[i][2] + '\">' + alAanmeldingen[i][1] + '</font>';						
							sSM += "<a href='./memberlist.php?mode=viewprofile&u=" + alAanmeldingen[i][0] + "'>" + description + "</a>";
							if (i<alAanmeldingen.length-1) sSM += ", ";		
							if (alAanmeldingen[i][3]=='true') bOn = true;	
						}						
						sSM += "</td></tr></table>";
						sMb.innerHTML = sSM;
						if (alAanmeldingen[0]=='Welke surfmaatjes zijn er allemaal geweest?') bPast = true;
					}
								
					if (divSM != null) 
					{
						if (bPast) divSM.innerHTML = '<div style=\"padding-bottom:5px;padding-left:1px;font-weight:bold;\">Schrijf je in voor surfmaatje zodat je surfmaatjes kunnen zien dat jij er ook bij bent!</div><div style=\"padding-bottom:3px;padding-left:24px;\"><img src=\"/styles/opperhoofd/custom/surfmaatje2.gif\" border=\"0\" alt=\"\" align=\"absbottom\"><font style=\"color:#92cae3;\">Ik ben er ook bij</font>&nbsp;&nbsp;&nbsp;<img src=\"/styles/opperhoofd/custom/no_surfmaatje2.gif\" border=\"0\" alt=\"\" align=\"absbottom\"><font style=\"color:#92cae3;\">Ik meld me af</font></div>';
						else if (bOn) divSM.innerHTML = '<div style=\"padding-bottom:5px;padding-left:1px;font-weight:bold;\">Schrijf je in voor surfmaatje zodat je surfmaatjes kunnen zien dat jij er ook bij bent!</div><div style=\"padding-bottom:3px;padding-left:24px;\"><img src=\"/styles/opperhoofd/custom/surfmaatje2.gif\" border=\"0\" alt=\"\" align=\"absbottom\"><font style=\"color:#92cae3;\">Ik ben er ook bij</font>&nbsp;&nbsp;&nbsp;<img src=\"/styles/opperhoofd/custom/no_surfmaatje.gif\" border=\"0\" alt=\"\" align=\"absbottom\"><a onclick=\"aanMelden(' + tID + ')\" onmouseover=\"menu_over(this)\" onmouseout=\"menu_out(this)\" title=\"Klik hier om je af te melden voor deze surfdag.\">Ik meld me af</a></div>';
						else divSM.innerHTML = '<div style=\"padding-bottom:5px;padding-left:1px;font-weight:bold;\">Schrijf je in voor surfmaatje zodat je surfmaatjes kunnen zien dat jij er ook bij bent!</div><div style=\"padding-bottom:3px;padding-left:24px;\"><img src=\"/styles/opperhoofd/custom/surfmaatje.gif\" border=\"0\" alt=\"\" align=\"absbottom\"><a onclick=\"aanMelden(' + tID + ')\" onmouseover=\"menu_over(this)\" onmouseout=\"menu_out(this)\" title=\"Klik hier om je aan te geven dat je deze surfdag er bij bent.\">Ik ben er ook bij</a>&nbsp;&nbsp;&nbsp;<img src=\"/styles/opperhoofd/custom/no_surfmaatje2.gif\" border=\"0\" alt=\"\" align=\"absbottom\"><font style=\"color:#92cae3;\">Ik meld me af</font></div>';
					}
				}
			}
		}
		 
		xmlhttp.send(null)
	}
}


function aanMelden(tID) {

	if(parseInt(tID) > 0)
	{
		var reqUrl = "/windsurfing.php?dW=a&t=" + tID + "&rand=" + Math.round(Math.random()*987654321);
		var xmlhttp=false;

		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		 try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
		   xmlhttp = false;
		  }
		 }
		@end @*/

		if (!xmlhttp && typeof XMLHttpRequest!='undefined')
		{
		  xmlhttp = new XMLHttpRequest();
		}
	
		xmlhttp.open("GET", reqUrl, true);
		xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4)
			{
				//alert(xmlhttp.responseText);
				var sM = document.getElementById('surfMaatje');
				if(!document.getElementById('aanMeldingen'))
				{
					var b = document.createElement("p");
						b.setAttribute("id", "aanMeldingen");
					sM.appendChild(b); 

					document.getElementById('aanMeldingen').innerHTML = xmlhttp.responseText;
					wieAangemeld(tID);
				}
				else
				{

					document.getElementById('aanMeldingen').innerHTML = xmlhttp.responseText;
					wieAangemeld(tID);
				}


				if(xmlhttp.responseText != 'Je bent nog niet ingelogd...')
				{
					wieAangemeld(tID);
				}
				else
				{
					document.getElementById('aanMeldingen').innerHTML = xmlhttp.responseText;
				}	

			}
		 }
		 xmlhttp.send(null)
	}

	if(parseInt(tID) > 0)
	{
		wieAangemeld(tID);
	}

}


function spotInfo(tID) {

	if(parseInt(tID) > 0)
	{
		var reqUrl = "/windsurfing.php?dW=s&t=" + tID + "&rand=" + Math.round(Math.random()*987654321);
		var xmlhttp=false;

		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		 try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
		   xmlhttp = false;
		  }
		 }
		@end @*/

		if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
		{
		  xmlhttp = new XMLHttpRequest();
		}
	
		xmlhttp.open("GET", reqUrl, true);
		xmlhttp.onreadystatechange=function()
		{
			if (xmlhttp.readyState==4)
			{
				spotinfo = eval(xmlhttp.responseText);
				if(spotinfo)
				{
					var sM = document.getElementById('surfMaatje');
					var b = document.createElement("h2");
					b.innerHTML = decodeURI(spotinfo[1]);
					sM.appendChild(b); 
				}
				else
				{
					var sM = document.getElementById('surfMaatje');
					var b = document.createElement("h2");
					b.innerHTML = " - ";
					sM.appendChild(b); 
				}



				if(!document.getElementById('aanMeldingen'))
				{
					var b = document.createElement("p");
						b.setAttribute("id", "aanMeldingen");
					sM.appendChild(b); 
				}
				wieAangemeld(tID);


			}
		 }
		 xmlhttp.send(null);
		 
	}
}


function relatedTopics(tID) {

	if(parseInt(tID) > 0)
	{
		var reqUrl = "/windsurfing.php?dW=r&t=" + tID + "&rand=" + Math.round(Math.random()*987654321);

		// http request naar windsurfing.php
		// wacht op het antwoord
		// js functie wieAangemeld aanroepen

	}
}

function mySurfmaatjes(uID) {

	if(parseInt(vID) > 0)
	{
		document.write('<div id=\"my_Surfmaatjes\"></div>');			
		if(document.getElementById("my_Surfmaatjes"))
		{
			var reqUrl = "/windsurfing.php?dW=m&v=" + vID + "&rand=" + Math.round(Math.random()*987654321);		
			var xmlhttp=false;
	
			/*@cc_on @*/
			/*@if (@_jscript_version >= 5)
			// JScript gives us Conditional compilation, we can cope with old IE versions.
			// and security blocked creation of the objects.
			 try {
			  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			 } catch (e) {
			  try {
			   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			  } catch (E) {
			   xmlhttp = false;
			  }
			 }
			@end @*/
	
			if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
			{
			  xmlhttp = new XMLHttpRequest();
			}
		
			xmlhttp.open("GET", reqUrl, true);
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState == 4)
				{
					var mS = document.getElementById("my_Surfmaatjes");
					var mSu = document.createElement("ul");
					mS.appendChild(mSu);
	
					surfmaatjes = eval(xmlhttp.responseText);
					if(surfmaatjes)
					{

						var numMaatjes = surfmaatjes.length;
						for(var i=1; i < numMaatjes; i++)
						{
							var arr = surfmaatjes[i];
				
							var mSl = document.createElement("li");
								mSl.innerHTML = "...";
							mSu.appendChild(mSl); 
						}	
	
	
						
					}
				}
			 }
			 xmlhttp.send(null);
		}
	}
}


function profielViews(vID,uID) {

	if(parseInt(vID) > 0 && parseInt(uID) > 0)
	{
		// http request naar windsurfing.php
		var reqUrl = "/windsurfing.php?dW=r&t=" + tID + "&rand=" + Math.round(Math.random()*987654321);

		// met de opgegeven ID's
		// wachten op het antwoord en klaar is kees
		// behalve als de vID == 216
		// dan een alert met het antwoord oppoppen :z
	}

}
