// --------
// Popup-functie
// --------
function popup(url, width, height, scrollers)
{
newwindow = window.open(url,'popup','width='+width+',height='+height+',scrollbars='+scrollers+',toolbar=no,location=no,left='+screen.availWidth/100*5+',top='+screen.availHeight/100*5);
if (window.focus) {newwindow.focus()}
}

function zoeken_provincies_click(id, positie)
{
	if(document.getElementById('provincie_hidden').value == id)
	{
	document.getElementById('provincie_hidden').value = 'none';	
	document.getElementById('map_nederland_hover').style.backgroundPosition = '0px 0px';
	}
	else
	{
	document.getElementById('provincie_hidden').value = id;
	document.getElementById('map_nederland_hover').style.backgroundPosition = positie + 'px 0px';
	}
}

function zoeken_provincies_mouseover(id, positie)
{
document.getElementById('map_nederland_hover').style.backgroundPosition = positie + 'px 0px';
}

function zoeken_provincies_mouseout(id)
{
var a_provincie_coords = new Array();
a_provincie_coords[3] = '-606';
a_provincie_coords[5] = '-1010';
a_provincie_coords[1] = '-1616';
a_provincie_coords[2] = '-404';
a_provincie_coords[9] = '-808';
a_provincie_coords[4] = '-202';
a_provincie_coords[10] = '-1818';
a_provincie_coords[8] = '-1414';
a_provincie_coords[12] = '-2222';
a_provincie_coords[11] = '-2020';
a_provincie_coords[7] = '-1212';
a_provincie_coords[6] = '-2424';

	if(document.getElementById('provincie_hidden').value == 'none')
	{
	document.getElementById('map_nederland_hover').style.backgroundPosition = '0px 0px';
	}
	
	if(document.getElementById('provincie_hidden').value != id && document.getElementById('provincie_hidden').value != 'none')
	{
	document.getElementById('map_nederland_hover').style.backgroundPosition = a_provincie_coords[document.getElementById('provincie_hidden').value] + 'px 0px';
	}
}

function submitform(){
document.plaats_beoordeling.submit(); }


function submitform_fotos(){
document.plaats_fotos.submit(); }


function voter_mouseover(vote, id) {
document.getElementById(vote).style.backgroundImage = 'url(/images/voter_' + id + '.gif)';
document.getElementById(vote + '_value').value = id; }


function vote(vote, id) {
document.getElementById(id).className = 'click'+vote;
document.getElementById('beoordeling_voter_'+id+'_value').value = vote; }


function getsubcats_2(sel) {
var hoofdcatid = sel.options[sel.selectedIndex].value;
document.getElementById('zoeken_subrubriek').options.length = 0;
alert('http://www.tripgids.nl/includes/ajax/subcats.php?hoofd='+hoofdcatid+'&alle_subrubrieken_enabled=true');
if(hoofdcatid.length>0){
ajax.requestFile = 'http://www.tripgids.nl/includes/ajax/subcats.php?hoofd='+hoofdcatid+'&alle_subrubrieken_enabled=true';
ajax.onCompletion = update_subcats_2;
ajax.runAJAX(); } }


function update_subcats_2(){
alert('tjakaa!');
var obj = document.getElementById('zoeken_subrubriek');
eval(ajax.response); }


function voterating(criteria, stem, rate) {
document.write('<tr><td align="right">'+criteria+':</td><td class="vote_tr">');
document.write('<UL ID="'+stem+'" CLASS="n'+rate+'line">');
document.write('<LI CLASS="n1"><A HREF="#" ONCLICK="vote(1, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n2"><A HREF="#" ONCLICK="vote(2, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n3"><A HREF="#" ONCLICK="vote(3, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n4"><A HREF="#" ONCLICK="vote(4, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n5"><A HREF="#" ONCLICK="vote(5, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n6"><A HREF="#" ONCLICK="vote(6, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n7"><A HREF="#" ONCLICK="vote(7, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n8"><A HREF="#" ONCLICK="vote(8, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n9"><A HREF="#" ONCLICK="vote(9, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<LI CLASS="n10"><A HREF="#" ONCLICK="vote(10, \''+stem+'\'); return false;">&nbsp;</A></LI>');
document.write('<INPUT ID="beoordeling_voter_'+stem+'_value" TYPE="hidden" NAME="beoordeling_voter_'+stem+'_value" VALUE="0">');
document.write('</UL></td></tr>'); }


function nieuw_bestand() {
if(document.getElementById('aantal_bestanden').value < 8) {
var nummer = parseInt(document.getElementById('aantal_bestanden').value) + 1;
var nieuw_bestand = document.createElement('div');
	
nieuw_bestand.innerHTML = '<table class="form" width="100%" cellpadding="5" cellspacing="0"><tr><td style="border-top: 1px solid #ffffff; line-height: 170%;" align="right"><B>Upload foto '+nummer+'</B>:</td>' +
'<td width="560" style="border-top: 1px solid #ffffff; line-height: 170%;"><input type="file" name="foto_'+nummer+'" ONCHANGE="nieuw_bestand();" /></td>' +
'</tr><tr><td align="right">Omschrijving:</td>' +
'<td><input name="omschrijving_'+nummer+'" type="text" width="30" value="" /></td></tr></table>';
document.getElementById('bestanden_div').appendChild(nieuw_bestand);
	
document.getElementById('aantal_bestanden').value = nummer; } else {
alert('Er kunnen maximaal 8 foto\'s worden geupload.'); } }


function upload_wait() {
document.getElementById('upload_form').style.display = 'none';
document.getElementById('upload_geduld').innerHTML = '<div style="background: #fff0f7; padding: 50px 0 50px 0; text-align: center; color: #7d0038; border: 1px solid #bb0053; margin-bottom: 5px;"><b style="color: #bb0053; font-size: 15px; text-transform: none; letter-spacing: 0px;">Een moment geduld...</b><BR><BR>Foto\'s worden geupload, dit kan enige tijd in beslag nemen.<BR><BR><BR><IMG SRC="http://www.tripgids.nl/images/indicator.gif" BORDER=0 ID="indicator"></div>';
setTimeout('document.images["indicator"].src = "http://www.tripgids.nl/images/indicator.gif"', 200); 
document.getElementById('upload_geduld').style.display = 'block'; }


function zoek_div(postcode) {
document.write('<div id="zoeken">');
document.write('<form name="form_postcode" method="post" action="#">');
document.write('<input type="hidden" name="form_postcode_hidden" value="true" />');
document.write('<div class="zoeken_titel">Postcode opgeven</div>');
document.write('<input name="postcode" type="text" value="'+postcode+'" onclick="if(this.value==\''+postcode+'\'){this.value=\'\';}" /><input type="submit" name="submit" value="submit" class="submit" />');

document.write('</form><form name="form_uitgebreid_zoeken" method="post">');
document.write('<input type="hidden" name="form_uitgebreid_zoeken_hidden" value="true" />');
document.write('<div class="zoeken_titel" id="zoeken_titel">Zoeken</div>');
document.write('<input name="zoekterm" class="input" type="text" value="zoekterm..." onclick="if(this.value==\'zoekterm...\'){this.value=\'\';}" /><input type="submit" name="submit" value="zoeken" class="submit" /><br />');
document.write('<select name="zoeken_hoofdrubriek" id="zoeken_hoofdrubriek">');
document.write('<option value="none">- selecteer hoofdrubriek -</option><option value="attracties">Attracties</option><option value="cultuur">Cultuur</option><option value="dieren">Dieren</option><option value="evenementen">Evenementen</option><option value="ontspanning">Ontspanning</option><option value="recreatie">Recreatie</option><option value="sport">Sport</option><option value="overig">Overig</option></select><br />');
document.write('<div id="div_rechts"><select name="zoeken_provincie" id="zoeken_provincie"><option value="none">- selecteer provincie -</option><option value="1">Drenthe</option><option value="2">Flevoland</option><option value="3">Friesland</option><option value="4">Gelderland</option><option value="5">Groningen</option><option value="6">Limburg</option><option value="7">Noord-Brabant</option><option value="8">Noord-Holland</option><option value="9">Overijssel</option><option value="10">Utrecht</option><option value="11">Zeeland</option><option value="12">Zuid-Holland</option></select></div>');
document.write('</form></div>'); }


function HTTP_Request() {
if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
else if (window.XMLHttpRequest) { xmlHttp = new XMLHttpRequest(); } }

function getsub(naam, thisid, div, subkeuze, width) {
getsub.select_div = div;
HTTP_Request();
xmlHttp.onreadystatechange = result_ajaxadres;
xmlHttp.open("GET", "http://www.tripgids.nl/includes/ajax/getsub.php?naam="+naam+"&id="+thisid+"&subkeuze="+subkeuze+"&width="+width, true);
xmlHttp.send(null); }

function result_ajaxadres() {
if(xmlHttp.readyState == 4 && xmlHttp.status == 200 && xmlHttp.responseText != "") {
document.getElementById(getsub.select_div).innerHTML = xmlHttp.responseText; } }


function lightbox(naam) {
strHTML = '<DIV CLASS="lightbox" ID="lightbox"><DIV CLASS="gray_overlay" ONCLICK="close_lightbox();"></DIV>';
strHTML+= '<TABLE CLASS="table" CELLSPACING=0 CELLPADDING=0><TR><TD WIDTH="50%"></TD><TD><DIV CLASS="content">';
strHTML+= '<DIV CLASS="titel">'+naam+'</DIV>';
strHTML+= '<DIV CLASS="close"><A HREF="#" ONCLICK="close_lightbox(); return false;">&nbsp;</A></DIV>';
strHTML+= '<SPAN ID="insert_content"></SPAN></DIV></TD><TD WIDTH="50%"></TD></TR></TABLE></DIV>';

document.body.style.height = '100%';
box = document.createElement('div');
box.innerHTML = strHTML;
document.getElementsByTagName('body')[0].appendChild(box); }

function open_lightbox(naam) { lightbox(naam);
document.getElementById('insert_content').innerHTML = '';
document.getElementById('lightbox').style.visibility = 'visible'; }

function close_lightbox() {
document.body.style.height = '0';
document.getElementById('insert_content').innerHTML = '';
document.getElementById('lightbox').style.visibility = 'hidden'; }

function lightbox_iframe(src, width, height, naam) {
open_lightbox(naam);
if(width == undefined) { width = 600; }
if(height == undefined) { height = 400; }
document.getElementById('insert_content').innerHTML = '<IFRAME SRC="http://'+src+'" WIDTH='+width+' HEIGHT='+height+' MARGINHEIGHT=0 MARGINWIDTH=0 FRAMEBORDER=0 SCROLLING="NO"></IFRAME>'; }







function zoeken_gemeente(pos, thisid)
{
	if(document.getElementById('map_nederland_hover').style.backgroundPosition != pos+'px 0px')
	{
	document.getElementById('zoek_gemeente_div').innerHTML = '<select style=\'width: 170px;\' disabled=\'disabled\' name=\'zoek_gemeente\' id=\'zoek_gemeente\'><option value=\'none\'> - kies eerst een provincie - </option></select>';
	}
	else
	{
	getsub('zoek_gemeente', thisid, 'zoek_gemeente_div', 1, 170);
	} 
}






function startUpload(id){

document.getElementById('busy').value = ++document.getElementById('busy').value;
document.getElementById('send').style.display = 'none';
document.getElementById('loading').style.display = 'inline';

var nieuw_foto = document.createElement('div');
nieuw_foto.innerHTML = '<DIV ID="foto_'+id+'" CLASS="foto_upload"><IMG SRC="/images/load.gif" ID="imgfoto_'+id+'" WIDTH=70 HEIGHT=70 BORDER=0 STYLE="float: left; padding: 0 10px 0 0;"><B>Beschrijving:</B><BR><INPUT TYPE="TEXT" ID="beschrijving_'+id+'" NAME="beschrijving_'+id+'" STYLE="border: 1px solid black; width: 235px; margin: 1px 0 6px 0;"><BR><A HREF="#" ONCLICK="delete_foto('+id+'); return false;"><IMG SRC="/images/lightbox_close.gif" BORDER=0></A><BR></DIV>';
document.getElementById('fotos_div').appendChild(nieuw_foto);
return true; }

function delete_foto(who, skip) {
document.getElementById('max_fotos').style.display = 'block';

if(skip != 1){
tel = document.getElementById('busy').value;
document.getElementById('busy').value = tel - 1;
if(document.getElementById('busy').value == 0) { document.getElementById('send').style.display = 'inline'; document.getElementById('loading').style.display = 'none'; } }

fotoarray.push(who);
var nog = fotoarray.length + 1;
if(nog == 1) { document.getElementById('nog').innerHTML = 'Je kan nog 1 foto uploaden!'; } else { document.getElementById('nog').innerHTML = 'Je kan nog '+nog+' foto\'s uploaden!'; }

var html = document.getElementById('bestanden_div').innerHTML;
if(html == ''){ nieuw_bestand(); }

who = 'foto_'+who;
if(typeof(who) == 'string') { who = document.getElementById(who); }
if(who && who.parentNode) { who.parentNode.removeChild(who); } } 

function rand(n) { return(Math.floor(Math.random() * n + 1)); }

function stopUpload(success, id, file){

tel = document.getElementById('busy').value;
document.getElementById('busy').value = tel - 1;
if(document.getElementById('busy').value == 0) { document.getElementById('send').style.display = 'inline'; document.getElementById('loading').style.display = 'none'; }

if(success == 1) { document.getElementById('imgfoto_'+id).src = 'http://www.tripgids.nl/fotos/temp/'+numm+'_foto_'+id+'_m.jpg?'+rand(1000)+rand(1000)+rand(1000);  }
else { document.getElementById('foto_'+id).style.display = 'none';

document.getElementById('error_table').style.display = 'block';
var error = document.createElement('div');
if (success == 2) { error.innerHTML = '<B>'+file+'</B>: Bestanden mogen maximaal 3.5MB groot zijn.';  }
else if (success == 3) { error.innerHTML = '<B>'+file+'</B>: Alleen foto\'s van de soort JPG, GIF en PNG zijn toegestaan.'; }
else if (success == 4) { error.innerHTML = '<B>'+file+'</B>: Foto\'s moeten de minimale afmeting hebben van 200 x 200 pixels.'; }
else if (success == 5) { error.innerHTML = '<B>Algemeen</B>: Bestanden mogen maximaal 3.5MB groot zijn.'; }
else { error.innerHTML = '<B>'+file+'</B>: Onbekende fout, probeer opnieuw.'; }
delete_foto(id, 1);
document.getElementById('error_div').appendChild(error); }

return true; }

function fixbar() {
window.barframe.document.write('');
window.barframe.close();
return; }

function nieuw_bestand() {
if(fotoarray.length > 0) {
if(fotoarray.length == 1) { document.getElementById('nog').innerHTML = 'Je kan nog 1 foto uploaden!'; } else { document.getElementById('nog').innerHTML = 'Je kan nog '+fotoarray.length+' foto\'s uploaden!'; }
var bestand_id = fotoarray.shift();
document.getElementById('bestanden_div').innerHTML = '<DIV ID="upform_'+bestand_id+'">' +
'<FORM ACTION="/includes/ajax/upload.php?id='+bestand_id+'&numm='+numm+'" METHOD="post" ENCTYPE="multipart/form-data" NAME="upload_'+bestand_id+'" TARGET="target_'+bestand_id+'" STYLE="padding: 0px; margin: 0px;">' +
'<INPUT NAME="myfile" TYPE="file" ONCHANGE="document.upload_'+bestand_id+'.submit(); startUpload('+bestand_id+'); nieuw_bestand();">' +
'</FORM></DIV>';

} else { document.getElementById('bestanden_div').innerHTML = '';
document.getElementById('max_fotos').style.display = 'none';
document.getElementById('nog').innerHTML = 'Je kan maximaal 8 foto\'s uploaden!'; } }

function submit_fotos(){
if(document.getElementById('foto_1')){ document.getElementById('hidden_foto_1').value = 1;
document.getElementById('hidden_foto_1_beschrijving').value = document.getElementById('beschrijving_1').value; }
if(document.getElementById('foto_2')){ document.getElementById('hidden_foto_2').value = 1;
document.getElementById('hidden_foto_2_beschrijving').value = document.getElementById('beschrijving_2').value; }
if(document.getElementById('foto_3')){ document.getElementById('hidden_foto_3').value = 1;
document.getElementById('hidden_foto_3_beschrijving').value = document.getElementById('beschrijving_3').value; }
if(document.getElementById('foto_4')){ document.getElementById('hidden_foto_4').value = 1;
document.getElementById('hidden_foto_4_beschrijving').value = document.getElementById('beschrijving_4').value; }
if(document.getElementById('foto_5')){ document.getElementById('hidden_foto_5').value = 1;
document.getElementById('hidden_foto_5_beschrijving').value = document.getElementById('beschrijving_5').value; }
if(document.getElementById('foto_6')){ document.getElementById('hidden_foto_6').value = 1;
document.getElementById('hidden_foto_6_beschrijving').value = document.getElementById('beschrijving_6').value; }
if(document.getElementById('foto_7')){ document.getElementById('hidden_foto_7').value = 1;
document.getElementById('hidden_foto_7_beschrijving').value = document.getElementById('beschrijving_7').value; }
if(document.getElementById('foto_8')){ document.getElementById('hidden_foto_8').value = 1;
document.getElementById('hidden_foto_8_beschrijving').value = document.getElementById('beschrijving_8').value; }
document.plaats_fotos.submit(); }

function hidden_forms() {
document.write('<IFRAME ID="barframe" SRC="#" STYLE="display: none;"></IFRAME>');
document.write('<INPUT TYPE="hidden" ID="hidden_foto_1" NAME="hidden_foto_1"><INPUT TYPE="hidden" ID="hidden_foto_1_beschrijving" NAME="hidden_foto_1_beschrijving">');
document.write('<INPUT TYPE="hidden" ID="hidden_foto_2" NAME="hidden_foto_2"><INPUT TYPE="hidden" ID="hidden_foto_2_beschrijving" NAME="hidden_foto_2_beschrijving">');
document.write('<INPUT TYPE="hidden" ID="hidden_foto_3" NAME="hidden_foto_3"><INPUT TYPE="hidden" ID="hidden_foto_3_beschrijving" NAME="hidden_foto_3_beschrijving">');
document.write('<INPUT TYPE="hidden" ID="hidden_foto_4" NAME="hidden_foto_4"><INPUT TYPE="hidden" ID="hidden_foto_4_beschrijving" NAME="hidden_foto_4_beschrijving">');
document.write('<INPUT TYPE="hidden" ID="hidden_foto_5" NAME="hidden_foto_5"><INPUT TYPE="hidden" ID="hidden_foto_5_beschrijving" NAME="hidden_foto_5_beschrijving">');
document.write('<INPUT TYPE="hidden" ID="hidden_foto_6" NAME="hidden_foto_6"><INPUT TYPE="hidden" ID="hidden_foto_6_beschrijving" NAME="hidden_foto_6_beschrijving">');
document.write('<INPUT TYPE="hidden" ID="hidden_foto_7" NAME="hidden_foto_7"><INPUT TYPE="hidden" ID="hidden_foto_7_beschrijving" NAME="hidden_foto_7_beschrijving">');
document.write('<INPUT TYPE="hidden" ID="hidden_foto_8" NAME="hidden_foto_8"><INPUT TYPE="hidden" ID="hidden_foto_8_beschrijving" NAME="hidden_foto_8_beschrijving">');

document.write('<IFRAME ID="target_1" NAME="target_1" SRC="#" STYLE="display: none;"></IFRAME>');
document.write('<IFRAME ID="target_2" NAME="target_2" SRC="#" STYLE="display: none;"></IFRAME>');
document.write('<IFRAME ID="target_3" NAME="target_3" SRC="#" STYLE="display: none;"></IFRAME>');
document.write('<IFRAME ID="target_4" NAME="target_4" SRC="#" STYLE="display: none;"></IFRAME>');
document.write('<IFRAME ID="target_5" NAME="target_5" SRC="#" STYLE="display: none;"></IFRAME>');
document.write('<IFRAME ID="target_6" NAME="target_6" SRC="#" STYLE="display: none;"></IFRAME>');
document.write('<IFRAME ID="target_7" NAME="target_7" SRC="#" STYLE="display: none;"></IFRAME>');
document.write('<IFRAME ID="target_8" NAME="target_8" SRC="#" STYLE="display: none;"></IFRAME>'); }


// Favorieten functies
// COOKIE UITLEZEN

function ReadCookie(name) {

var dc = document.cookie;

var prefix = name + "=";

var begin = dc.indexOf("; " + prefix);

if (begin == -1) {

begin = dc.indexOf(prefix);

if (begin != 0) return null; }

else begin += 2;

var end = document.cookie.indexOf(";", begin);

if (end == -1)

end = dc.length;

return unescape(dc.substring(begin + prefix.length, end)); }



// FUNCTION SET COOKIE

function set_cookie( name, value, exp_y, exp_m, exp_d, path, domain, secure ){

var domain = ".tripgids.nl";

path = "/";

var cookie_string = name + "=" + escape ( value );

if(exp_y){

var expires = new Date ( exp_y, exp_m, exp_d );

cookie_string += "; expires=" + expires.toGMTString();

}

if(path) cookie_string += "; path=" + escape (path);

if(domain) cookie_string += "; domain=" + escape (domain);

if(secure) cookie_string += "; secure";

document.cookie = cookie_string;

}

function strstr( haystack, needle, bool ) {
    var pos = 0;
 
    haystack += '';
    pos = haystack.indexOf( needle );
    if( pos == -1 ){
        return false;
    } else{
        if( bool ){
            return haystack.substr( 0, pos );
        } else{
            return haystack.slice( pos );
        }
    }
}

// tg_favorieten FUNCTIE

function tg_favorieten(id) {

if(document.getElementById('tg_favorieten_on').style.display == 'inline'){



document.getElementById('tg_favorieten_on').style.display = 'none';

document.getElementById('tg_favorieten_off').style.display = 'inline';



watchvar = ReadCookie("tg_favorieten");

set_cookie("tg_favorieten", id+','+watchvar, 2020, 01, 01);

/*// Auto-id uit bekeken verwijderen, anders komen ze dubbel voor
bekeken = ReadCookie("tg_bekeken");
if(strstr(bekeken, id) != '')
{
aantal_bekeken = document.getElementById('bekeken_aantal').innerHTML;
aantal_bekeken--
if(aantal_bekeken > -1){document.getElementById('bekeken_aantal').innerHTML = aantal_bekeken;}
set_cookie("tg_bekeken", bekeken.replace(','+id, ''), 2020, 01, 01);
}*/


str = document.getElementById('favorieten_aantal').innerHTML;

str++;

document.getElementById('favorieten_aantal').innerHTML = str;



} else {



watchvar = ReadCookie("tg_favorieten");

theArray = watchvar.split(',');

var toRemove = id;



Array.prototype.removeItems = function(itemsToRemove) {

if (!/Array/.test(itemsToRemove.constructor)) {

itemsToRemove = [ itemsToRemove ]; }

var j;

for (var i = 0; i < itemsToRemove.length; i++) {

j = 0;

while (j < this.length) {

if (this[j] == itemsToRemove[i]) {

this.splice(j, 1);

} else {

j++;

} } } }

theArray.removeItems(toRemove);



var klaararray = theArray.join(',');



set_cookie("tg_favorieten", klaararray, 2020, 01, 01);



var str = document.getElementById('favorieten_aantal').innerHTML;

str--;

document.getElementById('favorieten_aantal').innerHTML = str;



document.getElementById('tg_favorieten_on').style.display = 'inline';

document.getElementById('tg_favorieten_off').style.display = 'none';

}}