var newwindow = '';

function PopUp2(Url, Width, Height, bResizable, bScrollbars) 
{
  if (Width > (screen.width - 50)) {
   Width = screen.width - 50;
  }
  
  if (Height > (screen.height - 50)) {
   Height = screen.height - 50;
  }
  
  posLeft = (screen.width-Width)/2;
  posTop  = (screen.height-Height)/2;
  
  var Options = "";
  
  if (bResizable) {
    Options += ",resizable=1";
  } else {
    Options += ",resizable=0";
  }
  
  if (bScrollbars) {
    Options += ",scrollbars=1";
  } else {
    Options += ",scrollbars=0";
  }
  
  newWindow = window.open(Url,"newWindow","width="+Width+",height="+Height+",left="+posLeft+",top="+posTop+Options);
  newWindow.focus();
}

function PopUp(Url, Width, Height) 
{
  PopUp2(Url, Width, Height, false, false);
}

function PopUpImage(imageName, imageWidth, imageHeight) 
{
  
	if (imageWidth > (screen.width - 50)) {
	 imageWidth = screen.width - 50;
	}

	if (imageHeight > (screen.height - 50)) {
	 imageHeight = screen.height - 50;
	}

	posLeft = (screen.width-imageWidth)/2;
	posTop  = (screen.height-imageHeight)/2;
	
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+imageName+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
	newWindow.document.write('<body><img src="'+imageName+'" width="'+imageWidth+'" height="'+imageHeight+'" alt="'+imageName+'">'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function PopupWritetoParent(Field, newValue, bLast)
{
	var FieldId = window.opener.document.getElementById(Field);
	
	if (FieldId && (newValue.length > 0)) {
		FieldId.value = newValue;
		if (bLast) {
			CloseMe();	
		}
	}			
}

function CloseMe()
{ 
	self.close(); 
}

function PopUpMessage(Message)
{
	if (Message.length > 0) {
		alert(Message);
	}
}

function GetUserValidation(Message)
{
	var bUserConfirmed = false;
	if (Message.length > 0) {
		if (confirm(Message)) {
			bUserConfirmed = true;
		}
	}
	return bUserConfirmed;
}
