
//= require "menu"
//= require "onglets"
//= require "blocks"
//= require "forms"
//= require "tooltip"

function init() {
	
	// Forms
	$$('.autocomplete').each(function (field, index) {var myCompleter = new autoCompleter(field);}.bind(this));
	$$('input[type=text]').each(function (field, index) {var myField = new Field(field);}.bind(this));
	$$('input[type=password]').each(function (field, index) {var myField = new Field(field);}.bind(this));
	$$('.select').each(function (field, index) {var mySelectBox = new SelectBox(field);}.bind(this));
	$$('.vote').each(function (field, index) {var myField = new voteBoxes(field);}.bind(this));
	$$('.manageable').each(function (field, index) {var myManager = new listManager(field);}.bind(this));
	$$('.orderable').each(function (field, index) {var myOrder = new listOrder(field);}.bind(this));
	$$('input[type=submit]').each(function (field, index) {var myField = new Button(field);}.bind(this));

	// share
	if($('shareTip')) $('shareTip').hide();
	
	// widgets
	$$('.widgets').each(function (el, index) {var myWidgets = new Widgets(el);}.bind(this));
	
	//blocks
	$$('.block').each(function (el, index) {var myBloc = new Block(el);}.bind(this));
	
	// menu
	new menu($('navigation').down('ul'));
	
	// onglets
	$$('ul.onglets').each(function (field, index) {var myOnglets = new Onglets(field);}.bind(this));
	
	//patchwork
	new Equalizer('.patchwork li').equalize('height');
	
}

function start() {

	// Bookmarks
	$$('div.bookmarkImage').each(function(element, index) {myBookmark = new Bookmark(element);});
	$$('div.bookmarkImage a').each(function(anchor) {
		anchor.writeAttribute('alt',anchor.readAttribute('href'));
		anchor.setAttribute('href','#');
		Event.observe(anchor,'dblclick', function(ev) {
			document.location.href = Event.element(ev).parentNode.readAttribute('alt');
		});
	});

	// overlay
	Popup.load();
	
	// rollovers
	$$('.rollover').each(function (el, index) {var myRollover = new Rollover(el);}.bind(this));
	
	// tooltips
	$$('.tooltip').each(function (el, index) {var myToolTip = new toolTip(el);}.bind(this));
	$$(".tip").each(function(node) {
		new Tooltip(node, node.title);
		node.removeAttribute("title");
	});
	
	// share
	$$('a.share').each(function (el, index) {var myShareLink = new shareLink(el);}.bind(this));
	
	//tabs
	$$('.tabs').each(function(el, index) {var myTabs = new tabsList(el);}.bind(this));
	
}

Event.observe(document, 'dom:loaded', init, false);
Event.observe(window, 'load', start, false);


