$(document).ready(function() { 
    
    $("img[alt='loading...']").attr("src","/images/ajax-loader.gif");
    
    var activeLink = $("h3.entry-title").text(); 
    $("#sidebar_content a.second_main:contains('"+activeLink+"')").addClass("second_main_active");
    $("#sidebar_content li li:contains('"+activeLink+"') a").addClass("sidebar_active");        

    
    $("ul#secondary_nav li:contains('Secured.aspx')").hide();

    
    $("#footer ul.main_nav li:first").css("border","none");
    
    $("h3.entry-title").sifr({color:'#1a1974',path: '/files/',font: 'Caecilia_Heavy'});
   
    $("#home_clientlogos").innerfade({speed: 1000, timeout: 5000, type: 'sequence'});
    $("#power_of_e_book").innerfade({speed: 1000, timeout: 5000, type: 'sequence'});
  
    var firstImage = $("#gallery li a:eq(0)").attr("href");
    
    $("#gallery").jcarousel({
        scroll: 5
    });
    
    $("div#gallery_image").append('<img class="gallery_image" src="'+firstImage+'" />');
    
    $("a[@rel=gallery]").click(function(){
        var fullImage = $(this).attr("href");
        $("div#gallery_image img").attr("src",fullImage);
        return false;
    });
    
    $('a.media').media();

    $('div.location a').addClass('global_link');
    
    $("#contact_submit input").attr("type","image");
    $("#contact_submit input").attr("src","/images/btn_submit.gif");
    
    var listedPromos = eval($(".mem_list_column li").size() + $(".portfolio_featured_promos").size());
    
    $.getJSON("/cgi-bin/rest.pl/promo_count",
        function(data){
           var count = data.promo_count;
           if (!isNaN(count)) {
               $("span.count").append("Our Portfolio contains "+ listedPromos+" of "+count+" live promotions being managed by ePrize.");
           }
        }
    );
    

    $("div.learn_more_positions_link").append("<span class=\'global_link\'>Learn More & Apply</span>");
    $("div.posting_learn_more").hide();
    $("div.learn_more_positions_link").click(function() {
           $(this).hide();
           $(this).next(".posting_learn_more").show();
    });
    
    $("span.hide_link").click(function() {
           var linkContainer = $(this).parent();
           var learnMoreContainer = $(linkContainer).parent();
           $(learnMoreContainer).hide();
           $(learnMoreContainer).prev("div.learn_more_positions_link").show();
    });
    
    $(".form_header").click(function(){
        $(this).next("form").slideToggle();
    });
    
    if ($('fieldset:contains("Required")')) {
            $('fieldset:contains("Required")').parent('form').css('display','block');
        }
        
    $('#contact-us form').removeClass('zemContactForm');
    $('#contact-us form').addClass('contact');

});

function onABCommComplete() {
	var textArea = document.getElementById("recipient_list");
	document.getElementById("candyHearts").updateList(textArea.value);
	textArea.value = "";
}

function checkPlaxo(){
	//alert("I am in focus");	
	//document.write("hello");
	var textArea = document.getElementById("recipient_list");
	if(!Plaxo.abl.abWin || Plaxo.abl.abWin.closed)
	{
		document.onfocus = null;
		
		document.getElementById("candyHearts").reactivate();
	}
}

function openPlaxo(str){
	var textArea = document.getElementById("recipient_list");
	textArea.value = str;

	showPlaxoABChooser('recipient_list','/plaxo_widget.php');
	//document.onfocus = checkPlaxo;
	//Plaxo.abl.abWin.onunload =alert("this is a test");
	//alert("unload func successful!");
}

function closePlaxo(){
	if(Plaxo.abl)
		Plaxo.abl.abWin.close();
}

