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';
	}
}


/* 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";
	
	var top = y0+(wndHeight - parseInt (obj.offsetHeight)) /2;
	if (top<0)
		top=0;
	obj.style.top  = top+"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 ();
			}
		}});
	}
}
