/* AJOUT AUX FAVORIS */
var urlAddress = "http://www.mutuelle-sg.com";
var pageName = "La mutuelle du personnel du Groupe Société Générale";
function addToFavorites() {
	if (window.sidebar) window.sidebar.addPanel(pageName,urlAddress,"");
	else if(document.all) window.external.AddFavorite(urlAddress,pageName);
	else if(window.opera&&window.print) return true;
}



/* FONCTION DE ROLLOVER D'IMAGE */
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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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];}
}


/* FONCTION D'ECRITURE DE FLASH */

function WriteSWF(path, file, width, height, wmode, bgcolor, id, url){
var EmbedSWF = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" id=\""+id+"\" width=\""+width+"\" height=\""+height+"\"><param name=\"movie\" value=\""+path+file+"\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\""+wmode+"\" /><param name=\"bgcolor\" value=\""+bgcolor+"\" /><param name=\"allowScriptAccess\" value=\"sameDomain\" /><embed src=\""+path+file+"\" bgcolor=\""+bgcolor+"\" wmode=\""+wmode+"\" menu=\"false\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" id=\""+id+"\" name=\""+id+"\" allowScriptAccess=\"sameDomain\" width=\""+width+"\" height=\""+height+"\"></embed></object>";
if(url != undefined) EmbedSWF = '<a href="' + url + '">' + EmbedSWF + '</a>';
document.write(EmbedSWF);
}


/* FONCTION DE DÉFINITION DES CALQUES */
function NameDiv(id){
	if(document.all){doc = document.all[id];}
	if(document.getElementById){doc = document.getElementById(id);}
	return doc;
}


/* FONCTION DE DEFINITION D'UN STYLE D'ELEMENT */
// id : id de l'élement
// prop : propriété du style (display, position, color...)
// value : valeur de la propriété (none, absolute, #ffcc00...)
function SetObjProp(id, prop, value){
	//alert(id);
	NameDiv(id);
	doc.style[prop] = value;
}



/* FONCTION D'AFFECTATION DE CLASSE AUX ELEMENTS */
// id : id de l'élement
// cssName : nom de la classe
function SetObjCss(id, cssName){
	NameDiv(id);
	//alert(doc);
	doc.className=cssName;
}


/* FONCTION DE DEPLOIEMENT DE LA NAVIGATION */
var nItems=4; // A parametrer en fonction du nombre de sous-menus effectifs
var foldstate = new Array();
for(i=0; i<nItems; i++){
	foldstate[i]=0;
}
function FoldUnfoldNav(id){
	for(i=0; i<nItems; i++){
		if(i==id){
			if(foldstate[i]==0){
				SetObjProp("Subnav"+i, "display", "block");
				SetObjCss("NavBtn"+i, "on");
				foldstate[i]=1;
			}else{
				SetObjProp("Subnav"+i, "display", "none");
				SetObjCss("NavBtn"+i, "off");
				foldstate[i]=0;
			}
		}else{
			SetObjProp("Subnav"+i, "display", "none");
			SetObjCss("NavBtn"+i, "off");
			foldstate[i]=0;
		}
	}
}


/* FONCTION DE CHANGEMENT DE TAILLE DE TYPO SUR UNE CLASSE PRECISE */
function getElementsByClass(searchClass, node, tag) {
    var classElements = new Array();
    if ( node == null )
        node = document;
    if ( tag == null )
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if ( pattern.test(els[i].className) ) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}

var fontstate=0;
function tailleFonte(classe){
	if(fontstate==0){
		taille="15px";
		fontstate=1;
	}else{
		taille="11px";
		fontstate=0;
	}
	cibles = getElementsByClass(classe);
	for (i=0; i < cibles.length; i++){
		cibles[i].style.fontSize = taille;
	}
}


/* FONCTION DE CALCUL DE LA COTISATION */
function CalculCotisation(){
	var msgError = "Veuillez :\n";
	var ragb = document.forms["CalculCotisation"].ragb.value;
	if(ragb == ""){msgError += "- entrer votre rémunération annuelle brute fixe théorique\n";}
	if(document.forms["CalculCotisation"].regime_am[0].checked==false && document.forms["CalculCotisation"].regime_am[1].checked==false){
		msgError += "- préciser si vous êtes bénéficiaire du régiment dit \"Alsace-Moselle\"";
	}
	/*
	if(ragb >48276){ ragb = 48276; }
	var cotisation = ((ragb * 1.108)/1200).toFixed(2);
	*/

	/*
	if(ragb >65707){ ragb = 65707; }
	//var cotisation = ((ragb * 0.94842 )/1200).toFixed(2);
        var cotisation = ((ragb * tauxCalculette )/1200).toFixed(2);
	*/

	if(ragb >54558){ragb = 54558;}
	var cotisation = ((ragb * 0.94842)/1200).toFixed(2);

	for(i=0; i<document.forms["CalculCotisation"].regime_am.length; i++){
		if(document.forms["CalculCotisation"].regime_am[i].checked==true){
			//alert(document.forms["CalculCotisation"].regime_am[i].value);
			if(document.forms["CalculCotisation"].regime_am[i].value == "oui"){
				cotisation = (cotisation*0.9).toFixed(2);
			}
		}
	}
	if(msgError != "Veuillez :\n"){
		alert(msgError);
		return false;
	} else {
		//alert("Calcul de votre cotisation en cours...");
		document.forms["CalculCotisation"].result.value = cotisation+ " €";
		return false;
	}
}

/* FORMULAIRES CHAMPS EXCLUSIVEMENT NUMERIQUES */
function checkLength(texteArea, maxLength){
	if(texteArea.value.length>=maxLength){
		  texteArea.value = texteArea.value.substr(0,maxLength);
	}
	if(is_numeric(texteArea.value)==false){
		  texteArea.value = texteArea.value.substr(0,texteArea.value.length-1);
	}
}

function is_numeric(v){
	return (isNaN(v)) ? false : true;
}

function nextField(texteArea, maxLength, nextArea){
	if(texteArea.value.length>=maxLength){
		 document.forms["pech"][nextArea].focus();
	}

}


/* FORMULAIRES CHAMPS MAILS */
function validMail(texteArea,myMail){
	var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
	if (reg.exec(myMail)==null){
		texteArea.value="";
		texteArea.focus();
	}
}



/* VALIDATION FORMULAIRE DE SIMULATION */
function validSimuldent(thisAction){
	var myForm = document.simuldent;

	if (myForm['cas'].value == 0) {
		alert("Vous n'avez pas choisi votre prestation.");
	}
	else if (!is_numeric(myForm['frais_reel'].value)) {
		alert("Le montant n'est pas un nombre.");
	}
	else if (myForm['frais_reel'].value=='') {
		alert("Le montant est vide.");
	}
	else {
		myForm.id_rubrique.value = id_rubrique;
		myForm.action = thisAction;
		myForm.submit();
	}
}

function checkMail(str) {
	var verif = /^[a-zA-Z0-9\-\_]{1,}[a-zA-Z0-9\.\-\_]*[a-zA-Z0-9\-\_]{1,}@[a-zA-Z0-9]{1,}[a-zA-Z0-9\.\-\_]*[a-zA-Z0-9]{1,}[.][a-zA-Z]{2,4}$/;
	if(verif.test(str)) return true;
	else return false;
}

/* VALIDATION FORMULAIRE DE CONTACT */
function validContact(thisAction){
	var myForm = document.contact;
	var alertMsg = "";
	var firstError = "";

	if (myForm['objet'].value=='0'){
		alertMsg += "- Veuillez renseigner l'objet de votre demande.\n";
		firstError = "objet";
	}

	if (myForm['civilite'].value=='0'){
		alertMsg += "- Veuillez renseigner votre civilité.\n";
		firstError = "civilite";
	}
	if (myForm['nom'].value=='') {
		alertMsg += "- Veuillez renseigner votre nom.\n";
		firstError = "nom1";
	}
	if (myForm['prenom'].value=='') {
		alertMsg += "- Veuillez renseigner votre prénom.\n";
		firstError = "prenom";
	}
	if(myForm['email1'].value == '') {
		alertMsg += "- Veuillez renseigner votre email\n";
		firstError = "email1";
	}else if(!checkMail(myForm['email1'].value)) {
		alertMsg += "- Votre email n'est pas valide.\n ";
		firstError = "email1";
	}

	if (myForm['nsecu'].value=='') {
		alertMsg += "- Veuillez renseigner votre n° de sécurité sociale.\n";
		firstError = "nsecu";
	}
	if (myForm['message'].value=='') {
		alertMsg += "- Veuillez entrer un message.\n";
		firstError = "message";
	}

        if(maxlength(myForm['message'],750)){

            alertMsg += '- Votre message est limité à 750 caractères\n';
           // alertMsg += '- Votre message a été tronqué !';
            firstError = "message";

        }

        if(myForm['email1'].value !=  myForm['email2'].value){

            alertMsg += "- Vos E-mails ne sont pas identique\n";
            firstError = "message";

        }


	if (alertMsg != ""){
		alert(alertMsg);
		myForm[firstError].focus();
	} else {
		myForm.action = thisAction;
		myForm.submit();
	}
}

 function maxlength(oForm,limit) {

         var bOverLimit =  false;

       if(oForm.value.length > limit){
           bOverLimit = true;
           //oForm.value=oForm.value.substring(0, limit);
        }

        return bOverLimit;

    }

    function maxlength2(oForm,limit) {

         var bOverLimit =  false;
         var alertMsg;
         var elt = document.getElementById('messageLimit');
         var nbChar = oForm.value.length;
         var tt = limit - nbChar;

         if(tt < 0){ tt=0;
            // message = 'limité à ' + tt + ' caractères <br /> Vous avez un excédant de ' + ((limit - nbChar) *( - 1)) + ' caractère(s)';
             message = 'limité à ' + tt + ' caractères';
         }else{
             message = 'limité à ' + tt + ' caractères';
         }
         elt.innerHTML = message;




         if(oForm.value.length < limit)
             return true;

       if(oForm.value.length > limit){

            alertMsg = '- Votre message est limité à 750 caractères\n';
            //alertMsg += '- Votre message a été tronqué !';

            alert(alertMsg);
           //oForm.value=oForm.value.substring(0, limit-1);

       }


    }

 function set_callback_events()
 {
 if (document.addEventListener){
 // alert('FF');
 document.addEventListener('keypress', verif_textarea_length, false);
 document.addEventListener('keyup', verif_textarea_length, false);
 document.addEventListener('blur', verif_textarea_length, false);
 } else if (document.attachEvent){
 // alert('IE');
 document.attachEvent('onkeypress', verif_textarea_length);
 document.attachEvent('onkeyup', verif_textarea_length);
 document.attachEvent('onblur', verif_textarea_length);
 }
 }

/* VALIDATIONS FORMULAIRE DE PRISE EN CHARGE */
	function validPriseEnCharge(thisAction){
		var myForm = document.pech;
		var alertMsg = "";
		var firstError = "";

		if (myForm['civilite1'].value=='0'){
			alertMsg += "- Veuillez renseigner la civilité de l'assuré.\n";
			firstError = "civilite1";
		}
		if (myForm['nom1'].value=='') {
			alertMsg += "- Veuillez renseigner le nom de l'assuré.\n";
			firstError = "nom1";
		}
		if (myForm['prenom1'].value=='') {
			alertMsg += "- Veuillez renseigner le prénom de l'assuré.\n";
			if(firstError=='') firstError = "prenom1";
		}
		if (myForm['dobd1'].value=='') {
			alertMsg += "- Veuillez renseigner le jour de naissance l'assuré.\n";
			if(firstError=='') firstError = "dobd1";
		}
		if (myForm['dobm1'].value=='') {
			alertMsg += "- Veuillez renseigner le mois de naissance de l'assuré.\n";
			if(firstError=='') firstError = "dobm1";
		}
		if (myForm['doby1'].value=='') {
			alertMsg += "- Veuillez renseigner l'année de naissance de l'assuré.\n";
			if(firstError=='') firstError = "doby1";
		}
		if (myForm['nsecu1'].value=='') {
			alertMsg += "- Veuillez renseigner le n° de sécurité sociale de l'assuré.\n";
			if(firstError=='') firstError = "nsecu1";
		}
		if(myForm['email1'].value == '') {
			alertMsg += "- Veuillez renseigner votre email\n";
			firstError = "email1";
		}else if(!checkMail(myForm['email1'].value)) {
			alertMsg += "- Votre email n'est pas valide.\n ";
			firstError = "email1";
		}
		if (myForm['civilite2'].value=='0'){
			alertMsg += "- Veuillez renseigner la civilité de la personne hospitalisée.\n";
			firstError = "civilite2";
		}
		if (myForm['nom2'].value=='') {
			alertMsg += "- Veuillez renseigner le nom de la personne hospitalisée.\n";
			firstError = "nom2";
		}
		if (myForm['prenom2'].value=='') {
			alertMsg += "- Veuillez renseigner le prénom de la personne hospitalisée.\n";
			if(firstError=='') firstError = "prenom2";
		}
		if (myForm['dobd2'].value=='') {
			alertMsg += "- Veuillez renseigner le jour de naissance la personne hospitalisée.\n";
			if(firstError=='') firstError = "dobd2";
		}
		if (myForm['dobm2'].value=='') {
			alertMsg += "- Veuillez renseigner le mois de naissance de la personne hospitalisée.\n";
			if(firstError=='') firstError = "dobm2";
		}
		if (myForm['doby2'].value=='') {
			alertMsg += "- Veuillez renseigner l'année de naissance de la personne hospitalisée.\n";
			if(firstError=='') firstError = "doby2";
		}
		if (myForm['nsecu2'].value=='') {
			alertMsg += "- Veuillez renseigner le n° de sécurité sociale de la personne hospitalisée.\n";
			if(firstError=='') firstError = "nsecu2";
		}
		if(myForm['naturehospmedicale'].checked == false && myForm['naturehospchirurgicale'].checked == false && myForm['naturehospmaternite'].checked == false && myForm['naturehosppsychiatrie'].checked == false){
			alertMsg += "- Veuillez renseigner la nature de l'hospitalisation.\n";
			if(firstError=='') firstError = "naturehospmedicale";
		}
		if (myForm['deed'].value=='') {
			alertMsg += "- Veuillez renseigner le jour d'hospitalisation.\n";
			if(firstError=='') firstError = "deed";
		}
		if (myForm['deem'].value=='') {
			alertMsg += "- Veuillez renseigner le mois d'hospitalisation.\n";
			if(firstError=='') firstError = "deem";
		}
		if (myForm['deey'].value=='') {
			alertMsg += "- Veuillez renseigner l'année d'hospitalisation.\n";
			if(firstError=='') firstError = "deey";
		}
		if (myForm['nom3'].value=='') {
			alertMsg += "- Veuillez renseigner le nom de votre établissement.\n";
			firstError = "nom3";
		}
		if (myForm['nfiness'].value=='') {
			alertMsg += "- Veuillez renseigner le N°FINESS de votre établissement.\n";
			firstError = "nfiness";
		}
		if (myForm['cp'].value=='') {
			alertMsg += "- Veuillez renseigner le code postal de votre établissement.\n";
			firstError = "cp";
		}
		if (myForm['ville'].value=='') {
			alertMsg += "- Veuillez renseigner la ville de votre établissement.\n";
			firstError = "nom3";
		}
		if (myForm['fax'].value=='') {
			alertMsg += "- Veuillez renseigner le fax de votre établissement.\n";
			firstError = "fax";
		}


		if (alertMsg != ""){
			alert(alertMsg);
			myForm[firstError].focus();
		} else {
			if (confirm("Voulez-vous imprimer cette page ?")) {
			   window.print();
			}
			myForm.action = thisAction;
			myForm.submit();
		}
	}


	/* FONCTION DE COPIE SI ASSURE = HOSPITALISE */
	function checkSameHosp(assure){
		var myForm = document.pech;
		if (assure==1) {
			myForm['civilite2'].selectedIndex = myForm['civilite1'].selectedIndex;
			myForm['nom2'].value = myForm['nom1'].value;
			myForm['prenom2'].value = myForm['prenom1'].value;
			myForm['prenom2'].value = myForm['prenom1'].value;
			myForm['dobd2'].value = myForm['dobd1'].value;
			myForm['dobm2'].value = myForm['dobm1'].value;
			myForm['doby2'].value = myForm['doby1'].value;
			myForm['nsecu2'].value = myForm['nsecu1'].value;
		}
		if (assure==0){
			myForm['civilite2'].selectedIndex = myForm['civilite2'][0];
			myForm['nom2'].value = '';
			myForm['prenom2'].value = '';
			myForm['prenom2'].value = '';
			myForm['dobd2'].value = '';
			myForm['dobm2'].value = '';
			myForm['doby2'].value = '';
			myForm['nsecu2'].value = '';
		}
	}

	/* FONCTION DE GESTION DU TYPE D'HOSPITALISATION */
	function resetHosp (nom){
		var myForm = document.pech;
		myForm['naturehospmedicale'].checked = false;
		myForm['naturehospchirurgicale'].checked = false;
		myForm['naturehospmaternite'].checked = false;
		myForm['naturehosppsychiatrie'].checked = false;
		myForm[nom].checked = true;
	}


var nRubs;
/* FONCTION QUESTIONS/REPONSES */
function showRub(id, nRubs){
	hideAllRub(nRubs);
	if(document.all) doc = document.all[id];
	if(document.getElementById) doc = document.getElementById(id);

	doc.style.display = "block";
}
function hideRub(id){
	if(document.all) doc = document.all[id];
	if(document.getElementById) doc = document.getElementById(id);

	doc.style.display = "none";
}
function hideAllRub(nRubs){
	for(i=0; i<nRubs; i++){
		hideRub("niveau"+i);
	}
}

function popup() {
	window.open('popup.html','popup','width=450, height=400, toolbar=no, menubar=yes, location=no, resizable=yes, scrollbars=no, status=no');
}

var statenuevo = 0;
function changeFont(){
	NameDiv("Content");
	var balisesTitre = doc.getElementsByTagName("h4");
	var balisesTitrepara = doc.getElementsByTagName("h5");
	var balisesSousTitrepara = doc.getElementsByTagName("h6");
	var balisesBlockquote = doc.getElementsByTagName("blockquote");
	var balisesPara = doc.getElementsByTagName("p");
	var balisesList = doc.getElementsByTagName("li");
	var balisesTd = doc.getElementsByTagName("td");
	var balisesTh = doc.getElementsByTagName("th");
	var balisesEm = doc.getElementsByTagName("em");
	if(statenuevo == 1){

		for(h=0; h<balisesTitre.length; h++){
			balisesTitre[h].style.fontSize="22px";
		}

		for(i=0; i<balisesTitrepara.length; i++){
			balisesTitrepara[i].style.fontSize="17px";
		}

		for(j=0; j<balisesPara.length; j++){
			balisesPara[j].style.fontSize="13px";
		}

		for(k=0; k<balisesList.length; k++){
			balisesList[k].style.fontSize="13px";
		}

		for(l=0; l<balisesBlockquote.length; l++){
			balisesBlockquote[l].style.fontSize="13px";
		}

		for(m=0; m<balisesSousTitrepara.length; m++){
			balisesSousTitrepara[m].style.fontSize="15px";
		}

		for(n=0; n<balisesTd.length; n++){
			balisesTd[n].style.fontSize="13px";
		}

		for(o=0; o<balisesTh.length; o++){
			balisesTh[o].style.fontSize="13px";
		}

		for(p=0; p<balisesEm.length; p++){
			balisesEm[p].style.fontSize="13px";
		}

		statenuevo = 0;
	}
	else if(statenuevo == 0){

		for(h=0; h<balisesTitre.length; h++){
			balisesTitre[h].style.fontSize="15px";
		}

		for(i=0; i<balisesTitrepara.length; i++){
			balisesTitrepara[i].style.fontSize="12px";
		}

		for(j=0; j<balisesPara.length; j++){
			balisesPara[j].style.fontSize="11px";
		}
		for(k=0; k<balisesList.length; k++){
			balisesList[k].style.fontSize="11px";
		}

		for(l=0; l<balisesBlockquote.length; l++){
			balisesBlockquote[l].style.fontSize="11px";
		}

		for(m=0; m<balisesSousTitrepara.length; m++){
			balisesSousTitrepara[m].style.fontSize="12px";
		}

		for(n=0; n<balisesTd.length; n++){
			balisesTd[n].style.fontSize="11px";
		}

		for(o=0; o<balisesTh.length; o++){
			balisesTh[o].style.fontSize="11px";
		}

		for(p=0; p<balisesEm.length; p++){
			balisesEm[p].style.fontSize="11px";
		}

		statenuevo = 1;
	}
}

