function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ValidateOperatingSystem() 
{
    if (navigator.userAgent.indexOf("Windows NT 6.0") > -1) 
    {
        if (navigator.appVersion.indexOf("MSIE") > -1) 
        {
	        alert("Currently Vista platform is not supported for this demonstration. This will be added in near future.\r\nFor further details email info@globaltrustfinder.com");
	        return false;
        } 
        else 
        {
	        //Non Vista Operating System
        }
    } 
    else 
    {
        //Non Vista Operating System
    }
    return true;
}

function OpenPage(Document2Open)
{
    var URL = "ViewDocument.aspx?DocToShow=" + Document2Open;
    window.open(URL, '', 'width=722,height=593'); //'resizable,scrollbars'
    return false;
};

function OpenDocumentVerivicationStatus(Document2Open) {
    var URL = "ViewDocumentStatus.aspx?DocToShow=" + Document2Open;
    window.open(URL, '', 'width=380,height=200'); //'resizable,scrollbars'
    return false;
};

function HowItWorksCorporateSigning(Control_ID, ImageName)
{
    document.getElementById("HIW_STEP1").src = "images/how-work-step1.gif";
    document.getElementById("HIW_STEP2").src = "images/how-work-step2.gif";
    document.getElementById("HIW_STEP3").src = "images/how-work-step3.gif";

    document.getElementById(Control_ID).src = ImageName;
}

function HowItWorksDocumentArchiving(Control_ID, ImageName) {
    document.getElementById("HIW_STEP1").src = "images/how-work-Doc_Archive_step1.gif";
    document.getElementById("HIW_STEP2").src = "images/how-work-Doc_Archive_step2.gif";
    document.getElementById("HIW_STEP3").src = "images/how-work-Doc_Archive_step3.gif";

    document.getElementById(Control_ID).src = ImageName;
}

function HowItWorksGoSignProSigning(Control_ID, ImageName) {
    document.getElementById("HIW_STEP1").src = "images/how-work-GoSignPro-step1.gif";
    document.getElementById("HIW_STEP2").src = "images/how-work-GoSignPro-step2.gif";
    document.getElementById("HIW_STEP3").src = "images/how-work-GoSignPro-step3.gif";

    document.getElementById(Control_ID).src = ImageName;
}

function HowItWorksGrIDSureSigning(Control_ID, ImageName)
{
    document.getElementById("HIW_STEP1").src = "images/how-work-step14.gif";
    document.getElementById("HIW_STEP2").src = "images/how-work-step9.gif";
    document.getElementById("HIW_STEP3").src = "images/how-work-step10.gif";

    document.getElementById(Control_ID).src = ImageName;
}

function HowItWorksUserSigning(Control_ID, ImageName)
{
    document.getElementById("HIW_STEP1").src = "images/how-work-step4.gif";
    document.getElementById("HIW_STEP2").src = "images/how-work-step2.gif";
    document.getElementById("HIW_STEP3").src = "images/how-work-step3.gif";

    document.getElementById(Control_ID).src = ImageName;
}

function HowItWorksVerifying(Control_ID, ImageName)
{
    document.getElementById("HIW_STEP1").src = "images/how-work-step5.gif";
    document.getElementById("HIW_STEP2").src = "images/how-work-step6.gif";
    document.getElementById("HIW_STEP3").src = "images/how-work-step7.gif";

    document.getElementById(Control_ID).src = ImageName;
}

function HowItWorksZeroFootPrintSigning(Control_ID, ImageName)
{
    document.getElementById("HIW_STEP1").src = "images/how-work-step8.gif";
    document.getElementById("HIW_STEP2").src = "images/how-work-step9.gif";
    document.getElementById("HIW_STEP3").src = "images/how-work-step10.gif";

    document.getElementById(Control_ID).src = ImageName;
}

function ShowORHideInfo(DIV_ID)
{
    if(document.getElementById(DIV_ID).style.visibility == "visible")
    {
        document.getElementById(DIV_ID).style.visibility = "hidden";
        document.getElementById(DIV_ID).style.display = "none";
    }
    else
    {
        document.getElementById(DIV_ID).style.visibility = "visible";
        document.getElementById(DIV_ID).style.display = "block";
    }
    return false;
};


//GridSure Registration JAVASCRIPT
function GrIDSure_RegisterUserClicked()
{        
    document.getElementById("ctl00_GTFBody_lblErrorUserName").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorConfirmPIP").innerHTML = "";
    document.getElementById("tdAjaxResponse").innerHTML = "";

    var UserName = document.getElementById("ctl00_GTFBody_txtUserName").value;
    var UserID = document.getElementById("ctl00_GTFBody_txtUserID").value;
    var PIP = document.getElementById("ctl00_GTFBody_txtPIP").value;
    var ConfirmedPIP = document.getElementById("ctl00_GTFBody_txtConfirmationPIP").value;

    if(UserName == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorUserName").innerHTML = "User name cannot be empty.";
        return false;
    }
                
    if(UserID == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "User id cannot be empty.";
        return false;
    }

    if(PIP == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "Please enter your PIP.";
        return false;
    }

    if(PIP.length < 4)
    {
        document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "Incomplete PIP.";
        return false;
    }

    if(ConfirmedPIP == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorConfirmPIP").innerHTML = "Please confirm your PIP.";
        return false;
    }              
                
    if(ConfirmedPIP.length < 4)
    {
        document.getElementById("ctl00_GTFBody_lblErrorConfirmPIP").innerHTML = "Incomplete confirmed PIP.";
        return false;
    }

    if(PIP.toLowerCase() != ConfirmedPIP.toLowerCase())
    {
        document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "Your PIP and Confirmed PIP don't match.";
        return false;
    }

    document.getElementById("ProgressDIV").style.visibility = "visible";
    document.getElementById("ProgressDIV").style.display = "block";
 
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return false;
    } 

    var url = "AjaxHandler.aspx";
    url = url + "?Operation=GrIDSureRegistration";
    url = url + "&UserName=" + UserName;
    url = url + "&UserID=" + UserID;
    url = url + "&PIP=" + PIP;

    xmlHttp.onreadystatechange = GrIDSureRegistrationCompleted;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
   
    return false;
}

function GetXmlHttpObject()
{
    var xmlHttp;
    try
    {  
        xmlHttp=new XMLHttpRequest();  // For Fire fox, Opera, Safari
    }
    catch (e)
    {  
        try
        {    
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // For Internet Explorer  
        }
        catch (e)
        {    
            try
            {      
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
            }
            catch (e)
            {      
                return null;      
            }    
        }  
    }  
    return xmlHttp;
}
    
// This function will be called when the Server has replied with the response to our Ajax Query.
function GrIDSureRegistrationCompleted() 
{ 
    if (xmlHttp.readyState==4)
    { 
        var AjaxResponse = xmlHttp.responseText;        
        var EndIndex = AjaxResponse.indexOf("</AJAXRESPONSE>");       
        var ResponseHTML = AjaxResponse.substring(14, EndIndex);

        document.getElementById("ProgressDIV").style.visibility = "hidden";
        document.getElementById("ProgressDIV").style.display = "none";
        
        document.getElementById("tdAjaxResponse").innerHTML = ResponseHTML;
    }
}
// End (GridSure Registration JAVASCRIPT)

function ValidateContactUsPage()
{
    document.getElementById("ctl00_GTFBody_lblErrorName").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorPhoneNo").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorCompany").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorInterest").innerHTML = "";
    document.getElementById("ctl00_GTFBody_RegularExpressionValidator2").style.visibility = "hidden";
    
    var FullName = document.getElementById("ctl00_GTFBody_txtFullName").value;
    var EMailAddress = document.getElementById("ctl00_GTFBody_txtEMailAddress").value;
    var PhoneNo = document.getElementById("ctl00_GTFBody_txtPhoneNumber").value;
    var Company = document.getElementById("ctl00_GTFBody_txtCompany").value;
    
    if(FullName == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorName").innerHTML = "Please provide your full name.";
        return false;
    }    
    
    if(EMailAddress == "")
    {
        document.getElementById("ctl00_GTFBody_RegularExpressionValidator2").style.visibility = "visible";
        return false;
    }    

    if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator2").style.visibility == "visible")
    {
        return false;
    }
    
    if(PhoneNo == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorPhoneNo").innerHTML = "Please provide your phone number.";
        return false;
    }
    
    if(Company == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorCompany").innerHTML = "Please provide your company name.";
        return false;
    }    
    
    if(document.getElementById("ctl00_GTFBody_chkInterest1").checked)
        return true;
  
    if(document.getElementById("ctl00_GTFBody_chkInterest2").checked)
        return true;

    if(document.getElementById("ctl00_GTFBody_chkInterest3").checked)
        return true;

    if(document.getElementById("ctl00_GTFBody_chkInterest4").checked)
        return true;

    if(document.getElementById("ctl00_GTFBody_chkInterest5").checked)
        return true;
        
    document.getElementById("ctl00_GTFBody_lblErrorInterest").innerHTML = "Please check your area of interest.";  
    return false;
}

function SetDateTime(Date2Set)
{
    if(Date2Set == 1)
    {
        document.getElementById("ctl00_GTFBody_ExpiryDate_radDay").selectedIndex = 1;// "02 January 2007";
        document.getElementById("ctl00_GTFBody_ExpiryDate_radMonth").selectedIndex = 0;//"02 January 2007";
        document.getElementById("ctl00_GTFBody_ExpiryDate_radYear").selectedIndex = 27;//"02 January 2007";
    }
    else if(Date2Set == 2)
    {
        document.getElementById("ctl00_GTFBody_ExpiryDate_radDay").selectedIndex = 10;// "11 April 2008";
        document.getElementById("ctl00_GTFBody_ExpiryDate_radMonth").selectedIndex = 3;
        document.getElementById("ctl00_GTFBody_ExpiryDate_radYear").selectedIndex = 28;
    }
    else if(Date2Set == 3)
    {
        var time=new Date();
        document.getElementById("ctl00_GTFBody_ExpiryDate_radDay").selectedIndex = time.getDate()-1;// "10 April 2008";
        document.getElementById("ctl00_GTFBody_ExpiryDate_radMonth").selectedIndex = time.getMonth();
        document.getElementById("ctl00_GTFBody_ExpiryDate_radYear").selectedIndex = 28;
    }
    else if(Date2Set == 4)
    {
        document.getElementById("ctl00_GTFBody_RevocationDate_radDay").selectedIndex = 1;//"02 January 2007"
        document.getElementById("ctl00_GTFBody_RevocationDate_radMonth").selectedIndex = 0;
        document.getElementById("ctl00_GTFBody_RevocationDate_radYear").selectedIndex = 27;
    }
    else if(Date2Set == 5)
    {
        document.getElementById("ctl00_GTFBody_RevocationDate_radDay").selectedIndex = 4;//"11 April 2008"
        document.getElementById("ctl00_GTFBody_RevocationDate_radMonth").selectedIndex = 0;
        document.getElementById("ctl00_GTFBody_RevocationDate_radYear").selectedIndex = 30;
    }
    else if(Date2Set == 6)
    {
        var time=new Date();
        document.getElementById("ctl00_GTFBody_RevocationDate_radDay").selectedIndex = time.getDate()-1;
        document.getElementById("ctl00_GTFBody_RevocationDate_radMonth").selectedIndex = time.getMonth();
        document.getElementById("ctl00_GTFBody_RevocationDate_radYear").selectedIndex = 30;
    }
    else if(Date2Set == 7)
    {
        document.getElementById("ctl00_GTFBody_RevocationDate_radDay").selectedIndex = 9;//"10 April 2015"
        document.getElementById("ctl00_GTFBody_RevocationDate_radMonth").selectedIndex = 3;
        document.getElementById("ctl00_GTFBody_RevocationDate_radYear").selectedIndex = 35;
    }
    else if(Date2Set == 8)
    {
        document.getElementById("ctl00_GTFBody_ExpiryDate_radDay").selectedIndex = 0;//"1 January 2008"
        document.getElementById("ctl00_GTFBody_ExpiryDate_radMonth").selectedIndex = 0;
        document.getElementById("ctl00_GTFBody_ExpiryDate_radYear").selectedIndex = 28;
    }
    else if(Date2Set == 9)
    {
        document.getElementById("ctl00_GTFBody_RevocationDate_radDay").selectedIndex = 0;//"1 January 2008"
        document.getElementById("ctl00_GTFBody_RevocationDate_radMonth").selectedIndex = 0;
        document.getElementById("ctl00_GTFBody_RevocationDate_radYear").selectedIndex = 28;
    }
    return false;
}

function GetCurrentDate()
{
    var months=new Array(13);
    months[1]="January";
    months[2]="February";
    months[3]="March";
    months[4]="April";
    months[5]="May";
    months[6]="June";
    months[7]="July";
    months[8]="August";
    months[9]="September";
    months[10]="October";
    months[11]="November";
    months[12]="December";

    var time=new Date();
    var lmonth=months[time.getMonth() + 1];
    var date=time.getDate();
    var year=time.getYear();
    if (year < 2000)
        year = year + 1900;

    var CurrentDate = date + " " + lmonth + " " + year
    return CurrentDate;
}

function Certification_SubmitClick()
{
    document.getElementById("ctl00_GTFBody_lblErrorCommonName").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblPasswordError").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblCPasswordError").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";
    
    var CommonName = document.getElementById("ctl00_GTFBody_txtCommonName").value;
    var Password = document.getElementById("ctl00_GTFBody_txtPassword").value;               
    var CPassword = document.getElementById("ctl00_GTFBody_txtConfirmationPassword").value;               
              
    if(CommonName == "")
    {
        //alert("User id cannot be empty.");
        document.getElementById("ctl00_GTFBody_lblErrorCommonName").innerHTML = "Common name cannot be empty.";
        return false;
    }

    if(Password == "")
    {
        document.getElementById("ctl00_GTFBody_lblPasswordError").innerHTML = "Password cannot be empty.";
        return false;
    }
    
    if(CPassword == "")
    {
        document.getElementById("ctl00_GTFBody_lblCPasswordError").innerHTML = "Please confirm your password.";
        return false;
    }
    
    if(Password.toLowerCase() != CPassword.toLowerCase())
    {
        document.getElementById("ctl00_GTFBody_lblCPasswordError").innerHTML = "Password and Confirmation password doesn't match.";
        return false;
    }

    return true;
}

function OCSP_ReceiveOCSPResponseClicked()
{
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";
    var SerialNumber = document.getElementById("ctl00_GTFBody_txtSerialNumber").value;
    if(SerialNumber == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "Please provide some serial number.";
        return false;
    }
    
    if(SerialNumber.indexOf(' ') != -1)
    {
        document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "Please remove the spaces from the serial number.";
        return false;
    }
    
    if(IsHex(SerialNumber) == false)
    {
        document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "Please enter a valid serial number in HEX format.";
        return false;
    }
    
    return true;
}

function OCSP_ReceiveOCSPResponseClickedWithBrowsed() {
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";
    var SerialNumber = document.getElementById("ctl00_GTFBody_txtSerialNumber").value;
    if (document.getElementById("ctl00_GTFBody_rdbEnterSerialNumber").checked) {
        if (SerialNumber == "") {
            document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "Please provide some serial number.";
            return false;
        }

        if (SerialNumber.indexOf(' ') != -1) {
            document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "Please remove the spaces from the serial number.";
            return false;
        }

        if (IsHex(SerialNumber) == false) {
            document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "Please enter a valid serial number in HEX format.";
            return false;
        }
        return true;
    }
    else if (document.getElementById("ctl00_GTFBody_rdbBrowseCertificate").checked) {
        return true;
    }
    
}

function IsHex(value)
{
    var String2Validate = value.toLowerCase();
    var HEXStringChars = "0123456789abcdef";
    for(i=0 ; i<String2Validate.length ; i++)
    {
        if( HEXStringChars.indexOf( String2Validate.charAt(i) ) == -1)
            return false;
    }
    
    return true;
}

function EMailSigning_Submit()
{
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";
    var EMailAddress = document.getElementById("ctl00_GTFBody_txtEmailAddress").value;
    if(EMailAddress == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "Please provide recipient Email address.";
        return false;
    }
    
    if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator2").style.visibility == "visible")
    {
        return false;
    }
    
    if(document.getElementById("ctl00_GTFBody_radUseUploadedDocument").checked)
    {
        if(document.getElementById("ctl00_GTFBody_fuUserFile").value == "")
        {
            document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility = "visible";
            return false;
        }
    
        if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility == "visible")
        {
            return false;
        }
    }
    
    alert("Please check your email address in a few minutes for an email from info@globaltrustfinder.com.");
    
    return true;
}

function EMailVerification_Submit()
{
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";
    var EMailAddress = document.getElementById("ctl00_GTFBody_txtEmailAddress").value;
    if(EMailAddress == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "Please provide recipient Email address.";
        return false;
    }
    
    if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator2").style.visibility == "visible")
    {
        return false;
    }
    
    if(document.getElementById("ctl00_GTFBody_radUseUploadedDocument").checked)
    {
        if(document.getElementById("ctl00_GTFBody_fuUserFile").value == "")
        {
            document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility = "visible";
            return false;
        }
    
        if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility == "visible")
        {
            return false;
        }
    }

    alert("Please check your email address in a few minutes for an email from info@ascertia.com.");
    
    return true;
}

function ValidateCorporateSigningPage()
{
    if(document.getElementById("ctl00_GTFBody_radUseUploadedDocument").checked)
    {
        if(document.getElementById("ctl00_GTFBody_fuUserFile").value == "")
        {
            document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility = "visible";
            return false;
        }
    
        if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility == "visible")
        {
            return false;
        }
    }
}

function ValidateVerificationPage()
{
    if(document.getElementById("ctl00_GTFBody_radUseUploadedDocument").checked)
    {
        if(document.getElementById("ctl00_GTFBody_fuUserFile").value == "")
        {
            document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility = "visible";
            return false;
        }
    
        if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility == "visible")
        {
            return false;
        }
    }
}

function ValidateX509CertificateValidationPage()
{
    if(document.getElementById("ctl00_GTFBody_radUseUploadedDocument").checked)
    {
        if(document.getElementById("ctl00_GTFBody_fuUserFile").value == "")
        {
            document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility = "visible";
            return false;
        }
    
        if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility == "visible")
        {
            return false;
        }
    }
}

function ValidateTSAMainPage()
{
    if(document.getElementById("ctl00_GTFBody_radUseUploadedDocument").checked)
    {
        if(document.getElementById("ctl00_GTFBody_fuUserFile").value == "")
        {
            document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility = "visible";
            return false;
        }
    
        if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility == "visible")
        {
            return false;
        }
    }
}

function OnChecked_CreateLongtermSignatures()
{
    if(document.getElementById("ctl00_GTFBody_chkLongtermSignature").checked)
    {
        document.getElementById("ctl00_GTFBody_radTSSignature").disabled = "";
        document.getElementById("ctl00_GTFBody_radFullLongtermSignature").disabled = "";
    }
    else
    {
        document.getElementById("ctl00_GTFBody_radTSSignature").disabled = "disabled";
        document.getElementById("ctl00_GTFBody_radFullLongtermSignature").disabled = "disabled";
    }       
}

function OnlyEnterDigits(the_Character)
{
	if ( ! the_Character )
	{
		the_Character = event.keyCode;
	}
	if(the_Character >= 48 && the_Character <= 57)
	{	
	}
	else
	{
		event.keyCode = '';
	}		
}

function OnlyEnterPhoneNumber(the_Character)
{
	if ( ! the_Character )
	{
		the_Character = event.keyCode;
	}
	
	if(the_Character >= 48 && the_Character <= 57 || (the_Character == 40 || the_Character == 41 || the_Character == 43) )
	{	
	}
	else
	{
		event.keyCode = '';
	}		
}

function OnlyEnterHEX(the_Character)
{
	if ( ! the_Character )
	{
		the_Character = event.keyCode;
	}
	if(the_Character >= 48 && the_Character <= 57)
	{	
	}
	else if(the_Character >= 65 && the_Character <= 70)
	{
	}
	else if(the_Character >= 97 && the_Character <= 102)
	{
	}
	else
	{
		event.keyCode = '';
	}		
}

function GridSure_LogInClick()
{
    document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";

    var UserID = document.getElementById("ctl00_GTFBody_txtUserID").value;
    var PIP = document.getElementById("ctl00_GTFBody_txtPIP").value;               
              
    if(UserID == "")
    {
        //alert("User id cannot be empty.");
        document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "User id cannot be empty.";
        return false;
    }

    if(PIP == "")
    {
        //alert("Please enter your PIP.");
        document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "Please enter your PIP.";
        return false;
    }

    if(PIP.length < 4)
    {
        //alert("Incomplete PIP.");
        document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "Incomplete PIP.";
        return false;
    }

    return true;
}

function GrIDSure_SignClick()
{
    document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";

    var PIP = document.getElementById("ctl00_GTFBody_txtPIP").value;                           
    if(PIP == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "Please enter your PIP.";
        return false;
    }

    if(PIP.length < 4)
    {
        document.getElementById("ctl00_GTFBody_lblErrorPIP").innerHTML = "Incomplete PIP.";
        return false;
    }

    return true;
}

function OnClickUserDefaultDocument()
{
    document.getElementById("ctl00_GTFBody_fuUserFile").disabled = "disabled";    
}

function OnClickUserUploadedDocument()
{
    document.getElementById("ctl00_GTFBody_fuUserFile").disabled = "";
}

/******************/
function OnClickUserLocalKeys() {
    document.getElementById("ctl00_GTFBody_btnRegister").disabled = "disabled";
    document.getElementById("ctl00_GTFBody_txtUserID").disabled = "disabled";
     //   document.getElementById("ctl00_GTFBody_txtPassword").disabled = "disabled";
    if (document.getElementById("ctl00_GTFBody_rdbLocalHeldKeys").checked) {
        document.getElementById("ctl00_GTFBody_pnlLoginView").disabled = "disabled";
        document.getElementById("ctl00_GTFBody_pnlLoginView").style.display = 'none';
        document.getElementById("tr1").style.display = 'none';
    }
    document.getElementById("ctl00_GTFBody_pnlLoginView").style.display = 'none';
}

function OnClickUserRoamingKeys() {
    document.getElementById("ctl00_GTFBody_btnRegister").disabled = "";
    document.getElementById("ctl00_GTFBody_txtUserID").disabled = "";
    //document.getElementById("ctl00_GTFBody_txtPassword").disabled = "";
    document.getElementById("ctl00_GTFBody_pnlLoginView").disabled = "";
    document.getElementById("tr1").style.display = '';
    document.getElementById("ctl00_GTFBody_pnlLoginView").style.display = '';
}
/******************/
///*****Enable / Disable File Browsing for ZeroFootPrintPKCS7*******/
//function OnClickUserDefaultDocumentZeroFootPrintPKCS()
//{
//    document.getElementById("ctl00_GTFBody_GoSignFileChooser").disabled = "disabled";    
//}

//function OnClickUserUploadedDocumentZeroFootPrintPKCS()
//{
//    document.getElementById("ctl00_GTFBody_GoSignFileChooser").disabled = "";    
//}
///****************************************************************/

function OnClickSignFirstPage()
{
    document.getElementById("ctl00_GTFBody_radCertifiedSignature").disabled = "";
    document.getElementById("ctl00_GTFBody_radInvisibleSignature").disabled = "";
}

function OnClickSignAllPages()
{
    document.getElementById("ctl00_GTFBody_radCertifiedSignature").disabled = "disabled";
    document.getElementById("ctl00_GTFBody_radInvisibleSignature").disabled = "disabled";
}

function OnClickCreateVisibleSignature()
{
    document.getElementById("ctl00_GTFBody_radSignAllPages").disabled = "";
}

function OnClickCreateCertifiedSignature()
{
    document.getElementById("ctl00_GTFBody_radSignAllPages").disabled = "disabled";
}

function OnClickCreateInvisibleSignature()
{
    document.getElementById("ctl00_GTFBody_radSignAllPages").disabled = "disabled";
}

function OnClickCreateTimestampedSignature()
{
    document.getElementById("ctl00_GTFBody_radSignAllPages").disabled = "";
}

function OnClickArchivingStep1_SignDocument() {
    document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "";
    //    document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "";
    //    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";
    
    var ReferenceID = document.getElementById("ctl00_GTFBody_txtReferenceNumber").value;


    if (ReferenceID == "") {
        document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "<br/>Please provide reference number";
        return false;
    }
    return true;
}

function OnClickUserSigning_SignDocument()
{
    document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";

    var UserID = document.getElementById("ctl00_GTFBody_txtUserID").value;
    var Password = document.getElementById("ctl00_GTFBody_txtPassword").value;
    
    if(UserID == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "<br/>Please provide some user id";
        return false;
    }
    
    if(Password == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "Please enter a password";
        return false;
    }
    
    if(document.getElementById("ctl00_GTFBody_radUseUploadedDocument").checked)
    {
        if(document.getElementById("ctl00_GTFBody_fuUserFile").value == "")
        {
            document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility = "visible";
            return false;
        }
    
        if(document.getElementById("ctl00_GTFBody_RegularExpressionValidator1").style.visibility == "visible")
        {
            return false;
        }
    }

    return true;
}

function UserSigning_RegisterClick()
{    
    document.getElementById("ctl00_GTFBody_lblErrorUserName").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorConfirmPassword").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";
    document.getElementById("tdAjaxResponse").innerHTML = "";
    
    var UserName = document.getElementById("ctl00_GTFBody_txtCertificateAlias").value;
    var UserID = document.getElementById("ctl00_GTFBody_txtUserID").value;
    var Password = document.getElementById("ctl00_GTFBody_txtPassword").value;
    var ConfirmedPassword = document.getElementById("ctl00_GTFBody_txtConfirmationPassword").value;
    
    if(UserName == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorUserName").innerHTML = "Please provide some User Name.";
        return false;
    }

    if(UserID == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "Please provide some User ID.";
        return false;
    }

    if(Password == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "Password cannot be empty.";
        return false;
    }

    if(ConfirmedPassword == "")
    {
        document.getElementById("ctl00_GTFBody_lblErrorConfirmPassword").innerHTML = "Please confirm your password.";
        return false;
    }

    if(Password.toLowerCase() != ConfirmedPassword.toLowerCase())
    {
        document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "Password and Confirmation password doesn't match.";
        return false;
    }

    document.getElementById("ProgressDIV").style.visibility = "visible";
    document.getElementById("ProgressDIV").style.display = "block";
    
    xmlHttp = GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return false;
    } 

    var url = "AjaxHandler.aspx";
    url = url + "?Operation=UserSigningRegistration";
    url = url + "&UserName=" + UserName;
    url = url + "&UserID=" + UserID;
    url = url + "&Password=" + Password;

    xmlHttp.onreadystatechange = UserSigningRegistrationCompleted;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    
   
    return false;
}

/********Generate Roaming Key**********/
function UserRoamingKey_RegisterClick() {    
  //  document.getElementById("ctl00_GTFBody_lblErrorUserName").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorConfirmPassword").innerHTML = "";
    document.getElementById("ctl00_GTFBody_lblErrorMessage").innerHTML = "";
    document.getElementById("tdAjaxResponse").innerHTML = "";
    
    var UserName = document.getElementById("ctl00_GTFBody_txtUserID").value;
    var UserID = document.getElementById("ctl00_GTFBody_txtUserID").value;
    var Password = document.getElementById("ctl00_GTFBody_txtPassword").value;
    var ConfirmedPassword = document.getElementById("ctl00_GTFBody_txtConfirmationPassword").value;    
    if (UserName == "") {
        document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "User ID cannot be blank.";
        return false;
    }

    if (UserID == "") {
        document.getElementById("ctl00_GTFBody_lblErrorUserID").innerHTML = "User ID cannot be blank.";
        return false;
    }

    if (Password == "") {
        document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "Password cannot be empty.";
        return false;
    }

    if (ConfirmedPassword == "") {
        document.getElementById("ctl00_GTFBody_lblErrorConfirmPassword").innerHTML = "Please confirm your password.";
        return false;
    }

    if (Password.toLowerCase() != ConfirmedPassword.toLowerCase()) {
        document.getElementById("ctl00_GTFBody_lblErrorPassword").innerHTML = "Password and Confirmation password doesn't match.";
        return false;
    }

    document.getElementById("ProgressDIV").style.visibility = "visible";
    document.getElementById("ProgressDIV").style.display = "block";

    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return false;
    }

    var url = "AjaxHandler.aspx";
    url = url + "?Operation=GenerateRoamingKeys";
    url = url + "&UserName=" + UserName;
    url = url + "&UserID=" + UserID;
    url = url + "&Password=" + Password;

    xmlHttp.onreadystatechange = UserSigningRegistrationCompleted;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    return false;
}
/******************/
/*******************/
function Buy_Stock_Signing() {
    //document.getElementById("tdAjaxResponse").innerHTML = "";
    alert("Call Buy_Stock_Signing");
    var UserName = document.getElementById("txt_price").value;          //Price
    var UserID = document.getElementById("txt_contactDetails").value;   //Quantity
    //var Password = document.getElementById("ctl00_GTFBody_txtPassword").value;

    xmlHttp = GetXmlHttpObject();
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!");
        return false;
    }

    var url = "BuyConfirmationDemo.aspx";
    url = url + "?Price=" + UserName;
    url = url + "&Quantity=" + UserID;
    url = url + "&Company=" + "Emaar";

    xmlHttp.onreadystatechange = UserSigningRegistrationCompleted;
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
    return false;
}
/*******************/


function UserSigningRegistrationCompleted()
{
    if (xmlHttp.readyState==4)
    { 
        var AjaxResponse = xmlHttp.responseText;        
        var EndIndex = AjaxResponse.indexOf("</AJAXRESPONSE>");       
        var ResponseHTML = AjaxResponse.substring(14, EndIndex);

        document.getElementById("ProgressDIV").style.visibility = "hidden";
        document.getElementById("ProgressDIV").style.display = "none";
        
        document.getElementById("tdAjaxResponse").innerHTML = ResponseHTML;
    }
}

function UploadNonPDFFileCheck(source, arguments) {
    var sFile = arguments.Value;
    arguments.IsValid =
            sFile.endsWith('.cer') ||
            sFile.endsWith('.CER') ||
            sFile.endsWith('.cert') ||
            sFile.endsWith('.CERT');

}

function OnClickUserArchiveOperation() {
    if (document.getElementById("ctl00_GTFBody_radSecureArchiveDocument").checked) {
        document.getElementById("ctl00_GTFBody_fuUserFile").disabled = "";
        document.getElementById("ctl00_GTFBody_btnProceedArchive").disabled = "disabled";
        document.getElementById("ctl00_GTFBody_btnSecurlyArchiveFile").disabled = "";
        document.getElementById("ctl00_GTFBody_btnSearchArchive").disabled = "disabled";

        //Set Text Box and DropDown list Enable False
        document.getElementById("ctl00_GTFBody_txtReferenceNumber").disabled = "disabled";
        document.getElementById("ctl00_GTFBody_ddlArchiveOperatiionType").disabled = true;

        document.getElementById("ctl00_GTFBody_txtReferenceNumber").disabled = true;
        document.getElementById("ctl00_GTFBody_txtSearchByOwner").disabled = true;
        document.getElementById("ctl00_GTFBody_txtSearchByLocation").disabled = true;
        document.getElementById("ctl00_GTFBody_txtSearchByTitle").disabled = true;
        document.getElementById("ctl00_GTFBody_txtReferenceNumber").disabled = true;
        
        document.getElementById("ctl00_GTFBody_txtOwnerName").disabled = false;
        document.getElementById("ctl00_GTFBody_txtLocation").disabled = false;
        document.getElementById("ctl00_GTFBody_txtTitleToArchive").disabled = false;
    }
        else if (document.getElementById("ctl00_GTFBody_radManageArchive").checked) {
        document.getElementById("ctl00_GTFBody_fuUserFile").disabled = "disabled";
        document.getElementById("ctl00_GTFBody_btnProceedArchive").disabled = "";
        document.getElementById("ctl00_GTFBody_btnSearchArchive").disabled = "disabled";
        document.getElementById("ctl00_GTFBody_btnSecurlyArchiveFile").disabled = "disabled";

        //Disable/Enable Text Boxes
        document.getElementById("ctl00_GTFBody_txtSearchByOwner").disabled = true;
        document.getElementById("ctl00_GTFBody_txtSearchByLocation").disabled = true;
        document.getElementById("ctl00_GTFBody_txtSearchByTitle").disabled = true;

        document.getElementById("ctl00_GTFBody_txtReferenceNumber").disabled = true;
        document.getElementById("ctl00_GTFBody_txtOwnerName").disabled = true;
        document.getElementById("ctl00_GTFBody_txtLocation").disabled = true;
        document.getElementById("ctl00_GTFBody_txtTitleToArchive").disabled = true;
        
        document.getElementById("ctl00_GTFBody_txtReferenceNumber").disabled = false;
        
        //Enable Dropdown List
        document.getElementById("ctl00_GTFBody_ddlArchiveOperatiionType").disabled = false;        
        
    }
    else if (document.getElementById("ctl00_GTFBody_radSearchArchive").checked) {
    document.getElementById("ctl00_GTFBody_fuUserFile").disabled = "disabled";
    document.getElementById("ctl00_GTFBody_btnProceedArchive").disabled = "disabled";
    document.getElementById("ctl00_GTFBody_btnSearchArchive").disabled = "";
    document.getElementById("ctl00_GTFBody_btnSecurlyArchiveFile").disabled = "disabled";

    //Enable Text Boxes
    document.getElementById("ctl00_GTFBody_txtReferenceNumber").disabled = true;
    document.getElementById("ctl00_GTFBody_txtOwnerName").disabled = true;
    document.getElementById("ctl00_GTFBody_txtLocation").disabled = true;
    document.getElementById("ctl00_GTFBody_txtTitleToArchive").disabled = true;
    
    document.getElementById("ctl00_GTFBody_txtSearchByOwner").disabled = false;
    document.getElementById("ctl00_GTFBody_txtSearchByLocation").disabled = false;
    document.getElementById("ctl00_GTFBody_txtSearchByTitle").disabled = false;
    }
    
}

function OnClickUserArchiveOperation2() {
    document.getElementById("ctl00_GTFBody_fuUserFile").disabled = "";
}

function OnClickUserArchiveOperation3() {
    document.getElementById("ctl00_GTFBody_fuUserFile").disabled = "";
}

function confirmdel() {
    if (confirm("Are you Sure you want to delete the Metatags")) {
        return true;
    }
    return false;
}


