/* mapcuk 2010 */

/* Common part */

// alias to jQuery library, function noConflict release control of the $ variable 
var $ = jQuery.noConflict();

$(function() {
    path = window.location.pathname;
    $('.menu a[href=' + path + ']').parent().addClass('active');
})


$(function(){
    //console.log('hello')
    $('#hometown-window-close, #hometown-window ul li a').click(function(){
        $('#hometown-window').hide();
        /*
        cityName = $(this).text()
        citySlug = $(this).attr('alt')
        $('#city-change').text(cityName)
        $('.tab2 a').attr('href','/timetable/'+citySlug+'/')
        $('.tab3 a').attr('href','/afisha/'+citySlug+'/')
        $('.tab5 a').attr('href','/contacts/'+citySlug+'/')
        */
    })
    $('#city-change').click(function(){
        $('#hometown-window').show();
    })

    path = window.location.pathname;
    $('#menu a[href=' + path + ']').parent().addClass('active');
})

function cityChange() {
    
}

function bindPostCommentHandler() {
    var commentForm=$('#comment_form form');  
    //$('#comment_form form input.submit-preview').remove();
    commentForm.find('input:visible, textarea').focusin(function () {
        $(this).val('').unbind('focusin')
    })

    commentForm.submit(function() {
        $.ajax({  
            type: "POST",  
            data: commentForm.serialize(),  
            //url: "{% comment_form_target %}",
            url: commentForm[0].action,  
            cache: false,  
            dataType: "html",  
            success: function(html, textStatus) {  
                commentForm.replaceWith(html);  
                bindPostCommentHandler();  
                //window.location.reload();
            },  
            error: function (XMLHttpRequest, textStatus, errorThrown) {  
                commentForm.replaceWith('Your comment was unable to be posted at this time.  We apologise for the inconvenience.');  
            }  
        });  
        return false;  
    });  
}


