﻿jQuery.fn.toggleByClass = function(options, callback) {
        // Defaults
        if (!options) var options = {};
        return this.each(function() {
            var $$this = $(this);
            var switchText = $$this.attr('rel');
            //hide items
            if($$this.hasClass('prev')){
		        $$this.prev().toggle();
		    }
		    if($$this.hasClass('next')){
		        $$this.next().toggle();
		    }
            
			$(this).click(function(e){
			    if($$this.hasClass('prev')){
			        $$this.prev().toggle();
			    }
			    if($$this.hasClass('next')){
			        $$this.next().toggle();
			    }
			    //swap the text value
			    var tmp = $$this.find('.caption').text();
			    $$this.find('.caption').text(switchText)
			    switchText = tmp;
			}).show();
		});
    };
function setEqualHeight(items)
 {
     var highest = 0;
     items.each(
     function(){
        current = $(this).height();
        if(current > highest){
            highest  = current;
        }
     });
     items.height(highest);
 };
function InitGoogleMaps(){
    if ( typeof InitGoogleMaps.mapsLoaded == 'undefined' ) {
        google.load("maps", "2.x");
        InitGoogleMaps.mapsLoaded = true;
        $(document).ready(function(){
            //geocoder = new GClientGeocoder();
            //set up map links
            $('a.googlemap').click(function(e){
                e.preventDefault();
                var $this = $(this);
                //console.log($this.attr("rel"));
                var map = $("<div class='map'></div>").insertAfter($this);
                try{
//                    map.googleMaps({
//                        //geocode:$this.attr("rel")
//                        latitude: 	37.4419,
//			            longitude: -122.1419
//                        ,scroll: false
//                        ,markers:{
//    	                    //geocode:$this.attr("rel")
//    	                    latitude: 	37.4419,
//			                longitude: -122.1419
//    	                    ,draggable:true
//    	                    ,icon: {
//            	                image: 'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png'
//                            }
//    	                }
//                    }); 
                    //map=null;
                    var addr = $this.attr("rel");
                    map.gMap(
                        { markers: 
                            [{address: addr, html: "_address"}]
                            ,address: addr
                            ,zoom: 15
                        });

                }
                catch(Error)
                {
                    //console.log(Error);
                }
                $this.hide();//hide the map link
            });
        });
    }
}

