var today;
$(document).ready(function () {

    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
    $("ul.topnav li").click(function () { //When trigger is clicked...

        //Following events are applied to the subnav itself (moving subnav up and down)
        $(this).find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
        $(this).hover(function () {
        }, function () {
            $(this).find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
        });

        //Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function () {
        $(this).find("span").addClass("subhover"); //On hover over, add class "subhover"
    }, function () {	//On Hover Out
        $(this).find("span").removeClass("subhover"); //On hover out, remove class "subhover"
    });


    $.getTime = function (zone, success) {
        var url = 'http://json-time.appspot.com/time.json?tz='
            + zone + '&callback=?';
        $.getJSON(url, function (o) {
            success(o);
        });
    };

    // Usage:
    $.getTime('Europe/Athens', function (time) {
        //$('#currentTime').html(time.datetime);
        var Digital = new Date(time.datetime);
        $("#currentTime").clock({ "timestamp": Digital, "calendar": "false", "format": "24" });
    });


    /*$(function ($) {
    var options = {
    utc: true,
    utc_offset: 3
    };
    $('#currentTime').jclock(options);
    });
    */

    slideShow();

    $('.productsGalleryIndex li').tipsy({ fade: true, title: function () { return this.getAttribute('original-title') } });
    $('.productsGallery li').tipsy({ fade: true, title: function () { return this.getAttribute('original-title') } });


});


    function slideShow() {
        $('div.featuredText_image div').css({ opacity: 0.0 });
        $('div.featuredText_image div:first').css({ opacity: 1.0 });
        setInterval('gallery()', 10000);
    }


    function gallery() {
        var current = ($('div.featuredText_image div.show') ? $('div.featuredText_image div.show') : $('div.featuredText_image div:first'));
        var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('div.featuredText_image div:first') : current.next()) : $('div.featuredText_image div:first'));

        //Set the fade in effect for the next image, show class has higher z-index
        next.css({ opacity: 0.0 })
        next.show()
        
        .addClass('show')
        .animate({ opacity: 1.0 }, 1000);

        //Hide the current image
        
        current.animate({ opacity: 0.0 }, 1000)
        .removeClass('show');
        current.hide('slow')
    }
