function loadGoogleMap(zoom, pt_long, pt_lat, element_id) {
    if (GBrowserIsCompatible()) {
        var map1 = new GMap2(document.getElementById(element_id));
        map1.addControl(new GLargeMapControl3D());
        
        var latlng = new GLatLng(pt_lat, pt_long);
        map1.setCenter(new GLatLng(pt_lat, pt_long), zoom);
        
        map1.addOverlay(new GMarker(latlng));
    }
}

function showGoogleMap(linkEl, zoom, pt_long, pt_lat, element_id) {
    if($(linkEl).html() == "Show map") {
        $("#google_map_contact_" + element_id).show();
        
        if($("#google_map_static_contact_" + element_id).length > 0) {
            loadGoogleMap(zoom, pt_long, pt_lat, "google_map_contact_" + element_id);
        }
       
        $(linkEl).fadeOut("fast", function() {
            el = $(this);
            el.html("Hide map");
            el.removeClass("show_map");
            el.addClass("hide_map");
            el.fadeIn("fast");        
        });
     } else {
        $("#google_map_contact_" + element_id).hide();
        
        $(linkEl).fadeOut("fast", function() {
            el = $(this);
            
            el.html("Show map");
            el.removeClass("hide_map");
            el.addClass("show_map");
            el.fadeIn("fast");        
        });
    }
    
    return false;
}

function ewShowOurPeopleText(textid) {
    $("#our_people_text_" + textid).show();
    $("#our_people_sl_" + textid).show();
    $("#our_people_rm_" + textid).hide();
    
    return false;
}

function ewHideOurPeopleText(textid) {
    $("#our_people_text_" + textid).hide();
    $("#our_people_sl_" + textid).hide();
    $("#our_people_rm_" + textid).show();

    return false;
}

function stopPropagation(item) {
    $(item).click(function(event){ event.stopPropagation() });
 }


$(document).ready(function() {
    $("#slider_wrapper").css("overflow-x","hidden");
    
    if($("#slider_wrapper").length > 0) {
        $("#slider_wrapper").easySlider({
            auto: true,
            controlsFade: true
        });
    }
        
});


function openAllWineries(countries)
{
    var openAllHandler = $("a#show-me-all-wineries");
       
    if (openAllHandler.html() == "Show me all the Wineries") {
		openAllHandler.html("Close all the Wineries");
    } else {
	    openAllHandler.html("Show me all the Wineries");
	}

    for (i in countries) {
	    openWineries(countries[i]);
	}
	return false;
}


function openWineries(country) {
    var linkHandler = $("a#link-open-" + country);
       
    if(linkHandler.hasClass("open_winery")) {
       linkHandler.removeClass("open_winery");
       linkHandler.addClass("close_winery"); 
       linkHandler.html("Close");
       linkHandler.parents("li")
           .addClass("reveal")
           .addClass("clearfix");
       
       linkHandler.parents("li").prev("li").addClass('prev');
       
    } else {
        
        linkHandler.removeClass("close_winery");        
        linkHandler.addClass("open_winery");        
        linkHandler.html("Open");        
        linkHandler.parents("li")
            .removeClass("reveal")
            .removeClass("clearfix");        
        
        linkHandler.parents("li").prev("li").removeClass('prev');        
    }
    
    $("ul#list-" + country).toggle();    
    
    return false;
}