		if (top == self) 
		{
			var host = "http://www.soloklasse.nl";
			var loc = top.location.href.toString().toLowerCase();
						
			var hostlen = host.length;
			var loclen = loc.length;
			
					
			if (loclen > hostlen)
			{
				var testhost = loc.substr(0,hostlen);
				
				if (testhost == host)
					loc = top.location.href.toString().substr(hostlen + 1, loclen - hostlen);
			}
			
			self.location.href = "index.php?content=" + escape(loc);
		}

		var slideNr = 0;
		var buttonClicked = false;
		
		function startSlideShow()
		{
			nextSlide();
			window.setInterval(nextSlide,10000); 	
		}
		
		function callback() 
		{
			if (req.readyState == 4) 
				if (req.status == 200)
				{
					var url = req.responseXML.getElementsByTagName("url")[0];
					var image = document.getElementById("image");
					image.src = url.childNodes[0].nodeValue;
				}

		}
		
		function nextSlide()
		{
			if (window.XMLHttpRequest) 
			{
				req = new XMLHttpRequest();
			} else 
				if (window.ActiveXObject) 
				{
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
			
			slideNr = Math.floor(Math.random()*1000); //++;
			url = "fotoWebservice.php?slide=" + slideNr;
			req.open("GET", url, true);
			req.onreadystatechange = callback;
			req.send(null);
		}
		
		function submitForm1() 
		{
			document.frm.action.value=1;
      document.frm.submit();
		}
		
		function submitForm2(mode) 
		{
            if (document.frm.description != null)
            {
  						var s = document.frm.description.value;  						
  													
							if (s.length < 1)
              {
              	alert('Er is geen onderwerp ingevuld');
              	resetButton();
              	return;
              }
              
							for (i = 0; i < s.length; i++)
								if ((s.charCodeAt(i) == 34) || (s.charCodeAt(i) == 39))
								{
              	  alert("Enkele (') en dubbele (\") aanhalingstekens zijn niet toegestaan in het onderwerp");
              	  resetButton();
              		return 
             		}
            }
						
						if (document.frm.message != null)
  						if (document.frm.message.value.length < 1)
              {
              	alert('Er is geen bericht ingevuld');
              	resetButton();
              	return;
              }
            
				document.frm.mode.value = mode;
				document.frm.action.value=1;
        document.frm.submit();
		}
		
		function submitForm3(mode) 
		{
		  document.frm.mode.value = mode;
			document.frm.action.value=1;
      document.frm.submit();
		}
		
		function insert(icon)
		{
			var txtarea = document.forms.frm.message;
			var  text = '[icon]' + icon + '[/icon]';
			replaceText(text, txtarea);
		}
		
		function storeCaret(textEl) 
		{
			if (textEl.createTextRange) 
				textEl.caretPos = document.selection.createRange().duplicate();
		}
		
		function setBackground(object,color)
		{
			object.style.backgroundColor = color;
		}
		
		function resizeImage()
		{
			var image = document.getElementById('image');
			if (image.width > (document.body.clientWidth - 40))
				image.width = document.body.clientWidth - 40;
		}
		
		function insertText(type, obj, text)
		{
			if (type == 'textarea')
			{
				var txtarea = document.getElementById(obj);
				if (txtarea.createTextRange && txtarea.caretPos) 
				{
					var caretPos = txtarea.caretPos;
					caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
					txtarea.focus();
				} else {
					txtarea.value  += text;
					txtarea.focus();
				}
			}
			
			if (type == 'textedit')
			{
				document.getElementById(obj).value = text;
			}
		}
		
		function insertUrl(linkOrUrl, format, objType, obj, description)
		{
			var myWidth = 0, myHeight = 0;
  		if( typeof( window.innerWidth ) == 'number' ) 
  		{
    		//Non-IE
    		myWidth = window.innerWidth;
    		myHeight = window.innerHeight;
  		} else 
  			if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  			{
    			//IE 6+ in 'standards compliant mode'
   	 			myWidth = document.documentElement.clientWidth;
   	 			myHeight = document.documentElement.clientHeight;
  			} else 
  				if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  				{
    				//IE 4 compatible
    				myWidth = document.body.clientWidth;
    				myHeight = document.body.clientHeight;
  				}
  				
  		var popupWidth = 330;
  		var popupHeight = linkOrUrl == 'link' ? 340 : 260;
  		var popupLeft = (myWidth - popupWidth + 150) / 2;
  		var popupTop = (myHeight - popupHeight) / 2;
  		
  		var config = 'scrollbars=no,resizable=no';
  		config += ',width=' + popupWidth;
  		config += ',height=' + popupHeight;
  		config += ',left=' + popupLeft;
  		config += ',top=' + popupTop;
 		
			var URL = 'adminInsertUrl.php?objtype=' + objType + '&object=' + obj + '&format=' + format + '&linkorurl=' + linkOrUrl + '&description=' + description; 
			
			window.open(URL,'',config);	
		}
		
		function insertResult()
		{
			openUrlInWindow('adminInsertRegResult.php', 330, 100);
		}
		
		function openUrlInWindow(URL, windowWidth, windowHeight)
		{
			var myWidth = 0, myHeight = 0;

  		if( typeof( window.innerWidth ) == 'number' ) 
  		{
    		//Non-IE
    		myWidth = window.innerWidth;
    		myHeight = window.innerHeight;
  		} else 
  			if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  			{
    			//IE 6+ in 'standards compliant mode'
   	 			myWidth = document.documentElement.clientWidth;
   	 			myHeight = document.documentElement.clientHeight;
  			} else 
  				if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  				{
    				//IE 4 compatible
    				myWidth = document.body.clientWidth;
    				myHeight = document.body.clientHeight;
  				}

  		var popupWidth = windowWidth;
  		var popupHeight = windowHeight;
  		var popupLeft = (myWidth - popupWidth + 150) / 2;
  		var popupTop = (myHeight - popupHeight) / 2;
  		
  		var config = 'scrollbars=no,resizable=no';
  		config += ',width=' + popupWidth;
  		config += ',height=' + popupHeight;
  		config += ',left=' + popupLeft;
  		config += ',top=' + popupTop;

			window.open(URL,'',config);	
		}
		
		function clickButton(URL)
		{
			if (buttonClicked == true)
				return;
			
			buttonClicked = true;
			
			document.location = URL;
		}
		
		function resetButton()
		{
			buttonClicked = false;
		}
		
		// Surrounds the selected text with text1 and text2.
		function surroundText(text1, text2, textarea)
		{
			// Can a text range be created?
			if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
			{
				var caretPos = textarea.caretPos, temp_length = caretPos.text.length;
		
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
		
				if (temp_length == 0)
				{
					caretPos.moveStart("character", -text2.length);
					caretPos.moveEnd("character", -text2.length);
					caretPos.select();
				}
				else
					textarea.focus(caretPos);
			}
			// Mozilla text range wrap.
			else if (typeof(textarea.selectionStart) != "undefined")
			{
				var begin = textarea.value.substr(0, textarea.selectionStart);
				var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
				var end = textarea.value.substr(textarea.selectionEnd);
				var newCursorPos = textarea.selectionStart;
				var scrollPos = textarea.scrollTop;
		
				textarea.value = begin + text1 + selection + text2 + end;
		
				if (textarea.setSelectionRange)
				{
					if (selection.length == 0)
						textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
					else
						textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
					textarea.focus();
				}
				textarea.scrollTop = scrollPos;
			}
			// Just put them on the end, then.
			else
			{
				textarea.value += text1 + text2;
				textarea.focus(textarea.value.length - 1);
			}
		}
		
		function replaceText(text, textarea)
		{
			// Attempt to create a text range (IE).
			if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
			{
				var caretPos = textarea.caretPos;
		
				caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
				caretPos.select();
			}
			// Mozilla text range replace.
			else if (typeof(textarea.selectionStart) != "undefined")
			{
				var begin = textarea.value.substr(0, textarea.selectionStart);
				var end = textarea.value.substr(textarea.selectionEnd);
				var scrollPos = textarea.scrollTop;
		
				textarea.value = begin + text + end;
		
				if (textarea.setSelectionRange)
				{
					textarea.focus();
					textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
				}
				textarea.scrollTop = scrollPos;
			}
			// Just put it on the end.
			else
			{
				textarea.value += text;
				textarea.focus(textarea.value.length - 1);
			}
		}
		
		
		

