function OpenWindow( URL )
{
	window.open( URL, "", "width=500,height=500,scrollbars=yes,resizable=yes,menubar=yes" );
}

function OpenRulesWindow( URL )
{
	window.open( URL, "", "width=600,height=400,scrollbars=yes,resizable=no" );
}

function OpenUserInfoWindow( URL )
{
	window.open( URL, "", "width=450,height=220,scrollbars=no,resizable=no" );
}

function OpenMailUserWindow( URL )
{
	window.open( URL, "", "width=450,height=250,scrollbars=no,resizable=no" );
}

function OpenMagicWindow( URL )
{
	window.open( URL, "", "width=800,height=400,scrollbars=yes,resizable=no" );
}

function OpenMagicWindow2( URL )
{
	window.open( URL, "", "width=800,height=600,scrollbars=yes,resizable=yes" );
}

function confirm_prompt( submissionid, naam, datum )
{
	text = 'Weet U zeker dat U deze beurt op '+datum+' wilt overnemen van '+naam+' ?';
	if (confirm(text))
    	{
		newurl = "updaterooster.php?id="+submissionid+"&action=buy";
		window.location = newurl;
	}
}

function confirm_remove( submissionid, naam, datum )
{
	text = 'Weet U zeker dat U deze kaderbeurt van '+naam+' wilt verwijderen?';
	if (confirm(text))
    	{
		newurl = "updaterooster.php?id="+submissionid+"&action=del";
		window.location = newurl;
	}
}

function confirm_delflight( idflight, toestel, datum )
{
	text = 'Weet U zeker dat U deze vlucht ('+idflight+') op '+datum+' van de '+toestel+' wilt verwijderen?';
	if (confirm(text))
    	{
		newurl = "deleteflight.php?flightid="+idflight;
		window.location = newurl;
	}
}

function validate_bookform( CurrentUserClub )
{
	if (!CurrentUserClub) return;
	if (!document.bookform.Club) return;
	if (document.bookform.Club.options[document.bookform.Club.selectedIndex].text!=CurrentUserClub)
	{
		document.bookform.Coordinator.selectedIndex=0;
		alert("Let op: Omdat de dagcoordinator tot de vliegende club moet behoren, wordt dit veld geleegd !");
	}
}


var da,mo,yr,ho,mi,se;var countdownwidth='130px';var countdownheight='20px';var dd;function CountDownClock(endtime,servtime){var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");var dateq=endtime;var datetoday=servtime;da=dateq.substring(0,2);mo=dateq.substring(3,5);yr=dateq.substring(6,10);ho=dateq.substring(11,13);mi=dateq.substring(14,16);se='00';var ampm=dateq.substring(17,19);ampm=ampm.toUpperCase();if(ampm=="PM"){if(ho!=12){ho=parseInt(ho,10);ho=ho+12;}}
else{if(ampm=="AM"){if(ho==12){ho=0;}}}
var qdatestring=da+","+mo+","+yr+","+ho+","+mi+","+se;if(document.all){document.write('<span id="countdownie"></span>')}
if(document.getElementById)
{document.write('<div id="countdowndiv"></div>')}
futurestring=montharray[mo-1]+" "+da+" "+yr+" "+ho+":"+mi+":"+se;if(datetoday==0){today=new Date();todayy=today.getYear();if(todayy<1000){todayy+=1900;}
todaym=today.getMonth();todayd=today.getDate();todayh=today.getHours();todaymin=today.getMinutes();todaysec=today.getSeconds();todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;}
else{todayd=datetoday.substring(0,2);todaym=datetoday.substring(3,5);todayy=datetoday.substring(6,10);todayh=datetoday.substring(11,13);todaymin=datetoday.substring(14,16);todaysec=datetoday.substring(17,19);todaystring=montharray[todaym-1]+" "+todayd+" "+todayy+" "+todayh+":"+todaymin+":"+todaysec;}
dd=Date.parse(futurestring)-Date.parse(todaystring);window.onload=start_countdown;}
function start_countdown(){function resized(){if(pageWidth!=innerWidth||pageHeight!=innerHeight){location.reload();}}
if(document.layers){pageWidth=innerWidth;pageHeight=innerHeight;window.onresize=resized;document.countdownnsmain.visibility="show";}
countdown();}
function countdown(){var occasion="Auction End!"
var message_on_occasion="";var opentags=''
var tabletags="<TABLE WIDTH=\"100%\" HEIGHT=10 Border=0><tr><td width=\"20%\">tijd voor sluiting:</td>"
if(dd>=1000){dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<1){}
else{if(document.layers){document.countdownnsmain.document.countdownnssub.document.write(tabletags);document.countdownnsmain.document.countdownnssub.document.write("<td width=50 align=center>"+dday+" dagen")
document.countdownnsmain.document.countdownnssub.document.write("</td><td width=1></td><td width=\"20%\" align=center>"+dhour+" uren")
document.countdownnsmain.document.countdownnssub.document.write("</td><td width=1></td><td width=\"20%\" align=center>"+dmin+" min.")
document.countdownnsmain.document.countdownnssub.document.write("</td><td width=1></td><td width=\"20%\" align=center>"+dsec+" sec.")
document.countdownnsmain.document.countdownnssub.document.write("</td></tr></table>")
document.countdownnsmain.document.countdownnssub.document.close()}
else if(document.all){HTMLdisp=tabletags;HTMLdisp=HTMLdisp+"<td width=\"20%\" align=center>"+dday+" dagen"
HTMLdisp=HTMLdisp+"</td><td width=1></td><td width=\"20%\" align=center>"+dhour+" uren"
HTMLdisp=HTMLdisp+"</td><td width=1></td><td width=\"20%\" align=center>"+dmin+" min."
HTMLdisp=HTMLdisp+"</td><td width=1></td><td width=\"20%\" align=center>"+dsec+" sec."
HTMLdisp=HTMLdisp+"</td></tr></table>";countdownie.innerHTML=HTMLdisp}
else if(document.getElementById){content=tabletags;content+="<td width=\"20%\" align=center>"+dday+" dagen";content+="</td><td width=1></td><td width=\"20%\" align=center>"+dhour+" uren";content+="</td><td width=1></td><td width=\"20%\" align=center>"+dmin+" min.";content+="</td><td width=1></td><td width=\"20%\" align=center>"+dsec+" sec.";content+="</td></tr></table>";rng=document.createRange();el=document.getElementById('countdowndiv');rng.setStartBefore(el);htmlFrag=rng.createContextualFragment(content)
while(el.hasChildNodes())el.removeChild(el.lastChild);el.appendChild(htmlFrag);}}
dd=dd-1000;setTimeout("countdown()",1000);}
else{if(document.layers){document.countdownnsmain.document.countdownnssub.document.write(tabletags)
document.countdownnsmain.document.countdownnssub.document.write("<td width=\"20%\" align=center>0 dagen")
document.countdownnsmain.document.countdownnssub.document.write("</td><td width=1></td><td width=\"20%\" align=center>0 uren")
document.countdownnsmain.document.countdownnssub.document.write("</td><td width=1></td><td width=\"20%\" align=center>0 min.")
document.countdownnsmain.document.countdownnssub.document.write("</td><td width=1></td><td width=\"20%\" align=center>0 sec.")
document.countdownnsmain.document.countdownnssub.document.write("</td></tr></table>")
document.countdownnsmain.document.countdownnssub.document.close()}
else if(document.all){HTMLdisp=tabletags;HTMLdisp=HTMLdisp+"<td width=\"20%\" align=center>0 dagen"
HTMLdisp=HTMLdisp+"</td><td width=1></td><td width=\"20%\" align=center>0 uren"
HTMLdisp=HTMLdisp+"</td><td width=1></td><td width=\"20%\" align=center>0 min."
HTMLdisp=HTMLdisp+"</td><td width=1></td><td width=\"20%\" align=center>0 sec."
HTMLdisp=HTMLdisp+"</td></tr></table>"
countdownie.innerHTML=HTMLdisp}else if(document.getElementById){content=tabletags;content=content+"<td width=\"20%\" align=center>0 dagen"
content=content+"</td><td width=1></td><td width=\"20%\" align=center>0 uren"
content=content+"</td><td width=1></td><td width=\"20%\" align=center>0 min."
content=content+"</td><td width=1></td><td width=\"20%\" align=center>0 sec."
content=content+"</td></tr></table>"
rng=document.createRange();el=document.getElementById('countdowndiv');rng.setStartBefore(el);htmlFrag=rng.createContextualFragment(content)
while(el.hasChildNodes())el.removeChild(el.lastChild);el.appendChild(htmlFrag);}
return}}

var requester2;

function askinput4mail(){
	agewindow=dhtmlmodal.open('mail2day', 'div', 'modalalertdiv', 'Email sturen', 'width=650px,height=250px,left=150px,top=100px,resize=0,scrolling=0')
}

//Function to run when buttons within modal window is clicked on. Directly embedded inside hidden DIV, bypassing "onclose" event:
function process_age(whichbutton){
	if (whichbutton=="yes") {
		initConnection();
		var onderwerp = document.getElementById( "onderwerp" );
		var boodschap = document.getElementById( "boodschap" );
		var dedag = document.getElementById("theday");
		// alert( onderwerp.value);
		// alert( boodschap.value);
		// alert( dedag.innerHTML);
		bufferString = "sendmail2day.php?onderwerp=" + escape(onderwerp.value) + "&subject=" + escape(boodschap.value) + "&vliegdag=" + escape(dedag.innerHTML);
		// alert (bufferString);
		requester2.open("POST", bufferString );
		requester2.send(null);
	}
	agewindow.hide();
	if (whichbutton=="yes") {
		window.setTimeout('back2day(dedag)', 1000);
	}
}

function back2day( flyday)
{
	var jaartal = flyday.substring(0, 4);
	var maand = flyday.substring( 6, 2);
	var dag = flyday.substring( 9, 2);
	window.location="index.php?year="+jaartal+"&month="+maand+"&day="+dag;
}

function initConnection()
{
  try
  {
    requester2 = new XMLHttpRequest();
  }
  catch (error)
  {
    try
    {
      requester2 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (error)
    {
      requester2 = null;
    }
  }

  if (requester2 != null)
  {
    requester2.onreadystatechange = function() {
      if (requester2.readyState == 4) {
        if (requester2.status == 200 || requester2.status == 304) {
        }
        else
        {
          failure();
        }
      }
      return true;
    }
  }
  else
  {
    return false;
  }

  return true;
}

