// JavaScript Document
var numb      = "0123456789";
var phone     = "- ()"+numb;
var price     = ",.-"+numb;
var capitals  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var undercast = "abcdefghijklmnopqrstuvwxyz";
var alphabet  = capitals+undercast;
var numbalphabet = alphabet+numb;

function restrictKeys(t,v){
	var w = "";
	for (i=0; i < t.value.length; i++) {
		x = t.value.charAt(i);
		if (v.indexOf(x,0) != -1)
			w += x;
	}
	t.value = w;
}

function sendpopupOpen(tobj){
  popobj=document.getElementById('sendpopup');
  popobj.style.display='block';
  popobj.style.left=(findPosX(tobj)-10) + 'px'
  popobj.style.top=(findPosY(tobj) - popobj.offsetHeight) + 'px';
}
function reactionpopupOpen(tobj,objopen){
  popobj=document.getElementById(objopen);
  popobj.style.display='block';
  popobj.style.left=(findPosX(tobj)-10) + 'px'
  popobj.style.top=(findPosY(tobj) - popobj.offsetHeight) + 'px';
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function orderconfirm(){
	show('orderpopup');
	if(document.body.offsetHeight < screen.height){
	  theight=	screen.height;
	}
	else{
	  theight=document.body.offsetHeight;
	}
	document.getElementById('orderpopup').style.top = ((theight / 2) - document.getElementById('orderpopup').offsetHeight) + 'px';
	document.getElementById('orderpopup').style.left= ''+ (document.body.clientWidth /2 -(document.getElementById('orderpopup').offsetWidth/2)) +'px';
    return false;
}

function zipcheckpopup(addobj,subID){
	show('zipcheckdialog');
	show('dialogfade');
	if(document.body.offsetHeight < screen.height){
	  theight=	screen.height;
	}
	else{
	  theight=	document.body.offsetHeight;
	  
	}
	//alert(window.innerWidth);
	document.getElementById('popsubscriptionID').value=subID;
	document.getElementById('dialogfade').style.height =theight+ 'px';
	document.getElementById('zipcheckdialog').style.top = (findPosY(addobj) - document.getElementById('zipcheckdialog').offsetHeight) + 'px';
	document.getElementById('zipcheckdialog').style.left= ''+ (document.body.clientWidth /2 -(document.getElementById('zipcheckdialog').offsetWidth/2)) +'px';
    return false;
}

function zipcheckpopup2(addobj,kindID){
	show('zipcheckdialog2');
	show('dialogfade');
	if(document.body.offsetHeight < screen.height){
	  theight=	screen.height;
	}
	else{
	  theight=	document.body.offsetHeight;
	  
	}
	//alert(window.innerWidth);
	document.getElementById('popkindID').value=kindID;
	document.getElementById('dialogfade').style.height =theight+ 'px';
	document.getElementById('zipcheckdialog2').style.top = (findPosY(addobj) - document.getElementById('zipcheckdialog2').offsetHeight) + 'px';
	document.getElementById('zipcheckdialog2').style.left= ''+ (document.body.clientWidth /2 -(document.getElementById('zipcheckdialog2').offsetWidth/2)) +'px';
    return false;
}

function hide(id) {
   obj = document.getElementsByTagName("div");
   obj[id].style.display = 'none';
}

function show(id) {
    obj = document.getElementsByTagName("div");
    obj[id].style.display = 'block';
}

function showhide(id){
  obj = document.getElementsByTagName("div");
  if(obj[id].style.display=='block'){
    hide(id);
  }
  else{
    show(id);
  }
}

var tab = 'omschrijving';

function changeimage(id){
	if(id != tab){
		document.getElementById(tab+'tab').style.backgroundImage='url(images/tab.jpg)';
		document.getElementById(id+'tab').style.backgroundImage='url(images/tabclicked.jpg)';
		document.getElementById(tab).style.display='none';
		document.getElementById(id).style.display='block';
	}
	tab = id;
}

function openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function getscore(num){
	//imgobj=document.getElementsByTagName("img");
	document.getElementById('score').value=num;
	for(var i=1; i <= 5; i++){
		if(i<=num){
		  document.getElementById('star' + i).src='images/sterdonker.gif';
		}
		else{
		  document.getElementById('star' + i).src='images/sterlicht.gif';
		}
	}
}
function getscore2(num){
	//imgobj=document.getElementsByTagName("img");
	document.getElementById('score2').value=num;
	for(var i=1; i <= 5; i++){
		if(i<=num){
		  document.getElementById('star2' + i).src='images/sterdonker.gif';
		}
		else{
		  document.getElementById('star2' + i).src='images/sterlicht.gif';
		}
	}
}

function nextfield(field,upfield,xchar){
	if(upfield!=""){
		if(field.value.length == xchar){
			document.getElementById(upfield).focus();
		}
	}
}

function checkForumPost(theForm){
	if(!validRequired(theForm.iposttitle,'titel'))
	  return false;
	if(!validRequired(theForm.ipostname,'naam'))
	  return false;
	if(!validEmail(theForm.ipostemail,true))
	  return false;
	if(!validRequired(theForm.igenstring,'controle'))
	  return false;
	  
	return true;
}

function checkForumReaction(theForm){
	if(!validRequired(theForm.ipostname,'naam'))
	  return false;
	if(!validEmail(theForm.ipostemail,true))
	  return false;
	if(!validRequired(theForm.igenstring,'controle'))
	  return false;
	  
	return true;
}

function checkZipcheck(theForm){
	
	if(!validRequired(theForm.icheckzipnum,'postcode'))
	  return false;
	if(!validRequired(theForm.icheckzipchar,'letters'))
	  return false;
	if(!validRequired(theForm.icheckhousenr,'nummer'))
	  return false;
	  
	return true;
}

function openreviewdiv(tobj,cobj){
  popobj=document.getElementById(cobj);
  popobj.style.display='block';
  popobj.style.left=(findPosX(tobj) + 5) + 'px'
  popobj.style.top=(findPosY(tobj) + 23) + 'px';
}