//not tested properly
/*function validWebUrl(webUrl){
	wurl = webUrl.value
	var valid=true;
		if(wurl.search([/^\w+((-\w+)|(\.\w+))*]+\.[A-Za-z]+((\.|-)[A-Za-z]+)*\.[A-Za-z]+$/)!= -1){
				valid =true;
		}else{
			alert("Please re-enter the "+getDisplayTitle(webUrl));
			webUrl.focus();
			return false;
		}
		return valid;

}*/
//==================================================================================================================
/* Checks whether only nos are present,throw message,*/

function NumbersOnly_d(inputObject){
	if(inputObject.value=="")
	{
	return true;
	}
	else
	{
	the_element = trimSpace(inputObject)
	var inputtext = the_element.value;
	numcount=0;alphacount=0;
		for( i = 0; i<inputtext.length; i++){
			if((inputtext.charAt(i) >= "0") && (inputtext.charAt(i) <= "9")){
				numcount++;
			}
			if(((inputtext.charAt(i) >= "a") && (inputtext.charAt(i) <= "z")) ||((inputtext.charAt(i) >= "A") && (inputtext.charAt(i) <= "Z")) || (inputtext.charAt(i) == "-")){
				alphacount++;
			}
		}

		if(alphacount == 0&&numcount >0){
			return true;
		}else{
			alert(getDisplayTitle(inputObject)+" can contain only Numbers") ;
			inputObject.focus();
			return false;		
		}
	}
}

/* Function to check the Mandatory field. */

function isMandatory(inputObj){
var valid = true;
if((inputObj.className=="loginbox") && (inputObj.value == "")){
alert("Please enter your " +getDisplayTitle(inputObj));

/*if(inputObj.title == "Date of Birth")
	{
	 alert(inputObj.title);
     inputObj.blur();
	} */
inputObj.select();
inputObj.focus();
valid = false; 
}
return valid;
}

//===========================================================================
/*Function  to validate  the email id. */
function isValidEmail(inputObj){ 
var valid= true;
var inputstring = inputObj.value;
if (inputstring.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/)!= -1){
        valid = true;
}
else
{
		if (inputstring != "")
		{
			alert("Please re-enter "+getDisplayTitle(inputObj));
			inputObj.select();
			inputObj.focus();
			valid = false;
		}
		else
		{
			return true;
		}					
}
return valid;
}

//=========================================================================================================================
/* Function to check for alphanumeric data only & give appropriate error message,
Parameters : Value to be checked, the field name to be displayed in the alert.*/
function isAlphanumVal(inputObj){

  var inputstr = inputObj.value;
  var hasChar = false;
//   alert(inputstr.length);
	if (inputstr != null && inputstr != "")
	{
		for(var i = 0; i < inputstr.length; i++)

		{
		  
			if(((inputstr.charAt(i) >= "0") && (inputstr.charAt(i) <= "9")) || ((inputstr.charAt(i) >= "a") && (inputstr.charAt(i) <= "z")) || ((inputstr.charAt(i) >= "A") && (inputstr.charAt(i) <= "Z")) || (inputstr.charAt(i) == " ") ||(inputstr.charAt(i) == "\'"))
			{
				
				hasChar = true;
			}
			else
			{
				
				hasChar = false; 
				break;
			}
		}//for loop
	}//if loop
	if(!hasChar){
		if (inputstr.length != 0)
		{
			alert("Invalid value..Please Re-enter "+getDisplayTitle(inputObj));
			inputObj.select();
			inputObj.focus();
		}
		else
		{
			return true;
		}
    }
	return hasChar;
}
//=========================================================================================================================
/* Function to verify the minimum length. */
function verifyLength(inputObj,minlength){
var valid = true;
var checkStr = inputObj.value
var str      = checkStr.toString();
var strlength = str.length;
if (strlength < minlength){
alert("Minimum length of "+getDisplayTitle(inputObj)+ " should be "+minlength);
inputObj.select();
inputObj.focus();
valid = false;
}
else
{
valid = true;
}
return valid;
}

//=========================================================================================================================
/* Function to verify the maximum length. */
function verifyMaxLength(inputObj,maxlength){
var valid = true;
var checkStr = inputObj.value
var str      = checkStr.toString();
var strlength = str.length;
if (strlength > maxlength){
alert("Maximum length of "+getDisplayTitle(inputObj)+ " should be "+maxlength);
inputObj.select();
inputObj.focus();
valid = false;
}
else
{
valid = true;
}
return valid;
}

//=====================================================================================================================
/* Function is to check the value of the two string.
Parameters : Value of two strings to be checked. */
function isEqual(firstStr,secStr){

var valid = true;
var passwd = firstStr.value;
var confpasswd = secStr.value;
if(passwd.toString()== confpasswd.toString()){
valid = true;
}
else{
alert("Please check the following:Both passwords must match");
secStr.value="";
//secStr.select();
secStr.focus();
valid = false;
}
return valid;
}


//================================================================================================================
/* Combined function of mandatory, Min. lenght verification & alphaNummerical */
function PWNEW(inputObj){
	var n = '0123456789'					// numbers
	var a = 'abcdefghijklmnopqrstuvwxyz'	// alpha letters
	var u = 0								// upper case count
	var l = 0								// lower case count
	var an = a + n + a.toUpperCase()		// alpha numeric
  var inputstr = inputObj.value;
  var hasChar = false;
//   alert(inputstr.length);
		for(var i=0;i<inputstr.length;i++)
		{
			if(a.indexOf(inputstr.substring(i, i+1)) != -1)
			{
			l++
			}
			if(a.toUpperCase().indexOf(inputstr.substring(i, i+1)) != -1)
			{
			u++
			}
		}
		if(u>=1 && l >= 1){
		hasChar = true;
		}else{
		hasChar = false;
		alert("Password Must Contains Atleat one Upper Case Character");
		}
	return hasChar;
}
//================================================================================================================
/* Combined function of mandatory, Min. lenght verification & alphaNummerical */
/*function combofunction1(givenstring,minlength){
var valid = true;
var trimElement = trimSpace(givenstring);
var modifiedstring = replacesingleQuote(trimElement)

if(ismandatory(modifiedstring)){
if(verifyLength(modifiedstring,minlength)){
if(isAlphanumVal(modifiedstring)){
valid= true;
}
else{
valid = false;
}
}
else{
valid = false;
}
}
else{
valid = false;
}
return valid;
}*/
//=================================================================================================================
/* Combined function of Mandatory, and alphaNumerical and trimming the space.*/
function combofunction2(givenElement){
var valid = true;
var trimElement = trimSpace(givenElement);
var modifiedstring = replacesingleQuote(trimElement)

if(isMandatory(modifiedstring)){
if(isAlphanumVal(modifiedstring)){
valid= true;
}
else{
valid = false;
}
}
else{
valid = false;
}
return valid;
}

//=============================================================================================
/* Function to display the calender */
function showCalender(FieldName)
{   var url;
	if(FieldName=="txt_passport_exp_date"){
	url = "./Calender.jsp?FormName=input_details_individual3.jsp&ControlName=" + FieldName;	
	}
	if(FieldName=="txt_dt_of_birth"){
    url = "Calender.jsp?FormName=input_details_individual1.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Add_Company_FromDate"){
    url = "../Calender.jsp?FormName=Add_Company.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Add_Company_ToDate"){
    url = "../Calender.jsp?FormName=Add_Company.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Edit_Company_FromDate"){
    url = "../Calender.jsp?FormName=Edit_Company.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Edit_Company_ToDate"){
    url = "../Calender.jsp?FormName=Edit_Company.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Add_DOB"){
    url = "../Calender.jsp?FormName=Add_User.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Edit_DOB"){
    url = "../Calender.jsp?FormName=Edit_User.jsp&ControlName=" + FieldName;
	}
    if(FieldName=="txt_dt_of_incorporation"){
	url = "./Calender.jsp?FormName=input_details_corporates0.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Add_Tax_FromDate"){
    url = "../Calender.jsp?FormName=Add_Tax.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Add_Tax_ToDate"){
    url = "../Calender.jsp?FormName=Add_Tax.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Edit_Tax_FromDate"){
    url = "../Calender.jsp?FormName=Edit_Tax.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Edit_Tax_ToDate"){
    url = "../Calender.jsp?FormName=Edit_Tax.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Add_Seminar_FromDate"){
    url = "../Calender.jsp?FormName=Add_Seminar.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Add_Seminar_ToDate"){
    url = "../Calender.jsp?FormName=Add_Seminar.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Edit_Seminar_FromDate"){
    url = "../Calender.jsp?FormName=Edit_Seminar.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_Edit_Seminar_ToDate"){
    url = "../Calender.jsp?FormName=Edit_Seminar.jsp&ControlName=" + FieldName;
	}
    
	if(FieldName=="txt_start_date"){
    url = "../Calender.jsp?FormName=customer_registration.jsp&ControlName=" + FieldName;
	}
    if(FieldName=="txt_end_date"){
    url = "../Calender.jsp?FormName=customer_registration.jsp&ControlName=" + FieldName;
	}
   if(FieldName=="txt_email_status_start_date"){
    url = "../Calender.jsp?FormName=email_status.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_email_status_end_date"){
    url = "../Calender.jsp?FormName=email_status.jsp&ControlName=" + FieldName;
	}
	if(FieldName=="txt_start_date"){
    url = "../Calender.jsp?FormName=document_verification.jsp&ControlName=" + FieldName;
	}
    if(FieldName=="txt_end_date"){
    url = "../Calender.jsp?FormName=document_verification.jsp&ControlName=" + FieldName;
	}
	

	window.open(url, "calender", "resizable=no, height=235, width=280");
}
//============================================================================================
/* Function to get the display field name from any element
   Eg: element is txt_name
       Display name is Name.
*/
function getDisplayTitle(inputObj){
var str =  inputObj.title;
return str;
}
//=============================================================================================
/* Function to trim the leading and trailing spaces of given string.*/
function trimSpace(inputObj){

var chkStr    = inputObj.value;
var newString = chkStr.toString();
var size      = newString.length;
if(size != 0){
//trimming the leading space
while(newString.slice(0,1) == " "){
	newString = newString.substring(1,size);
	size      = newString.length;
}

//Strip the trailing space
while(newString.slice(size-1,size) == " "){
	newString = newString.substring(0,size-1);
	size      = newString.length;
}
inputObj.value = newString;
}//end of if
return inputObj;
}
//=============================================================================
/* Function to check the Numerical field */
function testisNumerical(inputObj){
var valid = true;
var value = inputObj.value;
//var chkstr  = value.toString();
var chkstr = parseInt(inputObj.value);
if (isNaN(chkstr) == true){
alert("Please check the "+getDisplayTitle(inputObj));
inputObj.select();
inputObj.focus();
valid = false;
}
return valid;
}

//=============================================================================
/* Function to check the Numerical field */
function isNumerical(inputObj){
var inputstr = inputObj.value;
var hasChar = true;
   
if (inputstr != null && inputstr != "")	{
for(var i = 0; i < inputstr.length; i++){
if((inputstr.charAt(i) >= "0") && (inputstr.charAt(i) <= "9")) {
hasChar = true;
}
else{
hasChar = false; 
break;
}
}//for loop
}//if loop
if(!hasChar){
alert("Please enter valid number in "+getDisplayTitle(inputObj));
inputObj.select();
inputObj.focus();
}
return hasChar;
}

//==========================================================================
/* Function to check the Mandatory & only numerical number. */
 function combofunction3(givenElement){
 var valid = true;
 var trimElement = trimSpace(givenElement);
 if(isMandatory(trimElement)){
 if(isNumerical(trimElement)){
		if(trimElement.name=="txt_residence_pin" ||trimElement.name=="txt_residence_telephone_no"||trimElement.name=="txt_residence_mobile"||trimElement.name=="txt_office_pin"||trimElement.name=="txt_residence_fax"||trimElement.name=="txt_office_telephone_no"||trimElement.name=="txt_mobile"||trimElement.name=="txt_office_fax"||trimElement.name=="txt_pin"||trimElement.name=="txt_telephone1"||trimElement.name=="txt_telephone2"||trimElement.name=="txt_fax"){
			if(trimElement.value<100000){
				alert("Can not be a Less than Six digit " +getDisplayTitle(trimElement)+"!")
					trimElement.focus();
				return false;
			}else{
				valid =true
			}
		}else{
			 valid= true;
		}
 }
 else{
 valid = false;
 }
 }
 else{
 valid = false;
 }

 return valid;
 }

//==========================================================================
/* Function to check the Mandatory & only numerical number. */
 function stdcode(givenElement){
 var valid = true;
 var trimElement = trimSpace(givenElement);
 if(isMandatory(trimElement)){
 if(isNumerical(trimElement)){
		if(trimElement.name=="txt_residence_std_telephone"||trimElement.name=="txt_residence_std_mobile"||trimElement.name=="txt_residence_std_fax"||trimElement.name=="txt_office_std_telephone"||trimElement.name=="txt_office_std_mobile"||trimElement.name=="txt_office_std_fax"){
			if(trimElement.value<1){
				alert("Can not be a Single digit " +getDisplayTitle(trimElement)+"!")
					trimElement.focus();
				return false;
			}else{
				valid =true
			}
		}else{
			 valid= true;
		}
 }
 else{
 valid = false;
 }
 }
 else{
 valid = false;
 }

 return valid;
 }

//==========================================================================
/* Function to  trim the space, if entered then check numerical number. */
function combofunction4(givenElement){
var trimElement = trimSpace(givenElement);
if(isNumerical(trimElement)){
		if(trimElement.name=="txt_residence_mobile"||trimElement.name=="txt_residence_fax"||trimElement.name=="txt_mobile"||trimElement.name=="txt_office_fax"||trimElement.name=="txt_telephone1"||trimElement.name=="txt_telephone2"||trimElement.name=="txt_fax"){
			if(trimElement.value<100000){
				alert("Can not be a Less than Six digit "+getDisplayTitle(trimElement)+"!" )
					trimElement.focus();
				return false;
			}else{
				valid =true
			}
		}else{
			 valid= true;
		}
}
else{
valid = false;
}
return valid;
}
//==========================================================================
 /** 
    Function to trim the space & check the only alphanumerical if entered
 */

function combofunction6(givenElement){
var valid= true;
if(givenElement.value != ""){
var trimElement = trimSpace(givenElement);
var modifiedstring = replacesingleQuote(trimElement)

if(isAlphanumVal(modifiedstring)){
valid= true;
}
else{
valid = false;
}
}//End of outer if
return valid;
} 
//=============================================================================
function checkSpCharacter(inputObj){
var iChars = "!@#$%^&*+=[];.{}|\"<>?~:";

var chkStr    = inputObj.value;
var newString = chkStr.toString();
var valid = true;
var size      = newString.length;
for (var i = 0; i < size; i++) {
if (iChars.indexOf(newString.charAt(i)) != -1) {
alert ("Invalid value..Please Re-enter "+getDisplayTitle(inputObj));
inputObj.select();
inputObj.focus();
return false;
}
}
return valid;

}//End of the function
//=============================================================================

function checkDotHyphenCharacter(inputObj){
var iChars = "!@#$%^&*+=[];{}|\"<>?~:";

var chkStr    = inputObj.value;
var newString = chkStr.toString();
var valid = true;
var size      = newString.length;
for (var i = 0; i < size; i++) {
if (iChars.indexOf(newString.charAt(i)) != -1) {
alert ("Invalid value..Please Re-enter "+getDisplayTitle(inputObj));
inputObj.select();
inputObj.focus();
return false;
}
}
return valid;

}//End of the function

//===================================================================================
/* Function to trim the space and allow the special charater like "-","," & "/" "'" */
function combofunction5(givenElement){
	var trimElement = trimSpace(givenElement);
	var modifiedstring = replacesingleQuote(trimElement)
	var valid = true;
	if(isMandatory(modifiedstring)){
//		if(isNumbersOnly(givenElement) == false){
			if(checkDotHyphenCharacter(modifiedstring)){
				valid = true;
			}
			else{
			valid = false;
			}
/*		}else{
			alert(getDisplayTitle(givenElement)+" cannot contain only Numbers");
			givenElement.focus();
			return false;
		}*/
	}else{
		valid = false;
	}
	return valid;
}
//===================================================================================
/* Function to trim the space and allow the special charater like "-"or "." */
function combofunction11(givenElement){
	//alert(givenElement);
var trimElement = trimSpace(givenElement);
var modifiedstring = trimElement
var valid = true;
if(isMandatory(modifiedstring)){

if(checkDotHyphenCharacter(modifiedstring)){
valid = true;
}
else{
valid = false;
}
}
else{
valid = false;
}
return valid;
}


//===================================================================================
/**
Function to trim the space and allow the special charater like "-","," & "/" "'" if entered only.
if entered*/

function combofunction7(givenElement){
var trimElement = trimSpace(givenElement);
var modifiedstring = replacesingleQuote(trimElement)
var valid = true;
if(checkSpCharacter(modifiedstring)){
valid = true;
}
else{
valid = false;
}
return valid;
}
//=============================================================================
/* Function to check the Floating point field */
function isFloat(inputObj){
var inputstr = inputObj.value;
var hasChar = true;
   
if (inputstr != null && inputstr != "")	{
for(var i = 0; i < inputstr.length; i++){
if((inputstr.charAt(i) >= "0") && (inputstr.charAt(i) <= "9") || (inputstr.charAt(i) == ".")) {
hasChar = true;
}
else{
hasChar = false; 
break;
}
}//for loop
}//if loop
if(!hasChar){
alert("Please enter numbers in "+getDisplayTitle(inputObj));
inputObj.select();
inputObj.focus();
}
return hasChar;
}

//=================================================================================
//Script Added by:Shashidhar k
//Date:21-02-2004
//=================================================================================
/** 
  Function to check the odd number consecutive single quote and replace it with the even no. of single quote
*/
function replacesingleQuote(inputObject){
	
//var inputtext = document.form0.elements[0];
var inputtext = inputObject.value;
var str = "" ;
var modifiedstring = "";
var i ;
var changeIndex= false;
for( i = 0; i<inputtext.length; ){

if(inputtext.charAt(i) == "\'"){
var even = 1;
//To check the even number of single quote.
for(var j = i+1; inputtext.charAt(j) == "\'" ;j++){
even++;
}
i=j;
if((even % 2)==0){
str = inputtext.substring(0,i);
}
else{
//Replace it.
str =inputtext.replace("\'","\''");
str = str.substring(0,i+1);
}
inputtext = inputtext.substring(i,inputtext.length);
modifiedstring =  modifiedstring+str;
changeIndex= true;
}//end of if


if(changeIndex){
i =0;
}
else{
++i;
}
  changeIndex = false;
}//end of outer for loop
 modifiedstring =  modifiedstring + inputtext;
 inputObject.value = modifiedstring;
 return  inputObject;
}

//=================================================================================
/* Combined function of combofunction1 function, Max. length verification & alphaNummerical */
function combofunction9(inputObj,minlength,maxlength){
	valid =false;
	var checkStr = inputObj.value;
	var givenstring      = checkStr.toString();
	if(givenstring.length == 0){
			alert("Please enter your "+getDisplayTitle(inputObj));
			inputObj.select();
			inputObj.focus();
			return valid;
	}
	if(combofunction1(inputObj,minlength)){
		valid = verifyMaxLength(inputObj,maxlength);
	
	}

	return valid;
}//end of combofunction9
//================================================================================================================
/* Combined function of Mandatory, Min. lenght verification & alphaNummerical */
function combofunction1(inputObj,minlength){
var valid = true;
var trimElement = trimSpace(inputObj);
var modifiedstring = replacesingleQuote(trimElement)

if(isMandatory(modifiedstring)){
if(verifyLength(modifiedstring,minlength)){
if(isAlphanumVal(modifiedstring)){
valid= true;
}
else{
valid = false;
}
}
else{
valid = false;
}
}
else{
valid = false;
}
return valid;
}
//=================================================================================================================
//Script Added by:Shashidhar k
//Company :GTL Limited,Mumbai
//Date:21-02-2004
//==================================================================================================================
function checkForSupportedBrowserVersion()
            {
                //------------------------------------------------------------------
                // Some unsupported Webbrowsers identify themselfs as IE or Netscape.
                // One of these unsupported Webbrowsers is Opera.
                // Therefore we check here specifically if the used Webbrowser is
                // Opera.
                if (navigator.userAgent.indexOf("Opera") > 0) {
                    return false;
                }

                //------------------------------------------------------------------
                // Check specifically for Netscape 6.
                // Netscape 6 is currently not supported.
                if (navigator.userAgent.indexOf("Netscape") > 0) 
				{
                    return false;
                }

                //------------------------------------------------------------------
                // Check if the client platform is Microsoft Windows
                if (navigator.appVersion.indexOf("Win") >= 0) {

                    //--------------------------------------------------------------
                    // Check if the browser is Netscape
                    if (navigator.appName.substring(0,8) == "Netscape") {

                        //----------------------------------------------------------
                        // Check if Netscape Version is 6.0 or newer.
                        if (parseFloat(navigator.appVersion.substring(0,4))>=6.0)
                        {

                            // Navigator version is supported
                            return true;
                        }
                        //----------------------------------------------------------
                        // Netscape Version is < 4.06
                        else {
                            // Navigator Version is not supported
                            return false;
                        }
                    }

                    //--------------------------------------------------------------
                    // The Browser is not Netscape
                    else {
                        //----------------------------------------------------------
                        // Check if the browser is Microsoft IE
                        if (navigator.appName.substring(0,9) == "Microsoft") {

                            //------------------------------------------------------
                            // Check if IE version is 5 or newer
                            if (parseFloat(navigator.appVersion.substring(0,3))>=5)
                            {

                                // IE Version is supported
                                return true;
                            }
                            else {

                                // IE Version is not supported
                                return false;
                            }
                        }
                        else {

                            // The browser is not supported
                            return false;
                        }
                    }
                }
                //------------------------------------------------------------------
                // The OS is not Microsoft Windows
                else {
                    //--------------------------------------------------------------
                    // Check if the client platform is MacOS
                    if (navigator.appVersion.indexOf("Mac") >= 0) {

                        //----------------------------------------------------------
                        // Check if browser is Netscape
                        if (navigator.appName.substring(0,8) == "Netscape") {

                            // -----------------------------------------------------
                            // Check if Netscape Version is 4 or newer
                            if (Number(navigator.appVersion.substring(0,3)) >= 4.06) 
                            {

                                // Netscape Version is supported
                                return true;
                            }
                            //------------------------------------------------------
                            // Netscape is older then 4.06
                            else {
                                // Netscape Version not supported
                                return false;
                            }
                        }
                        //----------------------------------------------------------
                        // The Browser is not Netscape
                        else {
                            // The Browser is not supported
                            return false;
                        }
                    }

                    //--------------------------------------------------------------
                    // The OS is not MacOS (and not Microsoft Windows)
                    else {
                        // The OS is not supported
                        return false;
                    }
                }
            }
			/***********************************************************************
            * This function is used from the functions checkSessionCookie() and
            * checkPersistentCookie() to read the value out of the cookie
            */
            function getValueFromCookie(cookieName)
            {
                //------------------------------------------------------------------
                // Define the cookie name to look for
                var cookieIndexName = cookieName + '="';

                //------------------------------------------------------------------
                // Check if any cookie exists in this document.
                if (document.cookie.length > 0) {
                    // A cookie is available in this document.

                    //--------------------------------------------------------------
                    // Look for the position of the cookie
                    var cookieStartIndex = document.cookie.indexOf(cookieIndexName);

                    //--------------------------------------------------------------
                    // Check if the appropriate cookie was found
                    if (cookieStartIndex != -1) {
                        // the CurrentUserCookie was found in the cookies of this
                        // document

                        //----------------------------------------------------------
                        // Look for the start and the end of the cookie
                        cookieStartIndex += cookieIndexName.length;
                        var cookieEndIndex
                                = document.cookie.indexOf('";', cookieStartIndex);

                        if (cookieEndIndex == -1) {
                            // the end of the cookie list is reached

                            cookieEndIndex = document.cookie.length-'"'.length;
                        }

                        //----------------------------------------------------------
                        // Return the value that was stored in the cookie
                        return unescape(document.cookie.substring(cookieStartIndex,
                                                                  cookieEndIndex));
                    }

                }
                //------------------------------------------------------------------
                // Return an empty string if nothing has been returned yet.
                return "";

            }

            /***********************************************************************
            * This function checks if session cookies can be set.
            */
            function checkSessionCookie()
            {
                //------------------------------------------------------------------
                // Set the needed variables
                var cookieName = "TruePassSessionTestCookie";
                var cookieValue = 'truepasstestCookieDummyValue';
                var timeBeforeSettingCookie = new Date();

                //------------------------------------------------------------------
                // Set the cookie
                document.cookie = cookieName + '="' + cookieValue + '";';

                //------------------------------------------------------------------
                // Calculate how much time was needed to set the cookie
                var timeDifference
                    = (new Date()).getTime() - timeBeforeSettingCookie.getTime();

                //------------------------------------------------------------------
                // Check if setting the cookie lasted to long in Netscape. If
                // setting the cookie took longer than a few hundred miliseconds
                // it indicates, that the user had enabled the cookie warnings and
                // it took him some time to click on a button of the cookie warning.
                // Netscape does not work properly if cookie warnings are shown.
                // This is only a problem in Netscape and it does not occur in IE.
                if (navigator.appName.substring(0,9) != "Microsoft"
                    && timeDifference > 200) {

                    return false;
                }
                else {
                    //--------------------------------------------------------------
                    // Check if the cookie was set correctly.
                    if (getValueFromCookie(cookieName) != cookieValue) {

                        // reset the cookie
                        document.cookie = cookieName + '=""'
                                          + 'expires='
                                          + (new Date()).toGMTString();

                        // The session cookie was not set properly
                        return false;
                    }
                    else {
                        // reset the cookie
                        document.cookie = cookieName + '=""'
                                          + 'expires='
                                          + (new Date()).toGMTString();

                        // The cookie test succeeded
                        return true;
                    }
                }
            }

            /***********************************************************************
            * This function checks if persistent cookies can be set
            */
            function checkPersistentCookie()
            {
                //------------------------------------------------------------------
                // Set the needed variables
                var cookieName = "TruePassPersistentTestCookie";
                var cookieValue = 'truepasstestCookieDummyValue';
                var timeBeforeSettingCookie = new Date();

                //------------------------------------------------------------------
                // Set the cookie
                document.cookie = cookieName + '="' + cookieValue + '";'
                                  + 'expires='
                                  + (new Date(timeBeforeSettingCookie.getTime()
                                              + 1000000)).toGMTString();

                //------------------------------------------------------------------
                // Calculate how much time was needed to set the cookie
                var timeDifference
                    = (new Date()).getTime() - timeBeforeSettingCookie.getTime();

                //------------------------------------------------------------------
                // Check if setting the cookie lasted to long in Netscape. If
                // setting the cookie took longer than a few hundred miliseconds
                // it indicates, that the user had enabled the cookie warnings and
                // it took him some time to click on a button of the cookie warning.
                // Netscape does not work properly if cookie warnings are shown.
                // This is only a problem in Netscape and it does not occur in IE.
                if (navigator.appName.substring(0,9) != "Microsoft"
                    && timeDifference > 200) {
                    return false;
                }
                else {
                    //--------------------------------------------------------------
                    // Check if setting the cookie was set correctly.
                    if (getValueFromCookie(cookieName) != cookieValue) {

                        // reset the cookie
                        document.cookie = cookieName + '=""'
                                          + 'expires='
                                          + (new Date()).toGMTString();

                        // The persistent cookie was not set properly
                        return false;
                    }
                    else {
                        // reset the cookie
                        document.cookie = cookieName + '=""'
                                          + 'expires='
                                          + (new Date()).toGMTString();

                        // The cookie test succeeded
                        return true;
                    }
                }
            }
			
			function checkJVMVersion13()
			{
//				alert(document.truepasstest.getJVMversion());
//				alert(document.truepasstest.getJVMversion().indexOf("1.3"));
				if(document.truepasstest.getJVMversion().indexOf("1.3")!=-1)
					return true;
				else
					return false;
			}
			
			function checkforAppletsScripting()
			{
				if(navigator.appName.substring(0,9) == "Microsoft")
				{
					if(typeof(document.truepasstest.myConst)=="string")
						return true;
					else
						return false;
				}
				else
					return true;
			}

//=================================================================================

function containsSpace(inputObject){
	var inputtext = inputObject.value;
	valid=true;
		for( i = 0; i<inputtext.length; i++){
			if(inputtext.charAt(i) == " "){
				valid=false;
				break;
			}
		}
		if(valid ==false){
				alert(getDisplayTitle(inputObject)+" should not contain spaces")
					return false;
			
		}else{
			return true;
		}


}
//=========================================================================================
/* Checks whether a combo of alpha & nums are present ,if not throws a message stating that both nos& alpha is a must*/

function AlphanumMust(inputObject){
	var inputtext = inputObject.value;
	numcount=0;alphacount=0;
		for( i = 0; i<inputtext.length; i++){
			if((inputtext.charAt(i) >= "0") && (inputtext.charAt(i) <= "9")){
				numcount++;
			}
			if(((inputtext.charAt(i) >= "a") && (inputtext.charAt(i) <= "z")) ||((inputtext.charAt(i) >= "A") && (inputtext.charAt(i) <= "Z"))){
				alphacount++;
			}
		}
		if(alphacount == 0||numcount ==0){
			alert(getDisplayTitle(inputObject)+" should contain a combination of both Alphabets and Numbers");
			inputObject.focus();
			valid= false;
		}else{
			valid= true;
		}
		return valid

}
//========================================================================================
/* Checks whether only alphabets are present,but throws a message stating that object can coontain only letters,*/

function AlphaOnly(inputObject){
	the_element = trimSpace(inputObject)
	var inputtext = the_element.value;
//alert(inputtext);
	numcount=0;alphacount=0;
		for( i = 0; i<inputtext.length; i++){
			if((inputtext.charAt(i) >= "0") && (inputtext.charAt(i) <= "9")){
				numcount++;
			}
			if(((inputtext.charAt(i) >= "a") && (inputtext.charAt(i) <= "z"))){
				alphacount++;
			}
			if(((inputtext.charAt(i) >= "A") && (inputtext.charAt(i) <= "Z"))){
				alphacount++;
			}
		}
		if(alphacount > 0&&numcount ==0){
			return true;
		}else{
			alert("Please enter Alphabates (A-Z,a-z) for "+getDisplayTitle(inputObject)+"!");
			inputObject.focus();
			return false;		
		}
}
//=========================================================================================
/* Checks whether only nos are present,but does not throw any message,*/

function isNumbersOnly(inputObject){
	the_element = trimSpace(inputObject)
	var inputtext = the_element.value;
	numcount=0;alphacount=0;
		
		for( i = 0; i<inputtext.length; i++){
			if((inputtext.charAt(i) >= "0") && (inputtext.charAt(i) <= "9")){
				numcount++;
			}
			if(((inputtext.charAt(i) >= "a") && (inputtext.charAt(i) <= "z")) ||((inputtext.charAt(i) >= "A") && (inputtext.charAt(i) <= "Z"))){
				alphacount++;
			}
		}

		if(alphacount == 0&&numcount >0){
			return true;
		}else{
			return false;		
		}
}
//=========================================================================================
function firstLetterAlphaOnly(inputobj){
	the_element = trimSpace(inputobj)
	inputtext = the_element.value;
		if(((inputtext.charAt(0) >= "a") && (inputtext.charAt(0) <= "z"))){
			valid = true;
		}else{
			if((inputtext.charAt(0) >= "A") && (inputtext.charAt(0) <= "Z")){
				valid=true
			}else{
				return false;
			}
		}
		return valid
}

//==========================================================================================
//========================================================================================
/* Checks whether only alphabets are present,but throws a message stating that object can coontain only letters,*/

function firstnameOnly(inputObject){
	the_element = trimSpace(inputObject)
	var inputtext = the_element.value;
	alphacount=0;othercount=0;
		for( i = 0; i<inputtext.length; i++){
			if(((inputtext.charAt(i) >= "a") && (inputtext.charAt(i) <= "z")) || ((inputtext.charAt(i) >= "A") && (inputtext.charAt(i) <= "Z")) ||(inputtext.charAt(i)==" ") ||(inputtext.charAt(i)==".") ){
				alphacount++;
			}else{
				othercount++;
			}
		}
		if(alphacount > 0 && othercount==0){
			return true;
		}else{
			alert("Please enter Alphabates (A-Z,a-z) for "+getDisplayTitle(inputObject)+"!");
			inputObject.focus();
			return false;		
		}
}

