Element.implement({
	pos:function(rel,relp,e,ofx,ofy,p){
		this.position({relativeTo: $(rel),position:relp,edge:e,offset:{x:ofx,y:ofy}});
		this.setStyles({'margin':'0','padding':'0','position':p});
	}
});
/****/
Element.implement({
	alphaover:function(aup,ahover){
		this.set('opacity',aup).addEvents({
			'mouseenter':function(){this.setStyle('opacity',ahover);},
			'mouseleave':function(){this.setStyle('opacity',aup);	}		
		});
	}
});
/*****/
window.addEvent('domready', function() {
	var pos = { 
			'f':'fixed',
			'a':'absolute'
		};
	var fl = {
			'tr':'topRight',
			'tl':'topLeft',
			'br':'bottomRight',
			'bl':'bottomLeft',
			'lc':'leftCenter'
		};
	var id = {
			'tr_h':$('tree_header'),
			'me_h':$('me_header'),'me_c':$('me_content'),
			'oe_h':$('oeuvres_header'),'oe_c':$('oeuvres_content'),
			'cv_h':$('cv_header'),'cv_c':$('cv_content'),
			'co_h':$('contact_header'),'co_c':$('contact_content')
		};
	var obj = {
			'fo':$('form'),
			'logo':$('logo'),
			'twit':$('twit'),
			'linktwit':$('twitter'),
			'mails':$$('a.mail'),
			'aext':$$('a.ext')
		};
	var menu = {
			'me':$('col_menu_me'),
			'oeuvres':$('col_menu_oeuvres'),
			'cv':$('col_menu_cv'),
			'contact':$('col_menu_contact')
		};
	/**************************************************/
	id['tr_h'].setStyle('margin','0');
	id['tr_h'].setStyle('position',pos['f']);
	
	obj['fo'].alphaover(.25,.8);
	obj['logo'].pos(id['tr_h'],fl['tr'],fl['tr'],30,60,pos['f']);
	obj['twit'].pos(id['tr_h'],fl['br'],fl['br'],10,-20,pos['f']);
	
	if($chk(id['tr_h'])) id['me_h'].pos(id['tr_h'],fl['tr'],fl['tl'],0,0,pos['f']);
	/* **** */
	if($chk(id['me_c'])){
		id['me_c'].pos(id['me_h'],fl['tr'],fl['tl'],0,0,pos['a']);
		id['oe_h'].pos(id['me_c'],fl['tr'],fl['tl'],0,0,pos['f']);
	}else{
		id['oe_h'].pos(id['me_h'],fl['tr'],fl['tl'],0,0,pos['f']);
	}
	/* *** */
	if($chk(id['oe_c'])){
		id['oe_c'].pos(id['oe_h'],fl['tr'],fl['tl'],0,0,pos['a']);
		id['cv_h'].pos(id['oe_c'],fl['tr'],fl['tl'],0,0,pos['f']);
	}else{
		id['cv_h'].pos(id['oe_h'],fl['tr'],fl['tl'],0,0,pos['f']);
	}
	/******/
	if($chk(id['cv_c'])){
		id['cv_c'].pos(id['cv_h'],fl['tr'],fl['tl'],0,0,pos['a']);
		id['co_h'].pos(id['cv_c'],fl['tr'],fl['tl'],0,0,pos['f']);
	}else{
		id['co_h'].pos(id['cv_h'],fl['tr'],fl['tl'],0,0,pos['f']);
	}
	
	id['co_c'].pos(id['co_h'],fl['tr'],fl['tl'],0,0,pos['f']);
	
	menu['me'].pos(id['me_h'],fl['lc'],fl['lc'],7,0,pos['f']);
	menu['cv'].pos(id['cv_h'],fl['lc'],fl['lc'],7,0,pos['f']);
	menu['oeuvres'].pos(id['oe_h'],fl['lc'],fl['lc'],7,0,pos['f']);
	menu['contact'].pos(id['co_h'],fl['lc'],fl['lc'],7,0,pos['f']);
	
	obj['fo'].pos(id['co_c'],fl['bl'],fl['bl'],0,0,pos['f']);
	obj['aext'].each(function(link){link.target="_blank";});
	
	obj['fo'].addEvents({
		'mouseover':function(){this.addClass('over');},
		'mouseleave':function(){this.removeClass('over');}
	});
	obj['linktwit'].addEvents({
		'click': function(){this.href = 'http://twitter.com/MindRising';},
		'mouseleave': function(){this.href = '#';}
	});
	obj['mails'].addEvents({
		'click': function(){this.href = 'mailto:jmeciar@gmail.com';},
		'mouseleave': function(){this.href = '#';}
	});
});
