/*if(navigator.appName =="Microsoft Internet Explorer") {
	if(navigator.userAgent.indexOf("Mac") == -1 && navigator.appVersion.indexOf("MSIE 5.0")<0) window.onresize = function(){window.document.location.reload();}
	else if(navigator.appVersion.indexOf("MSIE 5.0")>0) window.onresize = preload;
}

function preload() {
	window.document.location.reload();
}

if ((navigator.appName=="Netscape")) reloadPage(true);
function reloadPage(init) {
  if (init==true) {
    pageW=innerWidth;
	pageH=innerHeight;
	onresize=reloadPage;
	}
  else if (innerWidth!=pageW || innerHeight!=pageH) location.reload();
}*/
function getCookie(name){
	var ToExec = new RegExp(name + "=([^;]+)");
	var valeur = ToExec.exec(document.cookie);
	return (valeur != null) ? unescape(valeur[1]) : null;
}
function setCookie(name, value) {
	document.cookie=  name + "=" + escape(value) + "; path=/";
}


function getObj(name){
  if (document.getElementById){
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all){
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
}
function getTop(objectId){
	var x = (new getObj(objectId)).obj;
	xTop = x.offsetTop;
	while(x.offsetParent!=null) {
		xParent = x.offsetParent;
		xTop += xParent.offsetTop;
		x = xParent;
	}
	return xTop;
}
function getAbsoluteTop(objectId){
	var x = objectId;
	xTop = x.offsetTop;
	while(x.offsetParent!=null) {
		xParent = x.offsetParent;
		xTop += xParent.offsetTop;
		x = xParent;
	}
	return xTop;
}
function getAbsoluteLeft(objectId){
	var x = objectId;
	xLeft = x.offsetLeft;
	while(x.offsetParent!=null){
		xParent = x.offsetParent;
		xLeft += xParent.offsetLeft;
		x = xParent;
	}
	return xLeft;
}
function getWidth(objectId){
	var x = (new getObj(objectId)).obj;
	return x.offsetWidth;
}

function getHeight(objectId){
	var x = (new getObj(objectId)).obj;
	return x.offsetHeight;
}
function openPop(f,l,h,op)
{
	longueur=l;
	hauteur=h;
	haut = screen.height/2 - hauteur/2;
	dim = screen.width/2 - longueur/2;
	window.open(f,'','width='+longueur+',height='+hauteur+',left='+dim+',top='+haut+',resizable=no,'+op+'');
}
function openPopEcard(){
	openPop("/ecards/default.asp",400,400,"scrollbars=no");
}
function openEnvoiAmi(fromId,ficheId){
	openPop("/ecards/default.asp?fromId="+fromId+"&ficheId="+ficheId,400,400,"scrollbars=no");
}
function lanceCgv(){
	openPop("/boutique/cgv.asp",400,400,"scrollbars=yes");
}
function openEcardNoel(){
	openPop("/ecards_noel/default.asp",400,400,"scrollbars=no");
}
var speed = 2;
var HVisible= 558;

function scrollV(sens,targe){
	ts = new getObj(targe).obj;
	HDiv = ts.offsetWidth;
	if ( parseInt(ts.style.left) > (HVisible-HDiv) && (sens == -1) ||  parseInt(ts.style.left) < 0 && (sens ==1)){
		ts.style.left=parseInt(ts.style.left)+ sens*4+"px";
	}
}
function placeScroll(id){
	
	x = new getObj("p"+id);
	y = new getObj("fixe");
	z =  new getObj("contenu");
	
	initx = getAbsoluteLeft(x.obj) - getAbsoluteLeft(y.obj);
	
	if(initx>540){
		z.style.posLeft = -initx+(initx-540)+270;
	}
	if(-z.style.posLeft>getWidth("contenu")){
		z.style.posLeft = 540-getWidth("contenu");
	}

}
function swapImgin(obj){
	obj = obj.getElementsByTagName('img')[0];
	var ch = obj.src;
	var finfin=ch.substring(ch.length-3,ch.length);
	var fin=ch.substring(ch.length-5,ch.length-4);
	ch=ch.substring(0,ch.length-5);
	
	if(fin == "0")
	   obj.src=ch+"1."+finfin;
	else
	   obj.src=ch+"0."+finfin;
}

function validerEmail(mail) {
  if(mail == null) return null;
  if(mail.match(/^.+@.+\..+$/)) return mail;
  else return null;
}

function is_all_num(chaine) {
	for(var i=0;i<chaine.length;i++) if(isNaN(parseInt(chaine.substring(i,i+1)))) return false;
	return true;
}

function loadAlert()
{
	alert("Réservé aux membres, veuillez vous inscrire");
}

function jeuAmsterdam(){
	window.open('/jeu/inventeur/index.asp','Jeu','width=651,height=577,scrollbars=no');
}
function resultatAmsterdam(){
	window.open('/jeu/inventeur/resultats.htm','Resultats','width=643,height=617,scrollbars=no');
}


/* E-COUPON */

var checksum = 0;
function couponValide () {
	sendData("Demande coupon","/boutique/ecoupon.asp","POST","");
}

/***** Write Flash *****/
function writeFlash(url,id,w,h,o){
	document.write('\n<object id="'+id+'" type="application/x-shockwave-flash" data="'+url+'" width="'+w+'" height="'+h+'">\n');
	document.write('\t<param name="movie" value="'+url+'" />\n');
	if(o != ''){
		var flashOptionsTab = new Array();
		flashOptionsTab = o.split('|');
		for(i=0; i<flashOptionsTab.length; i++){
			var tempParam = flashOptionsTab[i].split('#')[0];
			var tempValue = flashOptionsTab[i].split('#')[1];
			document.write('\t<param name="'+tempParam+'" value="'+tempValue+'" />\n');
		}
	}
	document.write('</object>\n');
}
