
function checkIE6 () {
	var Browser = {
	  Version: function() {
	    var version = 999; // we assume a sane browser
	    if (navigator.appVersion.indexOf("MSIE") != -1)
	      // bah, IE again, lets downgrade version number
	      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
	    return version;
	  }
	}
	if (Browser.Version() < 7) {
	  document.getElementById('warning_ie6').style.display='block';
	}
}

/* Text size stuff */
function setTextSize (size) {
	fontSize = 11;
	switch (size) {			
			case 1: fontsize = 11; break;
			case 2: fontSize = 12; break;


		}

	
  jQuery('#content').css('font-size', fontSize);
  jQuery.cookie('contentFontSize', size, {path:'/'});
  
  

	jQuery('#content').jScrollPane({scrollbarWidth: 5, dragMaxHeight:120, scrollbarMargin:20 });
	initSlideshow ();
}


function initTextSize () {
	var size = 1;
	if (jQuery.cookie('contentFontSize')) {	  
		size = parseInt (jQuery.cookie('contentFontSize'));
	
	}
	setTextSize (size);
	
}


/* Ajax popup window stuff */
popupWindowId = '';

function showPopupWindowFilter () {	
	if (WSystem.ieVersion<7) {
		var filterHeight  = jQuery(document).height()-4;
		if (filterHeight<jQuery(window).height())
			filterHeight = jQuery(window).height();
		jQuery('#popupWindowFilter').attr('style', 'position:absolute;left:0;top:0;display:block;width:100%;height:'+filterHeight+'px;');	
	}
	else
		jQuery('#popupWindowFilter').attr('style', 'position:fixed;left:0;top:0;display:block;width:100%;height:100%;');	
	jQuery('#popupWindowFilter').hide();	
	jQuery('#popupWindowFilter').show();	
}

function hidePopupWindowFilter () {
	jQuery('#popupWindowFilter').hide();	
}

function closePopupWindow ()
{
	var obj = document.getElementById (popupWindowId);
	if (obj) {

		
		obj.style.display="none";
		obj.style.visibility = "hidden";

		hidePopupWindowFilter ();	
		WSystem.removeEvent (document,'keyup', onDocumentKeyPress);
		WSystem.removeEvent (document,'mousedown', onDocumentMouseClick);
	}
}

function onDocumentKeyPress (evt) {
	var keyCode = evt.which;
	if (navigator.appName.indexOf("Microsoft")!=-1)
		keyCode = window.event.keyCode;
	if (keyCode==27) { // ESC
		closePopupWindow ();
	}
	return true;
}

this.onDocumentMouseClick = function (evt)  {
	var mouseCoords = WSystem.getMouseCoords (evt);
	var obj = document.getElementById (popupWindowId);
	if (obj) {
		popupCoords = WSystem.getAbsoluteCoords (obj);
		var x  = popupCoords.x;
		var y  = popupCoords.y;
		var x2 = popupCoords.x+parseInt (obj.offsetWidth);
		var y2 = popupCoords.y+parseInt (obj.offsetHeight);
		if (!(
				mouseCoords.x>x && 
		    mouseCoords.x<x2 && 
		    mouseCoords.y>y && 
		    mouseCoords.y<y2 )) {
			// closePopupWindow ();
		}				
	}		
}

function showPopupWindow (id, popupURL, fAutoPrint) {
	var obj = document.getElementById (id);
	if (!obj)
		return;
	
	toggleFlag = true;
	currObjectImgIdx = 0;
	popupWindowId = id;
	var scrollPos = WSystem.getScrollPos ();
	var wndDim		= WSystem.getWindowDim ();
	var wndHeight = wndDim.windowHeight;
	var wndWidth  = wndDim.windowWidth;
	
	var x0 = scrollPos.x;			
	var x1 = x0 + wndWidth;
	var y0 = scrollPos.y;	
	var y1 = y0 + wndHeight;
	
  showPopupWindowFilter ();		
	obj.style.display="block";			


	obj.style.left = (x0+(wndWidth  - parseInt (obj.offsetWidth))  /2)+"px";
	obj.style.top  = (y0+(wndHeight - parseInt (obj.offsetHeight)) /2)+"px";
	
	obj.style.visibility = "visible";	

	// Esc key functions
	WSystem.addEvent (document,'keyup', onDocumentKeyPress, false);
	WSystem.addEvent (document,'mousedown', onDocumentMouseClick, false);

	// Load ajax content
	var fullURL = window.location.protocol+"//"+document.domain+"/"+popupURL;
	if (popupURL!='') {
		jQuery('#'+id+'_content').html ('<div style="text-align:center;"><img src="images/progress.gif" /></div>');
		jQuery.ajax({ url: fullURL, success: function(data) {
		
		
			jQuery('#'+id+'_content').html (data); 			
			
			if (jQuery('#'+id+'_content')) {
				jQuery('#'+id+'_content').jScrollPane({scrollbarWidth: 10, dragMaxHeight:120, scrollbarMargin:20 });			
			}
			
			if (fAutoPrint) {
				window.print ();
				closePopup ();
			}
		}});
	}
}


function initMenu ()
{
	var ulObj = document.getElementById ("menuitems").firstChild;	
	menuItems = createMenuItemsFromULStruct (ulObj);
	menu = new Menu (document.getElementById ("main_menu"), "mainmenu", 0, 0, menuItems, true);
}


function setFullHeight () {

	var height  = jQuery(document).height();

	var height2 = jQuery('#main_frame_in').height();
	if (height2>height)
		height=height2;
		

		
	if (WSystem.ieVersion<=6) {
		jQuery ('#main_frame_in').css ("height", height-90);	
	}
	else
		jQuery ('#main_frame_in').css ("min-height", height-90);

}


jQuery(document).ready(function() {  

	jQuery('#focus_id').focus ();

});

