/////////////////////////////////////////////////////////////
////
////	JavaScript Copyrighted By Seoptics
////			www.seoptics.com
////
/////////////////////////////////////////////////////////////

function doSort(sSort,sOrder) {
	document.forms.order.sSort.value = sSort;
	document.forms.order.sOrder.value = sOrder;
	document.forms.order.submit();
}
function bookmarksite(title, url){
if (document.all)
	window.external.AddFavorite(url, title);
else if (window.sidebar)
	window.sidebar.addPanel(title, url, "")
}

window.defaultStatus='Calorielijst.nl - De grootste caloriedatabase van Nederland!';

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

// menu script //

/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

// Home
var menu1=new Array()
menu1[0]='<a href="http://'+window.location.hostname+'">Calorielijst</a>'
menu1[1]='<a href="http://'+window.location.hostname+'/per-portie">Calorielijst per portie</a>'
menu1[2]='<a href="http://'+window.location.hostname+'/calorieen-zoeken">Producten zoeken</a>'
menu1[3]='<a href="/product/toevoegen">Product toevoegen </a>'
menu1[4]='<a href="http://'+window.location.hostname+'/hoeveelheid_energie">Energieschema</a>'
menu1[5]='<a href="http://'+window.location.hostname+'/calorieen-teller">Calorieen Zoeker</a>'
menu1[6]='<a href="http://'+window.location.hostname+'/links">Calorie Links</a>'
menu1[7]='<a href="http://'+window.location.hostname+'/e-nummers">E-nummers</a>'
menu1[8]='<a href="http://'+window.location.hostname+'/contact">Contact / Linkruil</a>'
menu1[9]='<a href="http://'+window.location.hostname+'/disclaimer">Disclaimer</a>'
menu1[10]='<a href="http://'+window.location.hostname+'/polls">Polls</a>'
menu1[11]='<a href="/gastenboek">Gastenboek</a>'

// calculators
var menu2=new Array()
menu2[0]='<a href="http://'+window.location.hostname+'/calculators/bmi">Body Mass Index</a>'
menu2[1]='<a href="http://'+window.location.hostname+'/calculators/calorieverbruik">Calorieverbruik</a>'
menu2[2]='<a href="http://'+window.location.hostname+'/calculators/ruststofwisseling">Ruststofwisseling</a>'
menu2[3]='<a href="http://'+window.location.hostname+'/calculators/energiebehoefte">Energiebehoefte</a>'
menu2[4]='<a href="http://'+window.location.hostname+'/calculators/vetpercentage">Vetpercentage</a>'

// Dieetnieuws
var menu3=new Array()
menu3[0]='<a href="http://'+window.location.hostname+'/dieetnieuws/archief">Archief</a>'
menu3[1]='<a href="http://'+window.location.hostname+'/dieetnieuws/rss/index.xml">RSS</a>'

// Caloriearme recepten
var menu4=new Array()
menu4[0]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=2">Atkins Dieet</a>'
menu4[1]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=12">Balans Slankclub</a>'
menu4[2]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=11">Bea\'s Afslankmeth.</a>'
menu4[3]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=8">Calorie Arm</a>'
menu4[4]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=13">Cholesterolverlagend</a>'
menu4[5]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=6">EGA</a>'
menu4[6]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=10">Glutenvrij</a>'
menu4[7]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=7">Koolhydraat Arm</a>'
menu4[8]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=4">Libelle Dieet</a>'
menu4[9]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=5">Methode Montignac</a>'
menu4[10]='<a href="http://'+window.location.hostname+'/afslank_recepten/?dieetgroep=1">Sonja Bakker Dieet</a>'

// Dieten
var menu5=new Array()
menu5[0]='<a href="/dieten/?id=11">Afslank kleding</a>'
menu5[1]='<a href="/dieten/?id=10">Allergieën en ziekten</a>'
menu5[2]='<a href="/dieten/?id=1">Caloriearme diëten</a>'
menu5[3]='<a href="/dieten/?id=12">Dieet hulpmiddelen</a>'
menu5[4]='<a href="/dieten/?id=5">Eetgewoontes</a>'
menu5[5]='<a href="/dieten/?id=6">Eiwitrijke diëten</a>'
menu5[6]='<a href="/dieten/?id=7">Koolhydraat diëten</a>'
menu5[7]='<a href="/dieten/?id=2">Maaltijdvervangers</a>'
menu5[8]='<a href="/dieten/?id=3">Medisch afvallen</a>'
menu5[9]='<a href="/dieten/?id=4">Pillen en tabletten</a>'
menu5[10]='<a href="/dieten/?id=8">Vasten en ontgiften</a>'
menu5[11]='<a href="/dieten/?id=9">Vetarme diëten</a>'

// Webshop
var menu6=new Array()
menu6[0]='<a href="/webshop/calorie_boeken">Gezondheidsboeken</a>'
menu6[1]='<a href="/webshop/fitness_dvds">Fitness DVD\'s</a>'
menu6[2]='<a href="/webshop/artikelen">Artikelen</a>'

var menuwidth='150px' //default menu width
var menubgcolor='' //menu bgcolor
var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}

function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu


function imeel(name,text,domain)
{
   var address = name + "\u0040" + domain + '?subject=' + text;
   var url = "mailto:" + address;
   if(!text)
   {
      text = address;
   }
   document.write("<a href=\"" + url + "\"><img src='/_lib/img/icons/icon_email.gif' class='icon' border='0' alt='Email deze persoon' /></a>");
}
var message="&copy; Calorielijst.nl"; 
function clickIE() {if (document.all) {(message);return false;}} 
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) { 
if (e.which==2||e.which==3) {(message);return false;}}} 
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;} 
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;} 
document.oncontextmenu=new Function("return false") 

var omitformtags=["input", "textarea", "select"]

function disableselect(e){
for (i = 0; i < omitformtags.length; i++)
if (omitformtags[i]==(e.target.tagName.toLowerCase()))
return;
return false
}

function reEnable(){
return true
}

function noSelect(){
if (typeof document.onselectstart!="undefined"){
document.onselectstart=new Function ("return false")
if (document.getElementsByTagName){
tags=document.getElementsByTagName('*')
for (j = 0; j < tags.length; j++){
for (i = 0; i < omitformtags.length; i++)
if (tags[j].tagName.toLowerCase()==omitformtags[i]){
tags[j].onselectstart=function(){
document.onselectstart=new Function ('return true')
}
tags[j].onmouseup=function(){
document.onselectstart=new Function ('return false')
}
}
}
}
}
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
}

function MakeArrayday(size)
{
	this.length = size;
	for(var i = 1; i <= size; i++)
	{
		this[i] = "";
	}
	return this;
}
function MakeArraymonth(size)
{
	this.length = size;
	for(var i = 1; i <= size; i++)
	{
		this[i] = "";
	}
	return this;
}
function Clock()
{
	var runTime = new Date(); 
	var hours = runTime.getHours(); 
	var minutes = runTime.getMinutes(); 
	var seconds = runTime.getSeconds(); 

	if (minutes <= 9)
	{ 
		minutes = "0" + minutes; 
	} 
	if (seconds <= 9)
	{ 
		seconds = "0" + seconds; 
	} 
	movingtime = hours + ":" + minutes + ":" + seconds; 
	document.getElementById("clock").innerHTML = movingtime;
	setTimeout("Clock()", 1000);
}
window.onload=function() {
Clock();
noSelect();
}
function doProdAdd() {
	var sError		= "";
	var f			= document.getElementById('form_prodadd');
	var prodname	= f.prodname.value;
	var merk		= f.merk.value;
	var eenheid		= f.eenheid.value;
	var groep		= f.groep.value;
	var kcal		= f.kcal.value;
	var kjoule		= f.kjoule.value;
	var eiwit		= f.eiwit.value;
	var koolh		= f.koolh.value;
	var vet			= f.vet.value;
	
	if(prodname == ""){sError = sError + "U hebt geen productnaam ingevuld\n";}
	if(prodname == ""){sError = sError + "U hebt geen merk ingevuld\n";}
	if(eenheid == "-1"){sError = sError + "U hebt geen eenheid gekozen\n";}
	if(groep == "-1"){sError = sError + "U hebt geen productgroep gekozen\n";}
	if(kcal == ""){sError = sError + "Aantal kcal is niet ingevuld\n";}
	if(kjoule == ""){sError = sError + "Aantal kjoule is niet ingevuld\n";}
	if(eiwit == ""){sError = sError + "Hoeveelheid eiwit is niet ingevuld\n";}
	if(koolh == ""){sError = sError + "Hoeveelheid koolhydraten is niet ingevuld\n";}
	if(vet == ""){sError = sError + "Hoeveelheid vet is niet ingevuld\n";}
	
	if(sError == "") {
		f.action = "process.asp";
		f.target = "iSubmit";
		f.submit();
	}else{
		alert(sError);
	}
}
function sethtml(div,content) 
{	
	var search = content; 
	var script; 
	
	while( script = search.match(/(<script[^>]+text\/javascript[^>]+>\s*(<!--)?)/i)) 
	{ 
		search = search.substr(search.indexOf(RegExp.$1) + RegExp.$1.length);
		if (!(endscript = search.match(/((-->)?\s*<\/script>)/))) break; 

		block = search.substr(0, search.indexOf(RegExp.$1)); 
		search = search.substring(block.length + RegExp.$1.length); 

		var oScript = document.createElement('script'); 
		oScript.text = block; 
		document.getElementsByTagName("head").item(0).appendChild(oScript); 
	}
	//content = content.replace(/\n/g, '\\n'); 
	document.getElementById(div).innerHTML=content;
}
