function isEmail(string)
{
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$/) != -1)
		return true;
	else
		return false;
}

function isPhone(string)
{
	if (string.search(/^((\(?[1-9][0-9][0-9]\)?)?\s?[1-9][0-9][0-9]\s?\d{4})?$/) != -1)
		return true;
	else
		return false;
}

function isNumeric(sText)
{
	var ValidChars = "0123456789.-";
	var isNumber = true;
	var Char;

	if(sText.length == 0)
		return false;

	for (i = 0; i < sText.length && isNumber == true; i++)
	{
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1)
			isNumber = false;
	}
	return isNumber;
}

function isEmpty(aTextField)
{
	if((aTextField.value.length == 0) || (aTextField.value == null))
	{
		return true;
	}
	else { return false; }
}

/*
Submit Once form validation- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

function submitOnce(theform)
{
	//document.body.style.cursor = "wait";
	//if IE 4+ or NS 6+
	if (document.all || document.getElementById)
	{
		//screen thru every element in the form, and hunt down "submit" and "reset"
		for (i=0; i < theform.length; i++)
		{
			var tempobj = theform.elements[i];
			if(tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset" || tempobj.type.toLowerCase() == "button")
				//disable them
				tempobj.disabled = true;
		}
	}
}

//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

var highlightcolor = "lightyellow";

var ns6 = document.getElementById && !document.all;
var previous = '';
var eventobj;

//Regular expression to highlight only form elements
var intended = /INPUT|TEXTAREA|SELECT|OPTION/;

//Function to check whether element clicked is form element
function checkel(which)
{
	if (which.style && intended.test(which.tagName))
	{
		if (ns6 && eventobj.nodeType == 3)
			eventobj = eventobj.parentNode.parentNode;
		return true;
	}
	else
		return false;
}

//Function to highlight form element
function highlight(e)
{
	eventobj = ns6? e.target : event.srcElement;
	if (previous!='')
	{
		if (checkel(previous))
			previous.style.backgroundColor = '';
		previous = eventobj;

		if (checkel(eventobj))
			eventobj.style.backgroundColor = highlightcolor;
	}
	else
	{
		if (checkel(eventobj))
			eventobj.style.backgroundColor = highlightcolor;
		previous = eventobj;
	}
}

//progression bar
var Tp_MaxIdx = 10;
var Tp_Idx = 0;
var passed_text;

function openWindow()
{
	// this window is being called on every page request. In order for it to open, only when Actualiser() is being called, 
	// check if Tp_Idx greater than 0.
	if(Tp_Idx > 0)
		Tempo = window.open('', 'Tempo', 'toolbar=0,width=200,height=100');
}

function Barre()
{
	text = '';
	for (i=0 ; i < parseInt(Tp_Idx/Tp_MaxIdx *10); i++)
	{
		text += '';
	}
	return text;
}

function Affichage(text, param)
{
	Tempo.document.close();
	Tempo.document.open();
	Tempo.document.write(text, param);
}

function Actualiser(text)
{
	if(text == undefined)
		passed_text = "";
	else
		passed_text = text;

	Tp_Idx++;
	if(Tp_Idx == 1)
		openWindow();

	Information =' <p>Loading in progress...<br>';
	Information += Math.round(Tp_Idx/Tp_MaxIdx * 100) + '%<br>';
	Information += "<font color='#0000FF'>" +Barre()+ "</font></p>";
	Affichage(Information, passed_text);
}

//Actualiser();
//Tempo.close();

var win;
function OpenWindow(mypage, myname, w, h, scroll)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	parameters = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+'';
	win = window.open(mypage, myname, parameters);
	if (parseInt(navigator.appVersion) >= 4)
	{
		win.focus();
	}
}

//Close pop-up after leaving the page
function exit()
{
	 if (win != null)
	 	win.close()
}

// toggle visibility 
function toggle(targetId)
{
	if(document.getElementById)
	{
		target = document.getElementById(targetId);
		if(target.style.display == "none")
			target.style.display = "";
		else
			target.style.display = "none";
	}
}