// these scripts are to be available to all pages on the site

//place gloabal variables here
var d = document;


// based on script by Paul Bellows; mod. by Avid Technology, Inc.
function evenColumns() {
	if (d.getElementById) { // determine if browser uses DOM
		var contentHeight = d.getElementById('ContentBody'); //middle column
		var rightHeight = d.getElementById('Rightside'); //right column
		var leftHeight = d.getElementById('Leftside'); //left column
		if (rightHeight != null) { //check if right column exists; set heights to largest
			//alert('I detect three columns/nNow, which one is the highest?');
			if ((contentHeight.offsetHeight >= rightHeight.offsetHeight) && (contentHeight.offsetHeight >= leftHeight.offsetHeight)) {
				//alert('content div is the highest');
				leftHeight.style.height = (contentHeight.offsetHeight) + 'px';
				rightHeight.style.height = (contentHeight.offsetHeight) + 'px';
				contentHeight.style.height = (contentHeight.offsetHeight) + 'px';
			} else if ((rightHeight.offsetHeight >= contentHeight.offsetHeight) && (rightHeight.offsetHeight >= leftHeight.offsetHeight)) {
				//content not the hightest; checking others...
				//alert('right div is the highest');
				leftHeight.style.height = (rightHeight.offsetHeight) + 'px';
				rightHeight.style.height = (rightHeight.offsetHeight) + 'px';
				contentHeight.style.height = (rightHeight.offsetHeight) + 'px';
			} else { //ok, only one column left to be the highest (yup, the left one)
				//alert('left div is the highest');
				leftHeight.style.height = (leftHeight.offsetHeight) + 'px';
				rightHeight.style.height = (leftHeight.offsetHeight) + 'px';
				contentHeight.style.height = (leftHeight.offsetHeight) + 'px';
			}
				
		} else { //assume only two columns; set heights to largest
			if (contentHeight.offsetHeight >= leftHeight.offsetHeight) {
				leftHeight.style.height = (contentHeight.offsetHeight) + 'px';
			}
		}
	}
}


//event firings
window.onload = function() {
	evenColumns();
}

window.onresize = function() {
	evenColumns();
}


function _checkContactUs()	{
	//	This is the form
	var myForm					= document.contactForm;
	//	These are the fields to check
	var k_theName				= myForm.theName.value;
	var k_theSurName			= myForm.theSurName.value;
	var k_thePosition			= myForm.thePosition.value;
	var k_theCompany			= myForm.theCompany.value;
	var k_theAddress			= myForm.theAddress.value;
	var k_theCity				= myForm.theCity.value;
	var k_theProv				= myForm.theProv.value;
	var k_theCAP				= myForm.theCAP.value;
	var k_thePhone				= myForm.thePhone.value;
	//var k_theFax				= myForm.theFax.value;
	var k_theEmail				= myForm.theEmail.value;
	var k_settoreAppartenenza	= myForm.settoreAppartenenza.value;
	var k_theCustomer			= myForm.theCustomer.value;
	var k_theProduct			= myForm.theProduct.value;
	var k_theBuy				= myForm.theBuy.value;
	var k_theContactMe			= myForm.theContactMe.value;
	var k_theKnowledge			= myForm.theKnowledge.value;

	//	regExp
	var FiltroMail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	var FiltroNum	= /^([0-9])+$/;

	//	... and now, check all!
	var errors	= "";
	if (k_theName == "")	{
		alert('Inserisci il tuo nome');
		myForm.theName.focus();
		return;
	}
	if (k_theSurName == "")	{
		alert('Inserisci il tuo cognome');
		myForm.theSurName.focus();
		return;
	}
	if (k_thePosition == "")	{
		alert('Inserisci la tua posizione');
		myForm.thePosition.focus();
		return;
	}
	if (k_theCompany == "")	{
		alert('Inserisci la tua societą');
		myForm.theCompany.focus();
		return;
	}
	if (k_theAddress == "")	{
		alert('Inserisci l\'indirizzo');
		myForm.theAddress.focus();
		return;
	}
	if (k_theCity == "")	{
		alert('Inserisci la cittą');
		myForm.theCity.focus();
		return;
	}
	if (k_theProv == "")	{
		alert('Inserisci la provincia');
		myForm.theProv.focus();
		return;
	}
	if (FiltroNum.test(k_theCAP) == false) {
		alert('Inserisci una CAP valido');
		myForm.theCAP.focus();
		return;
	}
	if (FiltroNum.test(k_thePhone) == false) {
		alert('Inserisci un numero di telefono valido');
		myForm.thePhone.focus();
		return;
	}
	if (FiltroMail.test(k_theEmail) == false) {
		alert('Inserisci una mail valida');
		myForm.theEmail.focus();
		return;
	}
	if (k_settoreAppartenenza == "")	{
		alert('Inserisci un settore di competenza');
		myForm.settoreAppartenenza.focus();
		return;
	}
	if (k_theCustomer == "")	{
		alert('Specifica se sei gią cliente Avid');
		myForm.theCustomer.focus();
		return;
	}
	if (k_theProduct == "")	{
		alert('Specifica un prodotto di interesse');
		myForm.theProduct.focus();
		return;
	}
	if (k_theBuy == "")	{
		alert('Specifica una previsione di acquisto');
		myForm.theBuy.focus();
		return;
	}
	if (k_theContactMe == "")	{
		alert('Specifica se vuoi essere contattato');
		myForm.theContactMe.focus();
		return;
	}
	if (k_theKnowledge == "")	{
		alert('Specifica come sei venuto a conoscenza di Avid');
		myForm.theKnowledge.focus();
		return;
	}
	myForm.submit();
}