// centered pop up window
function centeredPopUpWindow(mypage, myname, w, h, scroll){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// get position of child node
function getPosition(main,spec) {
	var items = main.getElementsByTagName(spec.tagName);
	var found = 0;
	for (p = 0; p < items.length; p++) {
		if (items[p] == spec) {
			found = 1;
			break;
		}
	}
	if (found) {
		return p;
	}
	else {
		return -1;
	}
}

// set date elements
var yy = new Date().getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
var dd = new Date().getDate();
var mm = new Array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");
var monthNumber = new Date().getMonth();
var monthLabel = mm[monthNumber];

// check dimensions of browser window
windowWidth = $(window).width();
windowHeight = $(window).height();
halfWindowWidth = windowWidth / 2;
halfWindowHeight = windowHeight / 2;

// get class name of element
$.fn.getClassNames = function(){
	if (name = this.attr("className")) {
		return name.split(" ");
	}
	else {
		return [];
	}
};
// get name of element
$.fn.getElementNames = function(){
	if (elementName = this.attr("name")) {
		return elementName.split(" ");
	}
	else {
		return [];
	}
};

$(document).ready(function(){
	
	// home page speakers navigation
	$("ul#speakersNav li:last").css({border: "none"});
	$("ul#speakersList li div.speakers:last-child").css({border: "none"});
	
	$("ul#speakersNav li.speakerNumbers").click(function(){
		
		var groupPosition = getPosition(this.parentNode,this);
		if ( $(this).hasClass("activeGroup") )
		{
			return false;
		}
		else
		{
			$("ul#speakersNav li").removeClass("activeGroup");
			$(this).addClass("activeGroup");
			$("ul#speakersList li").hide();
			$("ul#speakersList li:eq(" + groupPosition + ")").fadeIn(500);
			return false;
		}
	});
	
	// program table
	$("table#programTable tr td:nth-child(1)").css({
		width: "145px",
		fontWeight: "bold",
		borderRight: "1px solid #e9e8e8"
	});
	$("table#programTable tr td:nth-child(2)").css({paddingLeft: "15px"});
	$("table#programTable tr:last td").css({borderBottom: "none"});
	
	
	// links with rel="external" will open in a new window
	$("a[rel=external]").click(function(){
		 window.open(this.href);
		 return false;
	});
	
	// display year in footer
	$("span.currentYear").text(year);
	
	// translate pngs for ie 6
	// $(document).pngFix();
	
}); // << $(document).ready
