﻿/****************************************
 *                                      *
 *   author: gondo                      *
 *   email:  gondo@webdesigners.sk      *
 *                                      *
 ****************************************/

/* turn off error reporting */
window.onerror = new Function("return true;");

/* constants */
var isOpera = (window.navigator.userAgent.indexOf("Opera") > -1);
var isGecko = (navigator.product == "Gecko");
var isIe = (window.navigator.userAgent.indexOf("MSIE") > -1);
var rootDir = getRootDir();


/* functions setup */
window.onresize = my_onresize;
window.onload = function()
{
    window.onload;
    my_onload();
};

/* list of functions */
/* function called when whole page is loaded */
function my_onload()
{
    my_onresize();

    if (isGecko)
        clear_blur();

    //load lightbox
    myLightbox = new Lightbox();
}

/* return root directory of page */
function getRootDir()
{
    var src = document.getElementsByTagName("script")[0].src;
    var pos = src.lastIndexOf('js/');
    var root = src.substring(0, pos);

    return root;
}

/* function called when page is resized */
function my_onresize()
{
}

/* this function clears dotted border around <a> element which makes firefox */
function clear_blur()
{
    var array = document.getElementsByTagName('a');
    for(i=0;element=array[i];i++)
    {
        element.setAttribute("onFocus","blur();");
    };
};

/* cookies functions */
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 cookieArray = document.cookie.split(';');
    for(var i=0;i < cookieArray.length;i++)
    {
        var c = cookieArray[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);
}
