window.name = "MainWindow";
window.focus();

var currentpopupwindow;
function gotoURL(URL)
{
   self.location.href= URL;
}

function checkParent(URL) 
    { 
        if (self.opener) 
            { 
                self.opener.location.href=URL; 
            } 
        else 
            { 
                self.location.href=URL; 
            }
    }            

function OpenNewWindow(PageLink)	
	{
		iheight = this.screen.height * 0.65 ;
		iwidth = this.screen.width * 0.75 ;
		ihlocationup = (this.screen.height - iheight) / 3;
		iwlocation = (this.screen.width - iwidth) / 2;
		window.open(PageLink,'','width='+iwidth+',height='+iheight+',resizable=yes,toolbar=0,location=0,directories=0,status=yes,menubar=no,scrollbars=yes,left=' + iwlocation+ ',top='+ihlocationup +',screenX='+ iwlocation+',screenY='+ ihlocationup+'');		
	}

function OpenNewWindowWH(PageLink, iwidth, iheight)	
	{
	   if ((currentpopupwindow) && (!(currentpopupwindow.closed))) { currentpopupwindow.close(); }	
		ihlocationup = (this.screen.height - iheight) / 3;
		iwlocation = (this.screen.width - iwidth) / 2;
		currentpopupwindow = window.open(PageLink,'','width='+iwidth+',height='+iheight+',resizable=yes,toolbar=0,location=0,directories=0,status=yes,menubar=no,scrollbars=yes,left=' + iwlocation+ ',top='+ihlocationup +',screenX='+ iwlocation+',screenY='+ ihlocationup+'');		
	}

function openPopUpWindow(PageLink)	
	{
		iheight = 400 ;
		iwidth = 700 ;
		ihlocationup = (this.screen.height - iheight) / 3;
		iwlocation = (this.screen.width - iwidth) / 2;
		window.open(PageLink,'','width='+iwidth+',height='+iheight+',resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,left='+iwlocation+',top='+ihlocationup+',screenX='+iwlocation+',screenY='+ihlocationup+'');		
	}

function openHelpPopUpWindow(PageLink)	
	{
		iheight = 400 ;
		iwidth = 700 ;
		ihlocationup = (this.screen.height - iheight) / 3;
		iwlocation = (this.screen.width - iwidth) / 2;
		window.open(PageLink,'','width='+iwidth+',height='+iheight+',resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,left='+iwlocation+',top='+ihlocationup+',screenX='+iwlocation+',screenY='+ihlocationup+'');		
	}

	
function OpenZoomWindow(PageLink)	
	{
		// iheight = this.screen.height * 0.65 ;
		// iwidth = this.screen.width * 0.75 ;
		iheight = this.screen.height *.87
		iwidth = this.screen.width *.99
		//ihlocationup = (this.screen.height - iheight) / 3;
		//iwlocation = (this.screen.width - iwidth) / 2;
		ihlocationup = 1
		iwlocation = 1
		window.open('/utils/p_CommentZoom.asp?'+PageLink,'','width='+iwidth+',height='+iheight+',resizable=yes,toolbar=0,location=0,directories=0,status=yes,menubar=no,scrollbars=yes,left=' + iwlocation+ ',top='+ihlocationup +',screenX='+ iwlocation+',screenY='+ ihlocationup+'');		
	}
	
function OpenWindowwToolbar(PageLink)	
	{
		iheight = 600 ;
		iwidth = 800 ;
		ihlocationup = ((this.screen.height - iheight) / 3)-25;
		iwlocation = (this.screen.width - iwidth) / 2;
		window.open(PageLink,'','width='+iwidth+',height='+iheight+',resizable=yes,toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,left='+iwlocation+',top='+ihlocationup+',screenX='+iwlocation+',screenY='+ihlocationup+'');		
	}

function OpenCustomModalWindow(PageLink, iheight, iwidth)
{
		ihlocationup = ((this.screen.height - iheight) / 3)-25;
		iwlocation = (this.screen.width - iwidth) / 2;
		var returnvalue = showModalDialog(PageLink, '', 'dialogWidth:' + iwidth + 'px; dialogHeight:' + iheight + 'px;status:no;');
		return returnvalue
}


function OpenCustomModalWindowArg(PageLink, argument, iheight, iwidth)
{
		ihlocationup = ((this.screen.height - iheight) / 3)-25;
		iwlocation = (this.screen.width - iwidth) / 2;
		var returnvalue = showModalDialog(PageLink, argument, 'dialogWidth:' + iwidth + 'px; dialogHeight:' + iheight + 'px;status:no;');
		return returnvalue
}


function getModalDate(indate, dateformat)
{
	var adate = showModalDialog('/page/modal_calendar.asp?d='+indate+ '&dtform=' + dateformat , '', 'dialogWidth:200px; dialogHeight:275px;status:no;');
	if (adate=='') {
		return (indate);
	}
	else 
	{
		return (adate);
	}
}

		
function replaceChar(strOriginal,strChar,strReplace) {
   return strOriginal.split(strChar).join(strReplace);
}
	
function createBox(name, content, isTextOnly, boxType) {
	
	var divWidth;
	var divHeight;
	var colWidth;		
	var overFlow;
	// zoombox1 is the standard 180px X 100px text box
	// zoombox2 is a single line height 180px X 20 px box
	// zoombox3 is a wide 300px X 20 px box
	// zoombox4 is a double line height 180px X 40px box
	// zoombox5 is 100px tall and 420px wide 
	// default is the standard 180px X 100px text box
	
	//default zoom settings
	overFlow = "auto";	
	
	switch(boxType){
	case "zoombox1":
		divWidth = 180;
		divHeight = 100;
		colWidth = (divWidth-30);
		break;
	case "zoombox2":
		divWidth = 180;
		divHeight = 20;
		colWidth = (divWidth-30);
		overFlow = "hidden";
		break;
	case "zoombox3":
		divWidth = 300;
		divHeight = 100;
		colWidth = (divWidth-30);
		break;
	case "zoombox4":
		divWidth = 180;
		divHeight = 40;
		colWidth = (divWidth-30);
		break;
	case "zoombox5":
		divWidth = 420;
		divHeight = 100;
		colWidth = (divWidth-30);
		break;
	case "zoombox6":
		divWidth = 420;
		divHeight = 45;
		colWidth = (divWidth-30);
		break;
	case "zoombox7": 
		divWidth = 350;
		divHeight = 100;
		colWidth = (divWidth-30);
		break;
	case "zoombox8":
		divWidth = 340;
		divHeight = 35;
		colWidth = (divWidth-30);
		break;
	case "zoombox9":
		divWidth =  600;
		divHeight = 600;
		colWidth = (divWidth-30);
		break;
	default:
		divWidth = 180;
		divHeight = 100;
		colWidth = (divWidth-30);
	}
	
	var newname = name.split("-").join("__")
	var idname = "display_" + newname;
	
	var str;
	if (is_mac) {
		if (is_nav4up && ! is_nav6up) {
			//netscape 4
			document.write('<textarea WRAP COLS="20" ROWS="5" name="'+name+'">');
			document.write(content);
			document.write('</textarea>');
		}
		else {
			if (isTextOnly == 1) 
				document.write('<input type="hidden" name="'+name+'" id="'+name+'" value="'+content+'">');
			else
				document.write("<input type='hidden' name='"+name+"' id='"+name+"' value='"+content+"'>");

			//netscape 6 & 7, IE
			document.write('<div style="overflow: ' + overFlow + '; width: '+divWidth+'; height: '+divHeight+'; border-left: 1px gray solid; border-bottom: 1px gray solid; padding:0px; margin: 0px"><TABLE cellspacing=0 cellpadding=2><COL WIDTH='+colWidth+'><tr><td width='+colWidth+' valign="top" nowrap class="content">');
			document.write('<div id="' + idname + '">');
			if (isTextOnly == 1) {
				str = replaceChar(content,"\r","");
				str = replaceChar(str,"\n","<BR />");	
				document.write(str);
			}
			else document.write(content);
			document.write('</div>');
			document.write('</td></tr></table></div>');
		}
	}
	else {
		if (is_nav4up && ! is_nav6up) {
			//netscape 4
			document.write('<textarea WRAP COLS="20" ROWS="5" name="' + name + '">');
			document.write(content);
			document.write('</textarea>');
		}
		else {
			//netscape 6 & 7, IE
			if (isTextOnly == 1) 
				document.write('<input type="hidden" name="' + name + '" value="' + content + '">');
			else
				document.write("<input type='hidden' name='" + name + "' value='" + content + "'>");

			//netscape 6 & 7, IE
			document.write('<div style="overflow: ' + overFlow + '; width: '+divWidth+'; height: '+divHeight+'; border-left: 1px gray solid; border-bottom: 1px gray solid; padding:0px; margin: 0px"><TABLE cellspacing=0 cellpadding=2><COL WIDTH='+colWidth+'><tr><td width='+colWidth+' valign="top" nowrap class="content">');
			document.write('<div id="' + idname + '">');
			if (isTextOnly == 1) {
				str = replaceChar(content,"\r","");
				str = replaceChar(str,"\n","<BR />");	
				document.write(str);
			}
			else document.write(content);
			document.write('</div>');
			document.write('</td></tr></table></div>');
		}
	}
}
