// JavaScript Document
/*************************
* 
*  Misc functions
*
***************************/

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ReplaceAll = function(stringToFind,stringToReplace){
    var temp = this;
    var index = temp.indexOf(stringToFind);
        while(index != -1){
            temp = temp.replace(stringToFind,stringToReplace);
            index = temp.indexOf(stringToFind);
        }
        return temp;
		//alert(temp);
 }

/***********************************
*
* SiteCatalyst Tracking Functions
*
************************************/
function swGetEnv() {
	var sUrl = top.window.location.toString().toLowerCase();
	if ((sUrl.indexOf("misred") != -1) || (sUrl.indexOf("miscms") != -1)) {
		sEnv = "solidwdev";
	}
	else {
		sEnv = "solidwswugnorg";
	}
	return sEnv;
}

function scTrackMapSearch(scSearchString, scSearchResultsNum) {
	var s=s_gi(swGetEnv());
	s.linkTrackVars='events,prop27,prop28,eVar11';
	s.linkTrackEvents='event25';
	s.events='event25';
	s.prop27=scSearchString;
	s.prop28=scSearchResultsNum;
	s.eVar11=s.prop27;
	s.trackingServer='asc.solidworks.com';
	s.trackingServerSecure='sasc.solidworks.com';
	s.tl(true,'o','User Group Search');
}

/*******************
*
* Set Global vars
*
********************/
var mapObj = new mapquestCFC();

/**************************************************
*
* Method to get all POI's (Points of interest)
* from database based on country and zip,
* or city or address
* country will alwys be required
* method can accept zip or (address and city) or city
*
*****************************************************/

getPOI_noMap = function() {
	mapObj.setCallbackHandler(poi_nomapHandler);
	mapObj.getPOI_noMap(getVARCountry());
	}

poi_nomapHandler = function(returndata) {
	var poiDiv = document.getElementById("poi_list");
	var x='';
	if (returndata.length==0) {
		x='<strong>'+document.getElementById('uglocatorForm').xml_nodata.value+'</strong>';
	}
	for(i=0;i<returndata.length;i++) {
		newImage1= "url(/includes/uglocator/images/"+getImageName(returndata[i].DTSTYLE)+".png)  no-repeat";
		
		x =	x + '<div style="background:url(/includes/uglocator/images/'+getImageName(returndata[i].DTSTYLE)+'.png)"  id="VARline'+(parseInt(i)+1)+'" class="certtype" >'+(parseInt(i)+1)+'</div>' +'<div class="addressDiv">&nbsp;<a href="/swugn/calendar/ugdetails.htm?id='+returndata[i].ID+'">'+ returndata[i].COMPANYNAME+'</a><br />';
	
	x =	x + '<strong>'+returndata[i].GROUPCITY+'</strong><br />';
	x =	x + returndata[i].ADDRESS1+'<br />';
	x =	x + returndata[i].CITY+'';
	if (returndata[i].CITY.trim() !='') {
	x =	x + ', '+returndata[i].STATE;
	} 
	x =	x + '</div><br style="clear:both" />';

	}
	
if (	getVARCountry()=='Japan')	{
	
	/*$('#maparea').css('padding-top','450px');*/
		//$('#poi_list').css('padding-top','5px');
		//$('#poi_list').css('padding-left','3px');
		//$('#poi_list').css('text-weight','bold');
		//$('#poi_list').css('text-align','left');
		//$('#poi_list').css('color','#333333;');
		poiDiv.innerHTML = document.getElementById('uglocatorForm').xml_nomapjp.value+ ' '+getVARCountryName()+document.getElementById('uglocatorForm').xml_nomap2jp.value;	
		//poiDiv.innerHTML='jffjfj';		
	
	//poiDiv.innerHTML='';
	} else {
	poiDiv.innerHTML=x;
	}
	
}

getPOI = function() {
	mapObj.setCallbackHandler(poiHandler);
	mapObj.getPOI(getDTStyle_type(),document.getElementById('poiform').CountrySearch.value,document.getElementById('poiform').ZipSearch.value,document.getElementById('poiform').CitySearch.value,document.getElementById('poiform').StateSearch.value, document.getElementById('poiform').latitude.value, document.getElementById('poiform').longitude.value, document.getElementById('poiform').id.value);
	}

poiHandler = function(returndata) {
	var poiDiv = document.getElementById("poi_list");
	var x='';
	if (returndata.length==0) {
		x='<strong>'+document.getElementById('uglocatorForm').xml_nodata.value+'</strong>';
	}
	
	scTrackMapSearch(document.getElementById('poiform').CountrySearch.value+','+document.getElementById('poiform').ZipSearch.value+','+document.getElementById('poiform').CitySearch.value+','+document.getElementById('poiform').StateSearch.value, returndata.length)
	//returndata.length # or results
	//document.getElementById('poiform').CountrySearch.value,
	//document.getElementById('poiform').ZipSearch.value,
	//document.getElementById('poiform').CitySearch.value,
	//document.getElementById('poiform').StateSearch.value, 

	for(i=0;i<returndata.length;i++) {
		if (returndata[i].SINGLEPOI == 0) {
			newImage1= "url(/includes/uglocator/images/"+getImageName(returndata[i].DTSTYLE)+".png)  no-repeat";
			x =	x + '<div style="background:url(/includes/uglocator/images/'+getImageName(returndata[i].DTSTYLE)+'.png)"  id="VARline'+(parseInt(i)+1)+'" class="certtype" >'+(parseInt(i)+1)+'</div>' +'<div class="addressDiv">&nbsp;<a href="/swugn/calendar/ugdetails.htm?id='+returndata[i].ID+'">'+ returndata[i].COMPANYNAME+'</a><br />';
		} else {
			
			// check this
			
			x =	x + '<div style="background:url(/includes/uglocator/images/'+getSinglePOIImage()+'.png)"  id="VARline'+(parseInt(i)+1)+'" class="certtype" ></div>' +'<div class="addressDiv">&nbsp;'+ returndata[i].COMPANYNAME+'<br />';
			
		}
		
		 //end check
		x =	x + '<strong>'+returndata[i].GROUPCITY+'</strong>';
		//x =	x + returndata[i].CITY+'';
		if (returndata[i].GROUPSTATE.trim() !='') {
			x =	x + ', <strong>'+returndata[i].GROUPSTATE+'</strong>';
		} 
		x =	x +'<br />'
		if (returndata[i].SINGLEPOI == 0) {
			if (returndata[i].COUNTRY=='United States') {
				x =	x + returndata[i].DIST+' Miles away<br />';
			} else {
				x =	x + returndata[i].DIST+' Kilometers away<br />';	
			}
		}
		if (returndata[i].SINGLEPOI == 1) {
			x =	x + returndata[i].ADDRESS1+'<br />';
			if (returndata[i].ZIP !='') {
			x =	x + returndata[i].ZIP+'<br />';
			}
		}
		
			x =	x + '</div><br style="clear:both" />';
	}
	poiDiv.innerHTML=x;
}

// map map global var
var map = null;

function destroyMap() {
	if (map!=null)
	map.dispose();
}
/****************************
	Bing AJAX API  v7.0
****************************/
function Geocodec(credentials)
{
	map.getCredentials(MakeGeocodeRequest);
}

function Geocode2() {
	var geocodeRequest = "http://dev.virtualearth.net/REST/v1/Locations?CountryRegion="+getVARCountry()+"&adminDistrict="+"&locality="+getVARCity()+"&postalCode="+getVARZip()+"&addressLine="+getVARAddress() + "&output=json&jsonp=GeocodeCallback&key=" + 'AjNrkjNEbaUP4uKAid7Kwvh-uLmL2Cbf4gGQi1xZcEZYXW58W9kqeVVovnVuIvYT';
	CallRestService(geocodeRequest);
}
function Geocode() {	
	var geoObj = new mapquestCFC();
	geoObj.setCallbackHandler(GeocodeCallback);
	geoObj.geocode(getVARCountry(),getVARZip(),getVARState(),getVARCity());
}

function CallRestService(request) 
{
	//alert(request);
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", request);
	document.body.appendChild(script);	
}

// method used to get data and geocode info to get map default location
// will retrun invalid zip message if zip not retruning valid confidence code by mapquest
// see geoHandler
function validate_location() {
	if( $('#postalDiv').is(":visible") ) {
		if ($('#ZipSearch').val().trim()==''){			
			var message=document.getElementById('uglocatorForm').xml_ziprequired.value+' '+getVARCountryName()+document.getElementById('uglocatorForm').xml_ziprequired2.value;
			$('#errorText').html(message);
		}  else {
			$('#errorText').html("");
			Geocode();		
		} 
	}	else if ($('#cityDiv').is(":visible"))   {
		if ($('#CitySearch').val().trim()==''){	
			var message=document.getElementById('uglocatorForm').xml_cityrequired.value+' '+getVARCountryName()+document.getElementById('uglocatorForm').xml_cityrequired2.value;
			$('#errorText').html(message);		
		}  else {
			$('#errorText').html("");
			Geocode();	
		} 
		} else {
		$('#errorText').html("");
		Geocode();
	}	
}


/*******************************************************
* Methods used to process maps
********************************************************/
//window.onload = getMapKey; 
//var mapkey= null;

//function getMapKey() {
//$.ajax({
//	type: 'GET',
	//url: '/CFC/bing/bing.cfc?method=getMapKey&returnformat=json',
	//data: ({}),
	//	success: function (response) {
			//mapkey=$.parseJSON(response);
	//	},
	//	error: function(data) {
	//		alert('failed');	
	//	}
	//});
//}
// method used to get map of VAR when click on the VAR link in the VAR list
function getVARMap(id,lng,lat,rc) {
	document.getElementById('poiform').latitude.value=lat;
	document.getElementById('poiform').id.value=id;
	document.getElementById('poiform').longitude.value=lng;
	document.getElementById('poiform').result_code.value=rc;
	document.getElementById('mapview').result_code.value=rc;
	document.getElementById('poiform').DTStyle_type.value= '3402';
	document.getElementById('mapview').DTStyle_type.value='3402';
	document.getElementById('mapview').longitude.value=lng;
	document.getElementById('mapview').latitude.value=lat;
	document.getElementById('mapview').id.value=id;
	document.getElementById('poiform').certImage.value='MQ00404';
	document.getElementById('poiform').nonCertImage.value='MQ00403';
	
	var mapOptions = {
	credentials: "AjNrkjNEbaUP4uKAid7Kwvh-uLmL2Cbf4gGQi1xZcEZYXW58W9kqeVVovnVuIvYT",
	//credentials:  mapkey,
	center: new Microsoft.Maps.Location(lat,lng),
	width: 420,
	height:390,
	mapTypeId: Microsoft.Maps.MapTypeId.road,  // default map to Roads
	showScalebar: false, // disable scale
	enableSearchLogo: false, // disable search logo
	enableClickableLogo: false,  // disable abilit to click on logo to load bing search page
	showCopyright: false,  // disable copyrights
	showDashboard: true,
	showBreadcrumb: false,
	showMapTypeSelector:false,
	zoom: 10
	}
	document.getElementById("mapArea").style.display='block';
	//document.getElementById("mapArea").innerHTML='';
	destroyMap();
	map = new Microsoft.Maps.Map(document.getElementById("mapArea"), mapOptions);
	var pinLocation = new Microsoft.Maps.Location(lat, lng)
	//var NewPin = new Microsoft.Maps.Pushpin(pinLocation, { text: '', icon: '/includes/uglocator/images/MQ00031.png' });
	var NewPin = new Microsoft.Maps.Pushpin(pinLocation, { text: '', icon: '/includes/uglocator/images/poi_search_green.png' });
	map.entities.push(NewPin);
	var pushpinOptions = {  text: "1", icon: '/includes/uglocator/images/poi_search_green.png' };
	
	// places poi info in poi_list DIV
	getPOI();
}

function validateCountry(country) {
	var countryObj = new mapquestCFC();
	countryObj.setCallbackHandler(countryHandler);
	countryObj.validate_Country(countryname=country);
	}


// method used to get data and geocode info to get map default location
// will retrun invalid zip message if zip not retruning valid confidence code by mapquest
// see geoHandler


function validate_zip() {
	var geoObj = new mapquestCFC();
	geoObj.setCallbackHandler(GeocodeCallback);
	geoObj.geocode(getVARCountry(),getVARZip(),getVARState(),getVARCity());
	}

/*************************************************
* GeocodeCallback Result Handler for validate_zip
* also validates for valid zip code confdence code retruned from mapquest
*************************************************/
function GeocodeCallback(result) {
	//console.log(result);
	$('#poi_list').css('display','block');
	$('#mapArea').css('display','block');
	$('#mapArea').css('border','#555555 6px solid');
	$('#mapareaTotal').css('display','block');
	var resultDiv = document.getElementById("mapArea");
	// blank out session on new search 
	document.getElementById('mapview').ZipSearch.value=document.getElementById('uglocatorForm').ZipSearch.value;
	// getVARZip();
	document.getElementById('mapview').CountrySearch.value=getVARCountry();
	document.getElementById('mapview').CitySearch.value=getVARCity();
	document.getElementById('mapview').StateSearch.value=getVARState();
	document.getElementById('mapview').DTStyle_type.value=getDTStyle_type();
	document.getElementById('mapview').session.value='';
	document.getElementById('uglocatorForm').SWImage.value=getSWImage();
	document.getElementById('uglocatorForm').SimulationImage.value=getSimulationImage();
	var c = document.getElementById('uglocatorForm').CountrySearch.value.trim();
	if (result.INTMQ ==1)	{
		if (result.INTGEOPOSTAL == 1) {
		// assumes ipostal must be 1		
if ((result.INTGEOPOSTAL == 1 && ((result.CONFIDENCE =='High' || result.CONFIDENCE =='Medium') && (result.ENTITYTYPE == 'PopulatedPlace' ||  result.ENTITYTYPE== 'Postcode1'  ||  result.ENTITYTYPE== 'Neighborhood'))) || result.INTGEOPOSTAL != 1)  {
	//alert(result.DTStyle);
				$('#keyimage').show('fast');
				var mapOptions = {
	credentials: "AjNrkjNEbaUP4uKAid7Kwvh-uLmL2Cbf4gGQi1xZcEZYXW58W9kqeVVovnVuIvYT",
	//credentials: mapkey,
	center: new Microsoft.Maps.Location(result.LAT, result.LNG),
	mapTypeId: Microsoft.Maps.MapTypeId.road,  // default map to Roads
	width: 420,
	height:390,
	showScalebar: false, // disable scale
	enableSearchLogo: false, // disable search logo
	enableClickableLogo: false,  // disable abilit to click on logo to load bing search page
	showCopyright: false,  // disable copyrights
	showDashboard: true,
	showBreadcrumb: false,
	showMapTypeSelector:false
	}
	//document.getElementById("mapArea").innerHTML='';
	destroyMap();
	map = new Microsoft.Maps.Map(document.getElementById("mapArea"), mapOptions);
	var pushpinOptions = {  text: "1" };
	
	var pinLocation1 = new Microsoft.Maps.Location(result.LAT, result.LNG);
	$.ajax({
		type: 'POST',
		url: '/includes/UGLocator/CFC/maps.cfc?method=getPOIBing&returnformat=json',
		data: ({
			country: getVARCountry(),
			zipcode: getVARZip(),
			city: getVARCity(),
			state: getVARState()
		}),
      		success: function (response) {
				var pins = ColdFusion.JSON.decode(response);
				var zm=6;
				var maxdist = 0;
				$.each(pins, function (index, pin) {
					if (pin.KMDISTANCE > maxdist)   
						maxdist = pin.KMDISTANCE;
					var pinLocation = new Microsoft.Maps.Location(pin.LATITUDE, pin.LONGITUDE)
					//console.log(pin);
					if (pin.DTSTYLE == '3300'){
						var NewPin = new Microsoft.Maps.Pushpin(pinLocation, { text: ''+pin.CNT+'', icon: '/includes/uglocator/images/poi_search_red.png' });
					} else {
						var NewPin = new Microsoft.Maps.Pushpin(pinLocation, { text: ''+pin.CNT+'', icon: '/includes/uglocator/images/poi_search_green.png' });
					}			
					map.entities.push(NewPin);
					if (maxdist < 6000)
						zm=1;
					if (maxdist < 2000)
						zm=1;
					if (maxdist < 1500)
						zm=2;
					if (maxdist < 1100)
						zm=3;
					if (maxdist < 750)
						zm=4;
					if (maxdist < 400)//ok
						zm=5;
					if (maxdist < 250) //ok 300
						zm=6;
					if (maxdist < 150)
						zm=7;
					if (maxdist < 50) //good down
						zm=8;
					if (maxdist < 20)
						zm=9;
					if (maxdist < 10)
						zm=10;
					if (maxdist < 7)
						zm=11;
					if (maxdist < 4)
						zm=12;
	
					//map.setView( {center:  new Microsoft.Maps.Location(lat,lng) });
				});
				//alert(zm);
				map.setView({ zoom: zm });
			},
			error: function(data) {
				//console.log(data);
			alert('failed');	
			}
		});		
				$('#errorText').html("");
				$('#img_list').hide();
				document.getElementById('poiform').CountrySearch.value=getVARCountry();
				document.getElementById('poiform').ZipSearch.value=getVARZip();
				document.getElementById('poiform').StateSearch.value=getVARState();
				document.getElementById('poiform').CitySearch.value=getVARCity();
				getPOI();
		
			} else {
				//var message=document.getElementById('uglocatorForm').xml_invalidzip.value+' '+getVARCountry()+document.getElementById('uglocatorForm').xml_invalidzip2.value;
				var message = "You have entered either: an invalid Postal Code, an invalid City and State, or an invalid City";
				$('#errorText').html(message);
				//alert(document.getElementById('varlocatorForm').xml_invalidlocation.value+' '+getVARCountryName()+document.getElementById('varlocatorForm').xml_invalidlocation2.value);
				// blank out zip and give zip field focus....
				document.getElementById('uglocatorForm').ZipSearch.value='';
				document.getElementById('uglocatorForm').ZipSearch.focus();
			}
		} else {//returndata.IGEOPOSTAL !=1
			$('#img_list').hide();		
			ColdFusion.Ajax.submitForm('uglocatorForm','/cfc/varlocatorb/maps.cfc?method=buildMapGeoCode&returnformat=JSON', resultRegHandler1, editErrorHandler);
		}
	} else {// returndata.INTMQ !=1
		$('#img_list').hide();
		getPOI_noMap();
		// if no image name defined in DB then use the default world.gif
		if (result.IMAGENAME.trim()==''){
			var imgname='world.gif';
			} else {
			var imgname=result.IMAGENAME.trim()
		}
		$('#maparea').css('background-image',"url(/includes/varlocatorb/images/"+imgname+")");
		$('#maparea').css('background-repeat','no-repeat');
		$('#maparea').css('padding-top','200px');
		$('#maparea').css('text-align','center');
		$('#maparea').css('text-weight','bold');
		$('#maparea').css('font-size','2.0em');
		var resultDiv = document.getElementById("mapArea");
		if (	getVARCountry()=='Japan')	{	
		resultDiv.innerHTML ='';
		} else {
		resultDiv.innerHTML = 'No Map Data Available for ' +getVARCountry();
		}
	}		
}
countryHandler = function(returndata) {
	if (returndata.MAPQUEST==0 || returndata.COUNTRY=='Mexico') {
		document.getElementById('uglocatorForm').mapquest.value='0';
		document.getElementById('mapview').mapquest.value='0';
		document.getElementById('poiform').mapquest.value='0';
		$('#postalDiv').hide('fast');
		//$('#cityDiv').hide('fast');
		//$('#locationDiv').hide('fast');
		document.getElementById('buttonDiv').style.marginLeft='90px';
		document.getElementById('uglocatorForm').ZipSearch.value='';
		document.getElementById('mapview').ZipSearch.value='';
		document.getElementById('poiform').ZipSearch.value='';
		document.getElementById('CitySearch').value='';
	} else {
		$('#postalDiv').show('fast');
		//$('#cityDiv').show('fast');
		$('#locationDiv').show('fast');
		$('#locationtype1').attr('checked', 'checked');
		$('#locationtype0').attr('checked', '');
		document.getElementById('buttonDiv').style.marginLeft='365px';
	
		document.getElementById('uglocatorForm').mapquest.value='1';
		document.getElementById('mapview').mapquest.value='1';
		document.getElementById('poiform').mapquest.value='1';
		document.getElementById('CitySearch').value='';

	}
	if (returndata.COUNTRY=='Canada' || returndata.COUNTRY=='United States' ) {
		//$('#StateSearch').attr('disabled', '');
		$('#stateDiv').show('fast');
	} else {
		//$('#StateSearch').attr('disabled', 'disabled');
		$('#stateDiv').hide('fast');
		
	}
}

/**********************************
*
* Default error Handler when building 
* maps
* 
***********************************/
function editErrorHandler() {
		alert("Error Occured while processing Map, please try again later");
	}	

/**********************************
*
* Method to get address information 
* from form fields
*
***********************************/
//get country info
getVARCountry = function() {
	var strCountry = document.getElementById('uglocatorForm').CountrySearch.value;
	return strCountry.trim();
	}
// get zip
getVARZip = function() {
	var strZip = document.getElementById('uglocatorForm').ZipSearch.value;
	return strZip.trim();
	}
// get address - mostlike used with hong kong and ireland
getVARAddress = function() {
	var strAddress=''
	return strAddress.trim();
	}
// get city	 - mostlike used with hong kong and ireland
getVARCity = function() {
	var strCity=document.getElementById('uglocatorForm').CitySearch.value;
	if (getVARCountry()=='France') {
		strCity=strCity.ReplaceAll(" ", "-");
		}
	
	return strCity.trim();
	}
getVARState = function() {
	var strState=document.getElementById('uglocatorForm').StateSearch.value;
	return strState.trim();
	}
// gets style type to get from DB 3402=all 3400= non cert 3401=cert 
// currently gets 3402 only as this isi in a hidden form field
getDTStyle_type = function() {
	//alert(document.getElementById('uglocatorForm').DTStyle_type.value);
	var strDTStyle=document.getElementById('uglocatorForm').DTStyle_type.value;
	return strDTStyle.trim();
	
	}	
/*********************************************
*
* populates form field for images used in map
* change the image name here if need to change 
* image for certified and non certified VARS
* Also needs to be changed on maps.cfc
*
********************************************/
getImageName = function(dtstyle) {
	if (dtstyle==3301) {
	var i = getSWImage();
	} else {
		var i = getSimulationImage();
		}
	return i;
	}	
getSWImage = function() {
	var i = 'MQ00404';
	return i;
	}	

getSimulationImage = function() {
	var i = 'MQ00403';
	return i;
	}		
getSinglePOIImage = function() {
	//var i = 'MQ00031';
	var i = 'MQ00404';
	return i;
	}	

//function submitform() {
//	document.getElementById("varlocatorForm").submit();
//}

/********************************************
*
* Misc and supporting functions/  methods
*
************************************************/

// used with getImg() function
function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

// sets slider value used with
// resultHandler() and resultHandler1()
function setSlider(data) {
	var sliderform='';
	document.getElementById('mapview').slider.value=data;
	var i=0
	for(i=0;i<=14;i++) {
		sliderform='slider'+i;
		if (i==data) {
			eval("document.getElementById('"+sliderform+"').className='slideselect';");
			eval("document.getElementById('"+sliderform+"').onmouseout=function() {this.className='slideselect';}");
		} else {
			eval("document.getElementById('"+sliderform+"').className='slidenormal';");
			eval("document.getElementById('"+sliderform+"').onmouseout=function() {this.className='slidenormal';}");
		
		}
		//document.getElementById('mapOpeningDiv').style.display='none';
		//getElementById('mapDiv').style.display='block';
		//document.getElementById('mapareatotal').style.display='block';
		document.getElementById('ps').style.display='block';
		document.getElementById('pw').style.display='block';
		document.getElementById('pe').style.display='block';
		document.getElementById('pn').style.display='block';
		document.getElementById('mapsliderarea').style.display='block';
		
	}
}
displayZip = function(data) {
	if (data == 0) {
		document.getElementById("ZipSearch").value='';
		
		$('#ZipSearch').attr('disabled', 'disabled');
		$('#CitySearch').attr('disabled', '');
		$('#StateSearch').attr('disabled', '');
		} 
	else {
		document.getElementById("CitySearch").value='';
		document.getElementById("StateSearch").selectedIndex=0;
		$('#CitySearch').attr('disabled', 'disabled');
		$('#StateSearch').attr('disabled', 'disabled');
		$('#ZipSearch').attr('disabled', '');
	}
	}

