	function sentspace(control){
		return ($(control).value.empty()) ? ' ':$(control).value ;
	}
	
	function clearForm(formIdent){ 
		var form, elements, i, elm; 
	    form = document.getElementById ? document.getElementById(formIdent) : document.forms[formIdent]; 
	
		if (document.getElementsByTagName){
			elements = form.getElementsByTagName('input');
			for( i=0, elm; elm=elements.item(i++); ){
				if (elm.getAttribute('type') == "text" || elm.getAttribute('type') == "hidden" || elm.getAttribute('type') == "password"){
					elm.value = '';
					elm.className = '';
				}else if(elm.getAttribute('type') == "checkbox"){
					elm.checked = '';
				}
			}
			elements = form.getElementsByTagName('textarea');
			for( i=0, elm; elm=elements.item(i++); ){
					elm.value = '';
					elm.className = '';
			}
			elements = form.getElementsByTagName('select');
			for( i=0, elm; elm=elements.item(i++); ){
					elm.value = 0;
					elm.className = '';
			}
			elements = form.getElementsByTagName('span');
			for( i=0, elm; elm=elements.item(i++); ){
				if (elm.id.substr(0,3) == "err"){
					elm.innerHTML = '';
				}
			}
		}
	}
	
	function validateempty(txtValid,spanErr,errMsg) {
 		if (txtValid.value.empty()){
			spanErr.innerHTML = errMsg;
			txtValid.className = "errorcontrol";
			return false;
		}  
		else{
			spanErr.innerHTML = "";
			txtValid.className = "";
		}
	 }
	 
	  function errCss(txtValid,boolChange) {
 		if (boolChange){
			txtValid.className = "errorcontrol";
		}  
		else{
			txtValid.className = "";
		}
	 }
	 
	function validateemail(txtEmail,spanErr,errMsg) {
		
		var isnoterror = true;
		
		validRegExp = /\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b/i;

    	if (txtEmail.value.search(validRegExp) == -1){isnoterror =  false;}
 		
 		if (isnoterror){
			spanErr.innerHTML = "";
			txtEmail.className = "";
			return true;
		}  
		else{
			spanErr.innerHTML = errMsg;
			txtEmail.className = "errorcontrol"; 
			return false;
		}					
	}

	function validateselect(txtValid,spanErr,errMsg) {
 		if (txtValid.value == '0'){
			spanErr.innerHTML = errMsg;
			txtValid.className = "errorcontrol";
			return false;
		}  
		else{
			spanErr.innerHTML = "";
			txtValid.className = "";
		}
	 }
	
	function validatenumeric(txtValid,spanErr,errMsg)
    {
    	var value = txtValid.value;
      	
      	if (!(value.empty())){
	      	if (value.match(/^\d+$|^\d+\.\d{2}$/ )){
				spanErr.innerHTML = "";
				txtValid.className = "";
			}  
			else{
				spanErr.innerHTML = errMsg;
				txtValid.className = "errorcontrol";
				return false;
			}
      	}
      	else{
  			spanErr.innerHTML = "";
			txtValid.className = "";
      	}
    }
	
	function validatedate(txtValid,spanErr,errMsg) 
	{
		var value = txtValid.value;
	 	var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
 		var isnoterr = false;
		if (!(value.empty())){
			if(!objRegExp.test(value)){
  		  		isnoterr = false; 
  		  	}
	  		else {
				var strSeparator = value.substring(2,3) 
			    var arrayDate = value.split(strSeparator); 
			    //create a lookup for months not equal to Feb.
			    var arrayLookup = { '01' : 31,'03' : 31, 
			                        '04' : 30,'05' : 31,
			                        '06' : 30,'07' : 31,
			                        '08' : 31,'09' : 30,
			                        '10' : 31,'11' : 30,'12' : 31}
			    var intDay = parseInt(arrayDate[0],10); 
			
			    //check if month value and day value agree
			    if(arrayLookup[arrayDate[1]] != null) {
			    	if(intDay <= arrayLookup[arrayDate[1]] && intDay != 0){
			              isnoterr =  true; //found in lookup table, good date
			        }
			    }
			    
			    //check for February (bugfix 20050322)
			    //bugfix  for parseInt kevin
			    //bugfix  biss year  O.Jp Voutat
			    var intMonth = parseInt(arrayDate[1],10);
			    if (intMonth == 2) { 
			        var intYear = parseInt(arrayDate[2]);
			        if (intDay > 0 && intDay < 29) {
						isnoterr =  true;
			        }
			        else if (intDay == 29) {
			        	if ((intYear % 4 == 0) && (intYear % 100 != 0) || (intYear % 400 == 0)) {
			            // year div by 4 and ((not div by 100) or div by 400) ->ok
			            	isnoterr = true;
			          	}   
			        }
				}
			}  
	
	      	if (isnoterr){
				spanErr.innerHTML = "";
				txtValid.className = "";
			}  
			else{
				spanErr.innerHTML = errMsg;
				txtValid.className = "errorcontrol";
				return false;
			}
	   	}
      	else{
  			spanErr.innerHTML = "";
			txtValid.className = "";
		}
	}
	
	function compareDate(firstDate,SecondDate,spanErr,errMsg){
		var str1  = firstDate.value;
   		var str2  = SecondDate.value;
   		if (!str1.empty() && !str2.empty()){
	   		var dt1   = parseInt(str1.substring(0,2),10);
	   		var mon1  = parseInt(str1.substring(3,5),10);
	   		var yr1   = parseInt(str1.substring(6,10),10);
	   		var dt2   = parseInt(str2.substring(0,2),10);
	   		var mon2  = parseInt(str2.substring(3,5),10);
	   		var yr2   = parseInt(str2.substring(6,10),10);
	   		var date1 = new Date(yr1, mon1, dt1);
	   		var date2 = new Date(yr2, mon2, dt2); 
			
		    if(date2 < date1){
	   			spanErr.innerHTML = errMsg;
				SecondDate.className = "errorcontrol";
				return false;
	   		}
	   		else{
	   			spanErr.innerHTML = "";
				SecondDate.className = "";
			}
   		}
   		else{
   			spanErr.innerHTML = "";
			SecondDate.className = "";
   		}
	}
	
	function compareTime(firstTime,secondTime,spanErr,errMsg){
   		if (!firstTime.empty() && !secondTime.empty()){
	   		var h1   = parseInt(firstTime.substring(0,2),10);
	   		var m1  = parseInt(firstTime.substring(3,5),10);
	   		
	   		var h2   = parseInt(secondTime.substring(0,2),10);
	   		var m2  = parseInt(secondTime.substring(3,5),10);
	   		
	   		var time1 = new Date(0,0,0,h1,m1);
	   		var time2 = new Date(0,0,0,h2,m2); 
			
		    if(time2 <= time1){
	   			spanErr.innerHTML = errMsg;
				return false;
	   		}
	   		else{
	   			spanErr.innerHTML = "";
			}
   		}
   		else{
   			spanErr.innerHTML = "";
			secondTime.className = "";
   		}
	}
	 
	function checkall()
	{
		var chkbox = document.getElementsByName('gvrow');
		if($('chkall').checked){
			for(var i=0; i<chkbox.length; i++) {
				chkbox[i].checked = true;
			}
		}
		else{
			for(var i=0; i<chkbox.length; i++) {
				chkbox[i].checked = false;
			}
		}
	}
	 function updateTiny (strControl) {
		tinyMCE.updateContent(strControl); 	
	 }
	 
	 function gvCheck(strControl)
	 {
	 	if (strControl.empty()){
	 		var chkbox = document.getElementsByName('gvrow');
	 	}
	 	else{
	 		var chkbox = document.getElementsByName(strControl);
	 	}
	 	var arrCheck = new Array();
		for(var i=0; i<chkbox.length; i++) {
			if (chkbox[i].checked == true){
				arrCheck.push(chkbox[i].value);
			}
		}
		return arrCheck;
	 }
	
	function trim(str)
	{
		var trimmed = str.replace(/^\s+|\s+$/g, '') ;
		return trimmed;
	}