// JavaScript Document
// jQuery
// all the jQuery code goes into document.ready()!!!!!!!!!!!!!!!!!!!!!!!!
$(document).ready(function(){
	//superfish menu always here!
	$('.nav').superfish();
	// for tabs - galleries/index.php
	$('#tabSetGalleries').tabs();
	// what prettyPrint() does?
	prettyPrint();
	//tablesorter
	// add class .sortable so it won't sort all the tables!!!
	var sortableTable = $('table.sortable');
	sortableTable.tablesorter();
	var tableOddColor = $('table tbody tr:odd');
	tableOddColor.addClass('even');
	var tableHoverRowColor = $('table tbody tr');
	tableHoverRowColor.hover(
			function(){
				$(this).addClass('hover');
			},
			function(){
				$(this).removeClass('hover');
			}
		);
	//greybox
	 var gbOptions = {
		gbWidth: 1000,
		gbHeight: 700
  		};
	$('table.sortable a').greybox(gbOptions);
	// jmap
	//javascript:void(prompt('',gApplication.getMap().getCenter())); code for finding map center
	$('#map').jmap('init', {
			//mapCenter:[30.168, -85.685678], - Panama City, FL
			mapCenter:[29.494977, -98.571473],
			mapZoom:15,
			mapShowjMapIcon: false,
			mapControlSize: 'large',
			mapEnableScaleControl: true,
			mapEnableSmoothZoom: true,
			mapEnableOverview: true,
			mapType: 'map'
			});
		$('#map').jmap('addMarker', {
			pointLatLng:[29.494977, -98.571473],
			pointHTML: '<h3><span class="red">edyta jordan</span><br>1819 Babcock Rd., Apt. 507, San Antonio, TX 78229</h3>'
			});
	//function for buttons on click
	function myMap(mapType){
		var mapType;
		$('#map').jmap('init', {
			mapCenter:[29.494977, -98.571473],
			mapZoom:15,
			mapShowjMapIcon: false,
			mapControlSize: 'large',
			mapEnableScaleControl: true,
			mapEnableSmoothZoom: true,
			mapEnableOverview: true,
			mapType: mapType
			});
		$('#map').jmap('addMarker', {
			pointLatLng:[29.494977, -98.571473],
			pointHTML: '<h3><span class="red">edyta jordan</span><br>1819 Babcock Rd., Apt. 507, San Antonio, TX 78229</h3>'
			});
		$('a.selectedView').remove();
		var mapSelectedView = '<li><a href""  class="selectedView">selected view: ' +mapType+ '</a></li>';
		$('#mapTabs').append(mapSelectedView);
	}; //end of myMap()
	// jmap directions
	$('#getDirections').submit(function(){
		$('#directions2').empty();
		$('#directions2').append('<p id="closeDir">close [X]</p>');
		$('#map').jmap('searchDirections', 
		{
			toAddress: '1819 Babcock Rd., Apt. 507, San Antonio, TX 78229',
			fromAddress: $('#from').val(),
			directionsPanel: 'directions2'
		});
		var fromAddressValue = $('#from').val();
		if (fromAddressValue==''){
			$('#directions2').empty();
		};
		$('#closeDir').click(function(){
			$('#directions2').empty();
		});
		return false;
	});
	//
	$('#satelite').click(function(){
		myMap('sat');
	});
	$('#hybrid').click(function(){
		myMap('hybrid');
		$('#map').jmap('addMarker', {
			pointLatLng:[29.494977, -98.571473],
			pointHTML: '<h3><span class="red">edyta jordan</span><br>1819 Babcock Rd., Apt. 507, San Antonio, TX 78229</h3>'
			});
	});
	$('#myMap').click(function(){
		myMap('map');
	});
	$('#streetView').click(function(){
		$('a.selectedView').remove();
		$('#mapTabs').append('<li><a href""  class="selectedView">selected view: street view</a></li>');
	});
	//	
	$('#image').rotate(-25);
}); // end of document.ready - jQuery

// ----------------------------------------------------------------------------------------------------------
// other script for google map - street view
	// code thanks to: http://geochalkboard.wordpress.com/2008/04/06/google-maps-api-adds-street-view-classes/
	var myStreetView;
    function initialize() {
    	//(30.168931214711208, -85.68597793579102)
		//(30.169190930825646, -85.68591356277466)
		//(30.169636, -85.685678)
		var myStreet = new GLatLng(29.494977, -98.571473);
		panoramaOptions = { latlng:myStreet };
      	myStreetView = new GStreetviewPanorama(document.getElementById("map"), panoramaOptions);
      	GEvent.addListener(myStreetView, "error", handleNoFlash);
    }
    function handleNoFlash(errorCode) {
    	if (errorCode == FLASH_UNAVAILABLE) {
        alert("Error: Flash doesn't appear to be supported by your browser");
        return;
      	}
    }
