/**
* @version $Id: templateCore.js 205 2006-07-13 12:11:24Z danial $
* @package JJ Flex
* @Copyright (C) 2006 JoomlaJunkie.com & Clexus New Media - All rights reserved
* @license Released as a commercial addon
* @link http://www.joomlajunkie.com & http://www.clexus.com
**/

/*
* Helper Functions

function switchFont(newFont)
{
    $("body").removeClass().addClass(newFont);
    createCookie('font_size', newFont, 365);
    return false;
}

function switchStylestyle(styleName, cmode, availStyles)
{
    $('link[@rel*=style][@title]').each(function(i)
    {
        if (in_array(this.getAttribute('title'), availStyles))
        {
            this.disabled = true;

            if (this.getAttribute('title') == styleName)
            {
                this.disabled = false;
            }
        }
    });

    createCookie('style_' + cmode, styleName, 365);
}

// cookie functions http://www.quirksmode.org/js/cookies.html
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;
}

function eraseCookie(name)
{
    createCookie(name, "", -1);
}
// /cookie functions

function in_array(needle, haystack)
{
    for (h in haystack)
    {
        if (haystack[h] == needle)
        {
            return true;
        }
    }

    return false;
}


/*
* Continue


var style_id_list_c = new Array("red", "blue", "green", "orange");

$.preloadImages = function()
{
    for (var i = 0; i < arguments.length; i++)
    {
        img = new Image();
        img.src = arguments[i];
    }
};

$('.sizeswitch').each(function(i)
{
    style_id_list_s[i] = $(this).rel();
});


//initilizing the active states
var defCol = readCookie("style_color") ? readCookie("style_color") : "blue";
var defSiz = readCookie("font_size") ? readCookie("font_size") : "mediumText";

switchStylestyle(defCol, "color", style_id_list_c);
switchFont(defSiz);

$(document).ready(function()
{
    $('.styleswitch').click(function()
    {
        switchStylestyle(this.getAttribute("rel"), "color", style_id_list_c);
        $('.styleswitch').removeClass("active-option");
        $(this).addClass("active-option");
        return false;
    });

    $('.fontswitch').click(function()
    {
        switchFont(this.getAttribute("rel"));
        $('.fontswitch').removeClass("active-option");
        $(this).addClass("active-option");

        return false;
    });

    $('.sizeswitch').click(function()
    {
        switchStylestyle(this.getAttribute("rel"), "size", style_id_list_s);
        $('.sizeswitch').removeClass("active-option");
        $(this).addClass("active-option");
        return false;
    });

    //Added by Carlos Guimaraes[http://www.open4g.com]
    $("#shelf-bt").toggle(function()
    {
        $("div#footerfaux").slideUp(function()
        {
            $("div#footerfaux").style.height = "auto";
        });

        var ishf = $("img#shelf-img").src().replace(new RegExp("\-close\\b"), "-open");
        $("img#shelf-img").src(ishf);
    },                    function()
    {
        $("div#footerfaux").slideDown(function()
        {
            $("div#footerfaux").style.height = "auto";
        });

        var ishf = $("img#shelf-img").src().replace(new RegExp("\-open\\b"), "-close");
        $("img#shelf-img").src(ishf);
    });

    $(".styleswitch[@rel*=" + defCol + "]").addClass("active-option");
    $(".fontswitch[@rel*=" + defSiz + "]").addClass("active-option");
});*/
