﻿function OpenWindow(url)
{
    window.open(url, "_blank", 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=700,height=600');
    return false;
}

function Messages(msg, url)
{
    alert(msg);
    document.location.href = url;
}
function showImageDetail(DivPicture,BigPicture)
{
    var divObj = document.getElementById(DivPicture);
    var PWidth = document[BigPicture].width + 3;
    var PHeight = document[BigPicture].height + 3;
    divObj.style.width = PWidth + 'px';
    divObj.style.height = PHeight + 'px';
    divObj.style.visibility = 'visible';
    divObj.focus();
    return false;
}
function hideImageDetail(DivPicture)
{
    DivPicture.style.visibility='hidden';
    return false;
}
function Printer(url)
{
    window.open(url, "_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=650,height=600,left=60, top=60,screenX=60px,screenY=60px");
    return false;
}
function SendMail(url)
{
    window.open(url, "_blank","toolbar=no,location=no,directories=no,addressbar=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=530,height=220,left=230, top=120,screenX=230px,screenY=120px");
    return false;
}
function ActivePrinter(idTopHidden,idBottomHidden)
{
    document.getElementById(idTopHidden).style.visibility='hidden';
    document.getElementById(idBottomHidden).style.visibility='hidden';
    window.print();
    window.close();
    return false;
}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getInnerSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth,  myHeight ];
}
function GetCenteredXY(w, h) 
{
	var ps = getScrollXY();
	var sz = getInnerSize();
	var Left = (sz[0] - w) / 2 + ps[0];
	var Top = (sz[1] - h) / 2 + ps[1];
	return [ Math.ceil(Left), Math.ceil(Top) ];
}
function dx_OpenPopup(popup, width, height, url,HeaderText) 
{
    var ps = GetCenteredXY(width, height);
    var popupInstance = eval('window.' + popup);
    popupInstance.SetContentHTML('');
    popupInstance.SetHeaderText(HeaderText);
    popupInstance.ShowAtPos(ps[0], ps[1] - 50);
    if (url.indexOf('?')==-1)
        url += '?'; else
        url += '&';
	popupInstance.SetContentUrl(url + 'rand=' + Math.random() + '&instance=' + popup);
	popupInstance.SetSize(width,height);
}
