
/**************************************
'File Name		:	i_js.js
'Purpose		:	The JS File
'Issues			:
'Version		:	1.0.0
'*************************************/

/*Function to return string by removing initial and trailing spaces*/

function trim(pstrString)
{	var intLoop = 0;
	
	for(intLoop = 0; intLoop < pstrString.length;intLoop = intLoop + 1 )
	{	
		if(pstrString.charAt(intLoop) == " ")
			pstrString = pstrString.substring(intLoop + 1, pstrString.length);
		else
			break;
	}
	
	for(intLoop = pstrString.length - 1; intLoop >= 0; intLoop = pstrString.length - 1)
	{	
		if(pstrString.charAt(intLoop) == " ")
			pstrString = pstrString.substring(0,intLoop);
		else
			break;
	}
	
	return pstrString;
}

// Function to display error message and set focus to supplied object
 function AbortEntry(sMsg, Obj)
 {
	alert(sMsg);
	Obj.focus();
	return false;
 }
 
 //Function to Validate Email address entered by user in Obj
 function validate_email(Obj) 
  {
    if(Obj.value.length == 0) { 
      return AbortEntry("Please enter Email address",Obj); 
      }
    if(-1 == Obj.value.indexOf("@")) { 
       return AbortEntry("Your email must have a '@'",Obj); 
       }
    if(-1 != Obj.value.indexOf(",")) { 
       return AbortEntry("Your email must not have a ',' in it",Obj);
       }
    if(-1 != Obj.value.indexOf("#")) { 
       return AbortEntry("Your email must not have an '#' in it.",Obj); 
       }
    if(-1 != Obj.value.indexOf("!")) { 
       return AbortEntry("Your email must not have a '!' in it.",Obj); 
       }
    if(-1 != Obj.value.indexOf(" ")) { 
       return AbortEntry("Your email must not have a space in it.",Obj); 
       }
    if(Obj.value.length == (Obj.value.indexOf("@")+1) ) {
       return AbortEntry("Your email must have a domain name after the '@'.",Obj); 
       }
    if(-1 == Obj.value.indexOf(".")) { 
       return AbortEntry("Your email must have a '.'.",Obj); 
       }
    if(Obj.value.length == 0) { 
      return AbortEntry("Please enter your email.",Obj); 
      }
    return true;
  }



	
	
	
	

