/*
 *
 * Site Specific Functions:
 *
 */
    function setTableDisplay(items,displayValue,type){

            if(!type){type = 'table-row';}

            displayType = (displayValue)?(navigator.appName == "Netscape")?type:'inline':'none';

            itemArray = items.split(",");

            for(i=0;i<itemArray.length;i++){

                document.getElementById(itemArray[i]).style.display=displayType;

            } //end for

    } // function

/*
 *
 * REUSABLE FUNCTIONS
 *
 */
// Delete Prompt
function confirmDelete() {
    return confirm('Do you want to remove this?');
} // function

/**
 * This will ask the user a question.  You may pass a parameter message to
 * be the display value of the question.
 * @since 2006.03.30
 */
function ask(message) {

    if (message == "") {
        message = 'Are you sure?';
    } // if

    return confirm(message);

} // function


// Show/Hide Span!
function swap_content_image(url_to_images, content_id) {

    displayType=(document.getElementById(content_id).style.display=='none') ? 'block' : 'none';
    document.getElementById(content_id).style.display=displayType;

    document.getElementById(content_id + '_arrowimage').src=(document.getElementById(content_id).style.display=='none')
        ? url_to_images + 'arrow_up.gif'
        : url_to_images + 'arrow_down.gif';

}


myTimer = "";
function animateY(target,friction,finish_y,dify){
    clearTimeout(myTimer);
    if((dify>1 && finish_y!=startY) || (finish_y==startY && dify<(1)) ) {
        speed = dify*friction;
        document.getElementById(target).style.top = findPosY(document.getElementById(target),target,'0')+speed+'px';
        dify = finish_y-findPosY(document.getElementById(target),target,'0');
        myTimer = setTimeout("animateY('"+target+"','"+friction+"','"+finish_y+"','"+dify+"')",20);
    }

}


/*/
 *  Get the x position of an
 * 	object on the current page
 * 	and align the object by the
 * 	offset of a layer.
/*/
function findPosX(obj,layer,offSet){
    var layerOffset = 0;
    var curleft = 0;
    if (obj.offsetParent){
        while (obj.offsetParent){
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }else if (obj.x){
        curleft += obj.x;
    }
    return curleft-offSet;
}
/*/
 *  Get the y position of an
 * 	object on the current page
 * 	and align the object by the
 * 	offset of a layer.
/*/
function findPosY(obj,layer,offset){
    var curtop = 0;
    if (obj.offsetParent){
        while (obj.offsetParent){
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }else if (obj.y){
        curtop += obj.y;
    }
    return curtop-offset;
}


// Clear an input box
function clearBox(obj, defaultValue) {
    if (obj.value == defaultValue) {
        obj.value = '';
    } // if
} // function


// Redirect
function jsRedirect(url) {

    if (
        (url != 'NULL') &&
        (url != "")
    ) {
        window.location = url;
    } // if

} // function


/**
 * Show/Hide Span!
 */
function swap_content(content_id) {
    displayType=(document.getElementById(content_id).style.display=='none') ? 'block':'none';
    document.getElementById(content_id).style.display=displayType;
}


/**
 * Hide Span!
 */
function hide(content_id) {
    document.getElementById(content_id).style.display='none';
} // function


/**
 * Show Span!
 */
function show(content_id) {
    document.getElementById(content_id).style.display='block';
} // function


/**
 * changeClass
 *
 * Change the class of an HTML object.
 *
 * @param string id 		Element Id
 * @param string newClass 	New Class Name
 * @return true
 * @since 2006.01.11
 */
function changeClass(id, newClass) {

    identity=document.getElementById(id);
    identity.className=newClass;

    return true;

} // function


/**
 * find the Y position of any html element.
 * @see http://www.quirksmode.org/js/findpos.html
 */
function findElementPositionX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}


/**
 * find the Y position of any html element.
 * @see http://www.quirksmode.org/js/findpos.html
 */
function findElementPositionY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}


/**
 * setLayer
 *
 * Turn a layer on
 * @see http://www.quirksmode.org/js/findpos.html
 */
function setLayer(obj,layer)
{
    var newX = findElementPositionX(obj);
    var newY = findElementPositionY(obj);
    if (layer == 'testP') newY -= 50;
    var x = new getObj(layer);
    x.style.top = newY + 'px';
    x.style.left = newX + 'px';
    document.getElementById(layer).style.display='block';
}


/**
 * Get an object
 *
 * @see http://www.quirksmode.org/js/findpos.html
 */
function getObj(name)
{
 if (document.getElementById)
 {
       this.obj = document.getElementById(name);
       this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
       this.obj = document.all[name];
       this.style = document.all[name].style;
 }
 else if (document.layers)
 {
       if (document.layers[name])
       {
           this.obj = document.layers[name];
           this.style = document.layers[name];
       }
       else
       {
        this.obj = document.layers.testP.layers[name];
        this.style = document.layers.testP.layers[name];
       }
 }
}

/**
 * This function will display some help text via alert to the user
 * on how to use the date input field.
 */
function strtotimeHelp() {
    alert(
    "You may use the following formats for Date fields:\n"+
    "1972-09-24\n"+
    "72-9-24\n"+
    "72-09-24\n"+
    "9/24/72\n"+
    "24 September 1972\n"+
    "24 Sept 72\n"+
    "24 Sep 72\n"+
    "Sep 24, 1972\n"+
    "24-sep-72\n"+
    "24sep72\n"
    );
} // function


    /**
     * This is used with the FCKEditor FCKImageResizer to resize images from a
     * POSTED FCK buffer.
     * @param string target Target HTML element to grab images from.
     * @author Bill Numerick <bill@byte-productions.com>
     * @since 2005.07.15
     */
    function getImages(target){
        // Main iframe
        var iframe = document.getElementById(target+'___Frame').contentWindow;
        // iFrame with the html contents in it
        var iFrameEditor = iframe.document.getElementById('eEditorArea').contentWindow;
        // document of iFrameEditor
        var iframeDoc = iFrameEditor.document;
        var imageList="";
        for(i=0;i<iframeDoc.images.length;i++){
            // create element
            var element = document.createElement("input");
            // set to hidden
            element.type = "hidden";
            // give it a name
            element.name = "image["+i+"]";
            // create an string with name~width~height
            element.value = iframeDoc.images[i].src+"~"+iframeDoc.images[i].width+"~"+iframeDoc.images[i].height
            // append to document
            document.forms[0].appendChild(element);
        }
    }

