// JavaScript Document for Blank Template
// Created: CCA, 16th March 2009

$(document).ready(function(){
						   
	//AJAX SETUP
	$.ajaxSetup({
  		dataType: "html",
		type: "GET",
		timeout: 60000,
		error: function() { console.log("Error loading document"); }
	});

	//COMPANY LIST
	nextclass = "";
	firstnum = "";	
	
	
	//add edit favourites buttons
	$("a.editfavourites").click(function() { editFavourites(this); $("a.editfavourites.togglebal").toggle(); });
	
	//first letter for companylist
	$("table#companylist tbody tr").each(function() {
						var firstclass = $(this).attr("rel");
						
						if (isNaN(firstclass)) {
							if(firstclass != nextclass) {
									nextclass = firstclass;
									$(this).attr("id",firstclass);
									$("td:first",this).html(firstclass)
									$("td:last",this).append("<a href='#' class='tothetop'>&uarr; Top</a>");
									$("div#alphalist").find("a[title="+firstclass+"]").addClass("active").attr("href","#"+firstclass);								
								}
						} else {
							
							if (firstnum != 1) {
									$(this).attr("id","num");
									$("div#alphalist").find("a[title=num]").addClass("active").attr("href","#num");
									firstnum = 1;		
							}
						}
											  }); 

	//Alert for log in @ event
	$("a.eventsignin").click(function() {
		
			var dr = $("div#loginalert").css("right");
		
			$("#username-field").focus();
		
			$("div#loginalert").fadeIn(400).animate({right:"310px"}, 200, function() {
						$(this).animate({right:"300px"}, 200, function() {
								$(this).animate({right:"310px"}, 200, function() {
									$(this).animate({right:"300px"}, 200, function() {
										$(this).animate({right:"310px"}, 200, function() {
												$(this).animate({right:"300px"}, 200, function() {}).fadeOut(400);
											});
										
										});
									
									});
							
							});
				});
		
		});
		
	

});
