﻿    $(document).ready( function() {

        // Hide descriptions on pages with Circle Nav Widget
        $("#flashAnimationContent div").each( function() {
            $("#" + this.id).css("display", "none");
        });

        // Set the min-height on the #content container relative to their window height to avoid short pages
        var winHeight = $(window).height();
        var docHeight = $("body").height();
        var contentHeight = $("#contentContainer").height();
        var newContentHeight = contentHeight + (winHeight - docHeight);
        var newContentHeightInEm = newContentHeight.pxToEm();

	    if (contentHeight < newContentHeight)
	    {
        	$("#contentContainer").css("min-height",newContentHeightInEm);
        	// No min-height support in IE6, so just set height instead
        	if (jQuery.browser.msie) {
                if(parseInt(jQuery.browser.version) == 6) {
                    $("#contentContainer").css("height",newContentHeightInEm);
                }
            } 
	    }

        // Create accordion when #accordionContainer is present
        $(".ui-accordion-container").each( function() {
            $("#" + this.id).accordion({
                autoHeight: false,
                alwaysOpen: false,
                active: false,
                header: "a.ui-accordion-link"
            });
            $("#" + this.id + " li").css({"padding-bottom":"0"});
        });
        
        // Initialize facebox
        $("a[rel*=facebox]").facebox();
        
        // Truncated text
        $(".untruncated").each( function() {
            $(this).hide();
        });
        $(".showTruncated").click( function() {
            $(this).parent().hide().parent().find(".untruncated").show();
            return false;
        });
        $(".hideTruncated").click( function() {
            $(this).parent().hide().parent().find(".truncated").show();
            return false;
        });

        // Selects all elements with class of "Button" or "button" and replaces with roundButton class, then adds button end-caps
        // before and after the element
        $(".Button,.button").each( function() {
            $(this).attr("class","roundButton").before("<img src=\"images/roundButton_left.png\" style=\"vertical-align: top;\" />").after("<img src=\"images/roundButton_right.png\" style=\"vertical-align: top;\" />");
            if (jQuery.browser.msie) {
                $(this).css({"padding-bottom":"0.3em"});
            }
        });
        
        // Bind click event for pop-up classes
        $(".popup,.pdfLink,.extLink").click( function() { window.open(this.href); return false; });
        
        // Rounded corners on testimonial boxes
        $(".testimonialBoxRight").corner();
        
    }); // close document.ready
    
    // Destroy accordion when #destroyAccordion is clicked
    function destroyAccordion(id)
    {
        $("#" + id).accordion("destroy"),
        $("#" + id + "Destroy").remove(),
        $("#" + id + " .ui-accordion-link").each( function () {
            $(this).replaceWith("<h3 class=\"destroyed-accordion-header\">" + $(this).text() + "</h3>");
        });
        return false;
    //            $(".ui-accordion-data").css({"padding-bottom":"2em"});
    }
    
    // eWebEditPro initialization
    function eWebEditProExecCommand(sEditorName, strCmdName, strTextData, lData)
    {
        if("jsdynamicarticle" == strCmdName)
        {
            eWebEditPro.instances[0].editor.pasteHTML("~article=&LT;id&GT;~");
        }
        //return false;
        return true;
    }

    function eWebEditProReady(sEditorName)
    {
	    var objMedia = eWebEditPro.instances[sEditorName].editor.MediaFile();
	    var g_strConfiguredPath = objMedia.getPropertyString("DefDestinationDir");

	    objMedia.setProperty("DefDestinationDir", " ");
	    g_strConfiguredPath = objMedia.getPropertyString("DefDestinationDir");
    //	alert("g_strConfiguredPath = "+g_strConfiguredPath);

	    //var webroot = objMedia.getPropertyString("webroot");
	    //alert("webroot = "+webroot);
	    objMedia.setProperty('webroot', '<%=Application("FTPUploadDir")%>');
    //	webroot = objMedia.getPropertyString("webroot");
    //	alert("webroot = "+webroot);

	    objMedia.setProperty('domain', '<%=Application("FTPUploadDomain")%>');
	    objMedia.setProperty('LoginName', '<%=Application("FTPImageUser")%>');	
	    objMedia.setProperty('Password', '<%=Application("FTPImagePass")%>');	
    	
    }
