var $ = jQuery;
var justlaw = {};
// Load up the javascript for the page
justlaw.load = function(options){
	// This is the main baner rotator
	if( options.images ){
		$('.images').cycle({
			fx: options.images.animation,
			timeout: options.images.time,
			speed: 1000,
			random: 1
		});
	// if
	}
	// Remove the home text
	$('#logo_href').fadeTo(0,0);
	// This is for form submission
	$('form.wpcf7-form').submit(
		function(){
			//alert( options.goals[0] );
			_gaq.push(['_trackPageview', options.goals[0]]);
		// function
		}
	// submit
	);
	// This is the map
	justlaw.gmap( options.map, options.address );
	// This will clear the search bar
	$('input#s').click(
		function(){
			if( this.value == 'Search' ){
				this.value = '';
			}
		// function
		}
	// submit
	);
	
	// This is where we check to see what menus we want to display
	var copy = $('div.copy');
	var practice = $('div.practice');
	var links = $('div.links');
	var blog = $('div.blog');
	var actions = $('div.actions');
		
	/*
	// Show the links
	if( links && copy.outerHeight() > 200 ){*/
		links.css('display','block');
		
	// if
	/*}
	// Show the call to action
	if( blog && copy.outerHeight() > 400 ){*/
		blog.css('display','block');
	// if
	/*}
	// Show the call to action
	if( links && blog && actions && copy.outerHeight() > 800 ){
		// Set the style of the call to action menu
		actions.css({
					'display':'block',
					'min-height':(copy.outerHeight()-practice.outerHeight()-links.outerHeight()-blog.outerHeight())
					});
		// This is the call to actions rotator
		$('.actions').cycle({
			fx: options.actions.animation,
			timeout: options.images.time,
			speed: 1000,
			random: 1
		});
		
	// if
	}
	*/
// function
};
// This will make the map
justlaw.gmap = function( vmap, address ){
    var myOptions = {
      zoom: vmap.zoom,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
	  navigationControl: true,
	  mapTypeControl: false,
	  scaleControl: true
    }
	var gmap = new google.maps.Map(document.getElementById( vmap.element ), myOptions);	
    var geocoder = new google.maps.Geocoder();
	geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        gmap.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: gmap, 
            position: results[0].geometry.location
        });
      } else {
        //alert("Geocode was not successful for the following reason: " + status);
      }
    });
// function
}
