// Window Style And Parameters

function loadwindow(idWindow,idBackground,idFrame,url,width,height,pLeft,pTop)
{

	if (window.innerHeight && window.scrollMaxY) {
		// Firefox
		var pageWidth = window.innerWidth + window.scrollMaxX;
		var pageHeight = window.innerHeight + window.scrollMaxY;
	} else if(document.body.scrollHeight > document.body.offsetHeight) {	
		// all but Explorer Mac
		var pageWidth = document.body.scrollWidth;
		var pageHeight = document.body.scrollHeight;
	} else {
		// works in Explorer 6 Strict, Mozilla (not FF) and Safari
		var pageWidth = document.body.offsetWidth + document.body.offsetLeft;
		var pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}

	var HeightFrame = (height - 25 - 6 - 2);
	var WidthFrame = (width - 6);

	var ScreenTopPx = (pTop).toFixed(0);
	var ScreenLeftPx = (pageWidth * pLeft / 100).toFixed(0);

		document.getElementById(idWindow).style.top=ScreenTopPx+"px";
		document.getElementById(idWindow).style.left=ScreenLeftPx+"px";
		document.getElementById(idWindow).style.display="block";
		document.getElementById(idBackground).style.width=width+"px";
		document.getElementById(idBackground).style.height=height+"px";
		document.getElementById(idFrame).style.height=HeightFrame+"px";
		document.getElementById(idFrame).style.width=WidthFrame+"px";
		document.getElementById(idFrame).src=url;

		if (navigator.userAgent.indexOf('MSIE') >= 0)
		{
			document.getElementById(idWindow).filters[0].Apply();
			document.getElementById(idWindow).style.visibility="visible";
			document.getElementById(idWindow).filters[0].Play();
		}
}

function unloadwindow(idWindow)
{
	if (navigator.userAgent.indexOf('MSIE') >= 0)
	{
		document.getElementById(idWindow).filters[0].Apply();
		document.getElementById(idWindow).style.visibility="hidden";
		document.getElementById(idWindow).filters[0].Play();
		setTimeout("document.getElementById('"+idWindow+"').style.display='none'",2000);  
	} else {
		document.getElementById(idWindow).style.display="none";
	}
}
 
// Global object to hold drag information.
 
var dragObj = new Object();
dragObj.zIndex = 0;
 
function dragStart(event, id) {
 
  var el;
  var x, y;
 
  // If an element id was given, find it. Otherwise use the element being
  // clicked on.
 
  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;
 
    // If this is a text node, use its parent element.
 
    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }
 
  // Get cursor position with respect to the page.
 
  if (navigator.userAgent.indexOf('MSIE') >= 0)
  {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  } else {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }
 
  // Save starting positions of cursor and element.
 
  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);
 
  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;
 
  // Update element's z-index.
 
  dragObj.elNode.style.zIndex = ++dragObj.zIndex;
 
  // Capture mousemove and mouseup events on the page.
 
  if (navigator.userAgent.indexOf('MSIE') >= 0) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  } else {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}
 
function dragGo(event) {
 
  var x, y;
 
  // Get cursor position with respect to the page.
 
  if (navigator.userAgent.indexOf('MSIE') >= 0) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  } else {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }
 
  // Move drag element by the same amount the cursor has moved.
 
  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";
 
  if (navigator.userAgent.indexOf('MSIE') >= 0)
  {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  } else {
    event.preventDefault();
  }
}
 
function dragStop(event) {
 
  // Stop capturing mousemove and mouseup events.

  if (navigator.userAgent.indexOf('MSIE') >= 0)
  {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  } else {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}
