/**
* ITF javascript document
* @author	s.rossetti | http://www.contreforme.ch/
* @copy		2011 see @author
* @version	1
*/
function init(){
	$$('a').each(function(el,i){
		if(el.get('href') && el.get('href').test('http://')) el.set('target','_blank');
	});
	if($$('a.tip')){
		var tips = new Tips('.tipped',{text:''});
	}
	if($$('img.popup')){
		$$('img.popup').each(function(el,i){
			var src = el.src.replace('/mini_','/');
			var a = new Element('a',{'class':'milk', rel:'milkbox:pop',href:src}).inject(el,'before');
			a.grab(el);
		});
	}
	if($$('a.videobannerthumb')){
		$$('a.videobannerthumb').addEvent('click',function(ev){
			var ev = new Event(ev).preventDefault();
		//	SqueezeBox.open('http://player.vimeo.com/video/'+this.get('rel')+'?title=1&amp;byline=0&amp;portrait=0',{handler:'iframe',size:{x:650,y:366}});
			SqueezeBox.open('http://www.dailymotion.com/embed/video/'+this.get('rel')+'?foreground=%236B7CFF&highlight=%237BA8D5&background=%23000000',{handler:'iframe',size:{x:650,y:366}});
		});
	}
	if($('gmap')){
		loadGmap();
	}
}
function loadGmap(){
	if (GBrowserIsCompatible()) {
		var map = new GMap2($('gmap'),{mapTypes:[G_HYBRID_MAP,G_NORMAL_MAP]});
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		var point = new GLatLng(46.992684,6.932124);
		map.setCenter(point,15);
		map.addOverlay(createmarker(point));
		document.body.addEvent('unload',function(){
			GUnload();
		});
	}
}
function createmarker(point){
	var icon = new GIcon();
	icon.image = "__layout/itf_log_gmap.png";
	icon.iconSize = new GSize(26,26);
	icon.iconAnchor = new GPoint(13,26);
	var marker = new GMarker(point,icon);
	GEvent.addListener(marker, "click", function(){
		var win = window.open('http://maps.google.com/maps?f=q&source=s_q&hl=en&sll=46.992684,6.932124&sspn=0.001462,0.001886&ie=UTF8&z=16','_blank');
	});
	return marker;
}

window.addEvent('domready',init);
