/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
						I N D E X
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*	function destroypage()
*   function PopWin()
*   function ValidateURL()
*   function OpenNewWindow(URL,windowH,windowW,mStatus)
*	function OpenNewImageWindow(URL,windowH,windowW,mStatus)
*	function OpenNotesWindow(tobject)
*	function OpenImageWindow ?
*	function OpenImageShop ?
*	function OpenInLineWindow(cPicture,nWidth,nHeight,cMessage,nBorder)
*   function OpenPDFWindow ?
*   function modelesswin ?
*	function OpenHelpWindow(toURL)

*   These functions don't exist in here:
*	function OpenHelpWindow(tobject)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

var NewWindow;
var NewImageWindow;


/*
*********************************************************
destroypage
*********************************************************
*/
function destroypage()
{
	if (NewWindow!=null)NewWindow.close();
}	


/*
*********************************************************
PopWin - open document in new window
*********************************************************
*/

var popUp;

function PopWin(url, newWidth, newHeight) {
    var heightValue = 500;
    var widthValue = 700;

    if (popUp && !popUp.closed) {
        popUp.close();
    }

    if (newHeight != null && newHeight != "") {
        heightValue = newHeight;
    }

    if (newWidth != null && newWidth != "") {
        widthValue = newWidth;
    }

    popUp=window.open(url,"PopUp","scrollbars=1,resizable=1,width="+widthValue+",height="+heightValue+",left=0,top=0");
}

/*
*********************************************************
ValidateURL
*********************************************************
*/
function ValidateURL(URL)
{
    if (URL=="") {
    	alert("URL field is empty")
    return false 
    } else {
    	window.open(URL)
    	return true
    }
}	



/*
*********************************************************
OpenNewWindow
*********************************************************
*/
function OpenNewWindow(URL,windowH,windowW,mStatus)
	{
	var iTop,iLeft,available_width,available_height;
	
	
	 if(document.all) {
			available_width=window.screen.width;
			available_height=window.screen.height;
       } else {
			available_width=innerWidth;
			available_height=innerHeight;
       }
		
			
	
	iTop	= (parseFloat(available_height)/2)	- (parseFloat(windowH)/2);
	iLeft	= (parseFloat(available_width)/2)	- (parseFloat(windowW)/2);
	
	
		s = "width=" + windowW + ",height=" + windowH + ",top=" + iTop + ",left=" + iLeft + ",toolbar=no,status=yes,resizable=yes,scrollbars=yes"

	
	
	if (NewWindow!=null)NewWindow.close();
	
	NewWindow = window.open(URL,"popFrameless", s);
	NewWindow.window.status = mStatus;
	NewWindow.focus;
	}	

/*
*********************************************************
OpenNewImageWindow
*********************************************************
*/
function OpenNewImageWindow(URL)
	{
	var iTop,iLeft,available_width,available_height,windowH,windowW,sURL;
	windowH=(screen.availHeight - 122).toString();
	windowW=(screen.availWidth - 322).toString();

	sURL = "/popImage.aspx?processID=" + URL;
	
	 if(document.all) {
			available_width=window.screen.width;
			available_height=window.screen.height;
       } else {
			available_width=innerWidth;
			available_height=innerHeight;
       }

	iTop	= (parseFloat(available_height)/2)	- (parseFloat(windowH)/2);
	iLeft	= (parseFloat(available_width)/2)	- (parseFloat(windowW)/2);

	s = "width=" + windowW + ",height=" + windowH + ",top=" + iTop + ",left=" + iLeft + ",toolbar=no,status=yes,resizable=yes,scrollbars=yes"

	if (NewWindow!=null)NewWindow.close();
	
	NewWindow = window.open(sURL,"popFrameless", s);
	NewWindow.focus;
	}	


/*
*********************************************************
OpenNotesWindow
*********************************************************
*/
function OpenNotesWindow(tobject)
{
		var strFeatures;
		var strData;
		
		strFeatures = 'dialogWidth:500px;dialogHeight:350px;dialogTop:100px;';
		strFeatures = strFeatures + 'help:no;center:yes;border:thick;status:no;';
		strFeatures = strFeatures + 'scrollbars=no;toolbar=no;menubar=no;';

		strData = window.showModalDialog('frm_notes.asp',tobject.value, strFeatures);
		
		if (!isEmpty(strData))tobject.value = strData;
		
		
}			


/*
*********************************************************
OpenImageWindow
*********************************************************
*/
function OpenImageWindow(sURL)
{
		var strFeatures;
		var strData;
		
		strFeatures = 'dialogWidth:500px;dialogHeight:500px;dialogTop:25px;';
		strFeatures = strFeatures + 'help:no;center:yes;border:thick;status:no;';
		strFeatures = strFeatures + 'resizable=yes;scroll=yes;toolbar=no;menubar=no;';

		strData = window.showModalDialog(sURL,'', strFeatures);
		
			
}			

/*
*********************************************************
OpenImageShop
*********************************************************
*/
function OpenImageShop(nMoonType,nDocAdminType,nID)
{
		var sURL;

		sURL= "../docmanager/nxImageShop.aspx?moonburntype=" + nMoonType + "&doctype=" + nDocAdminType + "&processID=" + nID;
	
		OpenNewWindow(sURL,700,800,'mStatus');
		
			
}			


/*
*********************************************************
OpenInLineWindow
*********************************************************
*/
function OpenInLineWindow(sRoot,sTitle,cPicture,nWidth,nHeight)
	{
	var iTop,iLeft;
	var iPadding = 150;
	nHeight+=iPadding;
	nWidth+=iPadding;
	
	
	 if(document.all) {
			available_width=document.body.clientWidth;
            available_height=document.body.clientHeight;
       } else {
			available_width=innerWidth;
			available_height=innerHeight;
       }
	
	iTop	= (available_height/2)	- (nHeight/2);
	iLeft	= (available_width/2)	- (nWidth/2);
	
	if (NewWindow!=null)NewWindow.close();
	
	NewWindow=window.open("","NewOne","HEIGHT="+nHeight+",WIDTH="+nWidth+",scrollbars=yes,resizable=yes,top="+iTop+",left="+iLeft);
	NewWindow.document.write ("<html><head><title>" + sTitle);
	NewWindow.document.write ("</title></head>");
	NewWindow.document.write ("<body style=" + "'" + "text-align:center;" + "'>");	
	NewWindow.document.write ("<p>");
	NewWindow.document.write ("<a href='#' onClick='self.close()'>Close window</a><br /><br />");
	NewWindow.document.write ("<img src=" + "'" + cPicture + "'" + " style=" + "'" + "margin-bottom:25px" + "'>");
	NewWindow.document.write ("</p>");
	NewWindow.document.write ("</body></html>");
	NewWindow.document.close();
	NewWindow.focus();
	return false;
	}


/*
*********************************************************
OpenPDFWindow
*********************************************************
*/
function OpenPDFWindow(PDFileName)
	{
	
	if (NewWindow!=null)NewWindow.close();
	
	NewWindow=window.open(PDFileName);
	NewWindow.focus();
	return false;
	}


/*
*********************************************************
modelesswin
*********************************************************
*/
function modelesswin(url,mwidth,mheight){
if (document.all&&window.print) //if ie5
eval('window.showModelessDialog(url,"","help:0;resizable:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
else
eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")')
}

/*
*********************************************************
OpenHelpWindow
*********************************************************
*/
function OpenHelpWindow(theURL) {
window.open(theURL,'','toolbars=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=450,height=350');
}

/*
Form field Limiter script- By Dynamic Drive
For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
This credit MUST stay intact for use
*/
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}

function countlimitonload(maxlength,placeholder)
{
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (lengthleft>0)
	{
	theform.value=theform.value.substring(0,maxlength)
	placeholderobj.innerHTML=lengthleft
	}
}

function displaylimit(theform,thelimit){
var limit_text='<b><span id="'+theform.toString()+'">'+thelimit+'</span></b> characters remaining'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); 
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); 
}
countlimitonload(thelimit,theform)
}
