
var myimages = new Array();
function preloadimages() {
    for (i = 0; i < preloadimages.arguments.length; i++) {
        //alert(preloadimages.arguments[i]);
        myimages[i] = new Image();
        myimages[i].src = preloadimages.arguments[i];
    }
}


function preloadMenuImg() {
preloadimages('../img/menu/actualites_roll.gif','../img/menu/sav_roll.gif','../img/menu/spit_export_roll.gif','../img/menu/orange_arrow.gif','../img/img_menu/points_vente_roll.gif','../img/menu/produits_roll.gif','../img/menu/qui_sommes_nous_roll.gif','../img/menu/prescription_roll.gif','../img/menu/services_roll.gif','../img/menu/partenaires_roll.gif','../img/menu/black_arrow.gif');
}

function swapImage(imgName, imgSrc) {
	document.images[imgName].src = imgSrc;
}


function insertStylesheet() {
    if (isNS4) {
		var css_filename = "stylesheet_ns4.css";
	}
	else {
		var css_filename = "stylesheet.css";
	}
	document.writeln("<link rel=\"stylesheet\" href=\"../css/" + css_filename + "\" type=\"text/css\">");
}


pop = null;

function displayCenteredPopup(url, winName, winWidth, winHeight, features) {
	var winTop = (screen.height - winHeight) / 2;
	var winLeft = (screen.width - winWidth) / 2;
	
	window.open(url, winName, features + ',width=' + winWidth + ',height=' + winHeight + ',top=' + winTop + ', left=' + winLeft);
}


function centered_popup(url, name, width, height, options)
{
	var top = (screen.height - height) / 2;
	var left = (screen.width - width) / 2;
	window.open(url, name, options + ',width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ',screenX=' + left + ',screenY=' + top);
}


function popupPrint(printPage)
{
	var url = '../popup/popup_print.php?print=1&print_page=' + printPage;
	var name = 'print';
	var width = 580;
	var height = 400;
	var options = 'toolbar=1,resizable=1,scrollbars=1,menubar=1';
	
	centered_popup(url, name, width, height, options);
}


function popupin(product_id,specificity_id,specificity_name,lang)
{
	if (pop && pop.open && (! pop.closed)) {
		pop.close();
	}

	var wndName = specificity_name;
	
	if (isNS4) {
		var wndX = 0;
		var wndY = 0;
		var wndWidth = 150;
		var wndHeight = 100;
	}
	else if (isNS) {
		var wndX = 0;
		var wndY = 0;
		var wndWidth = 750;
		var wndHeight = 500;
	} else {
		var wndX = screen.width + 500;
		var wndY = 0;
		var wndWidth = 150;
		var wndHeight = 100;
	}
	
	var options = 'height=' + wndHeight + ',innerheight=' + wndHeight + ',width=' + wndWidth +
	',innerWidth=' + wndWidth + ',left=' + wndX + ',top=' + wndY + ',resizable=1,scrollbars=1';

    if (lang=="fr") rep = "../produits/";
	else rep = "../product_range/";
	var url = rep + 'popup.php?langue=' + lang + '&prod=' + product_id + '&spec=' + specificity_id + '&title=' + escape(specificity_name);
//	pop = window.open(url, wndName, options);

    pop = window.open(url,'',options);
}


function popup_img(mdp_img_url, mdp_img_width, mdp_img_height, wnd_title, lang) {
	if (pop && pop.open && (! pop.closed))
	{
		pop.close();
	}
	
	widthImg = mdp_img_width;
	heightImg = mdp_img_height;
	
	var str = "height=" + heightImg + ",innerHeight=" + heightImg;
	str += ",width=" + widthImg + ",innerWidth=" + widthImg;
 	
	if (window.screen) 
	{
    	var ah = screen.availHeight - 30;
    	var aw = screen.availWidth - 10;
	}
	
	var xc = (aw - widthImg) / 2;
	var yc = (ah - heightImg) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;

    if (lang=="fr") rep = "../produits/";
	else rep = "../product_range/";
	var url = rep + 'popup_img.php?page=' + mdp_img_url + '&titre=' + escape(wnd_title) + '&w=' + widthImg + '&h=' + heightImg;
	
    pop = window.open(url,'',str);
}

function popupCorporate(format,imgSrc) {
	/*(format == 0) ? widthF = 360 : widthF = 270;
	(format == 0) ? heightF = 270 : heightF = 360;*/
	if (format == 0) {
		widthF = 360;
		heightF = 270;
	}
	else {
		if (format == 1) {
			widthF = 270;
			heightF  = 360;
		}
		else {
			widthF  = 270;
			heightF  = 270;
		} 
	}
	var str = "height=" + heightF + ",innerHeight=" + heightF;
  	str += ",width=" + widthF + ",innerWidth=" + widthF;
	 if (window.screen) {
    	var ah = screen.availHeight - 30;
	    var aw = screen.availWidth - 10;

    	var xc = (aw - widthF) / 2;
    	var yc = (ah - heightF) / 2;

    	str += ",left=" + xc + ",screenX=" + xc;
    	str += ",top=" + yc + ",screenY=" + yc;
  	}
	url = '../zoom.php?image='+imgSrc.replace("../","");
	pop = window.open(url, '_blank', str);

}

// Fonction de fermeture d'un popup
function closePopup(popup) {
    if (popup) {
        if (!popup.closed && popup.open) {
            popup.close();
        }
    }
}

// Fonction de validation du formulaire de "A votre service" > "Aide au calcul"
function check_calcul_form(form)
{
	var company = (form.company.value);
	var last_name = (form.last_name.value);
	var chantier = (form.chantier.value);
	var address = (form.address.value);
	var zip = (form.zip.value);
	var city = (form.city.value);
	var country = (form.country.value);
	var phone = (form.phone.value);
	var fax = (form.fax.value);
	var email = (form.email.value);
	var at = email.indexOf("@",1);
	    
    if(! company)
    {        
		alert("Veuillez saisir le nom de votre société.");
		form.company.focus();
		return false;
    }
	else if (! last_name)
    {
        alert("Veuillez saisir votre nom.");
		form.last_name.focus();
		return false;
    }
	else if (! chantier)
    {
        alert("Veuillez saisir la référence de votre chantier.");
		form.chantier.focus();
		return false;
    }
	else if (! address)
    {
        alert("Veuillez saisir votre adresse.");
		form.address.focus();
		return false;
    }
	else if (! zip)
    {
        alert("Veuillez saisir votre code postal.");
		form.zip.focus();
		return false;
    }
	else if (! city)
    {
        alert("Veuillez saisir votre ville.");
		form.city.focus();
		return false;
    }
	else if (! country)
    {
        alert("Veuillez saisir votre pays.");
		form.country.focus();
		return false;
    }
	else if (! phone)
    {
        alert("Veuillez saisir votre numéro de téléphone.");
		form.phone.focus();
		return false;
    }
	else if (! email)
    {
        alert("Veuillez saisir votre adresse e-mail.");
		form.email.focus();
		return false;
    }
	else if (at == -1)
    {
        alert("Veuillez saisir une adresse e-mail valide.");
		form.email.focus();
		return false;
    }
    else
    {
        form.send.value="Patientez...";
        return true;
    }
}



//------------------------------ RECRUTE ----------------------------------------------
candidature_opened=0;
candidature=null;


function open_candidature(aff,annonce,type) {
    candidature = window.open('../popup/depot_cv.php?type='+type+'&affectation='+aff+'&annonce_id='+annonce,'candidature','scrollbars=yes,width=540,height=500,top=10,left=10');
}

//ferme le popup de candidature s'il est ouvert
function close_candidat_opened() {
    if (candidature_opened==1) {
        if (candidature!=null) {
        	if (!candidature.closed && candidature.open) {
            	candidature.close();
            	candidature_opened=0;
        	}
        }
    }
    return candidature_opened;
}

function rech_valid(form_rech,type) {
    with (form_rech) {
		if (type=="Emploi") {
        	if ((categorie.selectedIndex==0)&&(lieu_travail.selectedIndex==0)&&(etudes.selectedIndex==0)&&(experience.value<1)&&(ref_offre.value<1)&&(mots_cles.value<1))                   
        	{
            	alert("Veuillez rentrer au moins un critère de recherche.");
            	return false;
        	}
		}
		if (type=="Stage") {
        	if ((service.selectedIndex==0)&&(lieu_travail.selectedIndex==0)&&(etudes.selectedIndex==0)&&(duree.value<1)&&(mots_cles.value<1))                   
        	{
           	 	alert("Veuillez rentrer au moins un critère de recherche.");
            	return false;
        	} 
		}
		return true;
    }
}

function lancer_recherche(form_rech) {
    if (rech_valid(form_rech)) {
        form_rech.submit();
    }
}



//------------------------------ FIN RECRUTE ----------------------------------------------
