$(document).ready(function() 
{
  $("table tr:even").addClass("altRow");
  var homep = 2,first = 0,countLI = 0;
  function homephotos() {
		$('#photoWall').css('background-image','url(/p/TENA10/resources/mhome_photo'+homep+'.jpg)');
		$("#photoWall").animate({opacity: '+=0'}, 4000, function() { homep++; if(homep>4){homep=2;}homephotos(); });
		if (first == 0) { $(".pillars li").hide(); $(".pillars li:first-child").show(); first++; }
		else {
			total = $(".pillars li").size();
			$(".pillars li:nth-child("+countLI+")").hide();
			countLI++;
			if (countLI == total) { countLI = 0; }
			else { $(".pillars li:nth-child("+countLI+")").show(); }
		}
  }
  if (window.location.pathname == "/home_l" || window.location.pathname == "/home_l_2011") {
	homephotos();
	var newImg,tweet = 0,tweetpos = 0;
	$.ajax({         
		type: "GET", url: "/3p/tena10/jsonproxy.aspx?s=teched", dataType: "xml", 
		success: function(xml) 
		{ 
			$("#blogWidget").html("");
			$(xml).find("User").each(function() 
			{
			  if(tweet<5) {
				var userName = $(this).find('UserName').text();
				var profileImage = $(this).find('ProfileImage').text();
				var twitStatus = $(this).find('Status').text();
				var statusDate = $(this).find('StatusDate').text();
				newImg = $('<div title="'+userName+'" class="tooltip" id="tw'+tweet+'" name="tw'+tweet+'"><img width="40" height="40" src="'+profileImage+'" alt="'+twitStatus+'" /></div>');
				$("#blogWidget").append(newImg);
				tweet++;
			  }
			});
			tooltip();
		}
	});
  }
  if (window.location.pathname.toLowerCase() == "/preconferenceseminars_l") {
    $("#precons .topic .description").hide();
	$("#precons .category").each(function () {
	   if ($(this).find('span').html() == 'Session Type:') { $(this).hide(); }
	});
	$("#precons .title").click(function() {
		var index = $("#precons .title").index(this)+1;
		$("#precons .topic:nth-child("+index+") .description").slideToggle();
	});
  }
  var sponp = 1;
  function sponphotos() {
		$('#sponsorcycle').css('background-image','url(/p/TENA10/resources/mspon_right_'+sponp+'.jpg)');
		$("#sponsorcycle").animate({opacity: '+=0'}, 4000, function() { sponp++; if(sponp>3){sponp=1;}sponphotos(); });
  }
  if (window.location.pathname == "/becoming-a-sponsor_l") {
	sponphotos();
  }
  var netonp = 1;
  function netonphotos() {
		$('#imgslideNet').css('background-image','url(/p/TENA10/resources/monsite_'+netonp+'.jpg)');
		$("#imgslideNet").animate({opacity: '+=0'}, 4000, function() { netonp++; if(netonp>3){netonp=1;}netonphotos(); });
  }
  if (window.location.pathname == "/networkingonsite_l") {
	netonphotos();
  }
});

this.tooltip = function(){		
	xOffset = 40; yOffset = 15;				
	$("div.tooltip").hover(function(e){
		this.d = $(this).attr('id'); this.t = $(this).find('img').attr('alt'); this.u = $(this).attr('title'); this.p = $(this).position();
		$(this).find('img').attr('alt','');
		$(this).attr('title','');
		this.c = parseInt(this.d.substr(2,this.d.length));
			$("body").append("<p id='tooltip'><span>" + this.u + "</span>" + this.t + "</p>");
			$("#tooltip").css("top",(this.p.top - xOffset - $("#tooltip").height()) + "px").css("left","20px").fadeIn("fast");
    },
	function(){
		$(this).find('img').attr('alt',this.t);$(this).attr('title',this.u);$("#tooltip").remove();
    });			
};
