/**
 * @author efimochkin
 */
function openHash(){
    if(window.location.hash){$(window.location.hash.toString() + "-card a.local").trigger("click")};
}
$(function(){
    $(".maps img")
        .each(function(){this.src = this.src.replace("small", "blur");})
        .bind("mouseover", 
            function(){
                $(this)
                    .attr("src", $(this).attr("src").replace("blur", "small"))
                    .css("cursor","pointer");
            })
        .bind("mouseout", 
            function(){
                $(this)
                    .attr("src", $(this).attr("src").replace("small", "blur"))
                    .css("cursor","pointer");
            });
            
    $(".collapsible").hide();
    
    $(".xoxo.contacts").addClass("enabled");
    
    $(".vcard")
        .each(
            function(){
                $(this)
                    .find("h2")
                        .wrapInner("<a class='local' href='#"+(cityname = this.id.replace("-card",""))+"'></a>")
                    .end(); 
                this.id += "-card";
            });
            
                
    $(".vcard h2 a.local")
        .bind("click",
            function(){
                $(this)
                    .parents("li.vcard")
                        .toggleClass("expanded")
                        .find(".collapsible")
                            .slideToggle(250,
                                function(){
                                    if(this.style.display != "none") 
                                        {
                                            $.scrollTo($(this).parents("li.vcard"),400);
                                        }
                                });
                
            });            
            
    $(".area a")
        .bind("click", 
            function(){
                window.location.assign($(this).attr("href"));
                openHash();
                return false;
                });
            
    openHash();
});