/*--------------------------------------------------------------------------------------------------------------*/
// SETUPS:
// ===============================

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 620;
defaultHeight = 620;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["ImageZoom"].width;');writeln('window.innerHeight=document.images["ImageZoom"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<a href="javascript:window.close();"><img name="ImageZoom" src='+imageURL+' style="display:block;" border="0"></a></body></html>');
close();		
}}

/*--------------------------------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------------------------------------*/

function _ppp_select(script_name, id_select){
	str = script_name + eval('document.getElementById("'+id_select+'").options[document.getElementById("'+id_select+'").selectedIndex].value');
	top.location.href=str;
}

function _submit(formId){
	eval('document.getElementById("'+formId+'").submit()');
}

function _search_select(script_name, id_select, var_name,cat_type){
	var value = eval('document.getElementById("'+id_select+'").options[document.getElementById("'+id_select+'").selectedIndex].value');
	if(value>0)
		str = script_name + '?' + var_name + '=' + value+'&cat_type='+cat_type;
	else{
		if(var_name=='sf_id')
			str=script_name+'?f_id='+document.getElementById("rechFamille").options[document.getElementById("rechFamille").selectedIndex].value+'&cat_type='+cat_type;
		else{
			if(var_name=='f_id')
				str=script_name+'?sg_id='+document.getElementById("rechSSGamme").options[document.getElementById("rechSSGamme").selectedIndex].value+'&cat_type='+cat_type;
			else
				str=script_name+'?g_id='+document.getElementById("rechGamme").options[document.getElementById("rechGamme").selectedIndex].value+'&cat_type='+cat_type;
		}
	}
	top.location.href=str;
}

function _ajouter_panier(id_product,id_cant){
	var cant;
	cant = eval('document.getElementById("'+id_cant+'").value');
	cant = parseInt(cant);
	if(isNaN(cant) || cant<1){
		alert('Veuillez saisir une quantité!');
		eval('document.getElementById("'+id_cant+'").value=""');
		eval('document.getElementById("'+id_cant+'").focus()');
		return;
	}
	str = 'ajouter-produit-panier.php?cip=' + id_product + '&qt=' + eval('document.getElementById("'+id_cant+'").value');
	top.location.href = str;
}
//permet d'ajouter un produit à une ordonnance
function _ajouter_ordonnance(id_product,id_cant){
	var cant;
	cant = eval('document.getElementById("'+id_cant+'").value');
	cant = parseInt(cant);
	if(isNaN(cant) || cant<1){
		alert('Veuillez saisir une quantité!');
		eval('document.getElementById("'+id_cant+'").value=""');
		eval('document.getElementById("'+id_cant+'").focus()');
		return;
	}
	str = 'ajouter-produit-ordonnance.php?cip=' + id_product + '&qt=' + eval('document.getElementById("'+id_cant+'").value');
	top.location.href = str;
}
//Permet d'ajouter un produit sur prescription à l'ordonnance
function _ajouter_ordonnance_prescription(id_product,id_cant){
	var cant;
	cant = eval('document.getElementById("'+id_cant+'").value');
	cant = parseInt(cant);
	if(isNaN(cant) || cant<1){
		alert('Veuillez saisir une quantité!');
		eval('document.getElementById("'+id_cant+'").value=""');
		eval('document.getElementById("'+id_cant+'").focus()');
		return;
	}
	str = 'ajouter-produit-ordonnance.php?id_prescription=' + id_product + '&qt=' + eval('document.getElementById("'+id_cant+'").value');
	top.location.href = str;
}

function _panier_go(id_produit){
		str = 'ajouter-produit-panier.php?cip=' + id_produit + '&qt=' + eval('document.getElementById("cant_'+id_produit+'").options[document.getElementById("cant_'+id_produit+'").selectedIndex].value') + '&return=panier&cmd=set';
		top.location.href = str;
	}

function _ordonnance_go(id_produit){
		str = 'ajouter-produit-ordonnance.php?cip=' + id_produit + '&qt=' + eval('document.getElementById("cant_'+id_produit+'").options[document.getElementById("cant_'+id_produit+'").selectedIndex].value') + '&return=ordonnance&cmd=set';
		top.location.href = str;
	}
	
function _ordonnance_prescription_go(id_produit){
		str = 'ajouter-produit-ordonnance.php?id_prescription=' + id_produit + '&qt=' + eval('document.getElementById("cant_'+id_produit+'").options[document.getElementById("cant_'+id_produit+'").selectedIndex].value') + '&return=ordonnance&cmd=set';
		top.location.href = str;
	}	

function _ajout_touts_panier(){
	sir_ids = new Array();
	sir_qt = new Array();
	var index=0;
	for(i=1;i<=document.getElementById("h_counter").value;i++){
		id = eval('document.getElementById("h_'+i+'").value');
		cant = eval('document.getElementById("'+id+'").value');
		if(cant>0){
			sir_ids[index] = id.substring(8);
			sir_qt[index] = cant;
			index++;
		}
	}
	if(index>0)	top.location.href = 'ajouter-produit-panier.php?arr_ids='+sir_ids+'&arr_qt='+sir_qt;
}

function _ajout_touts_ordonnance(){
	sir_ids = new Array();
	sir_qt = new Array();
	var index=0;
	for(i=1;i<=document.getElementById("h_counter").value;i++){
		id = eval('document.getElementById("h_'+i+'").value');
		cant = eval('document.getElementById("'+id+'").value');
		if(cant>0){
			sir_ids[index] = id.substring(8);
			sir_qt[index] = cant;
			index++;
		}
	}
	if(index>0)	top.location.href = 'ajouter-produit-ordonnance.php?arr_ids='+sir_ids+'&arr_qt='+sir_qt;
}

function _ajout_touts_ordonnance_prescription(){
	sir_ids = new Array();
	sir_qt = new Array();
	var index=0;
	for(i=1;i<=document.getElementById("h_counter").value;i++){
		id = eval('document.getElementById("h_'+i+'").value');
		cant = eval('document.getElementById("'+id+'").value');
		if(cant>0){
			sir_ids[index] = id.substring(8);
			sir_qt[index] = cant;
			index++;
		}
	}
	if(index>0)	top.location.href = 'ajouter-produit-ordonnance.php?arr_id_prescription='+sir_ids+'&arr_qt_prescription='+sir_qt;
}

function _delete_sp(id){
	if(confirm('Voulez-vous vraiment supprimer la sauvegarde de panier "' + id + '" ?')){
		top.location.href='sauv-panier.php?idp='+id;
	}
}

function _delete_so(id){
	if(confirm('Voulez-vous vraiment supprimer la sauvegarde d\'ordonnance "' + id + '" ?')){
		top.location.href='sauv-ordonnance.php?ido='+id;
	}
}

function _delete_pp(id){
	if(confirm('Etes-vous sûr de vouloir supprimer le produit "' + id + '" de votre panier ? ')){
		top.location.href='ajouter-produit-panier.php?cip='+id+'&qt=0&return=panier';
	}
}

function _delete_po(id){
	if(confirm('Etes-vous sûr de vouloir supprimer le produit "' + id + '" de votre ordonnance ? ')){
		top.location.href='ajouter-produit-ordonnance.php?cip='+id+'&qt=0&return=ordonnance';
	}
}
//Suppression d'un produit sur prescription
function _delete_po_prescription(id,nom)
{
	if(confirm('Etes-vous sûr de vouloir supprimer le produit "' + nom + '" de votre ordonnance ? ')){
		top.location.href='ajouter-produit-ordonnance.php?id_prescription='+id+'&qt=0&return=ordonnance';
	}
}

function raz(){
  document.getElementById('rechGamme').selectedIndex=0;
  document.getElementById('rechSSGamme').selectedIndex=0;
  document.getElementById('rechSSGamme').value='-';
  document.getElementById('rechSSGamme').disabled=true;
  document.getElementById('rechFamille').selectedIndex=0;
  document.getElementById('rechFamille').value='-';
  document.getElementById('rechFamille').disabled=true;
  document.getElementById('rechSSFamille').selectedIndex=0;
  document.getElementById('rechSSFamille').value='-';
  document.getElementById('rechSSFamille').disabled=true;
  document.getElementById('rechRef').value='';
  document.getElementById('rechMots').value='';
}

