/**
 *	-tab-size = 3;	-enc = utf-8
 *	
 *	js/cosmetics.js
 *	-----------------------------------------------------------------------------
 *	This file is part of the www.archivesdelacritiquedart.org's design.
 *	Last Modif.: 2007-09
 *	-----------------------------------------------------------------------------
 *	(c) Copyright 2007 Fabrice Luraine / sofa-design.net.
 *	All Rights Reserved.
 *	-----------------------------------------------------------------------------  
 */

//	DomLoaded
//	--
//	© copyright 2005, Dean Edwards / Rob Cherny
//	http://www.cherny.com/webdev/27/domloaded-updated-again
//
//	use: DomLoaded.load(func) to add a function to run when dom is loaded
//


var DomLoaded =
{
	onload: [],
	loaded: function()
	{
		if (arguments.callee.done) return;
		arguments.callee.done = true;
		for (i = 0;i < DomLoaded.onload.length;i++) DomLoaded.onload[i]();
	},
	load: function(fireThis)
	{
		this.onload.push(fireThis);
		if (document.addEventListener) 
			document.addEventListener("DOMContentLoaded", DomLoaded.loaded, null);
		if (/KHTML|WebKit/i.test(navigator.userAgent))
		{ 
			var _timer = setInterval(function()
			{
				if (/loaded|complete/.test(document.readyState))
				{
					clearInterval(_timer);
					delete _timer;
					DomLoaded.loaded();
				}
			}, 10);
		}
		/*@cc_on @*/
		/*@if (@_win32)
		var proto = "src='javascript:void(0)'";
		if (location.protocol == "https:") proto = "src=//0";
		document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
		    if (this.readyState == "complete") {
		        DomLoaded.loaded();
		    }
		};
		/*@end @*/
	   window.onload = DomLoaded.loaded;
	}
};


// 
// Popups
// 
function _popUp(strURL,strWidth,strHeight, newwin,newwinname)
{
	var strOptions="resizable,scrollbars,height="+strHeight+",width="+strWidth;
 	if(!newwin.closed && newwin.location){newwin.location.href=strURL;}else{newwin=window.open(strURL,newwinname,strOptions);if(!newwin.opener)newwin.opener=self;}
	if(window.focus)newwin.focus();return false;
}
var pop='';
function popUp(strURL,strWidth,strHeight)
{
	_popUp(strURL,strWidth,strHeight,pop,'pop');
	return false;
}

//
// Open external and class 'popup' links in a new window
//
function changeExtLinks()
{
	var as,i,islink;
	as=document.getElementsByTagName('a');
	for(i=0;i<as.length;i++){
		islink=as[i].href;
		if(as[i].className == "popup")
		{
			as[i].onclick = function(){return popUp(this.href,420,460);};
			as[i].onkeypress = as[i].onclick;
		}
		else if(islink.indexOf(window.location.hostname)==-1 &&
		   islink.indexOf("javascript:")==-1 && 
		   islink.indexOf("mailto:")==-1)
		{
			as[i].title += ' ('+islink+')';
			as[i].onclick = function(){
									window.open(this.href,'newwin','');
									return false;
								 };
			as[i].onkeypress = as[i].onclick;
		}
	}
}

//
// execute changeExtLinks when DOM is ready
//
DomLoaded.load(changeExtLinks);




