﻿
/// <reference path="jquery-1.3.1.js" />

/// Will hide or show and element based on its state
/// if its display is block then it will set it to none
/// vice versa
function ShowHide(rid)
{

    //rid is the response id
    var resp = window.document.getElementById("Response_" + rid);



    if (resp.style.display == 'none')
    {
        resp.style.display = 'block';
    }
    else
    {
        resp.style.display = 'none';
    }

    return false;

}


function OpenRespWindow(url)
{

    window.open(url, 'ResponseWindow', 'width=550, height=337')
    return false

}


//###################################################################################################

function do_select(selName, selValue)
{
    //This function will check the correct value for a select element
    var checkFor;

    if (selValue != "")
    {
        var path = document.getElementById(selName)

        for (i = 0; i < path.length; i++)
        {
            checkFor = path[i].value
            if (checkFor == '') { checkFor = path[i].text }
            if (checkFor == selValue)
            {
                path[i].selected = true
            }

        }
    }

}

//##################################################################################################

//Gets to ids, and checks if they have the same hegiht.
//if not it will make them become the same height
//the adjust height will be added to the original height on demand.
//should usually be 0
function MakeSameHeight(Div1ID, Div2ID, AdjustHeight)
{
    if (typeof AdjustHeight == 'undefined' || AdjustHeight == null) { AdjustHeight = 0 };

    //Get both elements
    var div1 = $("#" + Div1ID);
    var div2 = $("#" + Div2ID);

    //Check if they have different height
    if (div1 != null && div2 != null)
    {

        if (div1.height() > div2.height())
        {

            div2.css('min-height', (div1.height() + AdjustHeight));

        }
        else
        {

            div1.css('min-height', (div2.height() + AdjustHeight));

        }

    }


}




//For creating the slide show
function slideSwitch()
{
    var $active = $('#MainLinks .MainLink.active');

    if ($active.length == 0) $active = $('#MainLinks .MainLink:last');

    var $next = $active.next().length ? $active.next()
        : $('#MainLinks .MainLink:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
        .addClass('active')
        .animate({ opacity: 1.0 }, 1000, function()
        {
            $active.removeClass('active last-active');
        });

    /*  
    var $activeLink = $('#LinksNav DIV.LinkActive');

    if ( $activeLink.length == 0 ) $activeLink = $('#LinksNav DIV:last');

    var $nextLink =  $activeLink.next().length ? $activeLink.next()
    : $('#LinksNav DIV:first');

    $activeLink.addClass('LinkLast-Active');
    
    $nextLink.addClass('LinkActive')
    .animate({ opacity: 0.0}, 1000, function(){
    $activeLink.removeClass('LinkActive LinkLast-Active');
    });
        
    */
}

///Will set the max height and width for an image, without ruining it
function MaxImage(MaxWidth, MaxHeight, imgId)
{

    var $MyImage = $(".imgId");

    if ($MyImage.length != 0)
    {

        alert($MyImage.height());

    }

}


function ShowHide_GoogleAds(divId)
{

    try
    {
        var _div = document.getElementById(divId);

        // Make sure our div is always on top
        $(window).scroll(function()
        {
            $('#' + divId).animate({ top: $(window).scrollTop() + "px" }, { queue: false, duration: 350 });
        });
   
        

    }
    catch (e)
    {

    }

}