function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function delset(){
setActiveStyleSheet=function(){}
}

function world(C){
optAant=C.options.length-1
if(C.selectedIndex===optAant){
	optVal=prompt('What country are you from?','')
	C.options[optAant].text=optVal
	C.options[optAant].value=optVal
}
bO(C.form)
}

preval=''
function tS(str,T) 
{ 
 if(T=='lc')regEx = new RegExp("^[A-Å '0-9\. ]*$","i"); 
 if(T=='l')regEx = new RegExp("^[A-Å '\. ]*$","i"); 
 if(T=='c')regEx = new RegExp("^[0-9]*$","i"); 
    if(regEx.test(str.value)){
preval=str.value
 if(str.form.verN)bO(str.form)
} 
  else {
  str.value=preval;
  }
}

function tD(v){
    d = v.value.split('\/')
    
    for(a=0;a<3;a++){
        d[a]=d[a]*1
    }
    d[1]--
    if(d[2]<12)d[2]+=2000
    if(d[2]<1900)d[2]+=1900
    dat=new Date(d[2],d[1],d[0])
    if(d[2]>2009||d[1]!=dat.getMonth())dat='NaN'
    if(dat!='NaN')preval=dat.getDate()+'/'+(dat.getMonth()+1)+'/'+dat.getFullYear()
    else alert('not dd/mm/yyyy format') 
    v.value=preval
}


function nav(laag) {
    if (laag == 'guest') laag = 'guestbook'
    if (laag == 'album') laag = 'registered'
    url = laag + '.ajax';
    $.get(url, function(data) {
        $('#onder').html(data);
        if (laag == 'location' || laag == 'area') load('mapLN');
        gastval();
    }, 'html');
}

function test(){
document.getElementById('boven').style.height="20%"
document.getElementById('onder').style.height="75%"
document.getElementById('onder').style.top="22%"
document.getElementById('onder').style.left="8%"
document.getElementById('onder').style.borderTopStyle='solid'
test=function(){}
}

window.onload = function() {
    if (document.getElementById('boven')) {
        document.getElementById('boven').innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" class="navigatie" align="middle"><param  name="allowScriptAccess" value="always" /><param name="movie" value="navigatie_6.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent"/><embed src="navigatie_6.swf" wmode="transparent" quality="high" class="navigatie" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'
        vertraging = setTimeout("setActiveStyleSheet('flashloos')", 5000)
    }
    load('mapLN');
    gastval()
}


function G_verz(form) {
    return false;
}

function gastval() {
    $('#gastinvoer').validate({
        submitHandler: function(form) {
            $.post(
            'guestbook.ajax',
            $(form).serialize(),
            function(data) {
                $('#onder').html(data);
                gastval()
            }
		);
    }
})

    $('#landform').validate({
        submitHandler: function(form) {
            laag = 'landen'
            if ($('#url').val().length == 8) laag = $('#url').val()+'cd'		
			$('#onder').html(' Subscribtion in progress');
			$.post(
				laag+ '.ajax',
				$(form).serialize(),
				function(data) {
					$('#onder').html(data);
					gastval()
				}
			);
		}
	})

$('#inschrijfform').validate({
    submitHandler: function(f) {
        fout = 'false content\n'
        if (f.land.selectedIndex == 0) fout += 'select a country \n'
        $('.naam').each(function(i) {
            if (this.value != '') {
                if ($('.geb')[i].value == 'dd/mm/yyyy') fout += 'insert the date of birth for ' + this.value + ' (member ' + (i+1) + ')\n'
                else if (agecheck($('.geb')[i].value, $('.soort')[i].value) == false) fout += 'the age of' + this.value + '(member ' + (i + 1) + ') is not valid for a competitor\n'
                if ($('.soort')[i].value == false) fout += 'select the type of participation for ' + this.value + '(member ' + (i + 1) + ')\n'
                if ($('.gesl')[i].value == false) fout += 'select the gender for ' + this.value + '(member ' + (i + 1) + ')\n'
            }
        })
        if (fout == 'false content\n') {
            laag = 'entry'
            if ($('#url').val().length == 8) laag = $('#url').val()+'12'
				$('#onder').html(' Subscribtion in progress');
                $.post(
                    laag+ '.ajax',
                    $(f).serialize(),
                    function(data) {
                        $('#onder').html(data);
						gastval()
                   }
               )
         }
        else {
            alert(fout)
        }
    }
    , rules: {
        verN: {
            required: true,
            minlength: 3
        },
        contactP: {
            required: true,
            minlength: 7
        },
        stNr: {
            required: true
        },
        straat: {
            required: true,
            minlength: 3
        },
        postC: {
            required: true,
            minlength: 4
        },
        gemeente: {
            required: true,
            minlength: 3
        },
        mail: {
            required: true,
            email: true
        }
    }
})    
    
}

function toevoegen(c) {
    teller=0
    $('.naam').each(function(i) {
        if(this.value=='')teller++
    })
    if (teller < 4){
        var containerdiv = document.getElementById(c);
        var nieuwe_div = containerdiv.getElementsByTagName('tr')[0].cloneNode(true);
        containerdiv.appendChild(nieuwe_div);
        nieuwe_div.getElementsByTagName('input')[0].value = '';
        nieuwe_div.getElementsByTagName('input')[1].value = '';
        nieuwe_div.getElementsByTagName('input')[2].value = 'dd/mm/yyyy';
        nieuwe_div.getElementsByTagName('select')[0].selectedIndex=0;
        nieuwe_div.getElementsByTagName('select')[1].selectedIndex=0;
    } 
}

function addTeam(){
    teller = 0
    $('.team').each(function(i) {
        if (this.value == '') teller++
    })
    if (teller < 1) {
        $('#teams').append('<label for="teams1">Name for team '+(1+$('.team').length)+'</label> <input type="hidden" class="rug" name="rug[]"/><input type="text" id="team'+(1+$('.team')).length+'" onkeyup="bO(this.form)" class="team" name="team[]" style="width:24em;" MAXLENGTH=20 /><br />');
    }
 }

function agecheck(geb,cat){
	d=geb.split('\/')
	j=1*d[2]; 
	if((j>2000||j<1994)&&cat==1){
		return false; 
	}
}

function bO(f) {
    addTeam(); 
bOp=0
borg = 0
    $('.naam').each(function(i) {
            if (this.value != '' && $('.soort')[i].value!=9) bOp++
      })
if(bOp!=0)borg=100
kost=70
if(f.land.selectedIndex<6)kost=85
//if(f.don.checked)kost+=35
//if(f.maan.checked)kost+=35

Ateams = 0; 
$('.team').each(function(i) {
    if (this.value != '') Ateams++
})
if (Ateams > 0) borg = (Ateams * 100)

document.getElementById('sO').innerHTML = bOp + ' * € ' + kost + ',-- = € ' + (bOp * kost) + ',--'
document.getElementById('sI').innerHTML=Ateams+' * € 50,-- = € '+(Ateams*50)+',--'

document.getElementById('sB').innerHTML=' € '+borg+',--' 
document.getElementById('sT').innerHTML=' € '+((Ateams*50)+(bOp*kost)+borg)+',--'
}	


function load(mL) {
   if (GBrowserIsCompatible()) {
		$(".map").each(function(){
		var map = new GMap2(this);
		map.setUIToDefault();
		map.setCenter(new GLatLng(51.261492, 5.075179), 18, G_SATELLITE_MAP);

		var icon = new GIcon(G_DEFAULT_ICON);

		function createMarker(point, icon,html,link) {
			var marker = new GMarker(point, {icon:icon,title:html});
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml("<center><H3>GENSB 2012 </H3><H4>"+html+"</H4>"+link);
			});
			return marker;
		}
		point = new GLatLng(51.264422, 5.075625);
		map.addOverlay(createMarker(point, icon, "Vakantieverblijf de Linde", "<a href='http://maps.google.be/maps?t=h&z=16&daddr=51.264355,5.076773' target='_blank' style='font-size:0.8em;'> plan route </a></center>"));
		point = new GLatLng(51.261492, 5.075179);
		map.addOverlay(createMarker(point, icon, "Oefenveld TTV Fam, Janssens", "<a href='http://maps.google.be/maps?t=h&z=16&daddr=51.261492,5.075179' target='_blank' style='font-size:0.8em;'> plan route </a></center>"));
})
		
		$(".map2").each(function() {
		    var map = new GMap2(this);
		    map.setUIToDefault();
		    map.setCenter(new GLatLng(51.264422, 5.075625), 17, G_SATELLITE_MAP);

		    var icon = new GIcon(G_DEFAULT_ICON);

		    function createMarker(point, icon, html, link) {
		        var marker = new GMarker(point, { icon: icon, title: html });
		        GEvent.addListener(marker, "click", function() {
		            marker.openInfoWindowHtml("<center><H3>GENSB 2012 </H3><H4>" + html + "</H4>" + link);
		        });
		        return marker;
		    }
		    point = new GLatLng(51.264422, 5.075625);
		    map.addOverlay(createMarker(point, icon, "Vakantieverblijf de Linde", "<a href='http://maps.google.be/maps?t=h&z=16&daddr=51.264355,5.076773' target='_blank' style='font-size:0.8em;'> plan route </a></center>"));
		    point = new GLatLng(51.261492, 5.075179);
		    map.addOverlay(createMarker(point, icon, "Oefenveld TTV Fam, Janssens", "<a href='http://maps.google.be/maps?t=h&z=16&daddr=51.261492,5.075179' target='_blank' style='font-size:0.8em;'> plan route </a></center>"));
		})
}
}
