﻿var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open() {
    jsddm_canceltimer();
    jsddm_close();
    ddmenuitem = $(this).find('ul').css('visibility', 'visible');
}

function jsddm_close()
{ if (ddmenuitem) ddmenuitem.css('visibility', 'hidden'); }

function jsddm_timer()
{ closetimer = window.setTimeout(jsddm_close, timeout); }

function jsddm_canceltimer() {
    if (closetimer) {
        window.clearTimeout(closetimer);
        closetimer = null;
    }
}


$(document).ready(function() {
    if (screen.height <= 600) {
        $("#eyecandy").animate({
            height: 204
        }, 0);
        $("#splatter").animate({
            height: 204
        }, 0);
        $("#bag").animate({
            height: 204,
            width: 764
        }, 0);
        $("#lcover").animate({
            height: 204,
            marginLeft: -392
        }, 0);
        $("#rcover").animate({
            height: 204,
            marginLeft: 237
        }, 0);
        $("#logobg").animate({
            height: 204,
            marginLeft: -310
        }, 0);
        $("#trulogo").animate({
            marginLeft: -310
        }, 0);
        $("#bag").css('overflow', 'hidden');
        $("#bshadow").animate({
            marginTop: -214
        }, 0);
        $("#feature").animate({
            width: 674
        }, 0);
        $("#feature #left").animate({
            width: 350
        }, 0);
        $("#feature #right").animate({
            width: 260
        }, 0);
        $("#footer .finner").animate({
            width: 764
        }, 0);
        $("#nav").animate({
            width: 764
        }, 0);
        $("#feature #center").css('display', 'none');
        $("#taglineover").css('display', 'none');
        $("#tagline").css('display', 'none');
        $("#maincover").animate({
            height: 204
        }, 0);

    }
    else if (screen.height > 600 && screen.height <= 768) {
        $("#eyecandy").animate({
            height: 300
        }, 0);
        $("#lcover").animate({
            height: 300,
            marginLeft: -460
        }, 0);
        $("#rcover").animate({
            height: 300,
            marginLeft: 347
        }, 0);
        $("#logobg").animate({
            height: 300
        }, 0);
        $("#splatter").animate({
            height: 300
        }, 0);
        $("#bag").animate({
            height: 300,
            width: 960
        }, 0);
        $("#bag").css('overflow', 'hidden');
        $("#bshadow").animate({
            marginTop: -118
        }, 0);
        $("#taglineover").animate({
        marginTop: -118,
            marginLeft:-435,
            width:920,
            fontSize:'16px'
        }, 0);
        $("#tagline").animate({
        marginTop: -118,
        marginLeft: -435,
            width: 920
        }, 0);
        $("#maincover").animate({
            height: 300
        }, 0);
    }
    else {
        $("#trulogo").animate({
            marginTop: 83
        }, 0);
    }
});


$(document).ready(function() {
    $(this).delay(1600, function() {
    $("#maincover").animate({
                opacity: 0
            }, 2500).animate({height: '10px'}, "fast");
        });        
    $('#jsddm > li').bind('mouseover', jsddm_open)
    $('#jsddm > li').bind('mouseout', jsddm_timer)
});

document.onclick = jsddm_close;

function itemOpening(sender, args) {
    var element = args.get_item().get_element();
    element.childNodes[1].style.left = -element.offsetLeft + "px";
}

jQuery.fn.delay = function(time, func) {
    this.each(function() {
        setTimeout(func, time);
    });

    return this;
};