/*************************************************************
CHANGE LOG
DATE		WHO		VER		WHAT
29-07-2005	FV		1.0		Initial revision


*************************************************************/
function validateInt(strValue){

	var objRegExp = /^\d+$/;
	
	return objRegExp.test(strValue);

}
function validateDouble(strValue){

	var objRegExp  = /^(\d*),(\d{2})$/;

	return objRegExp.test(strValue);
}
function validatePostCode( strValue ){
	var objRegExp = /(^\d{4})([A-Z]{2})/;
		
	return objRegExp.test(strValue) && strValue.length == 6;
}
function validateEmail(strValue){
	var objRegExp = /[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,4}/;
	
	return objRegExp.test(strValue);
}
function Trim(s) 
{
  
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function changeLists(sourceL, targetL, formName, warning) {
	  
	  var sourceList, targetList;
	  var sourceLen, targetLen;
	  var waarschuwing="";
	  
	  
	  
	  if(formName != '-1'){
	  	sourceList = eval(formName + '.' + sourceL);
	  	targetList = eval(formName + '.' + targetL);
	  }
	  else{
	  	sourceList = sourceL;
	  	targetList = targetL;
	  }
	  
	 
      if(sourceList.selectedIndex== -1){
      	alert("Maak een selectie");
      }
      else{
      if(warning != '0'  && sourceList.selectedIndex != -1){
	  	
	  	switch (warning) {
	  		case 'taal' : waarschuwing = 'Door deze taal te verwijderen word ook alle content in deze taal verwijderd, weet u het zeker?\n(de verwijdering vind pas plaats waneer u op verder klikt)';break;
	  		case 'func' : waarschuwing = 'Door deze functie te verwijderen word alle content die in deze functie is gemaakt ook verwijderd, weet u het zeker\n(de verwijdering vind pas plaats waneer u op verder klikt)';break;
	  		default : waarschuwing = 'U staat op het punt een actie uit te voeren die verregaande gevolgen kan hebben voor het syteem, maar waar nog geen melding voor is vastgelegd, neem bij twijfel contact op met de beheerder/leverancier van het systeem';break;
	  	}
	  	
	  	if(confirm(waarschuwing)){
	  		shiftList();
	  	}
	  }
      else{
      	shiftList();
      }
      
      function shiftList(){
      	for ( i=0; i<sourceList.length; i++){
        	if (sourceList.options[i].selected == true ) {
        	    targetList.options[targetList.length]= new Option(sourceList.options[i].text,sourceList.options[i].value);
        	}
    	}	
	
    	for ( i = (sourceList.length -1); i>=0; i--){
    	    if (sourceList.options[i].selected == true ) {
    	       sourceList.options[i] = null;
    	    }
    	}
    	sortList(targetList,formName);
      }	
}

function sortList(TargetL, formName){
		var targetList;
	
		if(formName != '-1'){
			targetList = eval(formName + '.' + targetL);
		}
		  else{
		   	targetList = targetL;
		}
		
		var tmpData = new Array(targetList.length-1);
        
        for(i=0;i<targetList.length;i++){
        	tmpData[i] = new targetEntry(targetList.options[i].text,targetList.options[i].value);
        }
        
        tmpData.sort(sortByText);
        
        for(i=0;i<tmpData.length;i++){
        	targetList.options[i].text = tmpData[i].Text;
        	targetList.options[i].value = tmpData[i].Value;
        }
        sourceList.selectedIndex = -1;
        targetList.selectedIndex = -1;
	}
	
	function targetEntry(text, value){
		this.Text = text;
		this.Value = value;
	}
	
	function sortByText(a, b) {
	    var x = a.Text.toLowerCase();
	    var y = b.Text.toLowerCase();
	    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
	}  
}

function selectAll(targetL, formName){
	var targetList;
	
	if(formName != '-1'){
		targetList = eval(formName + '.' + targetL);
	}
	  else{
	   	targetList = targetL;
	}
	
	for(var i=0;i<targetList.length;i++){
		targetList.options[i].selected = true;
	}
}

function previousPage(doel,bericht){
	if(Trim(bericht).length >0){
		if(confirm(bericht)){
			self.location=doel;
		}
	}
	else{
		self.location=doel;
	}
}

function setTdHeight(height,id){
	document.getElementById(id).style.height=height;
}

function changeRadio(name,value,cbNr,maxCb,form){
	var i;
	for(i=0;i<maxCb;i++){
	img = eval(name + '' + i);
		if(i == cbNr){
			eval(form+ '.' + name).value=value;
			img.src='../img/checkboxon.gif';
		}
		else{
			img.src='../img/checkbox.gif';
		}
	}
}

function initRadio(form){
	var i;
	var fName,fValue;
	fName = '';
	fValue = -1;
	
	for(i=0;i<configform.elements.length;i++){
		fName = eval(form).elements[i].name;
		fValue = eval(form+'.'+fName).value;
		img = eval(fName+''+fValue);
		img.src = '../img/checkboxon.gif';
	}
}


function popUp(url,w,h,sBar){
	
	bar = "no";
	if(sBar)
		bar = "yes";
	
	var popleft=((document.body.clientWidth - w) / 2)+window.screenLeft;
	var poptop=(((document.body.clientHeight - h) / 2))+window.screenTop-40;	
	window.open(url,"newWin","scrollbars="+bar+",width="+w+",height="+h+",left="+popleft+",top="+poptop);
}
function showPreview(cRechts){
	tmpAction = SaveForm.action;
	SaveForm.content.value = editor.getContentBody();
	SaveForm.action = '../preview.asp?contentRechts='+cRechts;
	SaveForm.target='_blank';
	SaveForm.submit();
	SaveForm.action = tmpAction;
	SaveForm.target='_self';
}


function checkBoxOn(cb,form){
	var cbVal,img;
	cbVal = eval(form+'.'+cb).value;
	img = eval(form+'.'+cb+'Img');
	
	if(cbVal==1){
		img.src = '../img/checkbox.gif';
		eval(form+'.'+cb).value = 0;
	}
	if(cbVal==0){
		img.src = '../img/checkboxon.gif';
		eval(form+'.'+cb).value = 1;
	}
	
}	
