
var _lang_fields_required =  ( _lang == 'fr' ? 'Veuillez noter que tous les champs obligatoires doivent être remplis.' : 'Please fill all the resquested fields.' );
var _lang_error_email =  ( _lang == 'fr' ? 'L\'adresse courriel ne semble pas être valide. Merci de recommencer.' : 'The email address is syntactically invalid. Please try again.' );



var typesize = 11;
var ElementID = 'contenu';
var AddNum = 0;
var ftSz = "ftSz";
var tagname = new Array();
var pgload = false;
var BckTopElement = "backtotop";
	var BckTopElementydef = 0;
	var BckTopElementy = 0;
var ElementBlank = "backtoblank";
	var ElementBlanky = 0;
var formulaire = false;
var name_formulaire = '';
var color = new Array('#fff','#f8dede');

/*
		tagname[0] = new Array('h2',20,null,20); //26
		tagname[1] = new Array('p',20,'sh2',20); //26
		tagname[1] = new Array('li',8,null,8); //26
		tagname[2] = new Array('h3',8,null,8); //13
		tagname[3] = new Array('p',8,null,8);  //13
*/
		tagname[0] = new Array('h2',20,null,26,16); //26
		tagname[1] = new Array('p',10,null,13,12);  //13
		tagname[2] = new Array('td',10,null,13,12);  //13
		tagname[3] = new Array('ul',10,null,13,12);  //13
		tagname[4] = new Array('li',10,null,13,12);  //13


		/*tagname[1] = new Array('li',8,null,13); //26
		tagname[2] = new Array('h3',8,null,13); //13
		tagname[3] = new Array('p',8,null,13);  //13
		tagname[4] = new Array('td',8,null,13);  //13
		tagname[5] = new Array('ul',8,null,13);  //13*/


var DisclaimerContent = '';
var DisclaimerContentDepli = false;
var DisclaimerArrowIn = 'right top';
var DisclaimerArrowOut = 'right -21px';
var DisclaimerArrow = '';

var AdvanceSearchContent = '';
var AdvanceSearchContentDepli = false;
var AdvanceSearchArrowIn = 'right top';
var AdvanceSearchArrowOut = 'right -21px';
var AdvanceSearchArrow = '';



window.onload = function(){
	pgload = true;
	linktocorecthref();
	getFontSize(ElementID);

	DisclaimerContent = document.getElementById('disclaimer');
	DisclaimerArrow = document.getElementById('disclaimer_arrow');
}


window.onscroll = window.onresize = function(){
	if(pgload){
		backtotop2();
	}
}

function FormContactus(){
	nameform = 'formcontactus';
	name_formulaire = nameform;
	formulaire = document.forms[name_formulaire];
	champs_form = new Array('Contact','Email','Comments');

	if(validform_champ(champs_form)){

		formulaire.submit();

	}
}

/*
cpassword
password
username
interest
specialty
postal
country
state
city
address
email
familyname
firstname

*/

// Fonction validform(); Valide le formulaire;

function validform(nameform){
	name_formulaire = nameform;
	formulaire = document.forms[name_formulaire];
	champs_form = new Array('firstname','lastname','email','address','city','country','postal','specialty','interest','password','cpassword');

	if(validform_champ(champs_form)){

		formulaire.submit();

	}

}


function alert_form_empty(){
	alert( _lang_fields_required );
}

// Fonction validform_champ(); Valide les champs passÃƒÂ© par l'array "champs_form";

function validform_champ(champs_form){

	formulaire = document.forms[name_formulaire];

	returnval = true;

	for(i=0;i<champs_form.length;i++){
		champ = champs_form[i];
		if(formulaire.elements[champ].value == ""){
			//alerting(champ);
			color_red(champ);
			returnval = false;
		}else{
			color_gray(champ);
		}

		if(champ == "email"){
			if(!verifiermail(formulaire.elements[champ].value)){
				//alerting(champ,"invalid");
				color_red(champ);
				returnval = false;
			}else{
				color_gray(champ);
			}
		}

		if(champ == "country"){
			box = formulaire.elements[champ];
			cntry = box.options[box.selectedIndex].value;

			if(cntry == '0' || cntry == 0 || !cntry){
				//alerting(champ,"invalid");
				color_red(champ);
				returnval = false;
			}else{
				color_gray(champ);
			}
		}

		if(champ == "cpassword"){
			password = formulaire.elements['password'].value;
			if(formulaire.elements[champ].value != password){
				//alerting(champ,"invalid");
				color_red(champ);
				returnval = false;
			}else{
				color_gray(champ);
			}
		}


		if(champ == "Comments"){
			if(formulaire.elements[champ].value == 'Please contact me.'){
				//alerting(champ,"invalid");
				color_red(champ);
				returnval = false;
			}else{
				color_gray(champ);
			}
		}

	}

	if(returnval == false){
		alert_form_empty();
	}

	return returnval;
}



function color_gray(champ){
	formulaire.elements[champ].style.backgroundColor = color[0];
}


function color_red(champ){
	formulaire.elements[champ].style.backgroundColor = color[1];
}


function alerting(var_name){
	invalid = alerting.arguments[1];
	color_red(champ);
	if(invalid){
		alert_form_invalid();
	}else{
		alert_form_empty();
	}
	formulaire.elements[champ].select();
	formulaire.elements[champ].focus();
}

function alert_form_invalid(){
	alert( _lang_error_email );
}


function verifiermail(mail) {
	if ((mail.indexOf("@")>=0)&&(mail.indexOf(".")>=0)) {
		return true
		// Bon email
	} else {
		return false
		// Mauvais email
	}
}


function getpage(){

 // Get page metrics
 page = Object();
 if (typeof(window.innerWidth) == "number") {
  page.width = window.innerWidth;
  page.height = window.innerHeight;
 } else if ((document.documentElement) && (document.documentElement.clientHeight > 0)) {
  page.width = document.documentElement.clientWidth;
  page.height = document.documentElement.clientHeight;
 } else if (document.body) {
  page.width = document.body.clientWidth;
  page.height = document.body.clientHeight;
 } else {
	page.width = 790;
	page.height = 500;
 }

 if( typeof( window.pageYOffset ) == 'number' ) {
     //Netscape compliant
     page.y1 = window.pageYOffset;
     page.x1 = window.pageXOffset;
   } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
     //IE6 standards compliant mode
     page.y1 = document.documentElement.scrollTop-12;
  page.x1 = document.documentElement.scrollLeft;
   } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
     //DOM compliant
     page.y1 = document.body.scrollTop;
     page.x1 = document.body.scrollLeft;
   } else return;
 page.x2 = page.x1 + page.width;
 page.y2 = page.y1 + page.height;

 return page;
}

function Print(){
	window.print();
}

function is_numeric(num){
	var exp = new RegExp("^[0-9-.]*$","g");
	return exp.test(num);
}

function showError( idName ){
	if( document.getElementById( idName ) ){
		document.getElementById( idName ).style.display = 'block';
	}
}

function hideError( idName ){
	if( document.getElementById( idName ) ){
		document.getElementById( idName ).style.display = 'none';
	}
}

function isChecked ( idName ){
	if( document.getElementById( idName ) && (
		document.getElementById( idName ).checked == 'checked' ||
		document.getElementById( idName ).checked == true ||
		document.getElementById( idName ).checked == 'true'
	)){
		return true;
	}

	return false;
}

function Connect_form(FormName){

	Form = document.forms[FormName];
	FormErr = false;

	if( Form ){

		if(FormName == 'create_account'){

			var inputs = {
				'firstname'  		: [Form.firstname, 'text','all'],
				'lastname' 			: [Form.lastname, 'text', 'all'],

				'email' 			: [Form.email, 'email', 'all'],
				'email_verif' 		: [Form.email_verif, 'email', 'all', 'email'],
				'password' 			: [Form.password, 'password', 'all'],
				'password_verif' 	: [Form.password_verif, 'password', 'all', 'password'],


				//type 1 form
				'type1_year_graduation' 	: [Form.type1_year_graduation, 'text', 'type1'],


				//type 2 form
				'type2_address' 			: [Form.type2_address, 'text', 'type2'],
				'type2_city' 				: [Form.type2_city, 'text', 'type2'],
				'type2_country' 			: [Form.type2_country, 'text', 'type2'],
				'type2_postal' 				: [Form.type2_postal, 'text', 'type2'],


				//type 3 form
				'type3_address' 			: [Form.type3_address, 'text', 'type3'],
				'type3_city' 				: [Form.type3_city, 'text', 'type3'],
				'type3_country' 			: [Form.type3_country, 'text', 'type3'],
				'type3_postal' 				: [Form.type3_postal, 'text', 'type3']


			};

			var type_form = '';
			if( isChecked( 'type_physician_can_physician' ) ){
				type_form = 'type1';
			}
			if( isChecked( 'type_physician_healthcare_worker' ) ){
				type_form = 'type2';
			}
			if( isChecked( 'type_physician_noncan_physician' ) ){
				type_form = 'type3';
			}

			for( var el in inputs ){
				var el_value = inputs[el];
				var input = el_value[0];
				var input_type = el_value[1];

				if( el_value[2] == 'all' || el_value[2] == type_form ){

					hideError( el + '_error');
					if( input.value.length < 2 ){
						FormErr = true;
						showError( el + '_error');
					}

					if( input_type == 'email' && !verifiermail( input.value ) ){
						FormErr = true;
						showError( el + '_error');
					}

					if( input_type == 'password' && input.value.length < 5 ){
						FormErr = true;
						showError( el + '_error');
					}

					if( el_value[3] && el_value[3] != '' && input.value != inputs[el_value[3]][0].value ){
						FormErr = true;
						showError( el + '_error' );
					}

				}

			}


			if( !FormErr ){
				Form.submit();
				//alert("Submit");
			}else{
				//alert( _lang_fields_required );
			}

		}

		if(FormName == 'signin'){

			var si_email = document.getElementById( 'signin_email' );
			var si_password = document.getElementById( 'signin_password' );

			hideError( 'signin_email_error' );
			if( si_email.value.length < 2 || !verifiermail( si_email.value ) ){
				FormErr = true;
				showError( 'signin_email_error' );
			}

			hideError( 'signin_password_error' );
			if( si_password.value.length < 5 ){
				FormErr = true;
				showError( 'signin_password_error' );
			}

			if( !FormErr ){
				if( Form.keep_signedin.checked){
					Form.keep_signedin.value='yes';
				}else{
					Form.keep_signedin.value='no';
				}

				Form.submit();
				//alert("Submit");
			}else{
				//alert( _lang_fields_required );
			}

		}


		if(FormName == 'forgot_password'){

			var fg_email = document.getElementById( 'forgot_email' );

			hideError( 'forgot_email_error' );
			if( fg_email.value.length < 2 || !verifiermail( fg_email.value ) ){
				FormErr = true;
				showError( 'forgot_email_error' );
			}

			if( !FormErr ){
				Form.submit();
				//alert("Submit");
			}else{
				//alert( _lang_fields_required );
			}

		}

		if(FormName == 'forgot_password_reset'){

			var fg_password = document.getElementById( 'box_forgot_password' );
			var fg_password_verif = document.getElementById( 'box_forgot_password_verif' );

			hideError( 'forgot_password_error' );
			if( fg_password.value.length < 2 ){
				FormErr = true;
				showError( 'forgot_password_error' );
			}

			hideError( 'forgot_password_verif_error' );
			if( fg_password_verif.value.length < 2 || fg_password_verif.value != fg_password.value ){
				FormErr = true;
				showError( 'forgot_password_verif_error' );
			}

			if( !FormErr ){
				Form.submit();
				//alert("Submit");
			}else{
				//alert( _lang_fields_required );
			}

		}


	}
}


function linktocorecthref(){

	var objLinks = document.getElementsByTagName('a');

	if(objLinks){
		for (var iCounter=0; iCounter<objLinks.length; iCounter++){
			var href = objLinks[iCounter].getAttribute('href');

			if(href && (href.match('.pdf') || href.match('.ppt'))){
				if(href.match('IMG/')){
					href = href.replace("IMG/",'');
					objLinks[iCounter].setAttribute('href', href);
				}

			}
		}
	}

}



function setFontSize(name){
	valeur = document.getElementById(ElementID);

	if(valeur){
		for (z=0;z<tagname.length;z++) {
			var items = valeur.getElementsByTagName(tagname[z][0]);
			/*
			if(name == 'low' && tagname[z][1] >= tagname[z][3]){
				tagname[z][1] = eval(tagname[z][1]-1);
			}else if(name == 'big' && tagname[z][1] < (tagname[z][3]+typesize)){
				tagname[z][1] = eval(tagname[z][1]+1);
			}else{
				if(setFontSize.arguments[1] == 'cookie'){
					tagname[z][1] = tagname[z][1]+name;
				}else{
					tagname[z][1] = tagname[z][3];
				}
			}
			*/
			if(name == 'low'){
				tagname[z][1] = eval(tagname[z][4]);
			}else if(name == 'mid'){
				tagname[z][1] = eval(tagname[z][4]+1);
			}else if(name == 'big'){
				tagname[z][1] = eval(tagname[z][4]+2);
			}else{
				if(setFontSize.arguments[1] == 'cookie'){
					tagname[z][1] = tagname[z][4]+name;
				}else{
					tagname[z][1] = tagname[z][4];
				}
			}

			for (i=0;i<items.length;i++) {
				classname = items[i].getAttribute("class");
				items[i].style.fontSize = tagname[z][1]+"px";
			}

		}
		/*
		if(name == 'low' && tagname[0][1] >= tagname[0][3]){
			AddNum = AddNum-1;
		}else if(name == 'big' && tagname[0][1] < (tagname[0][3]+typesize)){
			AddNum = AddNum+1;
		}else{
			AddNum = name;
		}
		*/

		if(name == 'low'){
			AddNum = 0;
		}else if(name == 'mid'){
			AddNum = 1;
		}else if(name == 'big'){
			AddNum = 2;
		}else{
			AddNum = null;
		}

		if(AddNum != null){
			eraseCookie(ftSz);
			createCookie(ftSz,AddNum,1);
		}
	}

}

function setFontSize2(name){
	valeur = document.getElementById(ElementID);

	if(valeur){
		for (z=0;z<tagname.length;z++) {

			if(valeur.getElementsByTagName(tagname[z][0])){
				var items = valeur.getElementsByTagName(tagname[z][0]);
				for (i=0;i<items.length;i++) {
					classname = items[i].getAttribute("class");

					if(name == 'low'){
						items[i].style.fontSize = tagname[z][1]+"px";
					}else if(name == 'big'){
						items[i].style.fontSize = tagname[z][3]+"px";
					}
				}
			}
		}
	}
}

function getFontSize(ID) {
	if(document.getElementById(ID)) {
		varcookie = readCookie(ftSz);
		if(varcookie != null){
			val = new Number(varcookie);
			setFontSize(val,'cookie');
		}
	}
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*3600*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function eraseCookie(name) {
	createCookie(name,"",-1);
}


function backtotop(){
	bktop = document.getElementById(BckTopElement);

	if(bktop){
		Start();
	}
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }

  //return [ scrOfX, scrOfY ];
  return scrOfY;
}

function backtotop2(){
	var page = getpage();

	var banne = getPosition("spacingtoback");
	var banner = getPosition(BckTopElement);
	bannerObj = document.getElementById(BckTopElement);

	if(bannerObj){
		Elementhauteur = 50;

		//totheight = (document.getElementById("bigwrapper").offsetHeight-Elementhauteur); //2493
		var eoc = getPosition("end-of-content");

		newY = page.y2-40;
		minY = banne.y1+10;
		maxY = eoc.y2-(banner.y2-banner.y1)+10;

		if (newY > maxY) {
			newY = maxY;
		}
		if(newY < minY)  {
			newY = minY;
		}

		bannerObj.style.position = "absolute";
		bannerObj.style.top = newY+"px";
	}
}

function getPosition(id) {
	x=0;
	y=0;
	e = document.getElementById(id);

	while(e){
		//if (e.offsetLeft) x+=e.offsetLeft;
		//if (e.clientLeft) x+=e.clientLeft;
		if (e.offsetTop) y+=e.offsetTop;
		//if (e.clientTop) y+=e.clientTop;
		//alert(e.id + "--" + e.offsetTop);
		e=e.offsetParent;
	}

	var banneObj = document.getElementById(id);
	w=0;
	h=0;

	if(banneObj){

		if (banneObj.width) {
			w = banneObj.width;
			h = banneObj.height;
		} else {
			w = banneObj.offsetWidth;
			h = banneObj.offsetHeight;
		}

	}
	var banne = Object();
	banne.x1 = x;
	banne.y1 = y;
	banne.x2 = banne.x1 + w;
	banne.y2 = banne.y1 + h;

	return banne;
}


function Start() {

	bktop = document.getElementById(BckTopElement);
	blank = document.getElementById(ElementBlank);

	//BckTopElementydef  1113

	Elementhauteur = 61;

	//ElementBlanky = GetTop(ElementBlank); //785, 842


	//alert(ElementBlanky);

	if (document.getElementById) { //IE5
		var wintop=document.body.clientHeight;
	}
	if ((document.getElementById)&&(!document.all)) { //NS6
		var wintop=window.innerHeight;
	}
	if ((document.all)&&(!document.getElementById)) { //IE4 seul
		var wintop=document.body.clientHeight;
	}
	if (document.layers) { //NS4.X seul
		var wintop=window.innerHeight;
	}

	var avail = getScrollXY();

	wintop = wintop-1; //785 fix
	totheight = (document.getElementById("bigwrapper").offsetHeight-Elementhauteur); //2493

	if(ElementBlanky == 0){
		ElementBlanky = wintop;
	}else{
		ElementBlanky = blank.offsetTop+avail;
	}

	toping = (ElementBlanky-Elementhauteur);
	//avail = 0, 117, ...



	if(ElementBlanky > BckTopElementydef){
		if(ElementBlanky < totheight){
			bktop.style.position = "absolute";
			bktop.style.top = toping+"px";
		}
	}else{
		bktop.style.position = "absolute";
		bktop.style.top = BckTopElementydef-50+"px";
	}

}


function GetTop(nom) {
	if (document.getElementById) { //IE5
		var pos=parseInt(document.getElementById(nom).style.top);
		var wintop=parseInt(document.body.scrollTop);
		var avail=document.body.clientHeight;
	}
	if ((document.getElementById)&&(!document.all)) { //NS6
		var pos=parseInt(document.getElementById(nom).style.top);
		var wintop=parseInt(window.pageYOffset);
		var avail=window.innerHeight;
	}
	if ((document.all)&&(!document.getElementById)) { //IE4 seul
		var pos=parseInt(document.all[nom].style.top);
		var wintop=parseInt(document.body.scrollTop);
		var avail=document.body.clientHeight;
	}
	if (document.layers) { //NS4.X seul
		var pos=parseInt(document.layers[nom].top);
		var wintop=parseInt(window.pageYOffset);
		var avail=window.innerHeight;
	}

	var delta=Math.ceil((pos-(wintop+avail-31)));
	var max = 20;
	if (delta>max) {delta=max;}
	if (delta<-1*max) {delta=-1*max;}

	var top=pos-delta;

	return top;
}


function DisclaimerOver(event){

	if(!DisclaimerContentDepli){
		if(event == 'over'){
			DisclaimerArrow.style.backgroundPosition = DisclaimerArrowOut;
		}else{
			DisclaimerArrow.style.backgroundPosition = DisclaimerArrowIn;
		}
	}else{
		if(event == 'over'){
			DisclaimerArrow.style.backgroundPosition = DisclaimerArrowIn;
		}else{
			DisclaimerArrow.style.backgroundPosition = DisclaimerArrowOut;
		}
	}
}


function DisclaimerClick(){
	if(!DisclaimerContentDepli){
		DisclaimerContent.style.display = 'block';
		DisclaimerContentDepli = true;
	}else{
		DisclaimerContent.style.display = 'none';
		DisclaimerContentDepli = false;
	}
}


function AdvanceSearchLoad(){
	AdvanceSearchArrow = document.getElementById('advancesearch_arrow');
	AdvanceSearchContent = document.getElementById('advancesearch_form');
}

function AdvanceSearchOver(event){

	if(!AdvanceSearchContentDepli){
		if(event == 'over'){
			AdvanceSearchArrow.style.backgroundPosition = AdvanceSearchArrowOut;
		}else{
			AdvanceSearchArrow.style.backgroundPosition = AdvanceSearchArrowIn;
		}
	}else{
		if(event == 'over'){
			AdvanceSearchArrow.style.backgroundPosition = AdvanceSearchArrowIn;
		}else{
			AdvanceSearchArrow.style.backgroundPosition = AdvanceSearchArrowOut;
		}
	}
}


function AdvanceSearchClick(){
	if(!AdvanceSearchContentDepli){
		AdvanceSearchContent.style.display = 'block';
		AdvanceSearchContentDepli = true;
	}else{
		AdvanceSearchContent.style.display = 'none';
		AdvanceSearchContentDepli = false;
	}
}

