// JavaScript Document


$(document).ready(function() {

	$('.serviceDropdown li a').click(function(){
		$("#locationFormField").attr("value", $(this).attr('data-url'));
		$(".selectedService").html($(this).html());
		$('.serviceDropdown').css('visibility', 'hidden');
		return false;
	});

	$('.serviceSelector').click(function(){
		$("#serviceFormField").attr("value", $(this).attr('id'));
	});

	$("#accordion").accordion({
		collapsible: true,
		clearStyle: true,
		active: false//$('#serviceFormField').attr('value')
	});

	var tempServiceArray =  new Array();
	tempServiceArray[3] = 0;
	tempServiceArray[2] = 1;
	tempServiceArray[4] = 2;
	tempServiceArray[5] = 3;
	tempServiceArray[1] = 4;

	$("#accordion_location").accordion({
		//active: tempServiceArray[$('#serviceFormField').attr('value')]
		collapsible: true,
		clearStyle: true,
		active: false//$('#serviceFormField').attr('value')
	});

	$('.green_button_large_b').click(function(){
		if($("#locationFormField").attr("value") != '' && $("#serviceFormField").attr("value") != ''){
			$('.locationServiceForm').submit();
		} else {
			alert('Please select a Location and Service to continue.');
		}
	});

	$('.selectedService').click(function(){
		$('.serviceDropdown').css('visibility', 'visible');
		return false;
	});

	$('.serviceDropdown').hover(
		function(){
			$('.serviceDropdown').css('visibility', 'visible');
		},
		function(){
			$('.serviceDropdown').css('visibility', 'hidden');
		}
	);

	$('.tooltip').qtip({
   		content: {
        	text: false // Use each elements title attribute
      	},
		position: {
	      my: 'bottom right',  // Position my top left...
	      at: 'top left', // at the bottom right of...
	   }
	});

});
