
var aplMaperServer = "www.getfacts.wisc.edu/proxy/proxy.php" 
function AddLayernotInLayerswitcher(name, text){
            // create WMS layer
            temp  = new OpenLayers.Layer.WMS(
                text,
                "http://" + aplMaperServer  + "?",
                {
                   layers: name,
                   styles: '',
                   srs: 'EPSG:4269',
                   format: 'image/png',
                   tiled: 'true',
                   transparent: true
                },
                {
                    'opacity': 0.80, 'isBaseLayer': false, 'wrapDateLine': true, 'visibility': false, 'displayInLayerSwitcher': false, 'displayOutsideMaxExtent': false
                }
            );
	return temp;
}
function AddLayerHidden(name, text){
            // create WMS layer
            temp  = new OpenLayers.Layer.WMS(
                text,
                "http://" + aplMaperServer  + "?",
                {
                   layers: name,
                   styles: '',
                   srs: 'EPSG:4269',
                   format: 'image/png',
                   tiled: 'true',
                   transparent: true
                },
                {
                    'opacity': 0.80, 'isBaseLayer': false, 'wrapDateLine': true, 'visibility': false, 'displayOutsideMaxExtent': false
                }
            );
	return temp;
}
function AddLayerVisible2(name, text){
            // create WMS layer
            var temp = new OpenLayers.Layer.WMS(
                "World Map",
                "http://" + aplMaperServer  + "?",
                {
                    transparent: 'TRUE',
                    layers: name
                }
            );
	return temp;
}

function AddLayerVisible(name, text){
            // create WMS layer
            temp  = new OpenLayers.Layer.WMS(
                text,
                "http://" + aplMaperServer  + "?",
                {
                   layers: name,
                   styles: '',
                   format: 'image/png',
                   tiled: 'true',
                   transparent: true
                },
                {
                    'opacity': 0.80, 'isBaseLayer': false, 'wrapDateLine': true, 'visibility': true, 'displayOutsideMaxExtent': false
                }
            );
	return temp;
}
function myIdentify(pos){
	var pixel = new OpenLayers.Pixel(pos.x,pos.y);
	var lonlat = map.getLonLatFromPixel(pixel);
      getDetails(lonlat.lat,lonlat.lon);
}
function mySplit(pos){
confirmed = window.confirm("You have selected a polygon to split. Would you like to continue? Click Cancel to stop.");

if (confirmed)
{
	var pixel = new OpenLayers.Pixel(pos.x,pos.y);
	var lonlat = map.getLonLatFromPixel(pixel);
      thedis = document.getElementById("splitgeo")
	StartAjaxRequest("toggleControl")
	thecolor = parseInt(parseInt(document.getElementById("sDisColor").selectedIndex) + 1)
	ajaxRequest.open("GET", "http://www.getfacts.wisc.edu/cgi/_redistrict.py?lat=" + lonlat.lat + "&longi=" + lonlat.lon + "&district=n&splitter=f&color=" + thecolor + "&county=dane", true);
	ajaxRequest.send(null); 
} 
else {deactivateSplit()}

}
function changeOpacity(byOpacity) {
      var maxOpacity = 0.9;
      var minOpacity = 0.1;
      var newOpacity = (parseFloat(document.getElementById('hOpacity').value) + byOpacity).toFixed(1);
      newOpacity = Math.min(maxOpacity,Math.max(minOpacity, newOpacity));
	document.getElementById('hOpacity').value = newOpacity
	document.getElementById('txtopacity').innerHTML = newOpacity
	CreateThematicMap()
}
function changeOpacity2() {
	//document.getElementById('mapOpacity').options[document.getElementById('mapOpacity').selectedIndex].value
	document.getElementById('hOpacity').value = document.getElementById('mapOpacity').selectedIndex
	CreateThematicMap()
}
function ZoomCounty(name){
  zoomcountySelect = document.getElementById(name)
  myString = zoomcountySelect.options[zoomcountySelect.selectedIndex].value
  var mySplitResult = myString.split(",");
  var val1 = parseInt(parseInt(mySplitResult[0]) + parseInt(-40000))
  var val2 = parseInt(parseInt(mySplitResult[1]) + parseInt(40000))
  var val3 = parseInt(parseInt(mySplitResult[2]) + parseInt(40000))
  var val4 = parseInt(parseInt(mySplitResult[3]) + parseInt(-40000))
  var usBounds = new OpenLayers.Bounds(val1, val2, val3, val4)
  map.zoomToExtent(usBounds);


}
function FullExtent(){
            var usBounds = new OpenLayers.Bounds(mapExtent[0], mapExtent[1], mapExtent[2], mapExtent[3]);
		map.zoomToExtent(usBounds);
}
function MapReset(varname){
	if (iswms == true){map.removeLayer(wms)};
	var divlegendEl = document.getElementById(varname);
	divlegendEl.style.display = 'none';
	iswms = false;
	FullExtent()
}

function layerOnOff(layer, thecheckbox){
			if (document.getElementById(thecheckbox).checked == true)
				layer.setVisibility(true)
			else
				layer.setVisibility(false)			
}
function setHiddenValsLabels(jlayer, thehidden){
	if (document.getElementById(jlayer).checked != true)
		document.getElementById(thehidden).value = "yes"
	else
		document.getElementById(thehidden).value = "no"
}
function addremoveLabelChecker(thecheckbox, layer, layerwlabel, thecheckboxLabel){
var visLayer = layer.getVisibility()
var visLayerLabel = layerwlabel.getVisibility()
		if (document.getElementById(thecheckbox).checked == true){
			if (document.getElementById(thecheckboxLabel).checked == true){
				layer.setVisibility(false)
				layerwlabel.setVisibility(true)
			}else{
				layer.setVisibility(true)
				layerwlabel.setVisibility(false)
			}
		}else{
			layer.setVisibility(false)
			layerwlabel.setVisibility(false)
		}
}



