//--------------------------------------------------------------------------------------
// General javascript methods.
//--------------------------------------------------------------------------------------
function redirect( url )
{
    self.location.replace( url );
}

//-------------------------------------------------------------------------
function CheckTerms()
{
    var obj = document.getElementById( 'cbAgreeToTerms' );
    if ( obj == null )
        return false;
        
    if ( obj.checked == false )
    {
        alert( 'Please agree to the Terms and Conditions before submitting\nyour document for conversion to PDF. Thank-You!');
        return false;
    }
    
    return true;
}

//-------------------------------------------------------------------------
function SetStep3( fld, state )
{
    var obj = document.getElementById( fld );
    obj.style.display = state;
}

//-------------------------------------------------------------------------
function ShowStep3()
{
    SetStep3( "tblShowDocSettings", "" );
    SetStep3( "tblHideDocSettings", "none" );
}

//-------------------------------------------------------------------------
function HideStep3( fld, state )
{
    SetStep3( "tblShowDocSettings", "none" );
    SetStep3( "tblHideDocSettings", "" );
}

//-------------------------------------------------------------------------
function SetControls()
{
    var obj = document.getElementById( 'ddlEncryption' );
    if ( obj != null )
        EnableDocSettings( obj.selectedIndex == 0 );
}

//-------------------------------------------------------------------------
function SetFld( fld, state )
{
    var obj = document.getElementById( fld );
    if ( obj != null )
    {
        obj.disabled = state;
        obj.style.display = "";
    }
}

//-------------------------------------------------------------------------
function EnableDocSettings( state )
{
    SetFld( 'tbDocumentOpenPassword', state );
    SetFld( 'tbPermissionsPassword', state );
    SetFld( 'ddlPrinting', state );
    SetFld( 'ddlContentCopyOrExtraction', state );
    SetFld( 'ddlChangingTheDocument', state );
}

//--------------------------------------------------------------------------------------
// General javascript methods.
//--------------------------------------------------------------------------------------
//-------------------------------------------------------------------------
function CheckUploadFilename(source, args)
{
    var s;
    var ss;
    
    args.IsValid = true;
    s = args.Value;

    if ( s.length >= 3 )
    {
        ss = s.substr( s.length-3, 3 );
        ss = ss.toUpperCase();
        if ( ss == ".PS" )
            return;
    }    

    if ( s.length >= 4 )
    {    
        ss = s.substr( s.length-4, 4 );
        ss = ss.toUpperCase();
        if ( ss == ".DOC" || ss == ".PPT" ||
             ss == ".TXT" || ss == ".RTF" ||
             ss == ".PRN" )
            return;
    }
    
    cvDataValidator.Text = "help";
    args.IsValid = false;
}

//-------------------------------------------------------------------------
function handleModalValues( strArg )
{
}

//-------------------------------------------------------------------------
function ShowDocTypesSupported()
{
    strArg  = '../App_SupportFiles/DialogFrame.aspx?';
    strArg += 'url=../_modalDialogs/DocTypesSupported.aspx';
    strArg += '&title=Other Document Types';
    doModal( strArg, 450, 225 );
}

//-------------------------------------------------------------------------
function ShowHowToCheckFileSize()
{
    strArg  = '../App_SupportFiles/DialogFrame.aspx?';
    strArg += 'url=../_modalDialogs/ShowHowToCheckDocSize.aspx';
    strArg += '&title=Show How To Check Document Size';
    doModal( strArg, 700, 790 );
}

//-------------------------------------------------------------------------
function ShowRestrictions()
{
    strArg  = '../App_SupportFiles/DialogFrame.aspx?';
    strArg += 'url=../_modalDialogs/DocRestrictionsInfo_fs.aspx';
    strArg += '&title=Document Settings';
    doModal( strArg, 620, 720 );
}
