var B ={};
Builder.dump(B);                               
var tracks_count = 0;
function $$$(){
	if (arguments.length > 1){
	 	for (var i = 0, elements = [], length = arguments.length; i < length; i++) elements.push($$(arguments[i]).first())
	    return elements
	}	
	if (Object.isString(arguments[0]))
		return $$(arguments[0]).first()	
}
function ie6_png_hack(rules){
	var img_node = $$(rules).first();   
	var img_src = img_node.src;
    img_node.src = "/images/blank.gif";
    img_node.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img_src + "')"
}

var make_nav_element = function(el){
 	el.observe('click', function(ev){
 		get_content(Event.element(ev).up('li').id)
 	})
	el.onclick = function(){return false;};
}
var get_content = function(page_id){ 
	new Ajax.Request('/websites/'+website_id+'/'+lang+'/'+page_id+'.html', {
		method: 'get',
		onComplete:function(transport){
		   load_content(transport)
		}
	});
}
var load_content = function(transport){ 
	$('wrap_in').update(transport.responseText)
}

$$('#navigation li').each(function(el){
	make_nav_element(el.down('a'));
})

if(Prototype.Browser.MobileSafari){ 
    $(document.body).style.fontSize="130%";
	$('player').remove();   
	//$(document.body).observe('mousewheel',function(ev){$('header').innerHTML = "ooo"})
}
                                                                                            
document.observe( 'dom:loaded', function() { 
                              
    $$('#share_options h3').each(function(el){
    	el.observe('click',function(ev){
			$$('#share_options .opt').each(function(el){
				if(el.visible()){ new Effect.Fade(el, {duration:2, from:1.0, to:0.0});}	
			});
			if(el.next().visible()){
				new Effect.Fade(el.next(), {duration:2, from:1.0, to:0.0});
			}else{
				new Effect.Appear(el.next(), {duration:2, from:0.0, to:1.0});
		    }
		});
		new Effect.Fade(el.next(), {duration:2, from:1.0, to:0.0});
		el.style.cursor = 'pointer';                
	});
	get_content($$$('#navigation li').id);
	
});
$$("input.perma_link").first().value = "http://cercledepaix.ca"
getElement = function(el) {
  	var element
if(el.target){
	if(el.target.tagName == "A") {
		element = el.target.href
	}else{
		element = el.target.up('a').href
	}
}else if(el.srcElement){
	element = el.srcElement.href
}
return element;
}
lBox.prototype.load_current_window_content = function(){
	if ( !this.is_handling_request ) {
		this.is_handling_request = true;
		var elementHref = getElement(this.current_window);
		if(elementHref.match(/\.jpg$/)){
			this.loading_show();
			this.show_images((this.current_window.target.tagName == "IMG") ? this.current_window.target.up('a') :this.current_window.target);
		}else if(elementHref.match(/scribd\.com/)){
			this.is_handling_request = false;
			var item = elementHref.replace(/http:\/\/www.scribd\.com\/full\//,"").split(/\?access_key\=/)
			$( LBOX_WINDOW_CONTENT_ID ).update().insert(B.DIV({"id":"scribd_container"}))
			var scribd_doc = scribd.Document.getDoc(item[0], item[1]);      
			scribd_doc.addParam("height", 480);
			scribd_doc.addParam("width", 720); 
			scribd_doc.write("scribd_container");
			this.parse_document_fragment( $( LBOX_WINDOW_CONTENT_ID ) );
			this.appear();
		}else{
			var content_request = new Ajax.Request(elementHref, { 
				method:'get',
				onCreate: this.loading_show(),
				onComplete: this.on_request_completed.bindAsEventListener(this) 
			});
		}
	}
}
mpl_autostart = false
document.observe("dom:loaded",function(){
	$$('#navigation a').first().addClassName("active")
	$("mpl_play_button").observe("click",function(){
		if($("mpl_play_button").hasClassName("user_paused")){
			$("mpl_play_button").removeClassName("user_paused")
		}else if(playerStatus != 2){
			$("mpl_play_button").addClassName("user_paused")
		}
	})
	$$('#navigation a').each(function(el){
		el.observe("click",function(ev){
			var e = Event.element(ev)
			$$('#navigation a.active').first().removeClassName("active")
			e.addClassName("active")
			if (e == $$('#navigation a').first()){
				if (playerStatus === 2 ) {
						$('mpl').sendEvent('playpause');                                   
					}
			}else if (!$("mpl_play_button").hasClassName("user_paused")) {
				if (playerStatus != 2) {
						$('mpl').sendEvent('playpause');                                   
				}
			}
			
		})
		el.onclick = function(){return false}
	})
})

lBox.prototype.show_images = function(el){
	var gallery_data = [];
	if(el.href){
		gallery_data.push(el.href);
	}
	this.render_galery(gallery_data);
	this.is_handling_request = false;
} 
lBox.prototype.render_galery = function(data){
	var lBox_title = this.current_window.target.innerHTML;
	var content = [];
	data.each(function(src){
		content.push( B.IMG({"src":src,"alt":""}) );
	});
	
	$( LBOX_WINDOW_CONTENT_ID ).update().insert(B.DIV({"id":"Bgallery_container"}, content ));
	this.parse_document_fragment( $( LBOX_WINDOW_CONTENT_ID ) );
	this.appear();
}