$().ready( function() {

	$.ajax({
		type:			"GET",
		url:			"files/slides_2011.xml",
		dataType:	"xml", 
		success:	function(xml) {
			$('slide',xml).each(function(i){
				$('<div />').attr({
					'id': 'mainslide' + i,
					'class': 'slideDiv',
					'external': $(this).find('external').text(),
					'href': $(this).find('link').text()
				}).css({
					'background-image': 'url(files/' + $(this).find('image').text() + ')'
				})
				.appendTo($('#slideshow'));
			});
			$('#slideshow').cycle({
				fx: 		'fade',
				pause:		1,
				speed:		1000,
				timeout:	5000,
				pager:  	'#numbers',
				pagerAnchorBuilder: function(i,el) {
					// custom pager anchor builder to center control div
					var obj = $('#controls');
					jQuery("#slideWrapper").show();
					/*return '<a href="#" class="dot' + i + '">'+(i+1)+'</a>';*/
					return'';
				}
			})
		}
	})

	$('.slideDiv').live('click', function() {
		if($(this).attr('external') == 'no') {
			window.location = $(this).attr('href');		
		}
		else {
			window.open($(this).attr('href'));					
		}
	})

	$('#newsLink').click( function() {
		window.location = 'http://investors.vrtx.com/alerts.cfm';
	});
	
	$('#eventsLink').click( function() {
		window.location = 'http://investors.vrtx.com/events.cfm';
	});

	$('#searchString').focus( function() {
		$(this).css({'color':'black'}).val('');
	})

})
