// JavaScript Document

function strReplace( text, stringToFind, stringRemplacement)
{
	var text = text.toString() ;
	var maReg = new RegExp( stringToFind, "gi") ;
	var resultat = text.replace( maReg, stringRemplacement ) ; 
	return  resultat ;
}

function popup(theURL,winName,features) { //v2.0
  var popUp=window.open(theURL,winName,features);
  popUp.focus();  
}

function coche(radioId,celluleId){
	var max=3;
	if(document.getElementById(radioId).checked){
		if(document.getElementById('selection').value<max){			
			document.getElementById('selection').value++;
			document.getElementById(celluleId).style.background='url(img/sous_menu_07_tel.gif)';
		} else {
			document.getElementById(radioId).checked=false;
			alert("Vous ne pouvez comparer que "+max+" téléphones en même temps.");			
		}
	}else{
		document.getElementById('selection').value--;
		document.getElementById(celluleId).style.background='url(img/sous_menu_08_tel.gif)';
	}
}

//ouvrir comparateur
function comparer(){
	var param="";
	var table=0;
	for(var i=1;i<=document.getElementById('nb').value;i++){		
		if(document.getElementById('radio'+i).checked==true){
			table++;
			param=param+"tel"+table+"="+document.getElementById('radio'+i).value+"&";
			document.getElementById('selection').value--;
		}		
		document.getElementById('radio'+i).checked=false;
		//document.getElementById('td'+i).style.background='url(img/sous_menu_08_tel.gif)';
	}
	//popup('mobiles/comparateur.php?'+param,'comparateur','scrollbars=yes,resizable=no,width=748,height=400');
	show_comparateur('mobiles/comparateur.php?'+param)
}
//show comparateur
function get_left(size) {
	var x=0;
	var ecran=screen.width;
	return Math.round((ecran/2)-(size/2));	
}

function get_top(size) {
	var y=0;
	var ecran=screen.height;
	return Math.round((ecran/2)-(size/2));	
}
function show_comparateur(adresse){
	if(document.getElementById('Layer1').style.visibility=='hidden'){	
		document.comparateur.location.href=adresse; 
		document.getElementById('Layer1').style.left=get_left(748)-25;
		document.getElementById('Layer1').style.top=290;
		document.getElementById('Layer1').style.visibility='visible';
		document.frames
	} else {
		document.getElementById('Layer1').style.visibility='hidden';
	}
}



//photo zoom
function popup_zoom(img_zoom_src){		
	var img_zoom = new Image();
	img_zoom.src=img_zoom_src;	
	titre="ZOOM"; 
	w=open("",'image','left=200,top=200,width=10,height=10,toolbar=no,scrollbars=no,resizable=no,status=no'); 
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>"); 
	w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+100,document.images[0].height+100); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>"); 
	w.document.write("<BODY onload='checksize()'  leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
	w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><TR>");
	w.document.write("<TD valign='middle' align='center'><IMG src='"+img_zoom_src+"' border=0 alt='Zoom' title='Zoom'>"); 
	w.document.write("</TD></TR></TABLE>");
	w.document.write("</BODY></HTML>"); 
	w.focus();
	w.document.close(); 
}

//fonctions dreamweaver
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];}
}