var win = null;

function popup(mypage,myname,w,h,scroll,resize)
{
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+''
	win = window.open(mypage,myname,settings)
	if(win.window.focus)
	{	win.window.focus();
	}
}

function validateNumber(field, tekst)
{	var val = field.value;
	if(!/^\d*$/.test(val)||val==-1)
	{	alert(tekst);
		field.focus();
		field.select();
	}
}

function profile(location)
{	popup(location+'&b=n','profile','550','350','yes','yes')
}

function smallpop(location)
{	popup(location+'&b=n','profile','400','150','yes','yes')
}

function CheckForm ()
{	if (document.forms.auth.username){if (document.forms.auth.username.value==""){alert("Geef je UserName a.u.b.");document.forms.auth.username.focus();return false;}}
	if (document.forms.auth.email){if (document.forms.auth.email.value==""){alert("Geef je Email adres a.u.b.");document.forms.auth.email.focus();return false;}}
	if (document.forms.auth.password){if (document.forms.auth.password.value.length<5){alert("Je wachtwoord dient tussen de 5 en 15 karakters lang te zijn.");document.forms.auth.password.focus();return false;}}
	if (document.forms.auth.passwordconfirm){if (document.forms.auth.passwordconfirm.value.length<5){alert("Je wachtwoord dient tussen de 5 en 15 karakters lang te zijn.");document.forms.auth.passwordconfirm.focus();return false;}}
	if (document.forms.auth.accepttc){if (document.forms.auth.accepttc.checked == false){alert("Je dient accoord te gaan met de voorwaarden");document.forms.auth.accepttc.focus();	return false;}}
	if (document.forms.auth.Naam){if (document.forms.auth.Naam.value==""){alert("Geef je naam a.u.b.");document.forms.auth.Naam.focus();return false;}}
	if (document.forms.auth.Adres){if (document.forms.auth.Adres.value==""){alert("Geef je adres a.u.b.");document.forms.auth.Adres.focus();return false;}}
	if (document.forms.auth.Huisnummer){if (document.forms.auth.Huisnummer.value==""){alert("Geef je huisnummer a.u.b.");document.forms.auth.Huisnummer.focus();return false;}}
	if (document.forms.auth.Postcode){if (document.forms.auth.Postcode.value==""){alert("Geef je postcode a.u.b.");document.forms.auth.Postcode.focus();return false;}}
	if (document.forms.auth.Woonplaats){if (document.forms.auth.Woonplaats.value==""){alert("Geef je Woonplaats a.u.b.");document.forms.auth.Woonplaats.focus();return false;}}
	if (document.forms.auth.Email){if (document.forms.auth.Email.value==""){alert("Geef je E-mail adres a.u.b.");document.forms.auth.Email.focus();return false;}}
	if (document.forms.auth.subject){if (document.forms.auth.subject.value==""){alert("Geef een kopregel op a.u.b.");document.forms.auth.subject.focus();return false;}}
	if (document.forms.auth.comments){if (document.forms.auth.comments.value==""){alert("Geef je reactie a.u.b.");document.forms.auth.comments.focus();return false;}}
	if (document.forms.auth.VerzNaam){if (document.forms.auth.VerzNaam.value==""){alert("Geef de naam a.u.b.");document.forms.auth.VerzNaam.focus();return false;}}
	if (document.forms.auth.VerzAdres){if (document.forms.auth.VerzAdres.value==""){alert("Geef je adres a.u.b.");document.forms.auth.VerzAdres.focus();return false;}}
	if (document.forms.auth.VerzNummer){if (document.forms.auth.VerzNummer.value==""){alert("Geef je huisnummer a.u.b.");document.forms.auth.VerzNummer.focus();return false;}}
	if (document.forms.auth.VerzPostcode){if (document.forms.auth.VerzPostcode.value==""){alert("Geef je postcode a.u.b.");document.forms.auth.VerzPostcode.focus();return false;}}
	if (document.forms.auth.VerzWoonplaats){if (document.forms.auth.VerzWoonplaats.value==""){alert("Geef je Woonplaats a.u.b.");document.forms.auth.VerzWoonplaats.focus();return false;}}
	if (document.forms.auth.Huisnummer){if(!/^\d*$/.test(window.auth.Huisnummer.value)||window.auth.Huisnummer.value==-1){alert("Huisnummer zonder toevoeging vermelden a.u.b.");document.forms.auth.Huisnummer.focus();return false;}}
	if (document.forms.auth.VerzNummer){if(!/^\d*$/.test(window.auth.VerzNummer.value)||window.auth.VerzNummer.value==-1){alert("Huisnummer zonder toevoeging vermelden a.u.b.");document.forms.auth.VerzNummer.focus();return false;}}
	return true
}

function Prev()
{	document.cookie = "tekst=" + escape(document.tf.mt.value);popup('preview.asp','voorbeeld','550','400','yes','yes')
}

function loadpg(url)
{	self.opener.location = url;
}

function CheckMail() {
	if (document.tf.mt.value=="")
	{	alert("Je hebt geen bericht ingetoetst.");
		document.tf.mt.focus();
		return false;
	}
	if (document.tf.mt.value.length > 3500)
	{	alert("Sorry, De maximale lengte van een bericht is 3000 karakters.");
		document.tf.mt.focus();
		return false;
	}
	document.tf.submit.disabled = true;
	return true
}

function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    document.getElementById('result').innerHTML = '<img align=top src="/webshop/img/ldicn.gif" alt=""> Actuele voorraad importeur wordt opgevraagd...';
    self.xmlHttpReq.open('GET', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(null);
}

function updatepage(str){
    var currentTime = new Date();
    var DateString = null;
    var Maand = currentTime.getMonth() + 1;
    DateString = ' (' + currentTime.getDate() + '-' + Maand + '-' + currentTime.getFullYear() + ')';
    document.getElementById('result').innerHTML = '<img align=top src="/webshop/img/ldicn2.gif" alt="Actuele voorraadgegevens"> ' + str;
    if (str.indexOf("werkdagen") > 0) {
    	document.getElementById('vimp').innerHTML = 'Ja' + DateString;
    }
    else if (str.indexOf("opgevraagd") > 0) {
    	document.getElementById('vimp').innerHTML = '-' + DateString;
    }
    else {
    	document.getElementById('vimp').innerHTML = 'Nee' + DateString;
	}
}

function del(replyid)
{	if(confirm("Weet je zeker dat je dit bericht wilt verwijderen?"))
	{	location='/forum/inc/delete.asp?i=' + replyid
	}
};
