YAHOO.util.Event.onDOMReady(setContactimations);



function toggleHeight(e, obj){

	if(YAHOO.util.Dom.hasClass(this.parentNode, 'closed') == true){
		obj.open_anim.animate();
		YAHOO.util.Dom.replaceClass(this.parentNode, 'closed', 'open');
	}
	else if(YAHOO.util.Dom.hasClass(this.parentNode, 'open') == true){
		obj.close_anim.animate();
		YAHOO.util.Dom.replaceClass(this.parentNode, 'open', 'closed');
	}
}



function setContactimations(){
	//the items with class name "contact_location" are the elements that will animate open and closed
	var contact_locations = YAHOO.util.Dom.getElementsByClassName('contact_location', 'div');
	

	
		for(var i = 0; i< contact_locations.length ; i++){
				
			var open_attr = {
					height: {to: contact_locations[i].offsetHeight}
			};
			var closed_attr = {
					height: {to: 18}
			};
			
			var object = {
					open_anim: new YAHOO.util.Anim(contact_locations[i], open_attr, 0.5, YAHOO.util.Easing.easeOut),
					close_anim: new YAHOO.util.Anim(contact_locations[i], closed_attr, 0.5, YAHOO.util.Easing.easeOut)
			};
			//this is a little workaround for how FF and IE handle the DOM children
			//but I'm not entirely sure why I'm passing in the child node in the first place
			//since the function being called uses the parent node.
			if(contact_locations[i].childNodes[0].nodeType == 1){
				var node = contact_locations[i].childNodes[0];
			}
			else{
				var node = contact_locations[i].childNodes[1];
			}
			
			YAHOO.util.Event.on(node, 'click', toggleHeight, object );
			YAHOO.util.Dom.setStyle(contact_locations[i], 'height', '18px');
			
			if(YAHOO.util.Dom.hasClass(contact_locations[i], 'open') == true){
				object.open_anim.animate();
			}
			
		}
		return;
	
}




