// CHANGING THE COLOR OF THE SCROLLBAR : Begin
/*function changeScrollbarColor(C) {
if (document.all) {
document.body.style.scrollbarBaseColor = C;
   }
}
changeScrollbarColor('#490c0a');*/
// CHANGING THE COLOR OF THE SCROLLBAR : End

function ChangeStyle(id)
{
	for (i=0; i<=10; i++){
		if (i==id){
			identity=document.getElementById("link"+id);
			identity.style.color='#ffffff';
			identity.style.background='url(_images/navleftbkgon.gif) no-repeat'
			document.ChangingStyle.WhichId.value=id;
		}
		else{
			identity=document.getElementById("link"+i);
			identity.style.color='#fe860c';
			identity.style.background='url(_images/navleftbkgoff.gif) no-repeat'
		}
	}
}

function RollOver(Id, Status){
	var LinkId = "link"+Id;
	var StayOn = document.ChangingStyle.WhichId.value;
	if (StayOn.length == 0){
		StayOn =0;
	}
	
	
	if (Status=="ON"){
		identity=document.getElementById(LinkId);
		identity.style.color='#ffffff';
		identity.style.background='url(_images/navleftbkgon.gif) no-repeat'
	}
	else{
		//alert(StayOn);
		if (StayOn==Id){
			identity=document.getElementById("link"+Id);
			identity.style.color='#ffffff';
			identity.style.background='url(_images/navleftbkgon.gif) no-repeat'
		
		}
		else{
			identity=document.getElementById(LinkId);
			identity.style.color='#fe860c';
			identity.style.background='url(_images/navleftbkgoff.gif) no-repeat'
		}
	}
}	

function getObj(name){
    //alert(name);
	if (document.getElementById){
	    //alert(document.getElementById("Containertxt_email"))
    	return document.getElementById(name);
    	// alert(name);
  	}
  	else if (document.all){
    	return document.all[name];
  	}
  	else if (document.layers){
    	return document.layers[name];
  	}
  	else return false;
}


function emailcheck(obj, container){
	var email = obj
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
		return (true);
	else {
	    getObj(container).innerHTML='<span class="textAlertJS">Votre adresse email est incorrect</span>';
	    return (false);
	}
}

// Function to check the validity of an email address
function checkEmail(email){
    
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email))
            return (true);
            
            return (false);
}

// Function to check field value
function ValidateField(strFieldName){
        var tmpStr = trim(strFieldName.value);    
    if (tmpStr.length>0)
        // Field contains a value
        return true;
    else 
        // Field is empty
        return false;
    
}


function validateForm()
{
    var allowSubmit = false;    var errorText = 'Please fill-in required fields :<br>';
    var requiredMsg = '';
    
    if(!ValidateField(getObj('txtName')))
    {   
        requiredMsg += '<li><b>Name</b></li>';    
        allowSubmit = false;
    }
    
    if(!ValidateField(getObj('txtEmail')))
    {   
        requiredMsg += '<li><b>Email</b></li>';        
        allowSubmit = false;
    }
    else
    {    
        if(!checkEmail(getObj('txtEmail').value))
        {   
            requiredMsg += '<li><b>Invalid email address</b></li>';            
            allowSubmit = false;
        }		
    }        
    
    if(!ValidateField(getObj('txtMessage')))
    {        
        requiredMsg += '<li><b>Message</b></li>';         
        allowSubmit = false;
    }        
    
    if(requiredMsg != '')
    {
        errorText += requiredMsg;
        getObj('ContainerErrorMsg').innerHTML=errorText;
        allowSubmit = false;
    }
    else
    {
        allowSubmit = true;
    }
        
    return allowSubmit;			
}

function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = / +/g;
   temp = temp.replace(obj, " ");
   if (temp == " ") { temp = ""; }
   return temp;
}

var Timer;
var Pas = 3;
function moveLayer(Sens, Support, Contenu) {
	Objet=document.getElementById(Contenu);
	if( parseInt(Objet.style.top) + (Pas*Sens)>0 )  {
		clearTimeout(Timer);
	}
	else if(parseInt(Objet.style.top) + (Pas*Sens)<-(Objet.offsetHeight-document.getElementById(Support).offsetHeight)) {
		clearTimeout(Timer);
	}
    else {
        Objet.style.top = (parseInt(Objet.style.top) + (Pas*Sens)) + "px";
	}
	Timer = setTimeout("moveLayer('" + Sens + "', '" + Support + "','" + Contenu + "');", 30);
}	