// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function remove_fields(link) {
  $(link).prev("input[type=hidden]").val("1");
  $(link).closest(".fields").hide();
}

function add_fields(link, association, content) {
  var new_id = new Date().getTime();
  var regexp = new RegExp("new_" + association, "g");
  $(link).parent().before(content.replace(regexp, new_id));
}

function show_flash_messages(message) {
    $(message).animate({opacity: 1.0, hight: 'toggle'}, 5000, function () {
        $(message).fadeOut('slow');
    })
}

$(document).ready(function() {
    $("img.show_overlay").mouseover(function() {
        $(this).css('cursor', 'pointer');
    })
    
    $("img[rel]").overlay();
    
    $(".search_text").click(function() {
        var search_value = $(this).val();
        
        if (search_value == 'Search...')
            $(this).val('');
    });
    
    $(".search_text").blur(function() {
        var search_value = $(this).val();
    
        if (search_value == '')
            $(this).val('Search...');
    });
    
    $("a.ext_link").click(function() {
        window.open(this.href);
        return false;
    });
    
    $("a.followus").click(function() {
        window.open(this.href);
        return false;
    });
    
    $("a.facebook").click(function() {
        window.open(this.href);
        return false;
    });
    
    $("#comment_name").click(function() {
        var comment_name = $(this).val();
      
        if (comment_name == 'Your name (required)')
            $(this).val('');
    });
    
    $("#comment_name").blur(function() {
        var comment_name = $(this).val();
      
        if (comment_name == '')
            $(this).val('Your name (required)');
    });
    
    $("#comment_email").click(function() {
        var comment_email = $(this).val();
      
        if (comment_email == 'Your email address (required)')
            $(this).val('');
    });
    
    $("#comment_email").blur(function() {
        var comment_email = $(this).val();
      
        if (comment_email == '')
            $(this).val('Your email address (required)');
    });
    
    $("#comment_website").click(function() {
        var comment_website = $(this).val();
      
        if (comment_website == 'Your web site')
            $(this).val('');
    });
    
    $("#comment_website").blur(function() {
        var comment_website = $(this).val();
      
        if (comment_website == '')
            $(this).val('Your web site');
    });
    
    $(".posts_body a").click(function() {
        window.open(this.href);
        return false;
    });

})
