/*
*	$Id: __global.js,v 1.1 2007/04/11 04:07:17 paladin Exp $
*	cpaulus@marquepage.net @ Sun Nov  6 19:33:05 CET 2005
*	(c) Copyright MarquePage.Net - http://www.marquepage.net
*/

	/* MM part */
	
function MM_preloadImages() { //v3.0
  var d=document; 
	if(d.images) { 
		if(!d.MM_p) d.MM_p=new Array();
		var i, j=d.MM_p.length, a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++) {
			if (a[i].indexOf("#")!=0) { 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

	/* MPN part */
	
function MPN_addPageFavorit () {
	if (document.all) { 
		window.external.AddFavorite(location.href, document.title); 
	} else { 
		alert('Vous pouvez faire CTRL + D pour ajouter cette page dans vos signets ou favoris.') 
	} 
}

function MPN_sendUrl () { 
	$url = window.location;
	titre = document.title;
	sujet = "Un site interessant";
	window.location = "mailto:?subject=" + sujet + "&body=\r\r\rCecite: \r " + $url;
} 

function MPN_sendUrl2c () { 
	$url = window.location;
	titre = document.title;
	window.location = "mailto:propolien@cecite.org?subject=Proposition%20de%20lien&body=\r\r\rProposition:\r";
} 

function MPN_cssIdExist ($css, $id) {
	return (
			$css.getAttribute("rel").indexOf("style") != -1 
		&&	$css.getAttribute("id") 
		&&	$css.getAttribute("id").toUpperCase() == $id.toUpperCase()
	);
}

function MPN_cookieCreate ($name, $value, $days) {
	if ($days) {
		var $date = new Date();
		$date.setTime($date.getTime() + ($days*24*60*60*1000));
		var $expires = "; expires=" + $date.toGMTString();
	} else {
		$expires = "";
	}
	document.cookie = $name + "=" + $value + $expires + "; path=/";
	return (true);
}

function MPN_cssDisplaySwitch ($ss, $to) {
	if (!$ss.disabled) {	// IE need that
		$ss.disabled = true;
	}
	if ($ss.disabled != $to) {
		$ss.disabled = $to;
	}
	return (true);
}

function MPN_enableCss ($id) {
	var $ii, $css;
	for ($ii = 0; ($css = document.getElementsByTagName("link")[$ii]); $ii++) {
		if (MPN_cssIdExist ($css, $id)) {
			if (MPN_cssDisplaySwitch ($css, false)) {	// active css
				MPN_cookieCreate ($id, true, 365);
			}
		}
	}
}

function MPN_disableCss () {
	var $ii, $css;
	var $args=MPN_disableCss.arguments;
	for($style=0; $style<$args.length; $style++) {
		for ($ii = 0; ($css = document.getElementsByTagName("link")[$ii]); $ii++) {
			if (MPN_cssIdExist ($css, $args[$style])) {
				if (MPN_cssDisplaySwitch ($css, true)) {	// d�sactive css
					MPN_cookieCreate ($args[$style], false, 365);
				}
			}
		}
	}
}

function MPN_cookieGet ($name) {
	var $cookies = document.cookie.split('; ');
	for (var $ii=0; $ii < $cookies.length; $ii++) {
		var $cc = $cookies[$ii];
		var $pos = $cc.indexOf('=');
		var $nn = $cc.substring(0, $pos);
		if ($nn == $name) {
			return ($cc.substring($pos+1));
		}
	}
	return (null);
}

var $css = [
	  "co.css-screen_bnw"
	, "co.css-screen_big"
	, "co.css-screen_huge"
	, "co.css-screen_galley"
];

window.onload = function () {
}

jQuery().ready(function(){
	
	var $co_visual_effect = false;
	
	jQuery.extend({
        ajouterOmbre: function(){
			$(".shadowme").addClass('doshadow');
			$(".doshadow").dropShadow();
			$(window).resize(function(){
				$(".doshadow").redrawShadow();
			});
			return(true);
        },
		supprimerOmbre: function(){
			$(".doshadow").removeShadow();
			$(".shadowme").removeClass('doshadow');
            $(window).resize(function(){
			});
			return(true);
        }
	});
				
	
	// restart if framed
	if (top != self) top.location = self.location;
	// get current css configuration
	for (var $ii = 0; $ii < $css.length; $ii++) {
		if (MPN_cookieGet($css[$ii]) == 'true') {
			$co_visual_effect = true;
			MPN_enableCss($css[$ii]);
			if($css[$ii] == "co.css-screen_bnw") {
				MM_swapImage('bg-image','','img/co-access-sq-bvw.jpg',1);
			}
		}
	}
	// si pas d'effet choisi, placer l'ombre
	if(!$co_visual_effect) {
		jQuery.ajouterOmbre();
	}
	
	MM_preloadImages(
			'img/co-access-sq-bvw.jpg'
		, 'img/co.corner-black.gif'
	);
	return (document.MM_returnValue = true);


});

