$(document).ready(function() {
   /* $("#client-login a").click(function () {
      if ($("div#sign-in").is(":hidden")) $("div#sign-in").slideDown("slow");
      else $("div#sign-in").slideUp("slow");
    return false;
    });
    $("#press01 h3 a").click(function () {
      if ($("#press01 .preview").is(":hidden")) $("#press01 .preview").slideDown("slow");
      else $("#press01 .preview").slideUp("slow");
return false;
    });
    $("#press02 h3 a").click(function () {
      if ($("#press02 .preview").is(":hidden")) $("#press02 .preview").slideDown("slow");
      else $("#press02 .preview").slideUp("slow");
return false;
    });
    $("#press03 h3 a").click(function () {
      if ($("#press03 .preview").is(":hidden")) $("#press03 .preview").slideDown("slow");
      else $("#press03 .preview").slideUp("slow");
return false;
    });*/

    /*$("a#all-contacts-trigger").click(function () {
      if ($("#all-contacts").is(":hidden")) {
      	$("#all-contacts-trigger").html("Loading....");
      	//$("#all-contacts").load(templateUri+'/bios_ajax.php').slideDown("slow");
      	$("#all-contacts").load(templateUri+'/bios_ajax.php', function(){$(this).slideDown("slow") });
      	$("#all-contacts-trigger").html("Close contacts");
      }
      else{
      	$("#all-contacts-trigger").html("View all contacts");
      	$("#all-contacts").slideUp("slow");
      }
    return false;
    });*/
    
    $("a#all-contacts-trigger").click(allContacts);
    checkShowAllContacts();    
    
});

function allContacts(){		
	
	if ( $("#all-contacts").is(":hidden")) {
      	$("#all-contacts-trigger").html("Loading....");            	
      	//$("#all-contacts").load(templateUri+'/bios_ajax.php').slideDown("slow");
      	$("#all-contacts").load(templateUri+'/bios_ajax.php?page_id='+currentPageId, function(){$(this).slideDown("slow") });
      	$("#all-contacts-trigger").html("Close contacts");      
      }
      else{
      	$("#all-contacts-trigger").html("View all contacts");
      	 $("#all-contacts").slideUp("slow");
      }
      
	return false;
}

function checkShowAllContacts(){
	
	//if an employee from other contacts has been selected keep the other contacts open
	if (keepAllContactsOpen ) {
		$("#all-contacts").slideDown("slow");
		$("#all-contacts-trigger").html("Close contacts");
		keepAllContactsOpen = false; //reset this var so that the other contacts listing can be closed
		return false;
	}

}