function submitRegisterFormOld(page, img){
		/*document.getElementById('registerFormError1').style.visibility='hidden';
		document.getElementById('registerFormBloc').style.display='none';
		document.getElementById('TB_window').style.backgroundImage='url(../images/'+img+')';
		document.getElementById('registerFormBlocDoc').style.display='block';	
		targetV1= 'ecoIntelligenceBrochure';*/
		alert('page='+page);
}

function submitRegisterForm(page, img){
var status = true;
var FirstName = document.forms["form1"].FirstName;
var LastName = document.forms["form1"].LastName;
var Email = document.forms["form1"].Email;
var ConfirmEmail = document.forms["form1"].ConfirmEmail;
var Company = document.forms["form1"].Company;
var Title = document.forms["form1"].Title;
var Interest = document.forms["form1"].Interest;
var InterestVal = '';
	if (FirstName.value== '' || LastName.value== '' ||  Company.value== '' ||  Title.value== '' || Email.value== '' || Email.value!=ConfirmEmail.value ){
		status = false;
	}
	
	if (status == true){status = validEmail(Email.value);}
	if (status == true){
			InterestVal = validerRadioSeul(Interest);
			if (InterestVal == false){
				status = false;
			}
	}

	if (status == true){
		saveRegister(FirstName.value, LastName.value, Email.value, Company.value, Title.value, InterestVal, page, img);
	}else{
		document.getElementById('registerFormError1').style.visibility='visible';
	}
}

function resetRegisterForm(img){
		document.getElementById('registerFormError1').style.visibility='hidden';
		document.getElementById('registerFormBloc').style.display='block';
		document.getElementById('TB_window').style.backgroundImage='url(../images/'+img+')';
		document.getElementById('registerFormBlocDoc').style.display='none';
		document.getElementById('menu').style.visibility='visible';
}

function saveRegister(F,L,E,C,T,I,P, img) {
	if (F!='' && L!='' && E!='' && C!='' && T!='' && I!='' && P!=''){
		var oXmlHttp = zXmlHttp.createRequest();
					oXmlHttp.open("get", "_SaveRegister.php?pa="+P+"&fi="+F+"&la="+L+"&em="+E+"&co="+C+"&ti="+T+"&in="+I+"&lang="+document.forms["form1"].lang.value, true);
						oXmlHttp.onreadystatechange = function () {
							if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200)  { 
								if (oXmlHttp.responseText==1)  {
									document.getElementById('registerFormError1').style.visibility='hidden';
									document.getElementById('registerFormBloc').style.display='none';
									document.getElementById('TB_window').style.backgroundImage='url(../images/'+img+')';
									document.getElementById('registerFormBlocDoc').style.display='block';	
									targetV1= 'ecoIntelligenceBrochure';
								}
							}       
						};
			 oXmlHttp.send(null);
	}
}

function loadAsMenu(image, cibleContenu){
var cibleImage = document.getElementById('menuTab');
var newH = new Number();
newH = Math.ceil(asMenuBlocsHeight[cibleContenu]/3)*150;
cibleImage.src='../images/'+image;
for (var i=0; i<asMenuBlocs.length;i++)	document.getElementById(asMenuBlocs[i]).style.visibility='hidden';
document.getElementById(cibleContenu).style.visibility='visible';
document.getElementById('blocContent').style.height=''+newH+'px';
}
function loadResMenu(image, cibleContenu){
var cibleImage = document.getElementById('menuTab');
cibleImage.src='../images/'+image;
for (var i=0; i<resMenuBlocs.length;i++)	document.getElementById(resMenuBlocs[i]).style.visibility='hidden';
document.getElementById(cibleContenu).style.visibility='visible';
}

function loadPhoto(cible, photo, nbItem, nomClasse){
	var cibleImage = document.getElementById(cible);
	cibleImage.src='../images/'+photo+'.jpg';
	for (var i=1; i<=nbItem;i++)	document.getElementById(photo.substr(0,(photo.length-1))+i).className=nomClasse;
	document.getElementById(photo).className=nomClasse+'On';
}


 function menurollover(id,statut,lien){
	var pix; var couleur;
		if(statut == 'on'){
			pix='0px -35px';
			couleur='#4e8bae';	
		}else{
			pix='0px 0px';
			couleur='#555555';	
		}
  		document.getElementById(id).style.backgroundPosition=pix;
  		document.getElementById(id+'Lien').style.color=couleur;
 }

function validSearch(){
	var status = true;
	str = document.forms["form2"].str;
			if (str.value.length <= 2 || str.value == 'SEARCH ON THIS SITE'){
			status = false;
			alert ('Please enter a valid search');
			str.focus();
			}
	if (status == true){
		document.forms["form2"].submit();
	}		
}

function validSearchSite(mess){
var status = true;
str = document.forms["form21"].q;
	if (str.value.length <= 2 || str.value == 'Search'){
		status = false;
		alert (mess);
		str.focus();
	}
	if (status == true){
		document.forms["form21"].submit();
	}	
}

function validQuickSearch(err){
	var status = true;
	type = document.forms["form1"].t;
	styl = document.forms["form1"].s;
			if (type.value == '' && (styl.value.length <= 2 ||  styl.value == '' || styl.value == 'Style Number') ){
			status = false;
			alert (err);
			}
	if (status == true){
		document.forms["form1"].submit();
	}		
}

function validLogin(object){
	var status = true;
			if (document.forms["form1"].login.value== '' || document.forms["form1"].pw.value == ''){
			status = false;
			document.getElementById(object).style.visibility='visible';
			document.forms["form1"].login.focus();
			}
	if (status == true){
		document.forms["form1"].submit();
	}
}

function validLost(object){
	var status = true;
			if (document.forms["form1"].login.value== ''){
			status = false;
			document.getElementById(object).style.visibility='visible';
			document.forms["form1"].login.focus();
			}
	if (status == true){
		document.forms["form1"].submit();
	}
}

function validSamples(object){
	var status = true;
			if (document.forms["form1"].lname.value== '' || document.forms["form1"].cie.value== '' || document.forms["form1"].phone.value== '' || document.forms["form1"].email.value== '' || document.forms["form1"].street.value== '' || document.forms["form1"].city.value== '' || document.forms["form1"].country.value== '' || document.forms["form1"].province.value== '' || document.forms["form1"].postalcode.value== '' ){
			status = false;
			document.getElementById(object).style.visibility='visible';
			}
	if (status == true){
		document.forms["form1"].submit();
	}
}


function validRegister(object){ /* a ameliorer (length pour pw, etc.)*/
	var status = true;
			if (document.forms["form1"].login.value== '' || document.forms["form1"].pw.value== '' || document.forms["form1"].pwConfirm.value== '' || document.forms["form1"].fname.value== '' || document.forms["form1"].lname.value== '' || document.forms["form1"].jobtitle.value== '' || document.forms["form1"].cie.value== '' || document.forms["form1"].phone.value== '' || document.forms["form1"].pw.value != document.forms["form1"].pwConfirm.value){
			status = false;
			/*document.forms["form1"].login.focus();*/
			}else{
			status = validEmail(document.forms["form1"].login.value);
			}
	if (status == true){
		document.forms["form1"].submit();
	}else{
		document.getElementById(object).style.visibility='visible';
	}
}

function validJob(object){
	var status = true;
			if (document.forms["form2"].file1.value== '' || document.forms["form2"].firstName.value== '' || document.forms["form2"].lastName.value== '' || document.forms["form2"].phoneNumber.value== ''){
			status = false;
			}
	if (status == true){
		document.forms["form2"].submit();
	}else{
		document.getElementById(object).style.visibility='visible';
	}
}


function saveNotes(id,occ,mess) {
	notesContent = document.form1.elements['notes'+occ].value;
	//if(notesContent){
	   var oXmlHttp = zXmlHttp.createRequest();
				oXmlHttp.open("get", "_Update.php?t=n&id="+id+"&n="+notesContent, true);
					oXmlHttp.onreadystatechange = function () {
						if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200)  { 
							if (oXmlHttp.responseText==1)  { 
								alert(mess);
							}
						}       
					};
		 oXmlHttp.send(null);
	//}
}


/*interact js & swf*/
function thisMovie(movieName) {
        var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? window[movieName] : document[movieName];
}
function makeCall(str) {
       thisMovie("tabPortfolio").asFunc(str);
}
function jsFunc(str) {
		makeCall(str);
        //document.inForm.inField.value = "AS > Hello " + str;
}

function addPortfolio(style,color,messOK,messNO) {
	   var oXmlHttp = zXmlHttp.createRequest();
				oXmlHttp.open("get", "_Add.php?t=p&s="+style+"&c="+color, true);
					oXmlHttp.onreadystatechange = function () {
						if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200)  { 
							if (oXmlHttp.responseText==1)  {
								jsFunc('refresh');
								document.getElementById('btnAddPort').style.visibility='hidden';
								document.getElementById('btnAskSample').style.left="0px";
								alert(messOK);
								/*recharge la page ou swf pour maj portfolio*/
							} else if (oXmlHttp.responseText==2)  { 
								alert(messNO);
							}
						}       
					};
		 oXmlHttp.send(null);
}

function addPortfolioFromList(style,color,messOK,messNO,btn) {
	   var oXmlHttp = zXmlHttp.createRequest();
				oXmlHttp.open("get", "_Add.php?t=p&s="+style+"&c="+color, true);
					oXmlHttp.onreadystatechange = function () {
						if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200)  { 
							if (oXmlHttp.responseText==1)  {
								jsFunc('refresh');
								document.getElementById(btn).style.visibility='hidden';
								alert(messOK);
								/*recharge la page ou swf pour maj portfolio*/
							} else if (oXmlHttp.responseText==2)  { 
								alert(messNO);
							}
						}       
					};
		 oXmlHttp.send(null);
}


function addPortfolioFromCS(mess) {
	alert(mess);
}

function ClearPortfolioContents(txt) {
       if (confirm(txt)) {
           window.location.href='_Clear.php?d=y';
       }
}

function GetSamplesPortfolio(txt) {
	var askSample = document.form1['askSample[]']; 
	var status = false;
	/*var req="";
	var k=1;
	for(var i=0; i < document.form1.askSample.length; i++){
		if(document.form1.askSample[i].checked){
			req += "as"+k+"="+document.form1.askSample[i].value+"&";
			k++;
		}
	}*/
	
	for (var i = 0; i < askSample.length; i++) {
		if(askSample[i].checked == true){
		status = true;
		break;
		}
	}

	if(status == false){ 
		alert(txt) ;
	}else{
	 	//window.location.href='getSamples.php?'+req;
		document.forms["form1"].submit();
	}
}


function validEmail(email){
var status = true;
		if ((email.indexOf('@',0)==-1) || (email.indexOf('.',0)==-1)) {
			status = false;
		}
return status;
}


function validerFormulaire(param1){
	var champValide = true;
	for (i=0 ; i < validerFormulaire.arguments.length ; i ++){
		if (document.forms[0][validerFormulaire.arguments[i]].value == "" || document.forms[0][validerFormulaire.arguments[i]].value == " "){
			alert ('Veuillez compléter le champs "'+validerFormulaire.arguments[i]+'"');
			document.forms[0][validerFormulaire.arguments[i]].focus();
			champValide = false;
			break;
		}
	}
	if (champValide == true){
		document.forms[0].submit();
	}		
}

function validSend(){
	if(document.form3.email == undefined)var email = ''; else var email = document.form3.email.value;
	if(document.form3.email_f == undefined)var email_f = ''; else var email_f = document.form3.email_f.value;
	if(document.form3.name == undefined)var name = ''; else var name = document.form3.name.value;
	var champValide = true;
		if(!email || !email_f || !name){
				alert ('Please complete all the fields!');
				champValide = false;
		}
			if (champValide == true){
				if ((email.indexOf('@',0)==-1) || (email.indexOf('.',0)==-1) || (email_f.indexOf('@',0)==-1) || (email_f.indexOf('.',0)==-1)) {
					alert ('Please complete the field Email correctly');
					champValide = false;
				}
			}
	if (champValide == true){
		document.forms["form3"].submit();
	}
}

function validerRadio(param1){
	var champValide = true;
	for (j=0 ; j< validerRadio.arguments.length ; j ++){
		var unchampValide = false;
		for (i=0; i<document.forms[0][validerRadio.arguments[j]].length ; i++) {
				if (document.forms[0][validerRadio.arguments[j]][i].checked){
					unchampValide = true;
					break;
				}
		}
		if (unchampValide == false){
			alert ('Veuillez compléter le champs "'+document.forms[0][validerRadio.arguments[j]][0].name+'"');
			document.forms[0][validerRadio.arguments[j]][0].focus();
			champValide = false;
			break;
		}
	}
	
	if (champValide == true){
		document.forms[0].submit();
	}
}

function validerRadioSeul(champs){
	var champValide = true;
	var unchampValide = false;
		for (i=0; i<champs.length ; i++) {
				if (champs[i].checked){
					unchampValide = champs[i].value;
					break;
				}
		}
		if (unchampValide == false){
			return false;
		}else{
			return unchampValide;
		}
}

function resetRadioSeul(champs){
		for (i=0; i<champs.length ; i++) {
				champs[i].checked='';
		}
}

function showPage(show,nb){
	var p = show.substr(0,1);
	var s = show.substr(1,2);
for (i=1; i<=nb ; i++) {
	document.getElementById('n'+i).style.visibility='hidden';
	document.getElementById('d'+i).style.visibility='hidden';
}
document.getElementById(show).style.visibility='visible';
document.getElementById('n'+s).style.visibility='visible';
}

function imgOn(name,img) {
        if (document.images) {
            document[name].src = "../images/"+ img;
        }
}
function imgOff(name,img) {
        if (document.images) {
            document[name].src = "../images/"+ img;
        }
}

function showO(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility='visible';
  } else if (document.all) {
    document.all[object].style.visibility='visible';
  }
}
function hideO(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility='hidden';
  } else if (document.all) {
    document.all[object].style.visibility='hidden';
  }
}

function changeZindex(object,niv) {
document.getElementById(object).style.zIndex = niv;
}
