// Open edit content
function openEditContent (id) {
	
	width = 550;
	height = 450;
	
	var popurl = 'editcontent.php?ckey=' + id;
	
	var winl = (screen.width - width) / 2;
    var wint = (screen.height - height) / 2;
	
	winpops=window.open(popurl,"","width=" + width + ",height=" + height + ",left=" + winl + ",top=" + wint + ", resizable=yes")
	
	winpops.focus();
}

// Content mouseover
function setCMS_ContentMO (id, oo) {
	
	// Check if over or out
	if (oo) {
		
		// Over
		document.getElementById(id).style.backgroundColor = '#FBEDBB';		
		document.getElementById(id).style.border = '2px solid #F2C019';		
		document.getElementById(id).style.padding = '10px';		
		
	} else {
		
		// Out
		document.getElementById(id).style.backgroundColor = '#FFFFFF';		
		document.getElementById(id).style.border = '2px solid #F2C019';		
		document.getElementById(id).style.padding = '10px';		
		
	}
	
}

// Log out
function logout () {

	// Get current url
	url = self.location;
	url = String(url);
	
	// A #?
	a = url.indexOf('#');
	if (a > 0) {
		url = url.substr(0, a);
	}
	
	// Already a ?
	if (url.indexOf('?') > 0) {
		url = url + '&logout=yes';
	} else {
		url = url + '?logout=yes';
	}
	self.location = url;
	
}

// Keep on top!
function ontop() {
   if (document.layers) {
        document.layers['cms_ontop'].pageY = window.pageYOffset;
		document.layers['cms_ontop2'].pageY = window.pageYOffset;
    }
    else if (document.all) {
	    document.all['cms_ontop'].style.position = 'absolute';
        document.all['cms_ontop'].style.top = document.body.scrollTop;
		document.all['cms_ontop2'].style.position = 'absolute';
        document.all['cms_ontop2'].style.left =  document.body.scrollWidth / 2 + 370;
		document.all['cms_ontop2'].style.top = document.body.scrollTop;
    } else {
		document.getElementById('cms_ontop2').style.position = 'fixed';
        document.getElementById('cms_ontop2').style.left =  document.body.scrollWidth / 2 + 370;
		
	}
	
    setTimeout('ontop()',100);
}


// Popup function
function popup (url, width, height) {
	var popurl=url;
	
	var winl = (screen.width - width) / 2;
    var wint = (screen.height - height) / 2;
	
	winpops=window.open(popurl,"","width=" + width + ",height=" + height + ",left=" + winl + ",top=" + wint)
	
	winpops.focus();
}
	
function swap(img){
	cursrc = img.src;
	
	overpos = cursrc.indexOf("_h.gif");
	normpos = cursrc.indexOf("_n.gif");
	
	if (normpos != -1) {
		//replace image
		begin = cursrc.substr(0,normpos)
		newsrc = begin + "_h.gif";
		img.src = newsrc;
	}
	
	if (overpos != -1) {
		//replace image
		begin = cursrc.substr(0,overpos)
		newsrc = begin + "_n.gif";
		img.src = newsrc;
	}		
}

		submitted = false;
		
		
			
		function echeck(str) {

			var at="@";
			var dot=".";
			var lat=str.indexOf(at);
			var lstr=str.length;
			var ldot=str.indexOf(dot);
			if (str.indexOf(at)==-1){
			  // alert("Invalid E-mail ID")
			   return false;
			}
	
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			  //alert("Invalid E-mail ID")
			   return false;
			}
	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			    //alert("Invalid E-mail ID")
			    return false;
			}
	
			 if (str.indexOf(at,(lat+1))!=-1){
			    //alert("Invalid E-mail ID")
			    return false;
			 }
	
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			   // alert("Invalid E-mail ID")
			    return false;
			 }
	
			 if (str.indexOf(dot,(lat+2))==-1){
			    //alert("Invalid E-mail ID")
			    return false;
			 }
			
			 if (str.indexOf(" ")!=-1){
			   // alert("Invalid E-mail ID")
			    return false;
			 }
	
	 		 return true		;			
		}
		
		
		/*function checkFields(form){		
			var verpl = new Array();
			var geslachtOk = false;
			var x = 0;
			if (form.voornaam.value.length <= 0){
				verpl[x] = "voornaam";
				x++;
			}
			if (form.achternaam.value.length <= 0){
				verpl[x] = "achternaam";
				x++;
			}
			for (i=0;i<form.geslacht.length;i++){
				if (form.geslacht[i].checked){
					geslachtOk = true;
				}
			}
			if (geslachtOk != true){
				verpl[x] = "geslacht";
				x++;
			}			
			if (form.adres.value.length <= 0){
				verpl[x] = "adres";
				x++;
			}
			if (form.postcode.value.length <= 0){
				verpl[x] = "postcode";
				x++;
			}
			if (form.woonplaats.value.length <= 0){
				verpl[x] = "woonplaats";
				x++;
			}
			if (form.email.value.length <= 0){
				verpl[x] = "e-mail";
				x++;
			}
			if (form.telefoon.value.length <= 0){
				verpl[x] = "telefoon overdag";
				x++;
			}
		
			// Valid e-mail adres?
			if (form.email.value.length > 0) { 
			
				if (echeck (form.email.value) != true) {
				
					verpl[x] = "een geldig email adres";
					x++;
				
				}			
			}
		
			if (x > 0){
				var tekst = "Vul a.u.b. de volgende velden in\n\n";
				for (i = 0;i < x; i++){
					tekst = tekst + "* " +  verpl[i] + "\n";								
				}
				alert(tekst);
			} else {		
				if (form.algemenevoorwaarden.checked){
					if (submitted != true) {			
						form.submit();	
						submitted = true;
						popup('bedankt.html',300,200);						
					}  else {					
						alert ("Het systeem verwerkt uw gegevens.\n\nEen moment geduld a.u.b.");					
					}					
				} else {
					alert("U moet accoord gaan met de actievoorwaarden voordat u zich kan aanmelden");
				}
			}
		}*/
