//Makes red borders of the box
function ShowDate(Language)
{
	if (Language=="En") {
    var isMonth = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var isDay = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
	today = new Date() ;
	aDate=today.getDate();
	document.write(isDay[today.getDay()]+", "+isMonth[today.getMonth()]+" "+aDate);
	return true;
	}
	if (Language=="Fr") {
    var isMonth = new Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
	var isDay = new Array("Dimanche", "Lundi", "mardi", "mercredi", "Jeudi", "Vendredi", "samedi", "dimanche");
	today = new Date() ;
	aDate=today.getDate();
	document.write(isDay[today.getDay()]+", "+isMonth[today.getMonth()]+" "+aDate);
	return true;
	}
}	

function red_it(thisbox)
{
	thisbox.className = (thisbox.className == 'tbox')?'tboxr':'tbox';
}

function bookmark(address,sitename) {
  if (window.sidebar) {
    window.sidebar.addPanel(sitename, address,"");
  } else if( document.all ) {
    window.external.AddFavorite(address, sitename);
  } else if( window.opera && window.print ) {
    return true;
  }
}

//Validate the Quote form
function validateForm(FormVal)
{
	trimAll(FormVal);
		if(FormVal.companyname.value == "")
	{
		alert("S'il vous plaît, écrivez le nom.");
		FormVal.companyname.focus();
		return false;
	}
	if(FormVal.email.value == "")
	{
		alert("S'il vous plaît entrez votre adresse électronique.");
		FormVal.email.focus();
		return false;
	}
	if(!CheckEmail(FormVal.email.value))
	{
		alert("S'il vous plaît entrer une adresse email valide.");
		FormVal.email.focus();
		return false;
	}
	if(FormVal.PhAreaCode.value == "" || FormVal.PhPrefix.value == "" || FormVal.PhSufix.value == "")
	{
		alert("S'il vous plaît entrer un numéro de téléphone valide.");
		FormVal.PhAreaCode.focus();
		return false;
	}
    if(FormVal.Name='ServicesQuote')
    {
	    FormVal.action = 'servicesquote.php';
		FormVal.submit();  
	}
}

function validateFormJoin(FormVal)
{
	trimAll(FormVal);
		if(FormVal.full_name.value == "")
	{
		alert("Please enter your Name.");
		FormVal.firstname.focus();
		return false;
	}
	if(FormVal.email.value == "")
	{
		alert("Please enter your Email Address.");
		FormVal.email.focus();
		return false;
	}
	if(!CheckEmail(FormVal.email.value))
	{
		alert("Please enter a valid Email Address.");
		FormVal.email.focus();
		return false;
	}
	if(FormVal.pass1.value =="")
	{
		alert("Please choose a password");
		FormVal.pass1.value="";
		FormVal.pass1.focus();
		return false;
	}
	
	if(FormVal.pass2.value =="")
	{
		alert("Please re-enter the password");
		FormVal.pass2.value="";
		FormVal.pass2.focus();
		return false;
	}
	if(FormVal.pass1.value != FormVal.pass2.value)
	{
		alert("The passwords don't match.");
		FormVal.pass1.value="";
		FormVal.pass2.value="";
		FormVal.pass1.focus();
		return false;
	}



    FormVal.action = 'register.php';
	FormVal.submit();
}

function validateFormSub(FormVal)
{
	trimAll(FormVal);
		if(FormVal.full_name.value == "")
	{
		alert("Please enter your Name.");
		FormVal.firstname.focus();
		return false;
	}
	if(FormVal.email.value == "")
	{
		alert("Please enter your Email Address.");
		FormVal.email.focus();
		return false;
	}
	if(!CheckEmail(FormVal.email.value))
	{
		alert("Please enter a valid Email Address.");
		FormVal.email.focus();
		return false;
	}

    FormVal.action = 'subscribe-query.php';
	FormVal.submit();
}

function validateFormUnsub(FormVal)
{
	trimAll(FormVal);
	if(FormVal.email.value == "")
	{
		alert("Please enter your Email Address.");
		FormVal.email.focus();
		return false;
	}
	if(!CheckEmail(FormVal.email.value))
	{
		alert("Please enter a valid Email Address.");
		FormVal.email.focus();
		return false;
	}

    FormVal.action = 'subscribe-query.php';
	FormVal.submit();
}
//additional functions
function trimAll(FormName)
{
	for(var i=0; i < FormName.elements.length; i++)
	{
	if(FormName.elements[i].type == "textarea" || FormName.elements[i].type == "text" || FormName.elements[i].type == "password")
		{
		FormName.elements[i].value = FormName.elements[i].value.replace(/^\s+|\s+$/g,"");
		}
	}
}



//-------------------------------------------------------------------------
function CheckEmail(EmailStr)
{
	var email_pattern = /^[a-z][a-z0-9_\.\-]*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*\.[a-z]+$/i;
	return(email_pattern.test(EmailStr));
}