$(document).ready(function() {
	//$(".infobox:contains('Locator')").hide();
	/* Check to see if the page is being viewed with css and prevent jquery from firing if not. */
    if($("#header h2").css("position") == "absolute"){	
			
		var $ss = $('#slideshow');         
		
		if(slideshowcount != 0){
			$ss.empty();
			for (var i = 0; i < slideshowcount; i++) 
			$ss.append('<a href="/gssiredbpics2/'+boardid+'/'+ (i+1) +'/'+picturesrcdir+'/'+picturesrc+'.jpg" alt="'+picturealt+'" onclick="return false;" style="cursor:default" rel="gallery"><img src="/gssiredbpics2/'+boardid+'/'+ (i+1) +'/'+picturesrcdir+'/'+picturesrc+'.jpg" alt="'+picturealt+'" /></a>'); 
		}

		/* Slideshow Init */
		slideshowcount = $('#slideshow img').length;
		$('#slideshownav span').html('(1 / '+slideshowcount+')');
		
		if(slideshowcount > 1){
			$('#slideshownav').prepend('<a href="#" class="icon first" title="Go to the First Image">First</a> <a href="#" class="icon previous" title="Go to the Previous Image">Previous</a> <a href="#" class="icon pause" title="Pause the Slideshow">Pause</a> <a href="#" class="icon next" title="Go to the Next Image">Next</a> <a href="#" class="icon last" title="Go to the Last Image">Last</a>');
		}
		
		/* start the slideshow */
		$ss.cycle({ 
			prev:   '.icon.previous', 
			next:   '.icon.next',
			timeout: 8000,
			after:  slideshowOnAfter
		});

		/* Slideshow actions */
		$('#slideshownav .icon.first').click(function() { 
			$('#slideshow').cycle(0); 
			return false; 
		});	
		$('#slideshownav .icon.last').click(function() { 
			$('#slideshow').cycle(slideshowcount-1); 
			return false; 
		}); 
		$('#slideshownav .icon.pause').toggle(
		  function () {
			$('#slideshow').cycle('pause');
			$(this).removeClass('pause').addClass('play');
			$(this).attr('title', 'Resume the Slideshow');
		  },
		  function () {
			$('#slideshow').cycle('resume', true);
			$(this).removeClass('play').addClass('pause');
			$(this).attr('title', 'Pause the Slideshow');
		  }
		);
		

	
           
	}
	/* END IF CSS */
});
function initMap(){

		/* IF we have an address, set up the map */
		if($('#propertymap').length && propertylat != '' && propertylng != ''){
			
			var latlng = new google.maps.LatLng(propertylat,propertylng);
				var myOptions = {
				zoom: 14,      
				center: latlng,      
				mapTypeId: google.maps.MapTypeId.ROADMAP,
				streetViewControl: true 
			};    
			var gmap = new google.maps.Map(document.getElementById("propertymap"), myOptions);
			var name ='<img src="/gssiredbpics2/'+boardid+'/1/'+picturesrcdir+'/'+picturesrc+'.jpg" alt="'+picturealt+'" style="width:215px; margin:0 auto" />';
			var marker = new google.maps.Marker({position: latlng, map: gmap});
    		google.maps.event.addListener(marker, "click", function() {
      			if (infowindow) infowindow.close();
      			infowindow = new google.maps.InfoWindow({content: name});
      			infowindow.open(gmap, marker);
    		});
		}
           

}
function slideshowOnAfter(curr, next, opts) {
	var index = $(this).parent().children().index(this);
	$('#slideshownav span').html('('+(index+1)+' / '+slideshowcount+')');
}

function getQuery(s) {
  var query = {};

  s.replace(/\b([^&=]*)=([^&=]*)\b/g, function (m, a, d) {
    if (typeof query[a] != 'undefined') {
      query[a] += ',' + d;
    } else {
      query[a] = d;
    }
  });

  return query;
}


var themeindex=new Array();
themeindex[0]="default";
themeindex[1]="maxwell";
themeindex[2]="homelife";
themeindex[3]="royallepage";
themeindex[4]="c21";
