//---- pop up scherm ---//

function showHide(name) {
    var eTxt = document.getElementById( 'div'+name );
    var eHead = document.getElementById( 'head'+name );
    
    //if( eTxt.style.position == 'relative' )
    if(eTxt.className=="noHide")
    {
        //eTxt.style.position = 'absolute';
        //eTxt.style.left = '-4000px';
        eTxt.className="hide";
        eHead.className="hide";
    }
    else
    {
        //eTxt.style.position = 'relative';
        //eTxt.style.left = '0px';
        eTxt.className="noHide";
        eHead.className="noHide";
    }
  }



  function showObject(name, text) {
    document.getElementById("popTxt").innerHTML = text;
    document.getElementById("popHead").innerHTML = name;
    showPopUp();
  }

  function showPopUp() {
    var arrayPageScroll = document.viewport.getScrollOffsets();
    var lightboxTop = arrayPageScroll[1];
    var arrayPageSize = getPageSize();
    var pHeight = arrayPageSize[1];
    var ieHeight = document.getElementById("mMidden").offsetHeight + document.getElementById("mBoven").offsetHeight + document.getElementById("mOnder").offsetHeight;;
    var ol = document.getElementById("overlay");
    var popUp = document.getElementById("popDiv");
    
    if (ieHeight > pHeight) { //IE7 hack
      pHeight = ieHeight; 
      arrayPageSize[0] = arrayPageSize[0] + 20;
    }

    
    ol.style.width = arrayPageSize[0] + "px";
    ol.style.height = pHeight + "px";
    new Effect.Appear(ol, { duration: 0.2, from: 0.0, to: 0.8 });
    ol.style.visibility = "visible";

    popUp.style.visibility = "visible";
    popUp.style.left = (arrayPageSize[0]/2)-200 + "px";
    popUp.style.top = lightboxTop +200+ "px";
  }

  function hidePopUp() {
    document.getElementById("overlay").style.display = "none";
    document.getElementById("popDiv").style.visibility = "hidden";
    document.getElementById("savePopButton").style.visibility = "hidden";
  }

  function createElement(text) {
    var el = document.createElement("div");
    el.innerHTML = text;

    var dest = document.getElementById("popDiv");
    dest.appendChild(el);
  }

  function setPopUpValues(text) {
    document.getElementById("popDiv");
  }
  
 
  function getPageSize() {
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}

function validateField(type, el, name) {
  tmpVar = 'fieldCheck.php?type=' + type + '&value=' + el.value + '&element=' + name;
  new Ajax.Updater('resdiv', tmpVar, {asynchronous:true});
}

//Als je deze functie aanpast, wijzig dan ook de php versie in forms.php
function formTypeToText(id){
  val = "";
  switch(id)
  {
    case "1":
      val = "Tekst met opmaak";
    break;

    case "2":
      val = "Label";
    break;

    case "3":
      val = "BoldLabel";
    break;

    case "10":
      val = "Checkbox";
    break;

    case "11":
      val = "Radiobutton";
    break;

    case "12":
      val = "Textarea";
    break;
  }
  return val;
}

