
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(){  
	$('select[name="sort"]').css({
		'position': 'relative',
		'left': '-40px'
	});

	$('form div select[name="sort"]').css({
		'position': 'relative',
		'top': '0px'
	});

	$('#jsddm > li').bind('mouseover', jsddm_open)
	$('#jsddm > li').bind('mouseout',  jsddm_timer)
	
	jQuery('a.lightbox').fancybox({
		hideOnContentClick: false,
		frameWidth: 640,
		frameHeight: 480
	}); 
	
	$('#jsddm li, #jsddm a').css({
		//'z-index': 5000,
/* 		'display': 'block', */
/* 		'position': 'relative', */
/* 		'top': '0' */
	});
});

document.onclick = jsddm_close;


function getStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}


function zIndexWorkaround()
{
    // If the browser is IE,
    //if(isIE())
    //{
        /*
        ** For each div with class menu (i.e.,
        ** the thing we want to be on top),
        */
        $("div.menu").parents().each(function() {
            var p = $(this);
            var pos = p.css("position");
 
            // If it's positioned,
            if(pos == "relative" ||
               pos == "absolute" ||
               pos == "fixed")
            {
                /*
                ** Add the "on-top" class name when the
                ** mouse is hovering over it, and remove
                ** it when the mouse leaves.
                */
                p.hover(function() {
                        $(this).addClass("on-top");
                    },
                    function() {
                        $(this).removeClass("on-top");
                    });
            }
        });
    //}
}

$(document).ready(function(){
	//zIndexWorkaround();

$(function() {
	var zIndexNumber = 1000;
	$('div').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
});
});
