var font_rules = {
	'body' : function(e) {
		try {
			Typekit.load();
		} catch(e) {}
	}
};
Event.addBehavior(font_rules);

var hyperlink_rules = {
    'a.external:click' : function(e) {
        if (!e.ctrlKey && !e.altKey && !e.shiftKey) {
          window.open(this.href);
          return false;
        }
    }
};
Event.addBehavior(hyperlink_rules);

var carousel_rules = {
	'.carousel': function(event){
		var carousel = new mashedCarousel.topCarousel(this);
	}
}
Event.addBehavior(carousel_rules);

var accordion_rules = {
	'.spotlight_detail' : function(event) {
		var accordion = new Accordion(this, {});
	}
}
Event.addBehavior(accordion_rules);

var form_rules = {
	'.field' : function(e) {
		var fieldLabel = this.up().previous('[for=' + this.id + ']');
		if (fieldLabel) {
			fieldLabel.hide();
			this.value = fieldLabel.innerHTML;
		}
	},
	'.field:focus' : function(e) {
		var fieldLabel = this.up().previous('[for=' + this.id + ']');
		if (this.value === fieldLabel.innerHTML) {
			this.value = '';
		}
		this.className = this.className.replace('-off','-on');
	},
	'.field:blur' : function(e) {
		var fieldLabel = this.up().previous('[for=' + this.id + ']');
		if(this.value === '') {
			this.value = fieldLabel.innerHTML;
		}
		this.className = this.className.replace('-on','-off');
	},
	'.field-small' : function(e) {
		var fieldLabel = this.up().previous('[for=' + this.id + ']');
		if (fieldLabel) {
			fieldLabel.hide();
			this.value = fieldLabel.innerHTML;
		}
	},
	'.field-small:focus' : function(e) {
		var fieldLabel = this.up().previous('[for=' + this.id + ']');
		if (this.value === fieldLabel.innerHTML) {
			this.value = '';
		}
		this.className = this.className.replace('-off','-on');
	},
	'.field-small:blur' : function(e) {
		var fieldLabel = this.up().previous('[for=' + this.id + ']');
		if(this.value === '') {
			this.value = fieldLabel.innerHTML;
		}
		this.className = this.className.replace('-on','-off');
	}
};
Event.addBehavior(form_rules);
