$(function(){
	$(".pulldown_set").each(function(){
		var photoGalleryModule = new PulldownModule(this)
	})
})

var PulldownModule = function(){
	this._container = null;
	this.initialize.apply(this, arguments);
}

var currentOpenPulldownModule;

PulldownModule.prototype = {
	initialize: function(container) {
		this._container = container;
		this.is_open = false;
		this.init();
    },
	init: function() {
		this.close();
		var ref = this;
		$(".pulldown_parent a",$(this._container)).click(function(){
			if(this.is_open){
				ref.close();
			}else{
				ref.open();
			}
		});
	},
	close: function() {
		var ref = this;
		$(".pulldown_child li",$(this._container)).each(function(){
			$(this).css({
				display:"none"
			});
			$(".pulldown_parent a",$(ref._container)).removeClass("rollover")
		});
		this.is_open = false;
    },
	open: function() {
		var ref = this;
		$(".pulldown_child li",$(this._container)).each(function(){
			$(this).css({
				display:"block"
			});
			$(".pulldown_parent a",$(ref._container)).addClass("rollover")
		});
		this.is_open = true;
		if(currentOpenPulldownModule){ currentOpenPulldownModule.close(); }
		currentOpenPulldownModule = this;
	}
};
