jQuery(document).ready(function(){

	//Get a random child from the Hero Images DIV
	selectedChild = randomChild(jQuery('#hero-images'));
	
	//Get the location and text	
	var heroLocation = selectedChild.children(".location").html();
	var heroText = selectedChild.children("p").html();
	
	//Split image location string to get image information
	// <image name>_<logo to use>_<top position>_<left position>
	var heroName = heroLocation.split(".")
	var matches = heroName[0].split("_");
	var logoType = matches[1]; var posTop = matches[2]; var posLeft = matches[3];
	
	jQuery("#hero-text").css("top",posTop + "%");
	jQuery("#hero-text").css("left",posLeft + "%");
	
	if(logoType == 'dark'){
		jQuery(".logo").css("background-image","url('templates/ed_home/images/logo_white.png')");
	}
	
	jQuery.backstretch(heroLocation,{speed: "slow"});
	
	if(heroText != ''){
		jQuery('#hero-text').html(heroText);
	}
	jQuery('#hero-text').delay(600).fadeIn("slow");
}); 

function randomChild(parent){
	var c = jQuery(parent).children().length;
	var r = Math.ceil(Math.random() * c);
	
	return parent.children(':nth-child(' + r + ')');
}


