/*--------------------------------------------------------------------
Basic Javascript Sheet - Frontoffice

Version: 1.0
Copyright: 2008, dicode® VOF - understanding internet
W: www.dicode.nl
E: info@dicode.nl
T: 0570-750680
--------------------------------------------------------------------*/

/* Global
--------------------------------------------------------------------*/

/* remove url dotted border */
$(document).ready(function() {
	
	var arr = document.getElementsByTagName('a');
	for(i = 0; i < arr.length; i++)
		arr[i].onfocus = new Function("this.blur()");
	
	var arr = document.getElementsByTagName('input');
	for(i = 0; i < arr.length; i++)
		if(arr[i].className == 'button')
			arr[i].onfocus = new Function("this.blur()");
			
	//FormElements.init();

	$('.popupwindow').each( function(index) {
		$(this).popupwindow({ front : {
			height:768,
			width:1024,
			toolbar:1,
			scrollbars:1,
			status:1,
			resizable:1,
			left:0,
			top:0,
			center:1,
			createnew:0,
			location:1,
			menubar:1
		} });
	});

	$('*').ifixpng();
    
});

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;
var hitem = 0;

function jsddm_open() {  
	jsddm_canceltimer();
  	jsddm_close();
  	ddmenuitem = $(this).find('ul').css('visibility', 'visible');
  	hitem = $('a:first', this).addClass('specialhover');
}

function jsddm_close() {
	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
  	if(hitem) hitem.removeClass('specialhover');
}

function jsddm_timer() { 
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer() {  
	if(closetimer) {
		window.clearTimeout(closetimer);
      	closetimer = null;
	}
}

$(document).ready(function() {  
	$('#id_menu > li').bind('mouseover', jsddm_open);
	$('#id_menu > li').bind('mouseout',  jsddm_timer);
	
	$.each($('#id_menu > li'), function() {
		var $maxWidth = $('a', this).width();
		if( $('li', $(this)).length ) {
			$('li', $(this)).each(function(i) {
				$maxWidth = $maxWidth < $('a', this).width() ? $('a', this).width() : $maxWidth;
			});

			$('li', $(this)).each(function() {
				$('a', this).width($maxWidth);
			});
		}
		
	});
});

document.onclick = jsddm_close;
