/****************************************************
* Common functions for etp
****************************************************/
var msg = 'This link will take you to another website to which this privacy policy does not apply. We encourage you to read the Privacy Policy of every Web site you visit. Click the Cancel button to return to this site or OK to continue.';

// Initialize the footer text for all pages but about this site and index
var footer = '<a href="about-this-site.htm">About this Site</a> | <a href="links.htm">Useful Links</a> | <a href="glossary.htm">Glossary</a> | <a href="privacy.htm">Privacy Policy</a> | <a href="legal.htm">Legal Notice </a> | <a href="sitemap.htm">Site Map</a> | <a href="contact.htm">Contact Us</a> | <a href="http://www.savoirpourmieuxagir.com">Fran&ccedil;ais</a><br><br>Updated January 2011. &nbsp;&copy; Janssen Inc. 2007-2011. <br />This site is intended for Canadian audiences and is published by Janssen Inc. which is solely responsible for its contents. ';

/*  Validate the search box before submitting */
function validateQuestion(who) {
	var validForm = true;
	var errmsg = document.getElementById("errormsg");
	errmsg.innerHTML = "";	
	if (!exists(document.askquestion.question.value)) {
		validForm = false;
		errmsg.innerHTML = 'Enter a question. ';
	} 
	if (!exists(document.askquestion.email.value)) {
		validForm = false;
		errmsg.innerHTML = errmsg.innerHTML + 'Enter your email. ';
	} else {
		apos=document.askquestion.email.value.indexOf("@");
		dotpos=document.askquestion.email.value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) {
	  		errmsg.innerHTML = errmsg.innerHTML + "Enter a valid email.";
			validForm = false;
		}
	}
	document.askquestion.expert.value = who;
	return validForm;
}

// Check if value entered into field
function exists(inputValue) {
	var aCharExists = false;
	for (var i=0; i<= inputValue.length; i++) {
		if (inputValue.charAt(i) != " " && inputValue.charAt(i) != "") {
			aCharExists = true;
			break
		}
	}
	return aCharExists;
}

// Play with  the visibility for the section
function toggle(section) { 
	if (document.getElementById(section).style.display == "block")
		document.getElementById(section).style.display = "none";
	else
		document.getElementById(section).style.display = "block";
}
function show(section) { 
	document.getElementById(section).style.display = "block";
}
function hide(section) { 
	document.getElementById(section).style.display = "none";
}

// Change characteristics of submit button on hover and on mouse out
function hoverButton(what) {
	document.getElementById(what).style.color = '#ED1C24';
	document.getElementById(what).style.backgroundColor = '#cccccc';
}
function outButton(what) {
	document.getElementById(what).style.color = '#333333';
	document.getElementById(what).style.backgroundColor = '#cccccc';
}
/*  Resize the fatigue assessment box and load with script */

function loadTool() {
	document.getElementById("FSimage").style.display = "none";
	document.getElementById("FSmovie").style.display = "block";
}
function unTool() {
	document.getElementById("FSimage").style.display = "block";
	document.getElementById("FSmovie").style.display = "none"

}

// Parse the URL variable and return the expert name
function getWho() { 
  	var searchString = document.location.search;
	if (searchString == '') {
		return '';
	
	}
	
	// should be a leading '?'
	apos=searchString.indexOf("?");
	if (apos < 0) {
		return '';
	
	}
	// should be an '='
	apos=searchString.indexOf("=");
	if (apos < 0) {
		return '';
	
	}
	searchString = searchString.substring(1);
	if (searchString == '') {
		return '';
	
	}
	var nvPairs = searchString.split("&");
	if (nvPairs == '') {
		return '';
	
	}
	var nvPair = nvPairs[0].split("=");
	if ((nvPair == '') || (nvPair.length == 0)) {
		return '';
	
	}
	// remove any '%20'
	if (nvPair[1] == '') {
		return '';
	
	}
	nvPair[1] = nvPair[1].replace("%20", " ");

	return nvPair[1];
} // end of function

/* Standard Dreamweaver functions */
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
