function Demo ()
{
	alert("Dit onderdeel is niet toegankelijk voor het demo account.");
}

function NaarDemo ()
{
	if ( confirm("Wil U nu inloggen met het demo account?\n\nLET OP: U kunt in het demo account niks wijzigen, u krijgt echter wel een goed beeld van de mogelijkheden van het systeem.\n\nEenmaal ingelogd kunt u uiloggen via de knop rechts boven.") )
	{
		document.location='beheer.php?pi=demo';
	}
}

function popUp (url,width,height) 
{
	winpops=window.open('popup.php?img='+url,"","width="+width+",height="+height+",status,scrollbars,resizable,");
}

function popUpScript ( url,width,height )
{
	winpops=window.open(url,"","width="+width+",height="+height+",status,scrollbars,resizable,");
}

function rC(theRow, theAction)
{
    var theCells = null;
    
    theDefaultColor='#FFFFFF';
    thePointerColor='#DDEEFF';
    theMarkColor='#FFFFFF';
    
    if ((thePointerColor == '' && theMarkColor == '') || typeof(theRow.style) == 'undefined') 
        return false;
    
    if (typeof(document.getElementsByTagName) != 'undefined') theCells = theRow.getElementsByTagName('td');
    else if (typeof(theRow.cells) != 'undefined') theCells = theRow.cells;
    else return false;
    
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;

    if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    } else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } 
    
    if (theAction == '1') newColor = thePointerColor;
    else if (theAction == '2') newColor = theDefaultColor;
    
        
    if (newColor) {
        var c = null;
        
        if (domDetect) 
	{
            for (c = 0; c < rowCellsCnt; c++) 
	    {
		theCells[c].setAttribute('bgcolor',newColor,0);
            } // end for
        } else {
            for (c = 0; c < rowCellsCnt; c++) 
	    {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } 
  
    return true;
}

function lM (id) { document.location='beheer.php?pi=mailings&action=edit&id='+id; }
function lP (id) { document.location='beheer.php?pi=planning&action=edit&id='+id; }
function lR (id) { document.location='beheer.php?pi=rapportage&action=details&id='+id; }
function lA (id) { document.location='beheer.php?pi=abonnementen&action=edit&id='+id; }
function lAB (list_id,member_id) { document.location='beheer.php?pi=abonnees&action=edit&list_id='+list_id+'&id='+member_id; }
function lT (id) { document.location='beheer.php?pi=templates&action=edit&id='+id; }
function lG (id) { document.location='beheer.php?pi=gebruikers&action=edit&id='+id; }


function startClock()
{
	var thetime=new Date();
	var nhours=thetime.getHours();
	var nmins=thetime.getMinutes();
	var nsecn=thetime.getSeconds();
	var nday=thetime.getDay();
	var nmonth=thetime.getMonth();
	var ntoday=thetime.getDate();
	var nyear=thetime.getYear();
	var AorP=" ";

	if (nhours==0) nhours=12;

	if (nsecn<10) nsecn="0"+nsecn;

	if (nmins<10) nmins="0"+nmins;

	if (nday==0) nday="Zondag";
	if (nday==1) nday="Maandag";
	if (nday==2) nday="Dinsdag";
	if (nday==3) nday="Woensdag";
	if (nday==4) nday="Donderdag";
	if (nday==5) nday="Vrijdag";
	if (nday==6) nday="Zaterdag";

	if (nmonth==0) nmonth="januari";
	if (nmonth==1) nmonth="februari";
	if (nmonth==2) nmonth="maart";
	if (nmonth==3) nmonth="april";
	if (nmonth==4) nmonth="mei";
	if (nmonth==5) nmonth="juni";
	if (nmonth==6) nmonth="juli";
	if (nmonth==7) nmonth="augustus";
	if (nmonth==8) nmonth="september";
	if (nmonth==9) nmonth="oktober";
	if (nmonth==10) nmonth="november";
	if (nmonth==11) nmonth="december";
	
	if (nyear<=99) nyear= "19"+nyear;

	if ((nyear>99) && (nyear<2000)) nyear+=1900;

	document.planningForm.klok.value=nday+", "+ntoday+" "+nmonth+" "+nyear+", "+nhours+":"+nmins+":"+nsecn;
	
	setTimeout('startClock()',1000);
} 

function showImage( naam, width, height )
{
	winpops=window.open("showimg.php?id="+naam,"","width="+width+",height="+height+",status,scrollbars,resizable,");
}

function checkFormAbonnement()
{
	if (! document.abonnementForm.naam.value)
	{
		alert("U dient tenminste een naam voor het abonnement op te geven.");
		document.abonnementForm.naam.focus();
	
	} else {
		document.abonnementForm.submit();
	}
}

function checkFormTemplate()
{
	if (! document.templateForm.naam.value)
	{
		alert("U dient tenminste een naam voor de template op te geven.");
		document.templateForm.naam.focus();
	
	} else {
		document.templateForm.submit();
	}
}

function checkFormAbonnee()
{
	if (! document.abonneeForm.naam.value)
	{
		alert("U dient een naam op te geven.");
		document.abonneeForm.naam.focus();
	} else if (! document.abonneeForm.email.value)
	{
		alert("U dient een e-mail adres op te geven.");
		document.abonneeForm.email.focus();
	} else document.abonneeForm.submit();
}

function checkFormGebruiker( type )
{
	var ok = 1;
	
	if (! document.gebruikerForm.username.value )
	{
		alert("U heeft geen inlognaam voor de gebruiker opgegeven.");
		document.gebruikerForm.username.focus();
		ok = 0;
	} else if (! document.gebruikerForm.naam.value) {
		alert("U heeft geen naam opgegeven.");
		document.gebruikerForm.naam.focus();
		ok = 0;
	} else if (! document.gebruikerForm.email.value) {
		alert("U heeft geen email adres opgegeven.");
		document.gebruikerForm.email.focus();
		ok = 0;
	} else if ( document.gebruikerForm.password1.value != document.gebruikerForm.password2.value ) {
		alert("Wachtwoorden komen niet overeen.");
		document.gebruikerForm.password1.focus();
		ok = 0;
	} else if ( document.gebruikerForm.password1.value == "" ) {
		if ( type == 'new' )
		{
			alert("Geen wachtwoord opgegeven.");
			document.gebruikerForm.password1.focus();
			ok = 0;
		}
	} else if ( document.gebruikerForm.password1.value.length < 4 ) {
		alert("Wachtwoord dient minimaal 4 tekens te omvatten.");
		document.gebruikerForm.password1.focus();
		ok = 0;
	}

	if ( ok == 1) document.gebruikerForm.submit();
	
}

function checkFormImport()
{
	if (! document.importeerAdressenForm.importeren_bestand.value)
	{
		alert("U heeft nog geen bestand geselecteerd.");
	} else {
		document.importeerAdressenForm.submit();
	}
}

function checkFormBlacklist()
{
	if (! document.blacklistForm.email.value)
	{
		alert("U dient een e-mail adres op te geven.");
		document.blacklistForm.email.focus();
	} else if ( document.blacklistForm.email.value.indexOf("@") ==-1 ) {
		alert("Vult u a.u.b. een geldig e-mail adres in.");
		document.blacklistForm.email.focus();
	} else if ( document.blacklistForm.email.value.indexOf(".") ==-1 ) {
		alert("Vult u a.u.b. een geldig e-mail adres in.");
		document.blacklistForm.email.focus();
	} else if ( document.blacklistForm.email.value.length < 6 ) {
		alert("Vult u a.u.b. een geldig e-mail adres in.");
		document.blacklistForm.email.focus();
	} else document.blacklistForm.submit();
}

function verwijderMailing( id, naam )
{
	if ( confirm("Verwijder "+naam+" mailing?") )
	{
		document.location="beheer.php?pi=mailings&action=del&id="+id;
	}
}

function verwijderPlanning( id, naam )
{
	if ( confirm("Verwijder '"+naam+"' planning?") )
	{
		document.location="beheer.php?pi=planning&action=del&id="+id;
	}
}

function verwijderTemplate( id, naam )
{
	if ( confirm("Verwijder deze template?") )
	{
		document.location="beheer.php?pi=templates&action=del&id="+id;
	}
}

function verwijderAbonnement( id, naam )
{
	if ( confirm("Verwijder '"+naam+"' abonnement?\n\nLET OP: Hiermee worden ook alle abonnees van het abonnement verwijderd!") )
		document.location="beheer.php?pi=abonnementen&action=del&id="+id;
}

function verwijderAbonnee( id, list_id, naam )
{
	if ( confirm("Verwijder '"+naam+"' abonnee?") )
		document.location="beheer.php?pi=abonnees&action=del&list_id="+list_id+"&id="+id;
}

function verwijderAfgemeld( id, list_id, naam )
{
	if ( confirm("Verwijder '"+naam+"' afgemelde abonnee?") )
		document.location="beheer.php?pi=afgemeld&action=del&list_id="+list_id+"&id="+id;
}

function verwijderBlacklist( id, list_id, naam )
{
	if ( confirm("Verwijder '"+naam+"' van blacklist?") )
	{
		document.location="beheer.php?pi=blacklist&action=del&list_id="+list_id+"&id="+id;
	}
}

function verwijderGebruiker( id, naam )
{
	if ( confirm("Verwijder de gebruiker "+naam+" ?") )
	{
		document.location="beheer.php?pi=gebruikers&action=del&id="+id;
	}
}

function confirmResetAbonnement( list_id )
{
	if ( confirm("Zeker weten dat u ALLE abonnees uit dit abonnement wilt VERWIJDEREN ?") )
	{
		document.location="reset_abonnement.php?list_id="+list_id+"&type=abonnees";
	}
	
}

function confirmResetBlacklist( list_id )
{
	if ( confirm("Zeker weten dat u ALLE adressen uit deze blacklist wilt VERWIJDEREN ?") )
	{
		document.location="reset_abonnement.php?list_id="+list_id+"&type=blacklist";
	}
	
}


function OptInReset()
{
	tmp = "Bedankt voor uw aanvraag !\n\n";
	tmp += "U heeft lidmaatschap aangevraagd van de nieuwsbrief:\n\n";
	tmp += "\t{[abonnement_naam]}\n\n";
	tmp += "Aanvraag om : {[aanvraag_datum_tijd]}\n";
	tmp += "Vanuit      : {[aanvraag_ip]}\n";
	tmp += "Vanaf       : {[aanvraag_referer]}\n";
	tmp += "\n";
	tmp += "Om uw aanmelding te bevestigen hoeft u alleen nog maar op onderstaande link te klikken:\n\n";
	tmp += "{[activation_link]}\n\n";
	tmp += "Mocht u dit NIET zelf hebben aangevraagd en u wilt de nieuwsbrief NIET ontvangen\n";
	tmp += "dan hoeft u niets te doen en zult u de nieuwsbrief vanzelfsprekend niet ontvangen.\n\n";
	tmp += "___________________________________________________________________________\n";
	tmp += "Mocht u zich in de toekomst willen afmelden dan kunt u dit doen via:\n\n";
	tmp += "\t{[afmelden_link]}\n\n";
	tmp += "Mocht u nog vragen hebben dan kunt u e-mailen naar: {[abonnement_support_email]}\n";
	
	document.abonnementForm.optin_body.value=tmp;
}

function OptOutReset()
{
	tmp  = "Bedankt voor uw aanvraag !\n\n";
	tmp += "U heeft opzegging van lidmaatschap aangevraagd van de nieuwsbrief:\n\n";
	tmp += "\t{[abonnement_naam]}\n\n";
	tmp += "Aanvraag om : {[aanvraag_datum_tijd]}\n";
	tmp += "Vanuit      : {[aanvraag_ip]}\n";
	tmp += "Vanaf       : {[aanvraag_referer]}\n";
	tmp += "\n";
	tmp += "Om uw afmelding te bekrachtigen hoeft u alleen nog maar op onderstaande link te klikken:\n\n";
	tmp += "{[deactivation_link]}\n\n";
	tmp += "Mocht u dit NIET zelf hebben aangevraagd en u wilt de nieuwsbrief blijven ontvangen\n";
	tmp += "dan hoeft u niets te doen en zult u de nieuwsbrief vanzelfsprekend blijven ontvangen.\n\n";
	tmp += "___________________________________________________________________________\n";
	tmp += "Mocht u zich in de toekomst weer willen aanmelden dan kunt u dit doen via:\n\n";
	tmp += "\t{[aanmelden_link]}\n\n";
	tmp += "Mocht u nog vragen hebben dan kunt u e-mailen naar: {[abonnement_support_email]}\n";
	
	document.abonnementForm.optout_body.value=tmp;
}
