// **********************************************************************************************
// 
// File: mm.js
//
// Purpose: Includes all of the MacroMedia Dreamweaver functions.
//          Also includes functions derrived from the MacroMedia
//          functions, such as startZimas().
//

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  winName = winName + "_" + document.Variables.SessionID.value;
  var objWin = window.open(theURL,winName,features);
  if (is5up) 
    objWin.window.focus();
}

function TB_animateWindow(windowWidth,windowHeight,targetWidth,targetHeight,widthMod,heightMod,fullScreen)
 {
   // www.timbooker.com
   // www.saltstonemedia.co.uk

	if (fullScreen)
	 {
		targetWidth = screen.availWidth;
		targetHeight = screen.availHeight;
	 }

	if (windowWidth < targetWidth) windowWidth += widthMod;
	if (windowHeight < targetHeight) windowHeight += heightMod;

	windowLeft = (screen.availWidth / 2) - (windowWidth / 2);
	windowTop = (screen.availHeight / 2) - (windowHeight / 2);

	top.window.resizeTo(windowWidth,windowHeight);
	top.window.moveTo(windowLeft,windowTop);

	if (windowWidth < targetWidth || windowHeight < targetHeight)
		setTimeout('TB_animateWindow(' + windowWidth + ', ' + windowHeight + ', ' + targetWidth + ', ' + targetHeight + ', ' + widthMod + ', ' + heightMod + ', ' + fullScreen + ');',10);
 }

function startZimas() {
  MM_openBrWindow('search.asp', 'ZIMAS', 'width=1014,height=643,menubar=yes,toolbar=yes,location=no,status=no');
}

function openPinReport(sPin, bIncludeMap, bIncludeCaseSummaries) {
  var html = '<html><head><title>ZIMAS - Zoning Information and Map Access System</title></head>';
  html += '<body onload="document.rptVariables.submit();">';
  html += '<form name="rptVariables" method="POST" action="report_pin.asp">';
  html += '<input type="hidden" name="IncludeMap" value="' + bIncludeMap.toString() + '">';
  html += '<input type="hidden" name="SelectedMultiAddress" value="' + document.Variables.SelectedMultiAddress.value + '">';
  html += '<input type="hidden" name="PIN" value="' + sPin + '">';
  html += '<input type="hidden" name="IncludeCaseSummaries" value="' + bIncludeCaseSummaries.toString() + '">';
  html += '<input type="hidden" name="SelType" value="' + (bIncludeMap ? document.Variables.SelType.value : '') + '">';
  html += '<input type="hidden" name="Selection" value="' + (bIncludeMap ? document.Variables.Selection.value : '') + '">';
  html += '<input type="hidden" name="MultiSelPin" value="' + (bIncludeMap ? document.Variables.MultiSelPin.value : '') + '">';
  html += '<input type="hidden" name="LegendStr" value="' + (bIncludeMap ? document.Variables.LegendStr.value : '') + '">';
  html += '<input type="hidden" name="BackgroundLayer" value="' + (bIncludeMap ? document.Variables.BackgroundLayer.value : '') + '">';
  html += '<input type="hidden" name="MapExtXMin" value="' + (bIncludeMap ? document.Variables.MapExtXMin.value : '') + '">';
  html += '<input type="hidden" name="MapExtXMax" value="' + (bIncludeMap ? document.Variables.MapExtXMax.value : '') + '">';
  html += '<input type="hidden" name="MapExtYMin" value="' + (bIncludeMap ? document.Variables.MapExtYMin.value : '') + '">';
  html += '<input type="hidden" name="MapExtYMax" value="' + (bIncludeMap ? document.Variables.MapExtYMax.value : '') + '">';
  html += '</form><div align="center"><br><br><br>';
  html += '<p><font face="Arial" color="#000066" size="3">';
  html += '<b>Please Wait While ZIMAS Prepares Your Report...</b></font></p><br><br>';
  html += '<img src="images/general/loading.png" border="0" WIDTH="120" HEIGHT="24"><br><br>';
  html += '</body></html>';

  var d = new Date();
  var s = d.getTime().toString();
  var win = window.open('about:blank', 'ZIMAS_REPORT' + s, 'width=800,height=500,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes');
  win.document.open();
  win.document.write(html);
  win.document.close();
  //win.document.forms[0].submit(); -- //Commented by Kavita R on Sept 17 2009 -- this was causing the report run twice - body onload + win.document.forms[0].submit!!!
  if (is5up) 
    win.window.focus();
}

function openCaseReport(bIncludeMap) {

  var html = '<html><head><title>ZIMAS - Zoning Information and Map Access System</title></head>';
  html += '<body onload="document.rptVariables.submit();">';
  html += '<form name="rptVariables" method="POST" action="report_case.asp">';
  html += '<input type="hidden" name="IncludeMap" value="' + bIncludeMap.toString() + '">';
  html += '<input type="hidden" name="SelectedMultiAddress" value="' + document.Variables.SelectedMultiAddress.value + '">';
  html += '<input type="hidden" name="SelType" value="' + document.Variables.SelType.value + '">';
  html += '<input type="hidden" name="Selection" value="' + document.Variables.Selection.value + '">';
  html += '<input type="hidden" name="MultiSelPin" value="' + document.Variables.MultiSelPin.value + '">';
  html += '<input type="hidden" name="BufferUnits" value="' + document.Variables.BufferUnits.value + '">';
  html += '<input type="hidden" name="BufferDistance" value="' + document.Variables.BufferDistance.value + '">';  
  html += '<input type="hidden" name="LegendStr" value="' + document.Variables.LegendStr.value + '">';
  html += '<input type="hidden" name="BackgroundLayer" value="' + document.Variables.BackgroundLayer.value + '">';
  html += '<input type="hidden" name="MapExtXMin" value="' + document.Variables.MapExtXMin.value + '">';
  html += '<input type="hidden" name="MapExtXMax" value="' + document.Variables.MapExtXMax.value + '">';
  html += '<input type="hidden" name="MapExtYMin" value="' + document.Variables.MapExtYMin.value + '">';
  html += '<input type="hidden" name="MapExtYMax" value="' + document.Variables.MapExtYMax.value + '">';
  html += '</form><div align="center"><br><br><br>';
  html += '<p><font face="Arial" color="#000066" size="3">';
  html += '<b>Please Wait While ZIMAS Prepares Your Report...</b></font></p><br><br>';
  html += '<img src="images/general/loading.png" border="0" WIDTH="120" HEIGHT="24"><br><br>';
  html += '</body></html>';
  
  var win = window.open('about:blank', '', 'width=800,height=500,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes');
  win.document.open();
  win.document.write(html);
  win.document.close();
  //win.document.forms[0].submit(); -- //Commented by Kavita R on Sept 17 2009 -- this was causing the report run twice - body onload + win.document.forms[0].submit!!!
  if (is5up) 
    win.window.focus();
}

function openMailingReport(bIncludeMap) {
  var html = '<html><head><title>ZIMAS - Zoning Information and Map Access System</title></head>';
  html += '<body onload="document.rptVariables.submit();">';
  html += '<form name="rptVariables" method="POST" action="report_mailing.asp">';
  html += '<input type="hidden" name="IncludeMap" value="' + bIncludeMap.toString() + '">';
  html += '<input type="hidden" name="SelectedMultiAddress" value="' + document.Variables.SelectedMultiAddress.value + '">';
  html += '<input type="hidden" name="SelType" value="' + document.Variables.SelType.value + '">';
  html += '<input type="hidden" name="Selection" value="' + document.Variables.Selection.value + '">';
  html += '<input type="hidden" name="MultiSelPin" value="' + document.Variables.MultiSelPin.value + '">';
  html += '<input type="hidden" name="BufferUnits" value="' + document.Variables.BufferUnits.value + '">';
  html += '<input type="hidden" name="BufferDistance" value="' + document.Variables.BufferDistance.value + '">';  
  html += '<input type="hidden" name="LegendStr" value="' + document.Variables.LegendStr.value + '">';
  html += '<input type="hidden" name="BackgroundLayer" value="' + document.Variables.BackgroundLayer.value + '">';
  html += '<input type="hidden" name="MapExtXMin" value="' + document.Variables.MapExtXMin.value + '">';
  html += '<input type="hidden" name="MapExtXMax" value="' + document.Variables.MapExtXMax.value + '">';
  html += '<input type="hidden" name="MapExtYMin" value="' + document.Variables.MapExtYMin.value + '">';
  html += '<input type="hidden" name="MapExtYMax" value="' + document.Variables.MapExtYMax.value + '">';
  html += '<input type="hidden" name="ReportQuery" value="' + document.Variables.ReportQuery.value + '">';
  html += '<input type="hidden" name="WorkOrder" value="' + document.Variables.WorkOrder.value + '">';
  html += '<input type="hidden" name="ReportFormat" value="' + document.Variables.ReportFormat.value + '">';
  html += '<input type="hidden" name="RandomFactor" value="' + document.Variables.RandomFactor.value + '">';
  html += '</form><div align="center"><br><br><br>';
  html += '<p><font face="Arial" color="#000066" size="3">';
  html += '<b>Please Wait While ZIMAS Prepares Your Report...</b></font></p><br><br>';
  html += '<img src="images/general/loading.png" border="0" WIDTH="120" HEIGHT="24"><br><br>';
  html += '</body></html>';
  
  var win = window.open('about:blank', '', 'width=800,height=500,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes');
  win.document.open();
  win.document.write(html);
  win.document.close();
  //win.document.forms[0].submit(); -- //Commented by Kavita R on Sept 17 2009 -- this was causing the report run twice - body onload + win.document.forms[0].submit!!!
  if (is5up) 
    win.window.focus();
}

function printMap() {
  var html = '<html><head><title>ZIMAS - Zoning Information and Map Access System</title></head>';
  html += '<body onload="document.rptVariables.submit();">';
  html += '<form name="rptVariables" method="POST" action="print_map.asp">';
  html += '<input type="hidden" name="SelectedMultiAddress" value="' + document.Variables.SelectedMultiAddress.value + '">';
  html += '<input type="hidden" name="SelType" value="' + document.Variables.SelType.value + '">';
  html += '<input type="hidden" name="Selection" value="' + document.Variables.Selection.value + '">';
  html += '<input type="hidden" name="MultiSelPin" value="' + document.Variables.MultiSelPin.value + '">';
  html += '<input type="hidden" name="BufferUnits" value="' + document.Variables.BufferUnits.value + '">';
  html += '<input type="hidden" name="BufferDistance" value="' + document.Variables.BufferDistance.value + '">';
  html += '<input type="hidden" name="LegendStr" value="' + document.Variables.LegendStr.value + '">';
  html += '<input type="hidden" name="BackgroundLayer" value="' + document.Variables.BackgroundLayer.value + '">';
  html += '<input type="hidden" name="MapExtXMin" value="' + document.Variables.MapExtXMin.value + '">';
  html += '<input type="hidden" name="MapExtXMax" value="' + document.Variables.MapExtXMax.value + '">';
  html += '<input type="hidden" name="MapExtYMin" value="' + document.Variables.MapExtYMin.value + '">';
  html += '<input type="hidden" name="MapExtYMax" value="' + document.Variables.MapExtYMax.value + '">';
  html += '</form><div align="center"><br><br><br>';
  html += '<p><font face="Arial" color="#000066" size="3">';
  html += '<b>Please Wait While ZIMAS Prepares Your Printable Map...</b></font></p><br><br>';
  html += '<img src="images/general/loading.png" border="0" WIDTH="120" HEIGHT="24"><br><br>';
  html += '</body></html>';

  var win = window.open('about:blank', '', 'width=800,height=500,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes');
  win.document.open();
  win.document.write(html);
  win.document.close();
  //win.document.forms[0].submit(); -- //Commented by Kavita R on Sept 17 2009 -- this was causing the report run twice - body onload + win.document.forms[0].submit!!!
  if (is5up) 
    win.window.focus();
}

function doLink(sField, sValue) {
  var aPIN = document.Variables.MultiSelPin.value;
  if (aPIN == null || aPIN == "")
  {
    aPIN = document.Variables.Selection.value.substr(1,document.Variables.Selection.value.length-2);
  }
  //Kavita Ravindran 09/07/05
  var sHseNbr = document.Variables.StartNbr.value;
  var sStrName = document.Variables.StrName.value;
  if (sStrName == "" || sStrName == null)
  {
    var sAdd = document.Variables.SelectedMultiAddress.value;
    var sAddArray = sAdd.split(" ");
    sHseNbr = sAddArray[0];
    var i = sAdd.indexOf(" ");
    sStrName = sAdd.substring(i+1);
    //Kavita Ravindran, 07.31.2006 - Check to see if StreetName has ' (single quote).  If yes, then replace it with the escape key ''
    if (sStrName.indexOf("'")>=0)
	{
		sStrName=sStrName.replace("'","''");
	}
  }
  if (sField == "BPI" && sHseNbr == "No")
  {
    alert("Building Permit Info cannot be displayed because the selected parcel has no address.");
  }
  else
  {
  //End Kavita Ravindran
	var sURL = 'link.asp?Field=' + escape(sField) + '&Value=' + escape(sValue)+'&pin=' +escape(aPIN)+'&HseNbr=' +escape(sHseNbr)+'&StrName=' +escape(sStrName);
	var datatab = document.Variables.ActiveDataTab.value;
	//Kavita Ravindran - Dec 07, 2006 - Check for IE 7 and modify window attributes accordingly
	if (isIE7)
	{
		var winFeatures1 = 'width=400,height=300,menubar=yes,toolbar=no,location=yes,status=no,scrollbars=yes,resizable=yes';
		var winFeatures2 = 'width=800,height=500,menubar=yes,toolbar=no,location=yes,status=no,scrollbars=yes,resizable=yes';
		var winFeatures3 = 'width=800,height=550,menubar=yes,toolbar=no,location=yes,status=no,scrollbars=yes,resizable=yes';
	}
	else
	{
		var winFeatures1 = 'width=400,height=300,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes';
		var winFeatures2 = 'width=800,height=500,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes';
		var winFeatures3 = 'width=800,height=550,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes';
	}
	//Kavita Ravindran 
	if(sField=="GENPLAN" || sField=="CPA_FN_NUM")
	{
	//  MM_openBrWindow(sURL, 'ZIMAS_LINK', 'width=400,height=300,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes');
		MM_openBrWindow(sURL, 'ZIMAS_LINK', winFeatures1);
	}
	else if ((datatab >= "CaseNumbers1" && datatab <= "CaseNumbers90") || (datatab >= "CitywideCodeAmendmentCases1" && datatab <= "CitywideCodeAmendmentCases90"))
	{
		MM_openBrWindow(sURL, 'ZIMAS_LINK', winFeatures2);
	}//End Kavita Ravindran 

	//dan halli
	else if (sField == "SPECPLAN")
	{	
	//	MM_openBrWindow(sURL, 'ZIMAS_LINK', 'width=800,height=550,menubar=no,toolbar=no,location=no,status=no,scrollbars=no,resizable=no');
		MM_openBrWindow(sURL, 'ZIMAS_LINK', winFeatures3);
	}
	else
	{
	//	MM_openBrWindow(sURL, 'ZIMAS_LINK', 'width=800,height=550,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=no');
		MM_openBrWindow(sURL, 'ZIMAS_LINK', winFeatures3);
	}
  }
}  

function doHPOZ(sPin,sAPN) {
//  window.open('hpoz1.asp?Pin=' + sPin + '&hpoz=' + sAPN, 'ZIMAS_HPOZ', 'width=800,height=600');
    window.open('hpoz1.asp?Pin=' + sPin + '&hpoz=' + sAPN, 'ZIMAS_HPOZ', 'width=830,height=600,menubar=yes,toolbar=yes,location=no,status=no,scrollbars=yes,resizable=yes');
}

function searchTab() {
  var sURL = 'search.asp?ToolTips=' + document.Variables.ToolTips.value;
  
  // Section to get name of active data tab and manipulate it so that the 
  // number following the data tab name is 1.  This involves trimming off
  // whatever number is at the right hand side of the string and replacing
  // it with the number 1.  We do this so that when the Active Data Tab is
  // propagated back to the map display, it will show the first data tab
  // of the selected category.
  var sDataTab = document.Variables.ActiveDataTab.value;
  var bContinue = true;					// Bool to continue loop
  var sChr;								// Chr to get from end of string and test
  while (bContinue) {					// Start the loop
    sChr = sDataTab.substr(sDataTab.length - 1, 1);		// Get the right most character
    if (isNaN(parseInt(sChr))) {		// See if it's a number
      sDataTab += '1';					// It's not a number, so add "1" to the string
      bContinue = false;				// And exit the loop
    } else {							// It is a number
      sDataTab = sDataTab.substring(0, sDataTab.length - 1);	// So trim off the right most character
    }
  }
  sURL += '&ActiveDataTab=' + sDataTab;
  
  if (document.Variables.LegendStr.value.length > 0)
    sURL += '&LegendStr=' + document.Variables.LegendStr.value;
  
  if (document.Variables.BackgroundLayer.value.length > 0)
    sURL += '&BackgroundLayer=' + document.Variables.BackgroundLayer.value;

  window.location.href = sURL;
}

function aboutDlg() {
  MM_openBrWindow('misc/AboutZIMAS.htm', 'ZimasDlg2', 'width=600,height=400,menubar=no,toolbar=no,location=no,status=no,scrollbars=no');
}

function termsDlg () {
  MM_openBrWindow('misc/Terms_and_Conditions.htm', 'ZimasDlg2', 'width=600,height=400,menubar=no,toolbar=no,location=no,status=no,scrollbars=no');
}

function supportDlg () {
  MM_openBrWindow('techsupport.asp', 'ZimasDlg', 'width=565,height=330,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes');
}

function tsupportDlg () {
  MM_openBrWindow('misc/support.asp', 'ZimasDlg', 'width=600,height=400,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes');
}

function commentsDlg () {
  MM_openBrWindow('comments.asp', 'ZimasDlg', 'width=565,height=330,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes');
}

function dataErrorsDlg () {
  MM_openBrWindow('dataErrors.asp', 'ZimasDlg', 'width=565,height=330,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes');
}

function mailingListDlg () {
  MM_openBrWindow('mailingList.asp', 'ZimasDlg', 'width=565,height=330,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes');
}

function popupDefinition(sFileName) {
  MM_openBrWindow('datatabs/'+sFileName, 'ZimasDefinition', 'width=400,height=300,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes');
}

function popupLayerDefinition(sFileName) {
  MM_openBrWindow('layers/'+sFileName, 'ZimasLayer', 'width=400,height=300,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes');  
}
