
	
	/*
	JavaScript Include

	Name:	 	: NieuwsBriefFormulier
	Address		: http://www.woonstadrotterdam.nl	
	Copyright	: Woonstad Rotterdam
	Author	 	: W.Steller(imtech)
	Created	 	: 2010-02-23T14:40:56

	About this JavaScript include:
	...
*/


// Compare two options within a list by VALUES

function compareOptionValues(a, b) 

{ 

  // Radix 10: for numeric values

  // Radix 36: for alphanumeric values

  var sA = parseInt( a.value, 36 );  

  var sB = parseInt( b.value, 36 );  

  return sA - sB;

}



// Compare two options within a list by TEXT

function compareOptionText(a, b) 

{ 

  // Radix 10: for numeric values

  // Radix 36: for alphanumeric values

  var sA = parseInt( a.text, 36 );  

  var sB = parseInt( b.text, 36 );  

  return sA - sB;

}

// Dual list move function

function moveDualList(srcList, destList,hiddenValueField,FinalDestList, moveAll ) {
	var sTemp;
  
  // Do nothing if nothing is selected
  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )  {

    return;

  }


  newDestList = new Array( destList.options.length );
  var len = 0;

  for( len = 0; len < destList.options.length; len++ ) {
    if ( destList.options[len] != null ) {  		
      newDestList[len] = new Option(destList.options[len].text, destList.options[len].value, destList.options[len].defaultSelected, destList.options[len].selected);
    }

  }

  for( var i = 0; i < srcList.options.length; i++ ) 

  { 

    if ( (srcList.options[i] != null) && ( srcList.options[i].selected == true || moveAll ) )

    {

       // Statements to perform if option is selected 

	   
       // Incorporate into new list
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, true );

       len++;

    }

  }



  // Sort out the new destination list

  newDestList.sort( compareOptionValues );   // BY VALUES

  //newDestList.sort( compareOptionText );   // BY TEXT



  // Populate the destination with the items from the new array

  	for ( var j = 0; j < newDestList.length; j++ ) {
    	if ( newDestList[ j ] != null ) {
      		destList.options[j] = newDestList[j] ;
    	}
  	}

  // Erase source list selected elements

  for( var i = srcList.options.length - 1; i >= 0; i-- )  { 

    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )   {

       // Erase Source
       //srcList.options[i].value = "";
       //srcList.options[i].text  = "";
       srcList.options[i]       = null;
    }

  }
  // Proccess destination
  // Populate the destination with the items from the new array
  	hiddenValueField.value='';

  	for ( var j = 0; j < FinalDestList.length; j++ ) {
			hiddenValueField.value=hiddenValueField.value + FinalDestList[j].value + ',';	  
  	}
	if (hiddenValueField.value!='') {
		sTemp = hiddenValueField.value;
		sTemp=sTemp.substring(0,sTemp.length-1);
		hiddenValueField.value=sTemp;
	}


} // End of moveDualList()

function msgEmpty(title) {
		alert(title);
	}
	
	function toggle_visibility(id, mode)
	{ 
	    var e = document.getElementById(id);
		if (e != null || e != undefined)	
		{
		    if (mode.length == 0) 
		    {
		        if(e.style.display == 'none') { e.style.display = 'block';
			    } else {
			        e.style.display = 'none';
			    }
			} else {
			    switch(mode) 
				{
			        case 'none':
			            e.style.display = 'none';
			            break;
			        case 'block': e.style.display ='block';
			            break;
			        default: e.style.display = 'none';
		        }
		    }
		}
	}


	function isEmail(email) {
		re=/(\w|-)+(\.(\w|-)+)*@(\w|-)+(\.(\w|-)+)*\.[A-Za-z][A-Za-z][A-Za-z]?[A-Za-z]?$/i;
		return(re.test(email));
	}
		
	function activate(obj) {
		obj.select();
		obj.focus();
	}
	
	function validateEmail(name) {
	
		var oObject = document.getElementById(name);
		
		if (oObject) {
			if (oObject.value=='') {
			msgEmpty('E-mail adres is niet ingevuld !');
			activate(oObject);
			return(false);
		}
				
		if (!isEmail(oObject.value)) {
			msgEmpty('E-mailadres is niet correct !');
			activate(oObject);
			return(false);
		} else return(true)
		}
	}	
	
	function validateEmpty(name, title) {

		var oObject = document.getElementById(name);	
		if (oObject) {
			if (oObject.value=='') {
				msgEmpty(title);
				activate(oObject);
				return(false);
			} else return(true)
		}	
	}
	
	function SelectNotEmpy(ohtmlobject, msg) {
	
		var selIndex = ohtmlobject.selectedIndex;
			if (selIndex==0) {
				alert(msg);
				return false;
			}
			else {
				return true;
			}
	}
	
	function ControleDeelgemeente(ohtmlobject, msg) {	
	
		if (ohtmlobject.options.length==0) {
			alert(msg);
			return false;
		}
		else {
			return true;
		}
		
	}
	
	function ControleSoortBouw(ohtmlobject, msg) {
		var TotalOn = 0;		
		var i;
		
		for (i=0; i<ohtmlobject.length; i++){
			if (ohtmlobject[i].checked==true) {
				TotalOn++;
			}
		}
				
		if (TotalOn==0) {
			alert(msg);
			return false;
		}
		else {
			return true;
		}
	}

	function PriceIsOK() 
	{ 
		var sMinPrice = '0';
		var sMaxPrice = '99999999';

		var oMinPrijs = document.getElementById('minprijs');
		var oMaxPrijs = document.getElementById('maxprijs');

		if (oMinPrijs != null || oMinPrijs != undefined)	
		{
			sMinPrice = oMinPrijs.value;
		}
					
		if (oMaxPrijs != null || oMaxPrijs != undefined)	
		{
			sMaxPrice = oMaxPrijs.value;
		}

		sMinPrice =(sMinPrice.length==0) ? 0 : sMinPrice;
	    var fMinPrice = parseFloat(sMinPrice);

	    sMaxPrice = (sMaxPrice.length==0) ? 99999999 : sMaxPrice;
	    var fMaxPrice = parseFloat(sMaxPrice);

	    if (fMinPrice > fMaxPrice) 
	    {
	        return false;
	    } else { 
	        return true;
	    }	
		
	}

