// JavaScript Document
var numberOfStories = 16;
var storyId = 1 + Math.floor(Math.random() * (numberOfStories));

$(document).ready(function() {
/*	
	$.ajax({
		type: "GET",
		url: "stories.xml",
		dataType: "xml",
		success: function(xml) {
				$(xml).find('stories').each( 
					function(){
						var story = $(this).find('story#'+storyId).text();
						$('#success-quote').html(story);
					}
				);
			}
	});

	$('#success-image').css('background-image','url(images/success/success-image'+storyId+'.jpg)');
*/
	
// Prepare Press & Awards
//	hide the descriptions
	$('#press-box li p').each( function(n) {
		$(this).hide();		
	});
	
	$('#press-box a.title').click(function() { return false; });
/*
//	remove the click url from titles
	$('#press-box li a').each( function(n) {
		$(this).click( function(){ return false; });
	});
//	add the read more links in the description.	
	$('#press-box li').each( function () {	
		var url = $(this).find('a').attr('href');
		$(this).find('p:last').append(' <p><a href="'+ url +'" target="_blank">Read more</a>...</p>');
	});
*/
//	bind a listeners to the list items and make them open and close.	
	$('#press-box li.plus').bind('mouseup', function (event) {
		$(this).siblings().not('li.hidden').css('background-color','#bddeff').removeClass('minus').addClass('plus').find('p').slideUp();
		if ($(this).attr('class') == 'plus') {
			$(this).css('background-color','#fff').removeClass('plus').addClass('minus').find('p').slideDown();
		} else {
			$(this).css('background-color','#bddeff').removeClass('minus').addClass('plus').find('p').slideUp();
		}
	})
	
// Prepare Research & Best Practices
//	hide the descriptions
	$('#research-box li p').each( function(n) {
		$(this).hide();		
	});
	
	$('#research-box a.title').click(function() { return false; });
	
/*
//	remove the click url from titles
	$('#research-box li a').each( function(n) {
		$(this).click( function(){ return false; });
	});
//	add the read more links in the description.	
	$('#research-box li').each( function () {	
		var url = $(this).find('a').attr('href');
		$(this).find('p:last').append(' <p><a href="'+ url +'" target="_blank">Read more</a>...</p>');
	});
*/
//	bind a listeners to the list items and make them open and close.	
	$('#research-box li.plus').bind('mouseup', function (event) {
		$(this).siblings().not('li.hidden').css('background-color','#bddeff').removeClass('minus').addClass('plus').find('p').slideUp();
		if ($(this).attr('class') == 'plus') {
			$(this).css('background-color','#fff').removeClass('plus').addClass('minus').find('p').slideDown();
		} else {
			$(this).css('background-color','#bddeff').removeClass('minus').addClass('plus').find('p').slideUp();
		}
	})
	
// success stories link
	$('#read-more a').click( function(){
			window.open('success/success-stories.html', 'success-stories', 'toolbar=0,menubar=0,location=0,resizable=0,width=792,height=410');
			return false;
	});
	
	$("li#cnn-video a").click(function(){
		url = $(this).attr("href");
		open_window(url, 350, 280, 'ff_extlink');
		return false;
	});	
	
});
