// JavaScript Document

$(document).ready(function(){
   
    $(".category-ad-templates").each(function() {
        $.height = $(this).parent().css('height');
        $.height = parseInt($.height);
        $.height = $.height - 42;
        $.height = $.height + "px";
        $(this).find('div').css('height',$.height);
    });
    
    $(".category-coops").each(function() {
        if ($(this).parent().attr('id') == 'sidebar_coops' || $(this).parent().attr('id') == 'coopDetails')
            return;
        
        //$.height = $(this).parent().css('height');
        //$.height = parseInt($.height);
        $.height = $(this).parent().height();
        $.height = $.height - 42;
        $.height = $.height + "px";
        $(this).find('div').css('height',$.height);
    });
    
    $("#startcoop").submit(function() {
        if ($("#startcoop_name").val() != '' && $("#startcoop_email").val() != '' && $("#startcoop_phone").val() != '')
            return true;
        else
            alert("Please enter a valid name, email, and phone number.");
        
        return false;
    });
    
    $("#joincoop").submit(function() {
        if ($("#joincoop_name").val() != '' && $("#joincoop_name").val() != 'FIRST &amp; LAST NAME' && 
            $("#joincoop_email").val() != '' && $("#joincoop_email").val() != 'EMAIL' && 
            $("#joincoop_phone").val() != '' && $("#joincoop_phone").val() != 'PHONE' &&
			$("#joincoop_bizname").val() != '' && $("#joincoop_bizname").val() != 'BUSINESS NAME' &&
			$("#joincoop_website").val() != '' && $("#joincoop_website").val() != 'WEBSITE')
            return true;
        else
            alert("Please enter a valid name, email, phone number, business name, and website.");
        
        return false;
    });
    
    $('a[rel=external]').attr('target','_blank');
     
});

