﻿function SwapImage(img, url)
{    
    var image = document.getElementById(img);
    
    if (image != null)
        image.src = url;
}

function Search(button, panel) {
    var btnSearch = document.getElementById(button);
    var pnlLoading = document.getElementById(panel);


    pnlLoading.className = "loading";
    btnSearch.click();
}

function BindRoundedCorners()
{
    //rounds the corners for all the title bars
    $(document).ready(function()
    { 
        $('div.bgTitle').corner('top');
        $('div.round').corner('top');
        $('div.searchContent').corner('top');
    });  
}

function ToggleVisibility(id) {
    var elem = document.getElementById(id);
    if (elem.style.display == 'none')
        elem.style.display = 'block';
    else
        elem.style.display = 'none';
}

function Clear(textbox) {
    if (textbox != null)
        textbox.value = "";
}

function ShowHelper(show) {
    var helper = document.getElementById('helper');
    if (show) 
    {
        var hideHelper = ReadCookie('hideHelper');

        if (hideHelper == null) 
        {
            if (helper != null) 
            {
                helper.style.display = "block";
            }
        }
    }
    else
    {
        CreateCookie("hideHelper", true, 100);
        if (helper != null)
            helper.style.display = "none";
    }
}

function CreateCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function ReadCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}