/*************************************************************************
	F O N C T I O N S   U T L I S E E S   P A R   L A   G A L L E R I E
**************************************************************************/	
function returnGallery(IdNomCache, IdNomImg, ImgPath, typeGallery, width, height, size)
{
	var Choix = opener.document.getElementById(IdNomImg);
	if(size)
	{		
		var sizeChoix = opener.document.getElementById(IdNomCache+"_size");
		var nameChoix = opener.document.getElementById(IdNomCache+"_name");
	}
	var cacheChoix = opener.document.getElementById(IdNomCache);
	
	if (typeGallery == js_constant["C_GAL_IMG"])
	{
		var maxWidth=100;
		var maxHeight=100;
		if(width > maxWidth)
		{			
			theoricHeight=Math.round((maxWidth/width) * height);
			width=maxWidth;
			if(theoricHeight > maxHeight)
			{
				width=Math.round((maxHeight/height) * width);
				height=maxHeight;				
			}else
			{
				height=theoricHeight;
			}			
		}
		if(opener.document.getElementById(IdNomCache+"_width"))
		{
			opener.document.getElementById(IdNomCache+"_width").value = width;
		}
		if(opener.document.getElementById(IdNomCache+"_height"))
		{
			opener.document.getElementById(IdNomCache+"_height").value = height;
		}
		Choix.src = ImgPath;
		Choix.alt = ImgPath;
		Choix.width = width;
		Choix.height = height;
	}
	else
	{
		a = ImgPath.split("/");
		Choix.value = a[a.length-1];
		if(size)
		{
			if(sizeChoix)
			{
				sizeChoix.value=size;
				//var path=Choix.src.split("/");
				nameChoix.value=Choix.value;
			}
		}
	}
	cacheChoix.value = ImgPath;
}

function changeGallery(IdNomImg,IdNomCache,type, dossier)
{
	var newwin = popup("index.php?type=mediatheque&bo_action=list&type_gallery="+ type +"&dir_origine="+ dossier +"&view=popup&mode=view&returngalhid="+ IdNomCache +"&returngalvis="+ IdNomImg,"yes",500,700);
}

function supprimeImage(NomImg,NomCache)
{
	var ObjImg = document.getElementById(NomImg);
	var ObjHidden = document.getElementById(NomCache);

	if (ObjImg.type == "text")
	{
		ObjImg.value = "";
	}
	else
	{
		ObjImg.src = images_path+"generiques/pix_transp.gif";
		ObjImg.alt = "Choisissez une image";
		ObjImg.width = 1;
		ObjImg.height = 1;		
	}

	ObjHidden.value = "";
}

function defaultImage(NomImg,NomCache)
{
	var ObjImg = document.getElementById(NomImg);
	var ObjHidden = document.getElementById(NomCache);
	
	var replaceValue = "{" + ObjHidden.name + "}";
	
	if( ObjHidden.value == "" || ObjHidden.value == replaceValue)
	{
    	supprimeImage(NomImg,NomCache)	
	}
	else
	{
		if (ObjImg.type == "text")
		{
			a = ObjHidden.value.split("/");
			ObjImg.value = a[a.length-1];
		}
		else
		{
	    	ObjImg.src = ObjHidden.value;
			ObjImg.alt = ObjHidden.value;
		}
	}
}

/*************************************************************************
	FONCTIONS utiles
**************************************************************************/	
function setFormGeneriqueValue(obj,value)
{
	obj.value=value;
}

function setObjValue(name,value)
{
	eval("var obj=document.wizard."+name);
	obj.value=value;
}

/*************************************************************************
	FONCTIONS BLOC COLOR
**************************************************************************/	
function setColorFormElement(name)
{	
	eval("var textInput=document.wizard."+name);
	eval("var colorInput=document.wizard.color_"+name);
	var myColor=webColor(textInput.value);
	setFormGeneriqueValue(textInput,myColor);
	colorInput.style.backgroundColor=myColor;
}


function resetColorFormElement(name)
{	
	eval("var textInput=document.wizard."+name);
	eval("var colorInput=document.wizard.color_"+name);
	setFormGeneriqueValue(textInput,'');
	colorInput.style.backgroundColor='white';	
}

function setDivColor(obj,value)
{
	obj.innerText='<font color="'+value+'">&nbsp;&nbsp;</font>';
}

/*************************************************************************
	FONCTIONS LINK
**************************************************************************/	
function setFreeUrl(name)
{
	eval("var obj=document.wizard."+name);
	obj.focus();
	document.execCommand("CreateLink");
}

function setTreeUrl(name)
{
	var newwin = popup("index.php?type=rubrik_admin&bo_action=link&view=popup&name="+name,"yes",500,700);
}

function setTreeUrlOnlyRub(name)
{
	var newwin = popup("index.php?type=rubrik_admin&bo_action=link&restrict=only_rub&view=popup&name="+name,"yes",500,700);
}

function setTreeUrlOnlyArt(name)
{
	var newwin = popup("index.php?type=rubrik_admin&bo_action=link&restrict=only_art&view=popup&name="+name,"yes",500,700);
}

function removeUrl(name)
{
	eval("var obj=document.wizard."+name);
	setFormGeneriqueValue(obj,"");
}

function affiche(obj){
   var tmp = "";
   for(i in obj){
	  tmp += i + "=" + obj[i] + "\t";
   }  
   alert(tmp);
}


/*************************************************************************
	FONCTIONS SAVEGIE
**************************************************************************/	
function iframeLink(iframe,url)
{
	window.document.frames(iframe).document.location=url;
}

function iframeTopLink(url)
{
	top.location.href=url;
}

function getIframeValue(iframe,field,destination)
{
	eval("var obj_init=window.document.frames(iframe).document.wizard."+field);
	eval("var obj_dest=document.wizard."+destination);
	obj_dest.value=obj_init.value;
}

function getIframeValuePN(field,id,name)
{
	eval("var obj_id=top.opener.document.wizard."+field);
	eval("var obj_name=top.opener.document.wizard.pn_compress_"+field);
	obj_id.value = id;
	obj_name.value = name;
	top.self.close();
}

//lot 2008.2 UAE sguyon 21/05/2008
function getIframeValuePNCons(field1,field2,field3,id,name1,name2,name3)
{
	eval("var obj_id=top.opener.document.wizard."+field1);
	eval("var obj_name=top.opener.document.wizard.pn_compress_"+field1);
	obj_id.value = id;
	obj_name.value = name1;
	
	eval("var obj_id=top.opener.document.wizard."+(field2));
	eval("var obj_name=top.opener.document.wizard."+field2);
	obj_id.value = id+1;
	obj_name.value = name2;
	
	eval("var obj_id=top.opener.document.wizard."+(field3));
	eval("var obj_name=top.opener.document.wizard."+field3);
	obj_id.value = id+2;
	obj_name.value = name3;
	
	top.self.close();
}
//fin


function getMultiIframeValue(iframe,nombre,field)
{
	var l=0;
	var tabFinal=new Array();
	eval("var obj_dest=document.wizard.elements['hidden_apurement_lst']");
	for(i=1;i<=nombre;i++){
	   var result="";
	   eval("var obj_init=window.document.frames('"+iframe+i+"_iframe').document.wizard.elements");
	   if(obj_init.length > 0){
			for(k=0;k < obj_init.length;k++){
				obj = obj_init[k];
				if(obj.value && obj.type == "select-one"){
					eval("var obj_input=window.document.frames('"+iframe+i+"_iframe').document.wizard.texte_"+obj.name);
					if(obj_input != null){
						tabFinal[tabFinal.length]= obj.name+"_"+obj_input.value+"_"+obj.value;			
					}		
				}
			}//end for
		}//end if	
	}//end for 
	obj_dest.value = tabFinal.join(",");
}

function pnSearch(name,reload_page)
{
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	
	eval("var value=document.wizard.pn_compress_"+name+".value;");
	var newwin = popupResizable("index.php?type=pn&bo_action=found&view=popup&mode=view&field="+name+"&pn_compresse="+value,"pnSearch",580,740);
	
}

// lot 2008.2 UAE sguyon 20/05/2008
function pnConsignationSearch(name,reload_page)
{
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	
	eval("var value=document.wizard.pn_compress_"+name+".value;");
	var newwin = popupResizable("index.php?type=pn&bo_action=foundConsignation&view=popup&mode=view&field="+name+"&pn_compresse="+value,"pnConsignationSearch",580,740);
	
}
//fin


//lot 2008.2 UAE sguyon 12/06/2008
function pnStockvendeurSearch(name,reload_page)
{
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	
	eval("var value=document.wizard.pn_compress_"+name+".value;");
	var newwin = popupResizable("index.php?type=pn&bo_action=foundStockvendeur&view=popup&mode=view&field="+name+"&pn_compresse="+value,"pnStockvendeurSearch",580,740);
	
}
//fin


function vendeurSearch(name)
{
	eval("var value=document.wizard.label_"+name+".value;");
	var newwin = popupResizable("index.php?type=societe&bo_action=found_vendeur&view=popup&field="+name+"&label="+value,"vendeurSearch",500,700);
}

function pnFiche(id)
{
	var newwin = popupResizable("index.php?type=pn&bo_action=view&view=popup&id="+id,"pnFiche",750,980);
}

function equivFiche(id)
{
	var newwin = popupResizable("index.php?type=snstock&bo_action=equiv&view=popup&id_pn="+id,"equivFiche",500,980);
}

function pnFicheFront(link)
{
	var newwin = popupResizable(link,750,980);
}

function newPN(pn_compresse)
{
	var newwin = popupResizable("index.php?type=pn&bo_action=add&view=popup&pn_compress_id="+pn_compresse,"pnAdd",750,980);
}

function updatePNInconnu(pn_compresse)
{
	var newwin = popupResizable("index.php?type=pn&bo_action=mod&view=popup&pn_compress_id="+pn_compresse,"pnUnknown",750,980);
}

function consignesVendeur(value)
{
	var newwin = popupResizable("index.php?type=consigne&bo_action=view&view=popup&id_pn="+ value,"consigneVendeur",500,700);
}

function pnEquivalent(value,mode)
{
	var newwin = popupResizable("index.php?type=pn_equivalent&bo_action=list&mode="+mode+"&view=popup&id_pn="+ value,"pnEquivalent",500,700);
}

function editCommentary(id,fields,mode){
	var newwin = popupResizable("index.php?type=traitlst&bo_action=edit&view=popup&id="+id+"&fields="+fields+"&mode="+mode,"editCommentary",275,275);
}

function editPiecesStx(id){
	var newwin = popupResizable("index.php?type=apurement&bo_action=esplus&view=popup&id="+id,"editPiecesStx",450,450);
}

function editCommentaries(id,fields,mode){
	var newwin = popupResizable("index.php?type=sortiestockattente&bo_action=editPopup&view=popup&id="+id+"&fields="+fields+"&mode="+mode,"editCommentaries",250,275);
}

function editCommentarie(id,fields,mode){
	var newwin = popupResizable("index.php?type=LivraisonAttente&bo_action=editPopup&view=popup&id="+id+"&fields="+fields+"&mode="+mode,"editCommentarie",250,275);
}

function viewCommentaireSN(id){
	var newwin = popupResizable("index.php?type=snstock&bo_action=view_comment&view=popup&id="+id,"viewCommentaireSN",150,500);
}

//OEMS Exigence F45, F54, F55 - ajout rcaruso le 25/01/2006
function viewTCOuvert(id, affiche){
	if(affiche == 1){
		var newwin = popupResizable("index.php?type=reception&bo_action=view_tc&view=popup&id="+id,"viewTCOuvert",450,900);
	}
}
//FIN

function closeWindow()
{
	self.close();
}

function saveSocietes(idy,code,libelle,type)
{
	var list = top.document.wizard.inputs.value;
	var tab= list.split(",");
	for(i in tab){
		eval("var obj=top.opener.document.wizard."+tab[i]);
		if(tab[i].indexOf('code_') != -1){
			obj.value = code;
		}else if(tab[i].indexOf('label_') != -1 || tab[i].indexOf('libelle_') != -1){
		   obj.value = libelle;
		}else if(tab[i].indexOf('type_') != -1){
			obj.value = type;
		}else{
		  obj.value = idy;
		}
	}	
	top.self.close();
}



function saveSR(idy,code,libelle,type, position,message)
{
	var list = top.document.wizard.inputs.value;
	var tab= list.split(",");
	
	if(position != '1'){
		alert(message);	
	}
	
	for(i in tab){
		eval("var obj=top.opener.document.wizard."+tab[i]);
		if(tab[i].indexOf('code_') != -1){
			obj.value = code;
		}else if(tab[i].indexOf('label_') != -1 || tab[i].indexOf('libelle_') != -1){
		   obj.value = libelle;
		}else if(tab[i].indexOf('type_') != -1){
			obj.value = type;
		}else{
		  obj.value = idy;
		}
	}	
	top.self.close();
}

function OuvPDF(link)
{
	var newwin = popupMenuEnabled(link,"FichierPDF",500,500);
}

function openCalculette(link)
{
	var newwin = popupResizable(link,"calculette",500,800);
}

function OuvPopup(link,title,w,h)
{
	var newwin = popupMenuEnabled(link,"doc",500,500);
}

function Edition(link)
{
	var newwin = popupMenuEnabled(link,"edit",500,800);
}

function editInfocomp(link)
{
	var newwin = popupMenuEnabled(link,"detail_info",400,500);
}

function getDetailSociete(id,type)
{
	var newwin = popupResizable("index.php?type=societe&bo_action=fiche&view=popup&mode=view&id="+id+"&type_soc="+type,"yes",700,800);
}

function initOpenerBeforeClose(inputs,list){
	var tab= inputs.split(",");
	var data= list.split(",");
	for(i in tab){
		eval("var obj=top.opener.document.wizard."+tab[i]);
		if(obj != null){
			obj.value = data[i];
		}
	}	
	self.close();	
}	


function getIframeValueNDP(field,id,name)
{
	eval("var obj_id=top.opener.document.wizard."+field);
	eval("var obj_name=top.opener.document.wizard.ndp_"+field);
	obj_id.value = id;
	obj_name.value = name;
	top.self.close();
}

//Mantis 145 - ajout rcaruso le 14/03/2007
function ndpSearch(name,reload_page)
{
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	
	eval("var value=document.wizard.ndp_"+name+".value;");
	var newwin = popupResizable("index.php?type=article&bo_action=found&view=popup&mode=view&field="+name+"&ndp="+value,"ndpSearch",580,740);
}

function addCana(){
    if(document.wizard.elements['list_cana'].value != 0){
        document.wizard.elements['infocomp_1'].value = document.wizard.elements['infocomp_1'].value+","+document.wizard.elements['list_cana'].value;
    }else{
        alert('Please select a value');
    }
}

function addCaco(obj){
    if(document.wizard.elements['list_caco'].value != 0){
        document.wizard.elements['infocomp_5'].value = document.wizard.elements['infocomp_5'].value+","+document.wizard.elements['list_caco'].value;
    }else{
        lert('Please select a value');
    }    
}
//FIN

//SGMIRA@08/04/2010 MANTIS 733 : Module Hotline
function selectContact(reload_page)
{
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	eval("var codeSociete=document.wizard.requestor_code_company.value;");
	eval("var nomSociete=document.wizard.requestor_libelle_company.value;");
	eval("var nomContact=document.wizard.requestor_name_contact.value;");
	eval("var prenomContact=document.wizard.requestor_firstname_contact.value;");
	eval("var tel=document.wizard.requestor_tel_contact.value;");
	eval("var fax=document.wizard.requestor_fax_contact.value;");
	eval("var mail=document.wizard.requestor_mail_contact.value;");
	
	tel = tel.replace("+","plus");
	fax = fax.replace("+","plus");
	
	var newwin = popupResizable("index.php?type=hotline&bo_action=selectcontact&view=popup&mode=view&code="+codeSociete+"&nomsociete="+nomSociete+"&nom="+nomContact+"&prenom="+prenomContact+"&tel="+tel+"&fax="+fax+"&mail="+mail,"selectcontact",800,1250);

	//newwin c'est le windows opener
	
}
function selectContactFenetre(reload_page)
{
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	eval("var codeSociete=document.wizard.requestor_code_company.value;");
	eval("var nomSociete=document.wizard.requestor_libelle_company.value;");
	eval("var nomContact=document.wizard.requestor_name_contact.value;");
	eval("var prenomContact=document.wizard.requestor_firstname_contact.value;");
	eval("var tel=document.wizard.requestor_tel_contact.value;");
	eval("var fax=document.wizard.requestor_fax_contact.value;");
	eval("var mail=document.wizard.requestor_mail_contact.value;");
	
	tel = tel.replace("+","plus");
	fax = fax.replace("+","plus");
	
	//alert(window.opener.location.href);
	window.location.href = "index.php?type=hotline&bo_action=selectcontact&view=popup&mode=view&code="+codeSociete+"&nomsociete="+nomSociete+"&nom="+nomContact+"&prenom="+prenomContact+"&tel="+tel+"&fax="+fax+"&mail="+mail;

	//alert(newwin.parent.location.href);
	//newwin c'est le windows opener
	
}
function selectcontactbyid(id,code,nom_societe,nom,prenom,tel,fax,mail)
{	
/*	
	if(tmp.lastIndexOf("nocontact=")!=-1)
		var result = tmp.replace(/&nocontact=[0-9]+/i,'&nocontact='+id);
	else
		var result = tmp+'&nocontact='+id;
	top.opener.document.location.href = result;
*/

	top.opener.document.wizard.requestor_code_company.value = code;
	top.opener.document.wizard.requestor_libelle_company.value = nom_societe;
	top.opener.document.wizard.requestor_name_contact.value = nom;
	top.opener.document.wizard.requestor_firstname_contact.value = prenom;
	top.opener.document.wizard.requestor_tel_contact.value = tel ;
	top.opener.document.wizard.requestor_fax_contact.value = fax ;
	top.opener.document.wizard.requestor_mail_contact.value = mail;
	top.window.close();
	//opener.top.document.location.href = "index.php?type=hotline&bo_action=selectcontact&view=popup&mode=view&key="+id+"&select=1";
}

function modcontactbyid(id)
{
	top.document.location.href = "index.php?type=hotline&bo_action=selectcontact&view=popup&mode=view&key="+id+"&mod=1";
}
//Sgmira
function  updateHotline(reload_page)
{
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	eval("var codeSociete=document.wizard.requestor_code_company.value;");
	eval("var nomSociete=document.wizard.requestor_libelle_company.value;");
	eval("var nomContact=document.wizard.requestor_name_contact.value;");
	eval("var prenomContact=document.wizard.requestor_firstname_contact.value;");
	eval("var tel=document.wizard.requestor_tel_contact.value;");
	eval("var fax=document.wizard.requestor_fax_contact.value;");
	eval("var mail=document.wizard.requestor_mail_contact.value;");
	
	opener.document.wizard.requestor_code_company.value = codeSociete;
	opener.document.wizard.requestor_libelle_company.value = nomSociete;
	opener.document.wizard.requestor_name_contact.value = nomContact;
	opener.document.wizard.requestor_firstname_contact.value = prenomContact;
	opener.document.wizard.requestor_tel_contact.value = tel ;
	opener.document.wizard.requestor_fax_contact.value = fax ;
	opener.document.wizard.requestor_mail_contact.value = mail;
	window.close();
}
function addCompany(reload_page)
{
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
eval("var codeSociete=document.wizard.requestor_code_company.value;");
eval("var nomSociete=document.wizard.requestor_libelle_company.value;");
var newwin = popupResizableCenter("index.php?type=hotline&bo_action=addcompany&view=popup&mode=view&code="+codeSociete+"&nomsociete="+nomSociete,"addcompany",250,400);

}


function addHotlineContact(reload_page){
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	eval("var codeSociete=document.wizard.requestor_code_company.value;");
	eval("var nomSociete=document.wizard.requestor_libelle_company.value;");
	eval("var nomContact=document.wizard.requestor_name_contact.value;");
	eval("var prenomContact=document.wizard.requestor_firstname_contact.value;");
	eval("var tel=document.wizard.requestor_tel_contact.value;");
	eval("var fax=document.wizard.requestor_fax_contact.value;");
	eval("var mail=document.wizard.requestor_mail_contact.value;");
	fax = fax.replace("+","plus");
	tel = tel.replace("+","plus");
	var newwin = popupResizable("index.php?type=hotline&bo_action=addcontact&view=popup&mode=view&code="+codeSociete+"&nomsociete="+nomSociete+"&nom="+nomContact+"&prenom="+prenomContact+"&tel="+tel+"&fax="+fax+"&mail="+mail,"selectcontact",800,1250);	
}
//sgmira
function modHotlineContact(reload_page){
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	eval("var codeSociete=document.wizard.requestor_code_company.value;");
	eval("var nomSociete=document.wizard.requestor_libelle_company.value;");
	eval("var nomContact=document.wizard.requestor_name_contact.value;");
	eval("var prenomContact=document.wizard.requestor_firstname_contact.value;");
	eval("var tel=document.wizard.requestor_tel_contact.value;");
	eval("var fax=document.wizard.requestor_fax_contact.value;");
	eval("var mail=document.wizard.requestor_mail_contact.value;");
	eval("var mail=document.wizard.requestor_mail_contact.value;");
	var tmp = window.location.href;
	var post = tmp.substring(tmp.lastIndexOf("key="));
	var keypost =  post.substring(post.indexOf("=")+1,post.indexOf("&"));
	
	var newwin = popupResizable("index.php?type=hotline&bo_action=modcontact&view=popup&mode=view&code="+codeSociete+"&nomsociete="+nomSociete+"&nom="+nomContact+"&prenom="+prenomContact+"&tel="+tel+"&fax="+fax+"&mail="+mail+"&key="+keypost,"selectcontact",800,1250);	
}
function saveCompany(reload_page,message){
	
	if (reload_page !='' && reload_page !='{refresh}')
	{
		var tmp = window.location.href;
		tmp = tmp+'&error=0';
		window.location.href = tmp;
	}
	
	eval("var codeSociete=document.wizard.requestor_code_company.value;");
	eval("var nomSociete=document.wizard.requestor_libelle_company.value;");
	
	eval("var type_company=document.wizard.type_company.value;");
	eval("var ville_company=document.wizard.ville_company.value;");
	eval("var id_iso_pays=document.wizard.id_iso_pays.value;");
	
	eval("var nomContact=opener.document.wizard.requestor_name_contact.value;");
	eval("var prenomContact=opener.document.wizard.requestor_firstname_contact.value;");
	eval("var tel=opener.document.wizard.requestor_tel_contact.value;");
	eval("var fax=opener.document.wizard.requestor_fax_contact.value;");
	eval("var mail=opener.document.wizard.requestor_mail_contact.value;");
	
	opener.document.wizard.requestor_code_company.value = codeSociete;
	opener.document.wizard.requestor_libelle_company.value = nomSociete;
	if(codeSociete!='' && nomSociete!='' && type_company!='' && ville_company!='' && id_iso_pays!='')
	{
		var newwin = popupResizable("index.php?type=hotline&bo_action=savecompany&view=popup&mode=view&code="+codeSociete+"&nomsociete="+nomSociete+"&type_company="+type_company+"&ville_company="+ville_company+"&id_iso_pays="+id_iso_pays+"&nom="+nomContact+"&prenom="+prenomContact+"&tel="+tel+"&fax="+fax+"&mail="+mail+"&click=1","addcompany",250,400);
		window.close();
	}
	else
		alert(message);
}


function openFileForHotline() {
	h = 500;
	w = 800;
	type = '';
	url = '/gallery_files/upload/' + document.getElementById('fileopen').innerHTML;
	var nsNav = (document.layers) ? 1 : 0;
	var ieNav = (document.all) ? 1 : 0;
	var left = 0;
	var top = 0;

	if (ieNav) {
		left = (document.body.clientWidth - w) / 2;
		top = (document.body.clientHeight - h) / 2;
	} else if (nsNav) {
		left = (self.innerWidth - w) / 2;
		top = (self.innerHeight - h) / 2;
	}
	wintype = "toolbar=yes,menubar=yes,location=no,status=1,scrollbars=1,resizable=1,top="
			+ top + ",left=" + left + ",height=" + h + ",width=" + w;
	var newwin = window.open(url, type, wintype);
	newwin.focus();
}
function supprimerFichier() {
	if (document.getElementById('ouvrirfichier').innerHTML != '') {
		document.getElementById('ouvrirfichier').innerHTML = '';
		document.getElementById('supprimerfichier').style.display = 'none';
		document.getElementById('ajouterfichierlibelle').style.visibility = 'visible';
		document.getElementById('ajouterfichierbutton').style.visibility = 'visible';
	} else {
		document.getElementById('supprimerfichier').style.display = 'none';
	}
}
function terminerVerification(url, form) {
	if( ! form)
	{
		form="wizard";
	}
	eval("var formObj=document."+form);
	
	var SelectTo = window.document.frames('contact_iframe_iframe').document.wizard.elements["list_right"];
	var listeidcontact = '';
	//Create result array
	for (i=0; i<SelectTo.options.length; i++)
	{
		listeidcontact = listeidcontact+SelectTo.options[i].value;
		if(i!=(SelectTo.options.length-1)){
			listeidcontact =listeidcontact+',';
		}
	}			
	if(formObj)
	{
		if(document.getElementById('ouvrirfichier').innerHTML='')	
			formObj.action=url+'&fichier=1&contact='+listeidcontact;
		else
			formObj.action=url+'&fichier=0&contact='+listeidcontact;
		postwizard(formObj.name);
	}else
	{
		alert(form+" n'existe pas.");
	}
}

function changeParametreHotline(){
	var tmp = window.location.href;
	if(tmp.lastIndexOf("iddoshotline=")!=-1)
		var post = tmp.substring(tmp.lastIndexOf("iddoshotline="));
	else
		var post='';
	var postfin=post.indexOf("&");
	if(postfin==-1)
		var keypost =  post.substring(post.indexOf("=")+1);
	else
		var keypost =  post.substring(post.indexOf("=")+1,post.indexOf("&"));
	window.location.href ="index.php?type=hotline&bo_action=modhotline&iddoshotline="+keypost;
	
}

function updateDispoPnHotline(id){	
	var msg_to_vendor = document.getElementById('msg_to_vendor').value;
	var msg_answer = document.getElementById('msg_answer').value;
	var select_answer = document.getElementById('select_answer').value=
	window.location.href = "index.php?type=hotline&bo_action=updatedispopn&iddoshotline="+id+"&select_answer="+select_answer+"&msg_to_vendor="+msg_to_vendor+"&msg_answer="+msg_answer;
}
function ouvrirpopupInfoDossier(lien)
{
	var newwin = popupResizable(lien,"infodossier",750,980);
}
//FIN MANTIS 733 : MODULE HOTLINE

//jpasquier 2010/05/06 mantis 640
function getSautDeLigne(nb) {
	if (nb > 1) {
		for(i=1; i<=nb; i++) {
			txt += "\n";
		}
	} else {
		txt = "\n";
	}	
	return txt;
}
function trim(myString) {
	return myString.replace(/^\s+/g,"").replace(/\s+$/g,"");
}
//SGMIRA@27/05/2010 TMATIC624
function infoSuplementaires(idsnstock)
{
	var newwin = popupResizableCenter("index.php?type=pieces&bo_action=infosup&view=popup&mode=view&idsnstock="+idsnstock,"Informations_suplémentaires",450,450);	
}

//fin
