function BrowseServer( startupPath, functionData )
{
    // You can use the "CKFinder" class to render CKFinder in a page:
    var finder = new CKFinder();
    // The path for the installation of CKFinder (default = "/ckfinder/").
    finder.BasePath = 'lib/php/ckfinder/' ;
    //Startup path in a form: "Type:/path/to/directory/"
    finder.StartupPath = startupPath;
    // Name of a function which is called when a file is selected in CKFinder.
    finder.SelectFunction = SetFileField ;
    // Additional data to be passed to the SelectFunction in a second argument.
    // We'll use this feature to pass the Id of a field that will be updated.
    finder.SelectFunctionData = functionData ;
    // Name of a function which is called when a thumbnail is selected in CKFinder.
    finder.SelectThumbnailFunction = ShowThumbnails ;
    // Launch CKFinder
    finder.Popup();
}

// This is a sample function which is called when a file is selected in CKFinder.
function SetFileField( fileUrl, data )
{
    document.getElementById( data["selectFunctionData"] ).value = fileUrl ;
}

// This is a sample function which is called when a thumbnail is selected in CKFinder.
function ShowThumbnails( fileUrl, data )
{
    var sFileName = decodeURIComponent( fileUrl.replace( /^.*[\/\\]/g, '' ) ) ;
    document.getElementById( 'thumbnails' ).innerHTML +=
        '<div class="thumb">' +
            '<img src="' + fileUrl + '" />' +
            '<div class="caption">' +
                    '<a href="' + data["fileUrl"] + '" target="_blank">' + sFileName + '</a> (' + data["fileSize"] + 'KB)' +
            '</div>' +
        '</div>' ;

    document.getElementById( 'preview' ).style.display = "";
    // It is not required to return any value.
    // When false is returned, CKFinder will not close automatically.
    return false;
}

function showSWF(holder_id, path, arg, width, height, bgColor, requiredMajorVersion, requiredMinorVersion, requiredRevision)
{
    var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

    // Check to see if the version meets the requirements for playback
    if (hasReqestedVersion) {
            // if we've detected an acceptable version
            // embed the Flash Content SWF when all tests are passed
            AC_FL_RunContent(
                "src", path,
                "urlvars", arg,
                "width", width,
                "height", height,
                "align", "middle",
                "base", ".",
                "wmode", "opaque",
                "id", holder_id+"swf",
                "quality", "high",
                "bgcolor", bgColor,
                "name", holder_id+"swf",
                "allowScriptAccess","sameDomain",
                "type", "application/x-shockwave-flash",
                'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
                "pluginspage", "http://www.adobe.com/go/getflashplayer"
            );
    } else {  // flash is too old or we can't detect the plugin
            var alternateContent = 'This content requires the Adobe Flash Player. '
            + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
            document.write(alternateContent);  // insert non-flash content
    }
}

function validateForm(formObj)
{
    isValid = true;

    $(".errMsg").css("display", "none");
   
    $( "#"+$(formObj).attr("id")+" .required").each(function(){
        errorFound = true;
        errorMsg = "";
        
        if( $(this).val() == "" ) {
            errorFound = false;
            errorMsg = " * Field is required";
        }
        else if( $(this).hasClass("email") )
        {
            emailReg = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
            errorFound = emailReg.test($(this).val());
            errorMsg = " * Invalid email format";
        }
        else if ( $(this).hasClass("regex") )
        {
            var regex = new RegExp($(this).attr("expression"));
            targetStr = $(this).val();
            errorFound = regex.test(targetStr);
            errorMsg = " * Invalid format " + $(this).attr("format");
        }

        if( !errorFound )
        {
            $(".errMsg[for="+$(this).attr("id")+"]").css("display", "inline");
            $(".errMsg[for="+$(this).attr("id")+"]").html(errorMsg);
            isValid = errorFound;
        }
    });

    return isValid;
}
