var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
     if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, "popUpWin",
  "toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+width+",height="+height+",left="+left+", top="+top+",screenX="+left+",screenY="+top);
}

function popupimage(plaatje,width,height){
	window.open('/images/img_popup.php?img_url='+plaatje,'Image','width='+width+',height='+height+',scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,screenX=120,screenY=100');
	return false;
}


function checkAnswers(){
	for (var i=0; i<allQuestions.length; i++){
		if(typeof(allQuestions[i])!='undefined'){
    		if(allQuestions[i]==false){
				alert('U heeft een of meerdere antwoorden vergeten in te vullen!');
				return false;
			}
		}
	}
}

function setQuestionDone(qnum,answer,qid){
	allQuestions[qnum]=true;
	
	
	if(readCookie('Questions')!=null && readCookie('Questions').length>0){
		var theQs=readCookie('Questions').split("_");
		// Now collapse the items that where collapsed...
	} else {
		var theQs=new Array();
	}
	theQs[theQs.length]=qid+'|'+answer;
	var cookieString=theQs.join("_");
	makeCookie('Questions',cookieString,31,'/');
}

function makeCookie(Name,Value,Expiry,Path,Domain,Secure) {
	if (Expiry != null) {
		var datenow = new Date();
		   //get a date
		datenow.setTime(datenow.getTime() + Math.round(86400000*Expiry));
		   //mutiply the number to make it represent days
		Expiry = datenow.toGMTString();
		   //convert to GMT time
	}

	Expiry = (Expiry != null) ? '; expires='+Expiry : '';
	   //has an expiration?
	Path = (Path != null)?'; path='+Path:'';
	   //has a path?
	Domain = (Domain != null) ? '; domain='+Domain : '';
	   //has a domain?
	Secure = (Secure != null) ? '; secure' : '';
	   //Secure?
	document.cookie = Name + '=' + escape(Value) + Expiry + Path + Domain + Secure;
	   //Make the cookie!
}

function readCookie(Name) {
	var cookies = document.cookie;
	   //Copy your cookies
	if (cookies.indexOf(Name + '=') == -1) return null;
	   //Woops, no cookie!
	var start = cookies.indexOf(Name + '=') + (Name.length + 1);
	   //Jump to start of cookie
	var finish = cookies.substring(start,cookies.length);
	   //Get a count from the cookies
	finish = (finish.indexOf(';') == -1) ? cookies.length : start + finish.indexOf(';');
	   //Find end of cookie
	return unescape(cookies.substring(start,finish));
	   //Here's your cookie! ( Sorry, no chocolate chips. :-)
}

function navRequest(theCaller){
	var seen=theCaller.options[theCaller.selectedIndex].getAttribute('seen');
	if(seen=='seen'){
		// Value is allowed do nothing.
	} else {
		// Go back to the last seen option.
		for(var i=theCaller.options.length-1;i>-1;i--){
			if(theCaller.options[i].getAttribute('seen')=='seen'){
				theCaller.selectedIndex=i;
				break;
			}
		}
	}
}

function doNavigate(){
	var theSel=document.getElementById('navselect');
	window.location.href=theSel.options[theSel.selectedIndex].value;
}



window.addEvent('domready', formFieldCaptions);

function formFieldCaptions(){
	$$('#email','#password','#searchtext').each(function(theEl){
			theEl.addEvents({
						 'focus' : checkCaptionStatus,
						 'blur'  : checkCaptionStatus,
						 'change': checkCaptionStatus
						 });
			theEl.fireEvent('blur');
	});
}

function checkCaptionStatus(e){
	if(e && e.type=='focus'){
		this.removeClass('showcaption');
	} else {
		if(this.value==''){
			this.addClass('showcaption');
		} else {
			this.removeClass('showcaption');
		}
	}
}







