function template_printpage(page_id, popup_width) {
	var intWidth = parseInt(popup_width);
	var intHeight = 600;
	var intLeft = (screen.availWidth - intWidth - 10) / 2;
	var intTop  = (screen.availHeight - intHeight - 29) / 2;
	objWin = window.open("/includes/pages/module_print.asp?page_id=" + page_id, 'ViewPopup', 'left=' + intLeft + ',top=' + intTop + ',width=' + intWidth + ',height=' + intHeight + ',menubar=no,toolbar=no,location=no,status=yes,scrollbars=no,resizable=no');
}

function lightbox_maxwidth() {
	return document.documentElement.clientWidth;
}
function lightbox_maxheight() {
	return document.documentElement.clientHeight;
}
function lightbox_pictures()
{
	var elm_container = document.getElementById("t04_template_contentarea");
	if(elm_container) {
		var arr_elements = elm_container.getElementsByTagName("a");
		for(var i=0; i<arr_elements.length; i++){
			current_elm = arr_elements[i];
			current_rel = current_elm.getAttribute("rel");
			if(current_rel != null) {
				if(current_rel.indexOf("lightbox") == 0) {
					var this_id = current_elm.getAttribute("id");
					var this_img = "/files/gallery/" + this_id + "/" + (lightbox_maxwidth()-200) + "/" + (lightbox_maxheight()-200) + "/"
					this_img = this_img.replace("img_","")
					document.getElementById(this_id).href = this_img;					
				}
			}
		}
	}
}
function critical_message() {
	var msg = document.getElementById("critical_warning");
	if(msg) {
		$(msg).fadeOut(1000).fadeIn(1000)
		$(msg).animate({top: "50px"}, 1000);
		$(msg).animate({top: "0px"}, 750);
	}
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function initTopDropdown() {
    
	$("ul.dropdown li").hover(function(){
        $(this).addClass("hover");
        $('ul:first',this).css('visibility', 'visible');
    }, function(){
        $(this).removeClass("hover");
        $('ul:first',this).css('visibility', 'hidden');
    });
    
    $("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");
}

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() {  
	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);
	$('#jsddmAbsTop > li').bind('mouseover', jsddm_open);
	$('#jsddmAbsTop > li').bind('mouseout',  jsddm_timer);   
});

document.onclick = jsddm_close;