// JavaScript Document
/*
########################################################### 
###  CREATED BY	  : Ajay Kumar Shukla		 
### CREATED ON    : 13 March 09		 
### CODE BRIEFING : User Component. 											
### COMPANY		  : Chetu India Pvt Ltd.		
########################################################### 
*/

   /**
	 * Added By:	Ajay Shukla
	 * Added On	 : 13 March 09
	 * DESC		 : check is is float
	 * @return boolen
	 */
	 
function is_double(number)
	{
		if(!number.match(/^[0-9]*\.?[0-9]*$/))
			return false;
		return true;
	}

  /**
	* Added By:	Ajay Shukla
	* Added On	 : 16 March 09
	* DESC		 : Returns the query
	* @return string The query to be used to retrieve the rows from the database
  */
	
function validationMsg(message)
{

 str  = "<dl id='system-message'>";
 str += "<dt class='error'>Message";
 str += "<dd class='error message fade'><ul>";
 
 /*** set loop *****/
 for(i = 0; i < message.length; i++){
	str += "<li>"+message[i]+"</li>";
 }

 str += "</ul></dd></dl>";

 return str;
}

  /**
	* Added By:	Ajay Shukla
	* Added On	 : 26 March 09
    * DESC		 :This file contains the functions for input data validation at client side with the help of java script.
	* @PARAM : string
    * @return  : trimed string 
	*/
	
function trim(inputString) 
{

   inputString=inputString.replace(/^\s+/g,"");
   inputString=inputString.replace(/\s+$/g,"");
   return inputString;
} 

// Ends the "trim" function

   /**
	* Added By:	Ajay Shukla
	* Added On	 : 07 March 09
    * this function checks the email format is correct or not
    and return true or false accordingly.
   * @return  :boolen 
   */
function is_email(email)
{
	if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
		return false;
	return true;
}	

    /**
	* Added By:	Ajay Shukla
	* Added On	 : 07 March 09
    * Checks the phone number like (001)-330-330 OR 9992592892.
    * @return  :boolen 
    */

function is_phone(varphone)
{
	if(varphone !=''){ 
	   if(!varphone.match(/^(\(?[0-9]*[-#\*\s]*[0-9]+\)?)+$/)){
			return false;
	  	 }
	 }
	return true
}
	
	/**
	* Added By:	Ajay Shukla
	* Added On	 : 07 March 09
    * Checks thezip code like 12345-1234 or 12345.
    * @return  :boolen 
    */
	
function isZip(s)
{
    // Check for correct zip code
     reZip = new RegExp(/(^\d{6}$)|(^\d{5}$)|(^\d{5}-\d{4}$)/);
     if (!reZip.test(s)) {
             return false;
     }

   return true;
} 

 /**
	* Added By	:	Ajay Shukla
	*  Added On	 : 07 March 09
	* DESC		:   This function has been developed to canecl the page 
	* @param string $option and  $useractivation
    * @return NULL
    * @access public
  */

function subCancel(site, redirect)
{
    var url = site+redirect;
	window.location = url;
	
}

/**
	* Added By	 : Ajay Shukla
	*  Added On	 : 08 March 09
	* DESC		 : This function has been developed to check that input value is a numeric or not 
	* @param     : input value
    * @return NULL
    * @access public
  */
function isNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

	