﻿//*********************************************************
//*********************************************************
//                   CALLBACK FUNCTIONS
//*********************************************************
//*********************************************************


//*********************************************************
//LAYER FUNCTIONS
//*********************************************************

function toggleMapResource(){
    var sMap = "";
    sMap = Aerial2010_On + ":" + Aerial2009_On + ":" + Aerial2008_On + ":" + Aerial2007_On + ":" + Aerial2006_On + ":" + Aerial2004_On + ":" + Base_On + ":" + BaseTrans_On + ":" + FutureDev_On + ":" + ResentSales_On + ":" + Zoning_On + ":" + Subdivisions_On + ":" + Plss_on + ":" + ForeClosure_on;
    var message = "ToggleMapResource" + ":" + sMap; 
    var context = "ToggleMapResource";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);   
}

//*********************************************************
//COMMON SEARCH FUNCTIONS
//*********************************************************

//search parcel
function searchParcel(pin){
    var message = "SearchPIN" + ":" + pin;
    var context = "SearchPIN";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
}

//search parcels
function searchParcels(pins){
    var message = "SearchAllPINS" + ":" + pins;
    var context = "SearchAllPINS";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
}

//show results
function showResults(results, showGraphicLayer){
    hideLayer("label_ajax_busylayer");
    var pResults = document.getElementById('Panel_Results');
	if(pResults != null){
	    pResults.innerHTML = results;
	}
	showPanel("Panel_Results");
	if(showGraphicLayer != null){
        var ckBox = document.getElementById('CkBoxHighlightParcel');
        if(ckBox != null){
            if(showGraphicLayer=="False"){
                ckBox.checked = false;
            }else{
                ckBox.checked = true;
            }
        }
	}
}

//show results
function showResultsPin(results, selpin){
    hideLayer("label_ajax_busylayer");
    var pResults = document.getElementById('Panel_Results');
	if(pResults != null){
	    pResults.innerHTML = results;
	}
	showPanel("Panel_Results");
    if(selpin != null){
      //  document.forms['frmMain'].pin.value = selpin;
	    document.frmMain.pin.value = selpin;
	//    alert(selpin);
	}
}

function showResultsPin(results, selpin, x, y){//alert(x + "--" + y + "--" + xmin + "--" + xmax + "--" + ymin + "--" + ymax);
    hideLayer("label_ajax_busylayer");
    var pResults = document.getElementById('Panel_Results');
	if(pResults != null){
//        var ifrm = document.getElementById('ifrImage');
//        ifrm.src = "MobileVideoImage.aspx?pin=" + selpin;
	    pResults.innerHTML = results;
	}
	showPanel("Panel_Results");
    if(selpin != null){
      //  document.forms['frmMain'].pin.value = selpin;
	    document.frmMain.pin.value = selpin;
	//    alert(selpin);
	}
	if(x != null && y != null){
	    identifyXCor = x;
	    identifyYCor = y;
	    window.setTimeout(' showIdentifyXY('+ x +',' + y + ');', 2000);
       // px = MapXToPixelX(x);
       // py = MapYToPixelY(y);
       // showIdentifyIconXYpixel(px, py);
        return false;
	}
}

function showResultsXY(x, y){//alert(x + "--" + y + "--" + xmin + "--" + xmax + "--" + ymin + "--" + ymax);
	if(x != null && y != null){
	    identifyXCor = x;
	    identifyYCor = y;
	    window.setTimeout(' showIdentifyXY('+ x +',' + y + ');', 2000);
        return false;
	}
}
//switch ighlight layer
function showHighlight(showGraphicLayer){
    if(showGraphicLayer != null){
        var ckBox = document.getElementById('CkBoxHighlightParcel');
        if(ckBox != null){
            ckBox.checked = showGraphicLayer;
        }
	}
}
//*********************************************************
//SEARCH PIN FUNCTIONS
//*********************************************************

//do search PIN
function doSearchPIN(){
 	var thePID = ""; 
	var isValid = false;
    var theOption;
   	var j = theForm.SearchParcelNumOption.length;
	for (i=0; i<j; i++){
		if(theForm.SearchParcelNumOption[i].checked){
			theOption = theForm.SearchParcelNumOption[i].value
		}
	}
	switch(theOption){
		case "SearchParcelNumOptionOne":
 			thePID = document.getElementById("SearchParcelNumPID1").value;
			thePID = TrimString(thePID);
	 		if(thePID != ""){
 				if(thePID.length == 20 || thePID.length==15){
 					thePIN = thePID.replace(/-/g,"");
					theSec = thePIN.substring(0,2)
 					theTwn = thePIN.substring(2,4)
 					theRng = thePIN.substring(4,6)
 					var theRest = thePIN.substring(6)
 					thePIN = theRng+theTwn+theSec+theRest;
 					isValid = true;
 				}else{
 					alert("Please enter valid Parcel ID numbers.");
 					isValid = false;
 				}
 			}else{
 				alert("Please enter Parcel ID numbers.");
 				isValid = false;		
 			}	
		    break;
        case "SearchParcelNumOptionTwo":
 			thePID = document.getElementById("SearchParcelNumPID2").value;
			thePID = TrimString(thePID);
	 		if(thePID != ""){
 				if(thePID.length == 20 || thePID.length==15){
 					thePIN = thePID.replace(/-/g,"");
					//theSec = thePIN.substring(0,2)
 					//theTwn = thePIN.substring(2,4)
 					//theRng = thePIN.substring(4,6)
 					//var theRest = thePIN.substring(6)
 					//thePIN = theRng+theTwn+theSec+theRest;
 					isValid = true;
 				}else{
 					alert("Please enter valid Parcel ID numbers.");
 					isValid = false;
 				}
 			}else{
 				alert("Please enter Parcel ID numbers.");
 				isValid = false;		
 			}	
		    break;
		case "SearchParcelNumOptionThree":
		    var seclist = document.getElementById("ddlSec");
            theSec = seclist.options[seclist.options.selectedIndex].value;
            var twnlist = document.getElementById("ddlTwn");
            theTwn = twnlist.options[twnlist.options.selectedIndex].value;
            var rnglist = document.getElementById("ddlRng");
            theRng = rnglist.options[rnglist.options.selectedIndex].value;
            var subbox = document.getElementById("txtSub");
 	        theSub = subbox.value;
 	        var blkbox = document.getElementById("txtBlk");
 	        theBlk = blkbox.value;
 	        var lotbox = document.getElementById("txtLot");
 	        theLot = lotbox.value;
 	        if((theSub == "") || (theBlk == "") || (theLot == "")){
 		        alert("Please enter subdivision, block and lot numbers.");
 		        isValid = false;
 	        } 
            else {
		        if(theSub.length == 1){
			        theSub = "000" + theSub;
		        }
		        if(theSub.length == 2){
			        theSub = "00" + theSub;
		        }
		        if(theSub.length == 3){
			        theSub = "0" + theSub;
		        }
		        if(theBlk.length == 1){
			        theBlk = "0" + theBlk;
		        }
		        if(theLot.length == 1){
			        theLot = "00" + theLot;
		        }
		        if(theLot.length == 2){
			        theLot = "0" + theLot;
		        }
		        thePIN = theRng+theTwn+theSec+theSub+theBlk+theLot;	  
		        isValid = true;
 			}
		    break;
	}
	
    if(isValid == true){
		var pResults = document.getElementById('Results_Search_PIN');
	    if(pResults != null){
	        //pResults.innerHTML = "<img src='images/ajax_loading.gif' align='middle'/> Getting Information. . .";
	    }
        var message = "SearchPIN" + ":" + thePIN;
        var context = "SearchPIN";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);   
    }
/*


    var seclist = document.getElementById("ddlSec");
    theSec = seclist.options[seclist.options.selectedIndex].value;
    var twnlist = document.getElementById("ddlTwn");
    theTwn = twnlist.options[twnlist.options.selectedIndex].value;
    var rnglist = document.getElementById("ddlRng");
    theRng = rnglist.options[rnglist.options.selectedIndex].value;
    var subbox = document.getElementById("txtSub");
 	theSub = subbox.value;
 	var blkbox = document.getElementById("txtBlk");
 	theBlk = blkbox.value;
 	var lotbox = document.getElementById("txtLot");
 	theLot = lotbox.value;
 	if((theSub == "") || (theBlk == "") || (theLot == "")){
 		alert("Please enter subdivision, block and lot numbers.");
 	} else {
		if(theSub.length == 1){
			theSub = "000" + theSub;
		}
		if(theSub.length == 2){
			theSub = "00" + theSub;
		}
		if(theSub.length == 3){
			theSub = "0" + theSub;
		}
		if(theBlk.length == 1){
			theBlk = "0" + theBlk;
		}
		if(theLot.length == 1){
			theLot = "00" + theLot;
		}
		if(theLot.length == 2){
			theLot = "0" + theLot;
		}
		thePIN = theRng+theTwn+theSec+theSub+theBlk+theLot;
		var pResults = document.getElementById('Results_Search_PIN');
	    if(pResults != null){
	        //pResults.innerHTML = "<img src='images/ajax_loading.gif' align='middle'/> Getting Information. . .";
	    }
        var message = "SearchPIN" + ":" + thePIN;
        var context = "SearchPIN";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
	} 
	*/   
}

//show results pin
function showResultsPIN(results){
    var pResults = document.getElementById('Results_Search_PIN');
	if(pResults != null){
	    pResults.innerHTML = results;
	}
}


//*********************************************************
//SEARCH OWNER FUNCTIONS
//*********************************************************

//do search owner
function doSearchOwner(){
    var ownbox = document.getElementById("txtOwner");
 	theOwner = ownbox.value;
 	if(theOwner == ""){
 		alert("Please enter an name.");
 	}else if(theOwner.toUpperCase() == "CONFIDENTIAL"){
 		alert("Please enter valid name.");
 	}else {
		var pResults = document.getElementById('Results_Search_Owner');
	    if(pResults != null){
	       // pResults.innerHTML = "<img src='images/ajax_loading.gif' align='middle'/> Getting Information. . .";
	    }
        var message = "SearchOwner" + ":" + theOwner;
        var context = "SearchOwner";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
	}    
}

//select owner
function selectOwner(theOwner){
    var message = "SearchOwner" + ":" + theOwner;
    var context = "SearchOwner";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);   
}

//*********************************************************
//SEARCH PROPERTY NAME FUNCTIONS
//*********************************************************

//do search property name
function doSearchPropertyName(){
    var namebox = document.getElementById("txtPropertyName");
 	thePropertyName = namebox.value;
 	if(thePropertyName == ""){
 		alert("Please enter a property name.");
 	}else if(thePropertyName.toUpperCase() == "CONFIDENTIAL"){
 		alert("Please enter valid property name.");
 	} else {
 	    var SearchArea;
 	    var ol = document.getElementById("rblPropertyNameSearchArea_0");
        if(ol.checked){
            SearchArea = "County";
        }else{
            SearchArea = "Current";
        }
		var pResults = document.getElementById('Results_Search_Owner');
	    if(pResults != null){
	       // pResults.innerHTML = "<img src='images/ajax_loading.gif' align='middle'/> Getting Information. . .";
	    }
        var message = "SearchPropertyName" + ":" + SearchArea + ":" + thePropertyName;
        var context = "SearchPropertyName";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
	}    
}

//select owner
function selectOwner(theOwner){
    var message = "SearchOwner" + ":" + theOwner;
    var context = "SearchOwner";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);   
}

//show results owner
function showResultsOwner(results, x, y, showGraphicLayer){
    var pResults = document.getElementById('Panel_Results');
	if(pResults != null){
	    pResults.innerHTML = results;
	}
	showPanel("Panel_Results");
	if(x != null && y != null){
	    identifyXCor = x;
	    identifyYCor = y;
	    window.setTimeout(' showIdentifyXY('+ x +',' + y + ');', 2000);
       // px = MapXToPixelX(x);
       // py = MapYToPixelY(y);
       // showIdentifyIconXYpixel(px, py);
       // return false;
	}
	if(showGraphicLayer != null){
        var ckBox = document.getElementById('CkBoxHighlightParcel');
        if(ckBox != null){
            if(showGraphicLayer=="False"){
                ckBox.checked = false;
            }else{
                ckBox.checked = true;
            }
        }
	}	
}

//*********************************************************
//SEARCH ADDRESS FUNCTIONS
//*********************************************************

//do search address
function doSearchAddress(){
    var numbox = document.getElementById("txtStNum");
    var namebox = document.getElementById("txtStName");
 	num = numbox.value;
 	name = namebox.value;
 	if(name == ""){
 		alert("Please enter street name.");
 	} else {
		var message = "SearchAddress" + ":" + num + ":" + name;
        var context = "SearchAddress";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
	}    
}

//select address
function selectAddress(theStreet){
    var namebox = document.getElementById("txtStName");
    if(namebox != null){
        namebox.value = theStreet;
    }   
}

//show results address
function showResultsAddress(results){
    var pResults = document.getElementById('Results_Search_Address');
	if(pResults != null){
	    pResults.innerHTML = results;
	}
}


//*********************************************************
//SEARCH SECTION FUNCTIONS
//*********************************************************

//do search section
function doSearchSection(){
    var seclist = document.getElementById("ddlSS");
    var twnlist = document.getElementById("ddlTT");
    var rnglist = document.getElementById("ddlRR");
    var ss = seclist.options[seclist.options.selectedIndex].value;
    var tt = twnlist.options[twnlist.options.selectedIndex].value;
    var rr = rnglist.options[rnglist.options.selectedIndex].value;
 	var message = "SearchSection" + ":" + rr + tt + ss;
    var context = "SearchSection";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);       
}

//show results section
function showResultsSection(results){
    var pResults = document.getElementById('Results_Search_Section');
	if(pResults != null){
	    pResults.innerHTML = results;
	}
}


//*********************************************************
//SEARCH COORDINATES FUNCTIONS
//*********************************************************

//do search coordinates
//do search coordinates
function doSearchCoordinates(){
 	switch(CoordinatesType){
		case "StateXY":
            var X = document.getElementById("txtCorX").value;
            var Y = document.getElementById("txtCorY").value; 
            X = Trim(X);
            Y = Trim(Y); 
            if(X != "" && Y != ""){//alert("-" + X + "-")
            
	            identifyXCor = X;
	            identifyYCor = Y;
	            window.setTimeout(' showIdentifyXY('+ X +',' + Y + ');', 2000);
                var message = "SearchCoordinate" + ":" + X + ":" + Y;
                var context = "SearchCoordinate";
                WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);  	            
	        }else{
	            alert("X, Y could not be empty!");
	        }
		break;
		case "LatLong":
            var lat = document.getElementById("txtlat").value;
            var lon = document.getElementById("txtlong").value;
            lat = Trim(lat);
            lon = Trim(lon); 
            if(lat != "" && lon != ""){
//        	    identifyXCor = X;
//        	    identifyYCor = Y;
//        	    window.setTimeout(' showIdentifyXY('+ X +',' + Y + ');', 2000);
                var message = "SearchLatLong" + ":" + lat + ":-" + lon;
                var context = "SearchLatLong";
                WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);  	
        	}else{
 	            alert("Latitude, Longitude could not be empty!");
        	}
			break;
		default:
	}
 }

//do search coordinates
function doSearchXY(x, y){
    var message = "SearchCoordinate" + ":" + x + ":" + y;
    var context = "SearchCoordinate";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);  
}
 
//show results coordinates
function showResultsCoordinates(results){
    var pResults = document.getElementById('Results_Search_Coordinates');
	if(pResults != null){
	    pResults.innerHTML = results;
	}
}


//*********************************************************
//SEARCH INTERSECTION FUNCTIONS
//*********************************************************

//do search intersection
function doSearchIntersection(){
    //alert("This functionality is under construction.");
    var intersectname1 = document.getElementById("intersectname1").value;
    var selObject = document.getElementById('intersectname2')
    var intersectname2 = selObject.options[selObject.options.selectedIndex].value;
    
	if (intersectname1 == "") {
 		alert("Please enter street one name.");
 	} 
 	else if (intersectname2 == "") {
 		alert("Please enter street two name.");
 	} 
 	else {
        var message = "SearchIntersection" + ":" + intersectname1 + ":" + intersectname2;
        var context = "SearchIntersection";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
 	} 
   
}

//show results intersection
//function showResultsIntersection(results){
//alert(results);
 //   var pResults = document.getElementById('Results_Search_Intersection');
//	if(pResults != null){
//	    pResults.innerHTML = results;
//	}
//}


//*********************************************************
//CREATE LABELS FUNCTIONS
//*********************************************************

//do create labels
function doCreateLabels(){
    alert("This functionality is under construction.");
    //var seclist = document.getElementById("ddlSS");
    //var ss = seclist.options[seclist.options.selectedIndex].value;
    //var message = "SearchCoordinates" + ":" + ss;
    //var context = "SearchCoordinates";
    //WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);       
}

//show results labels
function showResultsLabels(results){
    var pResults = document.getElementById('Results_Search_Labels');
	if(pResults != null){
	    pResults.innerHTML = results;
	}
}


//*********************************************************
//FUTURE DEVELOPMENT FUNCTIONS
//*********************************************************

//select future development
function selectFutureDevelopment(sSub){
    var message = "SearchFutureDevelopment" + ":" + sSub;
    var context = "SearchFutureDevelopment";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);       
}

//*********************************************************
//SELECT PARCEL FUNCTIONS
//*********************************************************


// map select parcel
function MapSelectParcel() {
    map = Maps['Map1'];
    MapPoint(map.controlName, "MapSelectParcel", false, "Help"); // frank change cursor
  //  MapPoint(map.controlName, "MapSelectParcel", false);
    map.divObject.onmouseup = MapSelectParcelUp;
}

// map select parcel up
function MapSelectParcelUp(e) {
     
    //get click coordinates
    getXY(e);
    var box = calcElementPosition(map.containerDivId);
    zleft = mouseX - box.left;
    ztop = mouseY - box.top;
    
    //use client side idetify
    identifyXCor = (zleft * currentZoomFactor) / (12 * 96) + minx
    identifyYCor = maxy - (ztop * currentZoomFactor) / (12 * 96)
    showIdentifyIconXYpixel(zleft, ztop);
    
    var message = "MapSelectParcel:" + zleft + ":" + ztop;
    var context = "MapSelectParcel";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);     

    map.mode = map.tempMode;
    map.actionType = map.tempAction;
    map.cursor = map.tempCursor;
    return false;
}

//*********************************************************
//SELECT ZONING FUNCTIONS
//*********************************************************

// map select parcel
function MapSelectZoning() {
    map = Maps['Map1'];
    MapPoint(map.controlName, "MapSelectZoning", false, "Help"); // frank change cursor
  //  MapPoint(map.controlName, "MapSelectParcel", false);
    map.divObject.onmouseup = MapSelectZoningUp;
}

// map select parcel up
function MapSelectZoningUp(e) {
     
    //get click coordinates
    getXY(e);
    var box = calcElementPosition(map.containerDivId);
    zleft = mouseX - box.left;
    ztop = mouseY - box.top;
    
    //use client side idetify
    identifyXCor = (zleft * currentZoomFactor) / (12 * 96) + minx
    identifyYCor = maxy - (ztop * currentZoomFactor) / (12 * 96)
    showIdentifyIconXYpixel(zleft, ztop);
    
    var message = "MapSelectZoning:" + zleft + ":" + ztop;
    var context = "MapSelectZoning";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);     

    map.mode = map.tempMode;
    map.actionType = map.tempAction;
    map.cursor = map.tempCursor;
    return false;
}

//*********************************************************
//SELECT ForeClosure FUNCTIONS
//*********************************************************
// map select ForeClosure
function MapSelectForeClosure() {
    map = Maps['Map1'];
    MapPoint(map.controlName, "MapSelectForeClosure", false, "Help"); // frank change cursor
    map.divObject.onmouseup = MapSelectForeClosureUp;
}

// map select PLSS up
function MapSelectForeClosureUp(e) {
     
    //get click coordinates
    getXY(e);
    var box = calcElementPosition(map.containerDivId);
    zleft = mouseX - box.left;
    ztop = mouseY - box.top;
    var message = "MapSelectForeClosure:" + zleft + ":" + ztop;
    var context = "MapSelectForeClosure";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);     
    map.mode = map.tempMode;
    map.actionType = map.tempAction;
    map.cursor = map.tempCursor;
    return false;
}
function IdentifyForeClosure(result){
    var str = "";
    var pResults = document.getElementById('ForeClosureInfoDiv');
	if(pResults != null){
	    pResults.innerHTML = result;
	}
	return false;
}

//*********************************************************
//SELECT PLSS FUNCTIONS
//*********************************************************

// map select PLSS
function MapSelectPLSS() {
    map = Maps['Map1'];
    MapPoint(map.controlName, "MapSelectPLSS", false, "Help"); // frank change cursor
    map.divObject.onmouseup = MapSelectPLSSUp;
}

// map select PLSS up
function MapSelectPLSSUp(e) {
     
    //get click coordinates
    getXY(e);
    var box = calcElementPosition(map.containerDivId);
    zleft = mouseX - box.left;
    ztop = mouseY - box.top;
    var message = "MapSelectPLSS:" + zleft + ":" + ztop;
    var context = "MapSelectPLSS";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);     
    map.mode = map.tempMode;
    map.actionType = map.tempAction;
    map.cursor = map.tempCursor;
    return false;
}

function IdentifyPLSS(result){
    var str = "";
    if(result ==""){
        str = "<B>No PLSS Control Point found at this location.:<BR></B>";
    }else{
        str = "<B>PLSS Control Point found at this location:<BR></B>";
        var url = "http://data.labins.org/2003/surveydata/landrecords/ccr/detail.cfm?docnum=" + result;
        str += "<B>Control Number: <a href='" + url + "' target = '_blank'><font style='font-size: 16px; font-weight: bold'>" + result + "</font></B></a><BR>"
        str += "<B>Click the link above to see detail information about the control point on LABINS (Land Boundary Information System) website.<BR></B>";
   }
    var pResults = document.getElementById('PLSSInfoDiv');
	if(pResults != null){
	    pResults.innerHTML = str;
	}
	return false;
}


//*********************************************************
//SUGGEST FUNCTIONS
//*********************************************************

//get possible matches
function getPossibleMatches(type){
    window.setTimeout("suggestPossibleMatches('" + type + "');",500);  
}

//suggest possible matches
function suggestPossibleMatches(type){

    switch(type){
        case "Owner":
            var ownbox = document.getElementById("txtOwner");
 	        value = ownbox.value;
 	        if(value == ""){
 	            showResultsOwner('');
 	        }
 	        break;
 	        
 	    case "Address":
 	        var namebox = document.getElementById("txtStName");
 	        value = namebox.value;
 	        if(value == ""){
 	            showResultsAddress('');
 	        }
 	        break;
    } 
    
    if(value != ""){
        var message = "SuggestPossibleMatches" + ":" + type + ":" + value;
        var context = "SuggestPossibleMatches";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
    }  
}


//*********************************************************
//PRINT FUNCTIONS
//*********************************************************


//get printable map
function getPrintableMap(){
    var plist = document.getElementById("ddlPaper");
    var ol = document.getElementById("rblOrientation_0");
    var paper = plist.options[plist.options.selectedIndex].value;
    if(ol.checked){
        orient = "L";
    }else{
        orient = "P";
    }
    showHighlight(true);
    SwitchHighlightLayer();
    var message = "GetPrintableMap" + ":" + paper + ":" + orient;
    var context = "PrintableMap";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true); 
    var pResults = document.getElementById('Results_Print');
	if(pResults != null){
	 pResults.innerHTML = "<img src='images/ajax_loading.gif' align='middle'/> Getting Information. . .";
	}
}
//get printable map only without parcel information
function getPrintMapOnly(){
    showHighlight(true);
    SwitchHighlightLayer();
    var message = "GetPrintMapOnly" ;
    var context = "PrintableMapOnly";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true); 
}
//show printable map
function showPrintableMap(){
    var usepdfformat = document.getElementById("ckboxPrintPdfFormat").checked; 
    var plist = document.getElementById("ddlPaper");
    var ol = document.getElementById("rblOrientation_0");
    var tbox = document.getElementById("txtTitle");
  //  var sbox = document.getElementById("txtSubtitle");
    var paper = plist.options[plist.options.selectedIndex].value;
    if(ol.checked){
        orient = "L";
    }else{
        orient = "P";
    }
    var title = tbox.value;
    var thePIN = document.frmMain.pin.value;
    if(usepdfformat==true){
        theURL = "PdfMap.aspx?title=" + escape(title) + "&pin=" + thePIN;
    
    }else{
//        theURL = "rptPrintMap.aspx?title=" + escape(title) + "&pin=" + thePIN;
    //    var subtitle = sbox.value;
        if(navType =="Mozilla" || navType == "Safari"){//Mozilla does not show file base image pic 
            theURL = "Print_Map1.aspx?title=" + escape(title) + "&pin=" + thePIN;
        }else{

            if(isIE && ieVersion < 8){
                theURL = "Print_Map.aspx?title=" + escape(title) + "&pin=" + thePIN;
            }else{ //ie8
                theURL = "Print_Map1.aspx?title=" + escape(title) + "&pin=" + thePIN;
            }
        }
    }
    printWin = window.open(theURL, "_blank", "width=800,height=700,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=0,top=0");
    var pResults = document.getElementById('Results_Print');
	if(pResults != null){
	 pResults.innerHTML = "";
	}
}

//show printable map without parcel information
function showPrintableMapOnly(){
//  var subtitle = sbox.value;
    var thePIN = document.frmMain.pin.value;
    if(navType =="Mozilla" || navType == "Safari"){//Mozilla does not show file base image pic 
         theURL = "Print_Map_Only1.aspx?pin=" + thePIN;
    }else{ 
        if(isIE && ieVersion < 8){
            theURL = "Print_Map_Only.aspx?&pin=" + thePIN;
        }else{ //ie8
            theURL = "Print_Map_Only1.aspx?&pin=" + thePIN;
        }
    }
    printWin = window.open(theURL, "_blank", "width=800,height=700,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=0,top=0");
}

//*********************************************************
//SALES REPORT FUNCTIONS
//*********************************************************
//show showForeclosure
function showForeclosure(){
    printWin = window.open("http://paarcgis2.ocpafl.org/salesreport/default.aspx?foreclosure=on", "_blank", "width=800,height=700,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=0,top=0");
}
//get sales report coords
function getSalesReportCoords(){
    var message = "GetSalesReportCoords";
    var context = "GetSalesReportCoords";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);    
}

 //use client side idetify
function showIdentifyXY(x,y){
       px = MapXToPixelX(x);
       py = MapYToPixelY(y);
       showIdentifyIconXYpixel(px, py); 
}
function MapXToPixelX(x){
    var px=0;
	if((x >= minx) && (x <= maxx)){
	    //var currentZoomFactor = LevelArray[map.level];
	    px = parseInt((x - minx)*12*96/currentZoomFactor);
    } 
    return px;  
}
function MapYToPixelY(y){
    var py=0;
	if((y >= miny) && (y <=maxy)){
	    //var currentZoomFactor = LevelArray[map.level];
	    py = parseInt((maxy - y)*12*96/currentZoomFactor);
    } 
    return py;  
}

function showIdentifyIconXYpixel(px, py){
   	map.xMin=px;
	map.yMin=py;
	var div = document.getElementById("IdentifyLocation");
	if (div==null) {
	    addIdentifyLocation();
	}

	var div = document.getElementById("IdentifyLocation");
	// point is bottom center... 2 pixels up for shadow
	var cWidth = Math.floor(div.clientWidth / 2);
	var cHeight = div.clientHeight;
	//alert(cWidth + " x " + cHeight); // width and height might not be available on first time.... if so, approximate size needed
	if (cWidth==0) cWidth = 11;
	if (cHeight==0) cHeight = 34;
	var idLeft = px - parseInt(map.divObject.style.left) - cWidth + 5;
	var idTop = py - parseInt(map.divObject.style.top) - cHeight + 4; // add two back for icon bottom
//	if (isIE) {
//	    idTop+=2; 
//	    //idLeft+=2;
//	}
	window.setTimeout('moveLayer("IdentifyLocation", ' + idLeft + ', ' + idTop + '); showLayer("IdentifyLocation");', 0);
}

var identifyFilePath = "";
var identifyImageType = "png";
function addIdentifyLocation() {
    var content = '<div id="IdentifyLocation" style="position: absolute; left: 0px; top: 0px; visibility: hidden;">';
    if (isIE  && ieVersion < 7 && (identifyImageType.toLowerCase()=="png")) 
	    content += '<img src="' + identifyFilePath + 'images/blank.gif" alt="" border="0"  hspace="0" vspace="0" style="filter:  progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + identifyFilePath + 'images/pushpin.png\');" />\n';
	else
	    content += '<img src="' + identifyFilePath + 'images/pushpin.png" alt="" border="0"  hspace="0" vspace="0" />\n';
    content += '</div>';
    map.overlayObject.insertAdjacentHTML("BeforeEnd", content);
}
//--end of use client side idetify

function SwitchHighlightLayer(){
    var sMap = document.getElementById("CkBoxHighlightParcel").checked;
    var message = "ToggleGraphicLayer" + ":" + sMap;
    var context = "ToggleGraphicLayer";
    WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);  
}

// show AdressMashup on map
function doAddressMashupFile(){
        showLayer("Panel_ajax_Status");
        var message = "AddressMashupFile";
        var context = "AddressMashupFile";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);           
}

// show AdressMashup on map
function displayAddressMashupLink(addmashuplink){
        showLayer("Panel_ajax_Status");
        var message = "DisplayAddMashupLink:" + addmashuplink;
        var context = "DisplayAddMashupLink";
        WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);           
}

//show map link
function addAddressMashupMapLink(link){
	var content = '<table  cellSpacing="0" cellPadding="3" border="0" width="250px">';
	content = content + '<tr><td width="265px">Paste link in <b>email</b></td>';
	content = content + '<td width="15" valign="top" align="right"><img onclick="closeMapLink();" style="float: right; CURSOR: pointer" onmouseover="this.src =\'images/close_o.gif\'" onmouseout="this.src = \'images/close.gif\'" height="13" alt="Close" src="images/close.gif" /></td><tr>';
	content = content + '<tr><td style="PADDING-BOTTOM: 5px" colSpan="2" align="center">';
	content = content + '<input style="border: 2px double #339933" value="' + link + '"size="42"></td></tr>';
	content = content + '</table>';
	document.getElementById('maplinkdiv').innerHTML=content;
	showLayer("maplinkdiv");
}

function closeMapLink(){
    document.getElementById('maplinkdiv').innerHTML="";
    hideLayer("maplinkdiv");
}

function Trim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

function ConvertLatLong_XY(type){
 	switch(type){
	    case "LatLongToXY":
            var lat = document.getElementById("ConvertTxtLat").value;
            var lon = document.getElementById("ConvertTxtLong").value;
            lat = Trim(lat);
            lon = Trim(lon); 
            if(lat != "" && lon != ""){
                var message = "ConvertLatLong_XY" + ":" + "ToXY" + ":" + lat + ":-" + lon;
                var context = "ConvertLatLong_XY";
                WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);  	
        	}else{
 	            alert("Latitude, Longitude could not be empty!");
        	}
			break;
	    case "XYToLatLong":
            var X = document.getElementById("ConvertTxtCorX").value;
            var Y = document.getElementById("ConvertTxtCorY").value; 
            X = Trim(X);
            Y = Trim(Y); 
            if(X != "" && Y != ""){
                var message = "ConvertLatLong_XY" + ":" + "FromXY" + ":" + X + ":" + Y;
                var context = "ConvertLatLong_XY";
                WebForm_DoCallback('__Page',message,processCallbackResult,context,postBackError,true);  	            
	        }else{
	            alert("X, Y could not be empty!");
	        }
		break;
		default:
	}
 }
 
function ShowLatLong_XY(str){
    if(str.indexOf("Error")!=-1){
        alert(str);
    }else{
        var resultArray = str.split(":");
        switch(resultArray[0]){
            case "FromXY":
                var lat = resultArray[2];
                var lon = resultArray[1].replace("-", "");

                if(lat != "" && lon != ""){
                    document.getElementById("ConvertTxtLat").value = lat;            
                    document.getElementById("ConvertTxtLong").value = lon;
    	        }else{
                    alert("Error!");
    	        }
		        break;
            case "ToXY":
                var X = resultArray[1];
                var Y = resultArray[2];
                if(X != "" && Y != ""){
                    document.getElementById("ConvertTxtCorX").value = X;
                    document.getElementById("ConvertTxtCorY").value = Y; 
	            
                }else{
                    alert("X, Y could not be empty!");
                }
	        break;
	        default:
        }
    }
}