/**
 * Ouvre une popup centrée dans l'écran
 *
 * @param string theURL, string winName, string width, string height, string features
 * @return
 */
function center_popup(theURL,winName,width,height,features) { 
//js-02/04/2001
var w = screen.width;
var h = screen.height;


	if(window.screen){
		ratio_x=(width/w)*100;
		ratio_y=(height/width)*100;
		win_x=(screen.width*ratio_x)/100;
		win_y=(win_x*ratio_y)/100;
		x=(screen.width-win_x)/2;
		y=(screen.height-win_y)/2;
	}else{
		x=0;
		y=0;
		win_x=w;
		win_y=y;
	}
	winfeatures=("top="+y+",left="+x+",width="+win_x+",height="+win_y+","+features);
	window.open(theURL,winName,winfeatures);
}

function popimage ( url ) { center_popup ( url, 'Image', 660, 500, 'scrollbars=0, status=0, resizable=0, location=0, menubar=0, toolbar=0' ) ; }
function popcalendar ( url ) { center_popup ( url, 'Image', 300, 280, 'scrollbars=0, status=0, resizable=0, location=0, menubar=0, toolbar=0' ) ; }

/**
 * Ouvre les liens qui ont un rel="external" dans une nouvelle fenêtre
 * (conforme XHTML 1.0 Strict  W3C)
 *
 * @param
 * @return
 */
function externalLinks()
	{ 
	if(!document.getElementsByTagName)
		return;
	
	var anchors = document.getElementsByTagName("a");
	
	for(var i=0; i< anchors.length; i++)
		{
		var anchor = anchors[i];
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
		}
	}
window.onload = externalLinks;

/**
 * Slide & go
 *
 * @param
 * @return
 */
var top_space = -192;
var i=0;

function slidengo_move(layer)
	{
	top_space = (top_space + 4);
	document.getElementById(layer).style.top = top_space +"px";
	
	slidengo_time(layer);
	}
	
function slidengo_time(layer)
	{
	i++;
	if(i<48)
		{
		setTimeout("slidengo_move(\""+ layer +"\")", 1);
		}
	}
function slidengo(layer)
	{
	slidengo_move(layer);
	}

/**
 * Ouvre une popup en plein écran
 *
 * @param string theUrl,  string winName
 * @return
 */
function fullpopup ( theURL, winName )
	{
	var w = screen.width ;
	var h = screen.height ;
	
	window.open( theURL, winName, 'width=' + w + ', height=' + h + ', top=0, left=0, scrollbars=0, status=0, resizable=0, location=0, menubar=0, toolbar=0, fullscreen=1' ) ;
	}

/**
 * Efface le texte par défaut des champs newsletter
 *
 * @param
 * @return
 */
function inputFocus(field)
{
	if ( document.getElementById(field).value == 'Votre email ici' )
		document.getElementById(field).value = '' ;
}
function inputBlur(field)
{
	if ( document.getElementById(field).value == '' )
		document.getElementById(field).value = 'Votre email ici' ;
}

/**
 * Envoi d'email en dissimulant l'adresse aux robots
 *
 * @param string nameEmail
 * @return
 */
function email ( nameEmail )
{
	window.location.href =  'mailto:' + nameEmail + '@' + 'masdugrandbosc' + '.com' ;
}

/**
 * Affiche ou masque un calque
 * ATTENTION: Spécial édition pour modifier le CSS "display" plutot que "visibility"
 *
 *
 */
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_showHideLayers()
	{ //v.6
	var i, p, v, obj, args = MM_showHideLayers.arguments ;
	for ( i=0; i < ( args.length-2 ); i+=3 )
		if ( ( obj = MM_findObj ( args[i] ) ) !=null )
		{
			v = args[i+2] ;
			if ( obj.style )
			{
				obj = obj.style;
				v = ( v == 'show' ) ? 'block' : ( v == 'hide' ) ? 'none' : v ;
			}
			obj.display=v ;
		}
	}
