jQuery.noConflict();

var Page = {
	init : function() {
		Page.enableDroppers();
		Page.enableExpanders();
		Page.enableNavbar();
	},
	enableDroppers : function() {
		jQuery('img.dropper').each(function() {
			this.dropitem = jQuery('#'+jQuery(this).attr('rel'))[0];
/*			this.imagebar = jQuery('.imagebar',this.dropitem)[0];
			this.link = jQuery(jQuery('a',this.dropitem)[0]).attr('href');
			var dropper = this;
			if (dropper.imagebar) {
				dropper.imagebar.build = function() {
					jQuery.getJSON(dropper.link+'/imagebar',{"json":true},function(data) {
						jQuery.each(data.images,function(i,item) {
							console.debug(item);
							jQuery(dropper.imagebar).append(
								'<img width="'+item.width+'" height="'+item.height+'" src="'+item.src+'" alt="'+item.title+'" title="'+item.title+'">'
							);
						});
						dropper.imagebar.built = true;
					});

				}
			}*/
			this.drop = function() {
/*				if (this.imagebar) {
					if (!this.imagebar.built) {
						this.imagebar.build();
					}
				}*/
				this.src = "static/images/ui/arrow_down.png";
				this.dropitem.className = 'dropped';
			}
			this.unDrop = function() {
				this.src = "static/images/ui/arrow_right.png";
				this.dropitem.className = 'dropitem';
			}
			jQuery(this).bind('click',function() {
				switch (this.dropitem.className) {
					case 'dropitem':
					this.drop();
					break;
					
					default:
					this.unDrop();
					break;
				}
			});
		});
	},
	enableExpanders : function() {
		if (jQuery('#expander')) {
			var expander = jQuery('#expander');

			expander.bind('click',function() {
				if (!this.getAttribute('exp')) {
					jQuery('img.dropper').each(function() {
						this.drop();
					});
					jQuery('#expimage')[0].src = 'static/images/ui/arrow_down_white.png';
					this.setAttribute('exp','y');
				}
				else {
					jQuery('img.dropper').each(function() {
						this.unDrop();
					});
					jQuery('#expimage')[0].src = 'static/images/ui/arrow_right_white.png';
					this.removeAttribute('exp');
				}
			});
		}
	},
	enableNavbar : function() {
		jQuery('#navimages/a/img').hover(
		function() {
			this.oldSrc = this.src;
			this.src = 'static/images/ui/'+this.id+'_over.png';
		},
		function() {
			this.src = this.oldSrc;//'static/images/ui/'+this.id+'.png';
		});
	}
}


jQuery(document).ready(function() {
	Page.init();
});