// JavaScript Document


function scrollVertical(value, element, slider) {

	element.scrollTop = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));

}

function showAddress(address, title) {

  geocoder.getLatLng(

    address,

    function(point) {

      if (!point) {

        alert(address + " not found");

      } else {

        map.setCenter(point, 13);

        var marker = new GMarker(point);

        map.addOverlay(marker);

        marker.openInfoWindowHtml(title+'<p>'+address+'</p>');

      }

    }

  );

}
function getTerm() {
	if($('term_0') == null || $('term_0') == 'undefined' || $('term_0').innerHTML == '') {
		$('livesearch').innerHTML = 'It appears your location is not in our system. Perhaps try a larger town or city nearby. Once you see an acceptable location in this list click enter to see lawyers in your area.';
		$('livesearch').show();
		return false;
	}
	else {
		$('liveTerm').value=$('term_0').innerHTML;
		location.href="/Impaired_Driving_Lawyers/"+$('prov_0').innerHTML+"/"+escape($('term_0').innerHTML)+"/";
		return false;
		}
		return false;
}
function getTerm2() {
	
	type = $RF('lawTypeId');
	$('livesearch2').show();
	if(type == 'Traffic') url = 'http://traffic-ticket-lawyers.ca/Criminal_Charges_Lawyers/';
	else if(type == 'Criminal') url = 'http://criminal-defence-lawyers.com/Criminal_Charges_Lawyers/';
	else url = "http://impaireddriving.ca/Impaired_Driving_Lawyers/";
	
	
	if($('term_0') == null || $('term_0') == 'undefined' || $('term_0').innerHTML == '') {
		$('livesearch2').innerHTML = 'It appears your location is not in our system. Perhaps try a larger town or city nearby. Once you see an acceptable location in this list click enter to see lawyers in your area.';
		$('livesearch2').show();
		return false;
	}
	else {
		$('liveTerm2').value=$('term_0').innerHTML;
		
		location.href=url+$('prov_0').innerHTML+"/"+escape($('term_0').innerHTML)+"/";
		return false;
		}
		return false;
}
function $RF(el, radioGroup) {
 if($(el).type && $(el).type.toLowerCase() == 'radio') {
	        var radioGroup = $(el).name;
	        var el = $(el).form;
    } else if ($(el).tagName.toLowerCase() != 'form') {
        return false;
    }
	 
	    var checked = $(el).getInputs('radio', radioGroup).find(
	        function(re) {return re.checked;}
	    );
	    return (checked) ? $F(checked) : null;
}
function showResult(searchTerm) {

	$('livesearch').show();
	new Ajax.Updater('livesearch', '/getCity.php?searchTerm='+searchTerm, { method: 'get' });		

}

function showResult2(searchTerm) {
 	type = $RF('lawTypeId');
	$('livesearch2').show();
	if(type == 'Traffic') url = '../traffic-ticket-lawyers.ca';
	else if(type == 'Criminal') url = '../criminal-defence-lawyers.com/';
	else url = "../impaireddriving.ca";
	
	new Ajax.Updater('livesearch2', url+'/getCity.php?searchTerm='+searchTerm, { method: 'get' });		

}
function bookmark() {
	
	if (window.sidebar) { // firefox
		window.sidebar.addPanel(document.title, location.href,"");
	} 
	else if( document.all ) { //MSIE
		window.external.AddFavorite( location.href, document.title);
	} 
	else {
		alert("Sorry, your browser doesn't support this");
	}
}



