﻿function showHide(element_id) {
	if (document.getElementById && document.getElementById(element_id) && document.getElementById(element_id).style) {
		var menu  = document.getElementById(element_id);
		var arrow = document.getElementById(element_id + '_arrow');
		if (menu.style.display == "block") {
			menu.style.display = "none";
			if (arrow.src) { arrow.src = arrow.src.replace("down","right"); }
		}
		else {
			menu.style.display = "block";
			if (arrow.src) { arrow.src = arrow.src.replace("right","down"); }
		}
	}
}

function changeHeight(new_height) {
	document.getElementById('banner').style.height = new_height + 'px';
}


//*******************************************************************
//			VALIDATE FEEDBACK FORM
//*******************************************************************

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1) {
		   alert("Invalid E-mail Address");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
		   alert("Invalid E-mail Address");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
		    alert("Invalid E-mail Address");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1) {
		    alert("Invalid E-mail Address");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {
		    alert("Invalid E-mail Address");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1) {
		    alert("Invalid E-mail Address");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1) {
		    alert("Invalid E-mail Address");
		    return false;
		 }

 		 return true;				
	}

function ValidateForm(){
	var frommailID=document.feedback.frommail
	var MessageID=document.feedback.Message
	var NatureID=document.feedback.Nature
	var n1 = document.getElementById('one')
	var n2 = document.getElementById('two')
	var n3 = document.getElementById('three')
	
	valid = true;
	 
	if ((frommailID.value==null)||(frommailID.value=="")) {
		alert("Please Enter your Email Address");
		frommailID.focus();
		return false;
	}
	
	if (echeck(frommailID.value)==false) {
		frommailID.value="";
		frommailID.focus();
		return false;
	}
	
	if ((n1.checked==false) && (n2.checked==false) && (n3.checked==false)) {
		alert("Please choose the nature of your message");
		return false;
	}
	
	if (MessageID.value=="") {
		alert("Please enter your message");
		MessageID.focus();
		return false;
	}
		return valid;
 }
 
 
 function echeckfr(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Adresse de courriel inadmissible")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Adresse de courriel inadmissible")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Adresse de courriel inadmissible")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Adresse de courriel inadmissible")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Adresse de courriel inadmissible")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Adresse de courriel inadmissible")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Adresse de courriel inadmissible")
		    return false
		 }

 		 return true					
	}

function ValidateFormFR(){
	var frommailID=document.feedbackfr.frommail
	var MessageID=document.feedbackfr.Message
	var NatureID=document.feedbackfr.Nature
	var n1 = document.getElementById('one')
	var n2 = document.getElementById('two')
	var n3 = document.getElementById('three')
	
	valid = true;
	 
	if ((frommailID.value==null)||(frommailID.value=="")) {
		alert("Veuillez tapper votre courriel");
		frommailID.focus();
		return false;
	}
	
	if (echeckfr(frommailID.value)==false) {
		frommailID.value="";
		frommailID.focus();
		return false;
	}
	
	if ((n1.checked==false) && (n2.checked==false) && (n3.checked==false)) {
		alert("Veuillez préciser la nature de votre message");
		return false;
	}
	
	if (MessageID.value=="") {
		alert("Veuillez entrer votre message");
		MessageID.focus();
		return false;
	}
		return valid;
 }

