function trimString(str){

      iEnd = str.length - 1;
      iStart = 0;
     // bLoop = true;
      cChar = str.charAt(iStart);
      while ((iStart < iEnd) && ((cChar == "\n") || (cChar == "\r") || (cChar == "\t") || (cChar == " "))){
         iStart ++;
         cChar = str.charAt(iStart);
      }
      cChar = str.charAt(iEnd);
      while ((iEnd >= 0) && ((cChar == "\n") || (cChar == "\r") || (cChar == "\t") || (cChar == " "))){
         iEnd --;
         cChar = str.charAt(iEnd);
      }
      if (iStart < iEnd){
         sTrimmed = str.substring(iStart, iEnd + 1);
      } else {
         sTrimmed = str;
      }
	  return sTrimmed;
}


function isDate(pDate,theForm) {
	if (pDate.length!=10){
			alert("Du har uppgett fel typ av datum, datum skrivs typ: 2000-01-01");	
			return(false);
		}
		yDate = pDate.substring(0,4);
		if (isNaN(yDate)){
			alert("Du har uppgett fel typ av datum, datum skrivs typ: 2000-01-01");			
			return(false);
		}
		yDate = pDate.substring(4,5);
		if (yDate!='-'){
			alert("Du har uppgett fel typ av datum, datum skrivs typ: 2000-01-01");			
			return(false);
		}
		yDate = pDate.substring(5,7);
		if (isNaN(yDate)){
			alert("Du har uppgett fel typ av datum, datum skrivs typ: 2000-01-01");			
			return(false);
		}
		yDate = pDate.substring(7,8);
		if (yDate!='-'){
			alert("Du har uppgett fel typ av datum, datum skrivs typ: 2000-01-01");			
			return(false);
		}
		yDate = pDate.substring(8,10);
		if (isNaN(yDate)){
			alert("Du har uppgett fel typ av datum, datum skrivs typ: 2000-01-01");			
			return(false);
		}
		return(true);
}
