function case_rouge(ID)
{
document.getElementById(ID).style.backgroundColor='#F7AFB6';
}


function case_blanche(ID)
{
document.getElementById(ID).style.backgroundColor='#FFFFFF';
}


function case_grise(ID)
{
document.getElementById(ID).style.backgroundColor='#EDEDED';
}


function popupcentree(page,largeur,hauteur,options)
{
	var top= 40 ///(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2; 	
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options).focus();

}


function isEmpty(str) {
  if (str==null || str=="")
    return true;
  return false;
}


function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	} else {
		countfield.value = maxlimit - field.value.length;
	}
}


function details(id)
{
var mt = document.getElementById(id);
	if(mt.style.display=='none') {
			mt.style.display='block';	
	}
	else{
		mt.style.display='none';	
	}
}


function details2(id)
{
var mt = document.getElementById(id);
	if(mt.style.display=='none') {
			mt.style.display='block';
			document.getElementById('detail'+id.substr(0,1)).src = 'img_fabricants_regionaux/icon_sfr/ico_sui2.gif';	
	}
	else{
		mt.style.display='none';
		document.getElementById('detail'+id.substr(0,1)).src = 'img_fabricants_regionaux/icon_sfr/ico_sui.gif';	
	}
}


function details_on(id)
{
var mt = document.getElementById(id);
 mt.style.display='block';
 document.getElementById('detail'+id.substr(0,1)).src = 'demo//icon_sfr/ico_sui2.gif';
}

function details_off(id)
{
var mt = document.getElementById(id);
 mt.style.display='none';
 document.getElementById('detail'+id.substr(0,1)).src = 'img_fabricants_regionaux/icon_sfr/ico_sui.gif';
}

function isValidExtention(filename, validExtentions)
{
 var valid = false;
 for(i = 0;i < validExtentions.length;i++)
 {
 		if(filename == validExtentions[i])
			
			valid = true;
 }
	return valid;

}


function valid_prod(){
case_blanche('Nom_produit_fr');
case_blanche('Desc_fr');
case_blanche('Nom_produit_en');
case_blanche('Desc_en');
case_blanche('Photo1');

	var $msg='';
	var validExtention1 = new Array(".jpg",".gif"); 
	
	if(document.getElementById("Version").value=='F')
	{
		if((document.form1.Nom_produit_fr.value==''))
		{
				$msg+="-> Nom du produit/service en français\n";
				case_rouge('Nom_produit_fr');
		}
		if((document.form1.Desc_fr.value==''))
		{
				$msg+="-> La description du produit en français\n";
				case_rouge('Desc_fr');
		} 
		
		if((document.form1.Photo1.value==''))
		{
			//	$msg+="-> L'image\n";
			//	case_rouge('Photo1');
		}
	}
	if(document.getElementById("Version").value=='A')
	{
		if((document.form1.Nom_produit_fr.value==''))
		{
				$msg+="-> Nom du produit/service en français\n";
				case_rouge('Nom_produit_fr');
		}
		if((document.form1.Desc_fr.value==''))
		{
				$msg+="-> La description du produit en français\n";
				case_rouge('Desc_fr');
		} 
		if((document.form1.Nom_produit_en.value==''))
		{
				$msg+="-> Nom du produit/service en anglais\n";
				case_rouge('Nom_produit_en');
		}
		if((document.form1.Desc_en.value==''))
		{
				$msg+="-> La description du produit en anglais\n";
				case_rouge('Desc_en');
		} 		
		if((document.form1.Photo1.value==''))
		{
			//	$msg+="-> L'image\n";
			//	case_rouge('Photo1');
		}
	}
	var extention1 = document.form1.Photo1.value.slice(-4);
	if(!isEmpty(document.form1.Photo1.value))
	{
		if(!isValidExtention(extention1,validExtention1))
		{
			$msg+="-> L'image doit être de format: ( .jpg ou .gif )\n";
			case_rouge('Photo1');
		}
	
	}
	
	if (!isEmpty($msg)){
		alert('Les informations suivantes sont obligatoires: \n'+$msg)
		return false;
	}
	document.form1.Submit.disabled='true';
	return true;
}

function valid_profil(){
var $msg='';
case_blanche('Nom_entreprise');
case_blanche('Adresse');
case_blanche('Ville');
case_blanche('Code_postal');
case_blanche('Responsable');
case_blanche('Email');
case_blanche('Telbur');
case_blanche('Province');
case_blanche('Pays');
case_blanche('Pass');
case_blanche('Desc_fr');

if((document.form1.Nom_entreprise.value==''))
{
	$msg+="-> Entreprise/Organisme\n";
	case_rouge('Nom_entreprise');
}

if((document.form1.Adresse.value==''))
{
	$msg+="-> Adresse #1\n";
	case_rouge('Adresse');
}

if((document.form1.Ville.value==''))
{
	$msg+="-> Ville\n";
	case_rouge('Ville');
}

if((document.form1.Code_postal.value==''))
{
	$msg+="-> Code postal\n";
	case_rouge('Code_postal');
}

if((document.form1.Responsable.value==''))
{
	$msg+="-> Contact\n";
	case_rouge('Responsable');
}

if((document.form1.Email.value==''))
{
	$msg+="-> Le Courriel destiné au public\n";
	case_rouge('Email');
}

if((document.form1.Telbur.value==''))
{
	$msg+="-> Le téléphone d'affaire\n";
	case_rouge('Telbur');
}

if((document.form1.Province.value==''))
{
	$msg+="-> Province\n";
	case_rouge('Province');
}
if((document.form1.Pays.value==''))
{
	$msg+="-> Pays\n";
	case_rouge('Pays');
}

if((document.form1.Pass.value==''))
{
	$msg+="-> Votre mot de passe\n";
	case_rouge('Pass');
}

if((document.form1.Desc_fr.value==''))
{
	$msg+="-> La présentation de l'entreprise/organisme\n";
	case_rouge('Desc_fr');
}

	if (!isEmpty($msg)){
		alert('Les informations suivantes sont obligatoires: \n'+$msg)
		return false;
	}
	document.form1.Submit.disabled='true';
	return true;
}