// JavaScript Document
var ns4, op5, op6, mac, ie, mac_ie;

function initPageLoad() {
  sniffBrowsers();

}

function sniffBrowsers() {
	ns4 = document.layers;
	op5 = (navigator.userAgent.indexOf("Opera 5") != -1) || (navigator.userAgent.indexOf("Opera/5") != -1);
	op6 = (navigator.userAgent.indexOf("Opera 6") != -1) || (navigator.userAgent.indexOf("Opera/6") != -1);
	var agt = navigator.userAgent.toLowerCase();
	mac = (agt.indexOf("mac") != -1);
	ie = (agt.indexOf("msie") != -1); 
	mac_ie = mac && ie;	
}



function fancybox_bindings() {
	$('a.fancybox').fancybox();
}

function prettyphoto_bindings() {
	$("a[rel^='prettyphoto']").prettyPhoto({
	  animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.80, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
		hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
		modal: false																			 
	});
}


var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function menu_open() {
  menu_canceltimer();
  menu_close();
  ddmenuitem = $(this).find('ul').css('visibility', 'visible');
}

function menu_close() {
  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');
}

function menu_timer() {
  closetimer = window.setTimeout(menu_close, timeout);
}

function menu_canceltimer(){
  if(closetimer){
	  window.clearTimeout(closetimer);
    closetimer = null;
	}
}

function menu_bindings() {
	$('#tq_menu > li').bind('mouseover', menu_open);
  $('#tq_menu > li').bind('mouseout',  menu_timer);
}

document.onclick = menu_close;
