//*****************************************************************//
//*********** (c) BY FREDERIC CHAPPE, 2004-2010 *******************//
//*****************************************************************//
var TheVersion = "v2.31 - last modification : October 26,2005";
var ErrorBackgroundColor = "yellow";
var ValidBackgroundColor = "white";

if(navigator.appName.substring(0,3) == "Net")	document.captureEvents(Event.MOUSEMOVE);	

//---------------------------------------------------------------------------
function RightClickOFF()
{
	document.oncontextmenu = ShowMessageRightClick;
	document.onclick = ShowMessageRightClick;
}
//---------------------------------------------------------------------------
function RightClickON()
{
	document.oncontextmenu = null;
	document.onclick = null;
}
//---------------------------------------------------------------------------
function ShowMessageRightClick()
{
	alert("(C)Copyright pdp-pgap.com");
	return(false);
}
//---------------------------------------------------------------------------
function ValidEmail(ObjectName,Lang)
{
	var Email = document.getElementById(ObjectName).value;
	Email = Email.toLowerCase();
	var at = Email.indexOf("@",1);
	var point = Email.indexOf(".",at+1);
	if  (Email.indexOf(' ') != -1 ) {
		ShowAlertNoSpaceEmail(Lang);
		document.getElementById(ObjectName).style.backgroundColor = ErrorBackgroundColor;
		return false;		
	}
	if ((at < 1) || (Email.length < 2) || (point < 2))
	{
		document.getElementById(ObjectName).style.backgroundColor = ErrorBackgroundColor;
		ShowAlertNoValidEmail(Lang);
		return false;
	}
	return true;
}
//---------------------------------------------------------------------------
function Init_ReceiveCode()
{
	document.getElementById('FirstName').style.backgroundColor = ValidBackgroundColor;
	document.getElementById('Name').style.backgroundColor = ValidBackgroundColor;
	document.getElementById('Organism').style.backgroundColor = ValidBackgroundColor;
	document.getElementById('Profession').style.backgroundColor = ValidBackgroundColor;
	document.getElementById('Texte').style.backgroundColor = ValidBackgroundColor;
	document.getElementById('Email').style.backgroundColor = ValidBackgroundColor;
	document.getElementById('BtnYes').style.backgroundColor = "eeeeee";
	document.getElementById('BtnNo').style.backgroundColor = "eeeeee";
}
//---------------------------------------------------------------------------
function ShowAlertCompleteFields(Lang)
{	
		if (Lang=="en") alert("Please, complete all yellow fields..."); 
		else            alert("Veuillez compléter tous les champs jaunes...");
}
//---------------------------------------------------------------------------
function TestObjectIfEmpty(ObjectName)
{
	document.getElementById(ObjectName).style.backgroundColor = ValidBackgroundColor;
	var Obj = document.getElementById(ObjectName);
	if (Obj.value.length == 0) {
		Obj.style.backgroundColor = ErrorBackgroundColor;
		return (true);
	}
	else return (false);
}
//---------------------------------------------------------------------------
function VerifDate(ObjectName,Lang)
{ 
	if (Lang=="en") Message = "The date must be in the form dd/mm/yyyy! ";
	else            Message = "La date doit être sous la forme jj/mm/aaaa !";

	var FormatDate = new RegExp("^[0-9]{2}/[0-9]{2}/[0-9]{4}$"); 
	var Obj = document.getElementById(ObjectName);
	if (Obj.value.match(FormatDate))  return true; 
    else {
		Obj.style.backgroundColor = ErrorBackgroundColor;
		alert (Message);
	}
	return false;
} 
//---------------------------------------------------------------------------
function ReplaceCar(Lang,ObjectName)
{
	if ((event.keyCode>=37) && (event.keyCode<=40)) return;
	
	var Chaine = new String;
	Chaine = document.getElementById(ObjectName).value;
	var Caract ="\\/:*?\"<>|',;{}()&^%$#!.+[]=";
	var Car="";
	for (i=0; i < Chaine.length; i++) {
		if (Chaine.charAt(i) == "[")      Car = "[";
		else if (Chaine.charAt(i) == "]") Car = "]";	
		else if (Chaine.charAt(i) == "+") Car = "+";	
		else if (Chaine.charAt(i) == "\\") Car = "\\";	
		else if (Chaine.charAt(i) == "/") Car = "/";
		else if (Chaine.charAt(i) == ":") Car = ":";	
		else if (Chaine.charAt(i) == "*") Car = "*";	
		else if (Chaine.charAt(i) == "?") Car = "?";	
		else if (Chaine.charAt(i) == "\"") Car = "\"";	
		else if (Chaine.charAt(i) == "<") Car = "<";	
		else if (Chaine.charAt(i) == ">") Car = ">";	
		else if (Chaine.charAt(i) == "|") Car = "|";	
		else if (Chaine.charAt(i) == "'") Car = "'";	
		else if (Chaine.charAt(i) == ",") Car = ",";	
		else if (Chaine.charAt(i) == ";") Car = ";";	
		else if (Chaine.charAt(i) == "{") Car = "{";	
		else if (Chaine.charAt(i) == "}") Car = "}";	
		else if (Chaine.charAt(i) == "(") Car = "(";	
	    else if (Chaine.charAt(i) == ")") Car = ")";	
		else if (Chaine.charAt(i) == "&") Car = "&";	
		else if (Chaine.charAt(i) == "^") Car = "^";	
		else if (Chaine.charAt(i) == "%") Car = "%";	
		else if (Chaine.charAt(i) == "$") Car = "$";	
		else if (Chaine.charAt(i) == "#") Car = "#";	
		else if (Chaine.charAt(i) == "!") Car = "!";	
		else if (Chaine.charAt(i) == ".") Car = ".";	
		else if (Chaine.charAt(i) == "=") Car = "=";
		
		
		
		
		if (Car != "") {
			if (Lang.toLowerCase() == "fr") alert("Les caractères suivants : \r\n" + Caract + "\r\n sont interdits.");
			else alert("The next caracters :\r\n" + Caract + "\r\n are forbidden.");
			Chaine = Chaine.replace(Car,"");
		}
		/*
		else {
			for (j=0; j < Caract.length; j++) {
				if (Chaine.charAt(i) == Caract.charAt(j)) {
					if (Lang.toLowerCase() == "fr") alert("Les caractères suivants " + Caract + " sont interdits.");
					else alert("The next caracters " + Caract + " are forbidden.");
					var reg=new RegExp("["+Caract+"]", "g");
					Chaine = Chaine.replace(reg,"");
				}
			}
		}
		*/
	}
	document.getElementById(ObjectName).value = Chaine;
}

//---------------------------------------------------------------------------
function Go(Link)
{
	window.location.href = Link;
}
//---------------------------------------------------------------------------
function EnglishOrder()
{
	var Text ="Deliveries of orders for Program related materials within Canada are usually within 5-10 business days.  As our standardized Programs cannot be provided without the necessary materials, please take this delivery time into consideration when you are scheduling your clients. We encourage clinicians to have on hand an extra copy of the materials in order to avoid delays in program implementation.\nPlease note that there are no refunds on materials, so please ensure you are ordering the correct materials for the Program you are offering. If an order requests both English and French, English materials must be ordered on the English Forms and French materials on the French Forms.\n\nThank you for your understanding.";
	//alert(Text);
	//win = open("../../files/orderform_english.pdf","");
}
//----------------------------------------------------------------------------
function FrenchOrder()
{
	var Text ="La livraison à l'intérieur du Canada des commandes de matériel relié au programme prend habituellement entre 5 et 10 jours ouvrables. Puisque notre programme standardisé ne peut être offert sans le matériel nécessaire, veuillez prendre ce délais de livraison en considération lors de la prise de rendez-vous avec vos clients. Nous encourageons les cliniciens à conserver une copie supplémentaire du matériel de façon à éviter les délais éventuels au niveau de l'application du programme.\n\nVeuillez noter que puisqu'il n'y a pas de remboursement sur le matériel, il est important de s'assurer que vous commandez le matériel approprié pour le programme que vous offrez. Si vous désirez commander du matériel en français et en anglais, le matériel en français doit être commandé avec le bon de commande français, tandis que le matériel anglais doit être commandé avec le bon de commande anglais.";
	alert(Text);
	win = open("../../files/orderform_french.pdf","");	
}
//----------------------------------------------------------------------------
function CenterPopUp(url, width, height)
{
	var top=(screen.height-height)/2;
  	var left=(screen.width-width)/2;
	var option = "width="+width+",height="+height+",top="+top+",left="+left+", status=no ,menubar=no ,resizable=yes ,scrollbars=1 ,toolbar=no ,location=no";
	
	var popup = window.open(url, "", option);
	popup.focus();
	if (!popup) {
		alert("This website uses 'PopUp'!");	
	}
	//return (popup);
}
//---------------------------------------------------------------------------
function ShowCopyright()
{
	document.write('&copy; 2004-2010 PDP Program Inc. | University Centre for Research on Pain and Disability');
	document.write(' | <a href="javascript:CenterPopUp(\'disclaimer.html\', 360, 420);" class="LinkWhiteText">Disclaimer</a>');
	
	
	document.write('<br> Developed By: <a href="mailto:infos@chappesoftware.com" class="LinkWhiteText">Fr&eacute;d&eacute;ric Chappe</a>');
}
//---------------------------------------------------------------------------
function SelectCountry(object, type, lang)
{
	var country = document.getElementById(object).value;
	if (!country) return;	
	var url = "../../search_clinician/";
	var fileName="";
	if (type=="pgap") fileName = "searchPGAP_";
	else fileName = "searchPDP_";
	
	if (country == "Canada")         url += fileName + "ca.php?lg="+lang;
	else if (country == "Ireland")   url += fileName + "ie.php?lg="+lang;
	else if (country == "USA")       url += fileName + "us.php?lg="+lang;
	else if (country == "Australia") url += fileName + "au.php?lg="+lang;
	else return;
	CenterPopUp(url, screen.availWidth, screen.availHeight);
}
//---------------------------------------------------------------------------