// <script type="text/javascript">

	var http = createRequestObject();

        function newWin(url,w,h) {
            var winl = (screen.width-w)/2;
            var wint = (screen.height-h)/2;
            var windowprops = "location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,name=testname" +
            ",left=" + winl + ",top=" + wint + ",width=" + w + ",height=" + h;
            var URL = url;
            popup = window.open(URL,"MenuPopup",windowprops);
        }
        function launchwin(url)
        {
        	//This launches a new window and then
			//focuses it if window.focus() is supported.
			newwin = window.open(winurl,'lyrics','scrollbars=yes,height=500,width=450,status=no, menubar=no');

			if(javascript_version > 1.0)
			{
				//delay a bit here because IE4 encounters errors
				//when trying to focus a recently opened window
				setTimeout('newwin.focus();',300);
			}
        }

        function launchurl(url) {
            top.location.href=url;
        }

        function MM_openBrWindow(theURL,winName,features) { //v2.0
            window.open(theURL,winName,features);
        }

		function newDynamicContentWindow(html,w,h)
		{
			var first = window.open("","window title","width="+w+",height="+h+",scrollbars=1,resizable=1");
			
			//variable name of window must be included for all three of the following methods so that
			//javascript knows not to write the string to this window, but instead to the new window
			first.document.open();
			first.document.write(html);
			first.document.close();
		}
		
		function previewNewsletter(id)
		{
            var url = "http://www.tierra.be/NewsletterPreview.php?id="+id;
            var windowprops = "scrollbars=yes,height=800,width=600,status=no, menubar=no";

            popup = window.open(url,"mywindow",windowprops);
            
			//alert('Test: klik op \'ok\'.');
			//var first = window.open("http://www.tierra.be/NewsletterPreview.php?id="+id,"Newsletter Preview",'scrollbars=yes,height=800,width=600,status=no, menubar=no');
			//first.document.open();
		}
		
        function closeMe(howLong){
            t = null;
            t = setTimeout('self.close()',howLong);
        }

        <!--
        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_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_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];}
        }

        function populateId(id,content)
        {
        	if(content != null && content !="")
        	{
        		id.innerHTML='<img src="../repository/thumbnails/'+content+'" class="blackborder">';
        		if(document.id.innerHTML)
        		{
        			document.id.innerHTML='<img src="repository/thumbnails/'+content+'" class=whiteborder>';
        		}
        		else
        		{
        			id.innerHTML='<img src="../repository/thumbnails/"'+content+'" class=whiteborder>';
        		}

        		/*
				//safe function to hide an element with a specified id
				if (document.getElementById) { // DOM3 = IE5, NS6
					document.getElementById(id).innerHTML=content;
				}
				else {
					if (document.layers) { // Netscape 4
						document.id.innerHTML=content;
					}
					else { // IE 4
						document.all.id.innerHTML=content;
					}
				}
				*/
				//document.all(id).innerHTML=content;

			}
			else
			{
				id.innerHTML='<img src="repository/thumbnails/noimage.gif" class="blackborder">';
				if(document.id.innerHTML)
        		{
        			document.id.innerHTML;//='<img src="repository/thumbnails/noimage.gif" class="whiteborder">';
        		}
        		else
        		{
        			id.innerHTML='<img src="../repository/thumbnails/noimage.gif" class="whiteborder">';
        		}
			}

        }
        
        
        function changeThumbnailColor(id,colorid)
        {
        	if(colorid != null && colorid !="")
        	{
        			// GET THE ACTUAL FILENAME
        			file = id.src.substring(id.src.lastIndexOf('/'), id.src.length);
        			// REPLACE THE  DIGITS
					newstring = file.replace(/[0-9][0-9][0-9]./,colorid+'.')
					// APPEND NEW FILENAME TO FIRST PART OF THE ORIGINAL SRC PATH
					id.src = id.src.substring(0,id.src.lastIndexOf('/')) + newstring
        	}        
        }
        

        function sendSelectedGallery()
        {
        	selectedId=document.galleryForm.galleryMenu.options[document.galleryForm.galleryMenu.selectedIndex].value;

        	launchurl(selectedId);
        }
        
        
        function showHideDisplay(tagid)
        {
			x=document.getElementById(tagid);
			if(x.style.display=="")
			{
				x.style.display="none";
			}
			else
			{
				x.style.display="";
			}
		}
		
		function showHide(element,classname)
		{
		// this function changes the 
		  anchorArray = document.getElementsByTagName(element);
		  for (i=0; i<anchorArray.length; i++)
		  {
			if(anchorArray.item(i).className == classname)
			{
				if(anchorArray.item(i).style.display=="")
				{
					anchorArray.item(i).style.display="none";
				}
				else
				{
					anchorArray.item(i).style.display="";
				}
			}
		  }
		}
		
		function MoveOption(objSourceElement, objTargetElement)
		{
			var aryTempSourceOptions = new Array();
			var x = 0;
			
			//looping through source element to find selected options
			for (var i = 0; i < objSourceElement.length; i++) {
				if (objSourceElement.options[i].selected) {
					//need to move this option to target element
					var intTargetLen = objTargetElement.length++;
					objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
					objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
				}
				else {
					//storing options that stay to recreate select element
					var objTempValues = new Object();
					objTempValues.text = objSourceElement.options[i].text;
					objTempValues.value = objSourceElement.options[i].value;
					aryTempSourceOptions[x] = objTempValues;
					x++;
				}
			}
			
			//resetting length of source
			objSourceElement.length = aryTempSourceOptions.length;
			//looping through temp array to recreate source select element
			for (var i = 0; i < aryTempSourceOptions.length; i++) {
				objSourceElement.options[i].text = aryTempSourceOptions[i].text;
				objSourceElement.options[i].value = aryTempSourceOptions[i].value;
				objSourceElement.options[i].selected = false;
			}
		}
		
		function CopyOption(objSourceElement, objTargetElement)
		{
			var aryTempSourceOptions = new Array();
			var x = 0;
			
			//looping through source element to find selected options
			for (var i = 0; i < objSourceElement.length; i++) {
				if (objSourceElement.options[i].selected) {
					//need to move this option to target element
					var intTargetLen = objTargetElement.length++;
					objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
					objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
				}
				else {
					//storing options that stay to recreate select element
					var objTempValues = new Object();
					objTempValues.text = objSourceElement.options[i].text;
					objTempValues.value = objSourceElement.options[i].value;
					aryTempSourceOptions[x] = objTempValues;
					x++;
				}
			}
		}
		
		function deleteOption(selectObject)
		{
			if (selectObject.selectedIndex!=-1 && selectObject.options.length!=0)
				selectObject.options[selectObject.selectedIndex]=null;
			else
				alert("Select an option and click Remove")
		}
		
		function selectAllOptions(selectObject)
		{
			x=document.getElementById(selectObject);
			//var e_select = document.forms['test_form'].elements[s_select];

			for (var i = 0; i < selectObject.options.length; i++)
				selectObject.options[i].selected = true;
		}
		
		function confirmSendNewsLetter(language)
		{
			if(language=='nl')
				$msg = "Bent u zeker dat u deze nieuwsbrief wenst te versturen naar de ontvangers?";
			if(language=='fr')
				$msg = "Etes-vous sur que vous voulez envoyer cette lettre aux destinataires?";
			if(language=='en')
				$msg = "Are you sure you want to send this newsletter to the recipients?";
			return confirmAlert($msg);
		}
		
		
		function unsubscribeUser(userEmail)
		{
			if(validateEmail(userEmail))
			{
				var val = 'UnsubscribeUser.php?address='+userEmail;
				sndDeleteReq(val);
				return false;
			}
			else
				alert("Gelieve een geldig e-mailadres in te vullen");
		}
		
		function createRequestObject() {
		    var ro;
		    var browser = navigator.appName;
		    if(browser == "Microsoft Internet Explorer"){
		        ro = new ActiveXObject("Microsoft.XMLHTTP");
		    }else{
		        ro = new XMLHttpRequest();
		    }
		    return ro;
		}
		
		function sndDeleteReq(action) {
		    http.open('get', action);
		    http.onreadystatechange = handleDeleteResponse;
		    http.send(null);
		}
		
		function handleDeleteResponse()
		{
		    if(http.readyState == 4)
			{
				if(http.responseText != 'ok')
					alert(http.responseText);
				else
				alert("Uw e-mail adres werd succesvol verwijderd uit de lijst.\n");
		    }
		}
		
        //-->

