/* 
	@handles roll over stuff on home page petal 
	and resource page
*/

$(document).ready(initPetals).ready(hideBlanks);				

/*
need blanks if all 4 petals not filled else hover goes funny
*/
function hideBlanks(){
	$("a.petal:contains('blank')").remove();
}
			
function initPetals(){

   $('img[usemap]').maphilight();	
  
   wireUpPetal(1);   
   wireUpPetal(2); 
   wireUpPetal(3);
   wireUpPetal(4);

   //on resource page wires up small petal
   wireUpSmallPetal();
}

function wireUpPetal(petalID){
   var petalLink = "#petal_" + petalID + "_link";
   var petal = "#petal_" + petalID;
   $(petalLink).mouseover(function(){
	$(petal).triggerHandler('mouseover');	
   });

   $(petalLink).mouseout(function(){
	$(petal).triggerHandler('mouseout');	
   });
	
}

function wireUpSmallPetal(){
	var i=1;
	$('.petal').each(function(index){
		if(this.id.indexOf("small")!=-1){
			var petal ="#petal_" + i + "_petal-small";
			var petalLink = ".petal"
			$(this).mouseover(function(){
				
				$(petal).triggerHandler('mouseover');	
   			});

  			$(this).mouseout(function(){
				$(petal).triggerHandler('mouseout');	
   			});
			i++;
		}
	});
}
