﻿jQuery(document).ready(function () {
    var currentPath = location.pathname;
    var splitted = new Array();
    splitted = currentPath.split('/');

    var root = splitted[0];
    var locale = splitted[1]; // or default.aspx
    var siteDefault = splitted[2];
    var firstChild = splitted[3];
    var grandChild = splitted[4];
    var grandGrandChild = splitted[5];

    var localeLength = locale.length;
    var finalPath = '';
    var finalSideBarPath = '';



    if (locale != undefined) {
        finalPath = '/' + locale + '/photodays';
        if (firstChild == undefined && grandChild == undefined && grandGrandChild == undefined) {
            if (localeLength == 0 || localeLength == 5 || locale == "default.aspx") {
                finalPath = '/hr-hr/photodays';
                if (localeLength == 5) {
                    finalPath = '/' + locale + '/photodays';
                }
                finalSideBarPath = 'x';
                if (siteDefault != undefined) {
                    if (siteDefault.length == 0) {
                        finalPath = '/' + locale + '/photodays';
                        finalSideBarPath = 'x';
                    }
                }
            }
        }
        jQuery('.home-logo').attr('href', finalPath);
    }

    if (siteDefault != undefined) {
        if (siteDefault.length > 0) {
            finalPath = "/" + locale + "/" + siteDefault;
        }
    }

    if (firstChild != undefined) {
        if (firstChild.length > 0) {
            finalPath = "/" + locale + "/" + siteDefault;
            finalSideBarPath = finalPath + "/" + firstChild;
        }
    }


    if (grandChild != undefined) {
        if (grandChild.length > 0) {
            finalPath = "/" + locale + "/" + siteDefault;
            finalSideBarPath = finalPath + "/" + firstChild + "/" + grandChild;
        }
    }

    if (grandGrandChild != undefined) {
        if (grandGrandChild.length > 0) {
            finalPath = "/" + locale + "/" + siteDefault;
            finalSideBarPath = finalPath + "/" + firstChild + "/" + grandChild + "/" + grandGrandChild;
        }
    }



    var $sideBarItem = jQuery('.menu-left a[href$="' + finalSideBarPath + '"]');
    $sideBarItem.addClass('current');

    var $item = jQuery('.top-header a[href$="' + finalPath + '"]');
    $item.addClass('topMenuCurrent');
    $item.css('color', '#ffffff');

});

jQuery(document).ready(function(){
	var $validate = jQuery('.validate');

});



jQuery(document).ready(function () {
    jQuery(function () {
        jQuery('#tab-long, #language-switcher').stop().animate({ 'marginLeft': '-24px' }, 1000);
        jQuery('#tab-long, #language-switcher').hover(function () { jQuery(this).stop().animate({ 'marginLeft': '0px' }, 400); },
							   function () { jQuery(this).stop().animate({ 'marginLeft': '-24px' }, 400); });
    });
});

jQuery(document).ready(function () {
    jQuery('#sidebar-nav-accordion').hoverAccordion({ speed: 'slow' });
});

jQuery(window).load(function () {
    jQuery('#slider').nivoSlider();
});


function getRandomImageUrl() {
    var num = Math.floor(Math.random() * 4) + 1;
    return '/shared/images/foto' + num + '.jpg';
};

$.backstretch(getRandomImageUrl());


