

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

	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_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_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];}}
	}

// NEW DESIGN FUNCTIONS

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		bwh_new_17_over = newImage("images/bwh_new_17-over.gif");
		bwh_new_19_bwh_new_17_over = newImage("images/bwh_new_19-bwh_new_17_over.gif");
		bwh_new_20_bwh_new_17_over = newImage("images/bwh_new_20-bwh_new_17_over.gif");
		bwh_new_25_bwh_new_17_over = newImage("images/bwh_new_25-bwh_new_17_over.gif");
		bwh_new_34_over = newImage("images/bwh_new_34-over.gif");
		bwh_new_50_bwh_new_52_over = newImage("images/bwh_new_50-bwh_new_52_over.gif");
		bwh_new_52_over = newImage("images/bwh_new_52-over.gif");
		bwh_new_55_bwh_new_52_over = newImage("images/bwh_new_55-bwh_new_52_over.gif");
		bwh_new_57_bwh_new_52_over = newImage("images/bwh_new_57-bwh_new_52_over.gif");
		bwh_new_58_bwh_new_52_over = newImage("images/bwh_new_58-bwh_new_52_over.gif");
		bwh_new_59_bwh_new_52_over = newImage("images/bwh_new_59-bwh_new_52_over.gif");
		bwh_new_60_bwh_new_52_over = newImage("images/bwh_new_60-bwh_new_52_over.gif");
		bwh_new_61_bwh_new_52_over = newImage("images/bwh_new_61-bwh_new_52_over.gif");
		bwh_new_62_bwh_new_52_over = newImage("images/bwh_new_62-bwh_new_52_over.gif");
		preloadFlag = true;
	}
}


// END NEW DESIGN FUNCTIONS


	function verifyLogon()
	{
		var var1 = document.logon.v1;
		var var2 = document.logon.v2;
		var result = true;
		if (var1.value == "") 
		{
			result = false;
			alert("Please enter a username");
			var1.focus();
		}
		else if (var2.value == "")
		{
			result = false;
			alert("Your password cannot be blank.\nPlease try again.");
			var2.focus();
		}
		return result;
	}
	
// ** start window functions **
	function windowOpen(URL)
	{
		var wHeigth = screen.availHeight-200;
		var wWidth = 580; //screen.availWidth-200;
		var xLoc = 50;
		var yLoc = 50;
		var newWin=window.open(URL, "mediaWindow", "scrollbars=yes,width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",screenX="+xLoc);
		newWin.focus();
	}

	function windowOpen3(URL)
	{
		var wHeigth = screen.availHeight-100;
		var wWidth = screen.availWidth-200;
		var xLoc = (screen.width-wWidth)/2;
		var yLoc = (screen.height-wHeigth)/2;
		var newWin=window.open(URL, "pdf", "scrollbars=yes,width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",screenX="+xLoc);
		newWin.focus();
	}


	function pwdOpen(URL)
	{
		var wHeigth = 400; //screen.availHeight-300;
		var wWidth = 450; //screen.availWidth-200;
		var xLoc = (screen.width-wWidth)/2;
		var yLoc = (screen.height-wHeigth)/2;
		var newWin=window.open(URL, "pwdWindow", "width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",screenX="+xLoc);
		newWin.focus();
	}

	function AddItemOpen(URL)
	{
		var wHeigth = 400; //screen.availHeight-300;
		var wWidth = 450; //screen.availWidth-200;
		var xLoc = (screen.width-wWidth)/2;
		var yLoc = (screen.height-wHeigth)/2;
		var newWin=window.open(URL, "addItemWindow", "width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",scrollbars,screenX="+xLoc);
		newWin.focus();
	}

	function faceOpen(URL)
	{
		var wHeigth = 450; //screen.availHeight-300;
		var wWidth = 450; //screen.availWidth-200;
		var xLoc = (screen.width-wWidth)/2;
		var yLoc = (screen.height-wHeigth)/2;
		var newWin=window.open(URL, "pwdWindow", "width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",screenX="+xLoc);
		newWin.focus();
	}
	
	function openParent(URL)
	{
		opener.location.href = URL;
		window.close();
	}

	function openSearchForm()
	{
		var wHeigth = 200;
		var wWidth = 580; //screen.availWidth-200;
		var xLoc = (screen.width- wWidth)/2;
		var yLoc = (screen.height- wHeigth)/2;
		var newWin=window.open("", "newSearchWindow", "width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",screenX="+xLoc);
		document.searchform.target = "newSearchWindow";
		document.searchform.submit();
//		newWin.focus();
	}

	function window2Open(URL)
	{
		var wHeigth = screen.availHeight-300;
		var wWidth = 630; //screen.availWidth-200;
		var xLoc = (screen.width-wWidth)/2;
		var yLoc = (screen.height-wHeigth)/2;
		var newWin=window.open(URL, "window2", "scrollbars=yes,width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",screenX="+xLoc);
		newWin.focus();
	}
	
	function windowOpen2(URL)
	{
		var wHeigth =350; //screen.availHeight-200;
		var wWidth = 450; //screen.availWidth-200;
		var xLoc = 150;
		var yLoc = 150;
		var newWin=window.open(URL, "bookmarkWindow", "width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",screenX="+xLoc);
		newWin.focus();
	}
	function windowOpen4(URL)
	{
		var wHeigth = 150; //screen.availHeight-200;
		var wWidth = 250; //screen.availWidth-200;
		var xLoc = (screen.width-wWidth)/2;
		var yLoc = (screen.height-wHeigth)/2;
		var newWin=window.open(URL, "bookmarkWindow", "width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",screenX="+xLoc);
		newWin.focus();
	}

	function jeadvOpen(article){
		var wHeigth = screen.availHeight-200;
		var wWidth = screen.availWidth-200;
		var xLoc = (screen.width-wWidth)/2;
		var yLoc = (screen.height-wHeigth)/2;
//		var newWin=window.open("jeadv_goto.asp?goto=" + article, "jeadvWindow", "width=" + wWidth +",height="+wHeigth+",left="+xLoc+",top="+yLoc+",screenY="+yLoc+",scrollbars,screenX="+xLoc);
		var newWin=window.open("jeadv_goto.asp?goto=" + article, "jeadvWindow");
		newWin.focus();
	
	
	}
	


	function openChromeslessWindow(openUrl, winName, wWidth, wHeight, wPosx, wPosy, wTIT,
			 windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel,
			 bCenter, sFontFamily, sFontSize, sFontColor){
		
		openchromeless(openUrl,winName, wWidth, wHeight, wPosx, wPosy, wTIT, wTIT ,
								windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel,
									bCenter, sFontFamily, sFontSize, sFontColor);
	}


// ** end window functions **
	function shrinktofitimage () {
	var image = document.images.FullImage;
	window.resizeTo(image.width+70,image.height+95);
	if(document.body && document.body.clientWidth+30)
		window.resizeBy(
		image.width - document.body.clientWidth+70,
		image.height - document.body.clientHeight+95
		)
	}
	
	function shrinktofitvideo () {
//	var image = document.ImageWindow.size;
/*	window.resizeTo(window.width,gMediaHeight+150);
	if(document.body && document.body.clientWidth+30)
		window.resizeBy(
		image.width - document.body.clientWidth+70,
		image.height - document.body.gMediaHeight+150
		)
*/	}

	function checkRadio(radioGrp)
	{
	// function returns true if 1 item in radio group buttons has been selected
	// otherwise returns false
		var tempresult = false;
		if (radioGrp.length>1){
			for (var i=0; i< radioGrp.length;i++)
			{
				//alert("value" + i + "= " + radioGrp[i].checked);
				if(radioGrp[i].checked == true)
				{
					tempresult = true;
				}
			}
		}
		else {
			if (radioGrp.checked == true){
				tempresult = true;
			}
		}
		return tempresult;
	}
	


	
// ** START VERIFY FORM FUNCTIONS
	function goSearch(){
		var result = true;
		var keyword = document.searchform.keyword;
		if (keyword.value == ""){
			result=false;
			alert("Please enter at least one word to search for.");
			keyword.focus();
			
		}
		else
		{
			document.searchform.submit();
		}
		return result;
	}
	function saveBookmark()
	{
		var bookmarkname = document.bookmark.bookmarkname;
		var result = true;
		if (bookmarkname.value == "")
		{
			result = false;
			alert("Please Enter a name for your bookmark before clicking the 'Save' button.\nOr choose 'Close window' to close this window without saving a bookmark.");
			bookmarkname.focus();
		}
		return result;
	}
	function saveNote()
	{
		var notename = document.note.notename;
		var result = true;
		if (notename.value == "")
		{
			result = false;
			alert("Please enter a note before clicking the 'Save' button.\nOr choose 'Close window' to close this window without saving a note.");
			notename.focus();
		}
		return result;
	}


	function verifyclaimcertificate()
	{
		var toclaimstring = document.claimcertificate.toclaim;
		var totalselected = 0;
		var result = false;
		if (toclaimstring.length>1){
			for (var i=0; i< toclaimstring.length;i++)
			{
				if(toclaimstring[i].checked == true)
				{
					totalselected = totalselected + 1;
				}
			}
		}
		if (totalselected == 4){
			alert("A new window will open with your certificate.\nPlease print it and keep it for your records.");
			result = true;
		}
		else{
			result = false;
			alert("You need at least, or maximum 4 presentations for 1 certificate.\nPlease reconsider your selection.");
		}
		return result;
	}

	function verifyRegister()
	{
		var name = document.register.NAME;
		var surname = document.register.SURNAME;
		var username = document.register.USERNAME;
		var password = document.register.PASSWORD;
		var email = document.register.EMAIL;
		var secretquestion = document.register.SECRETQUESTION;
		var secretanswer = document.register.SECRETANSWER;
		var result = true;
		
		if (name.value == "" )
		{
			result = false;
			alert("Please enter your name");
			name.focus();
		}
		else if (surname.value == "" )
		{
			result = false;
			alert("Please enter your surname");
			surname.focus();
		}
		else if (username.value == "" )
		{
			result = false;
			alert("Please enter a username");
			usernamename.focus();
		}
		else if (password.value == "" )
		{
			result = false;
			alert("Please enter a password");
			password.focus();
		}
		else if (email.value == "" )
		{
			result = false;
			alert("Please enter a valid email address");
			email.focus();
		}
		return result;
	}

	function verifyRegisterCME()
	{
		var title = document.register.M_title;
		var degree = document.register.IDdegree;
		var name = document.register.m_name;
		var surname = document.register.m_surname;
		var speciality = document.register.IDspecialty;
//		var organization = document.register.organization;
		var address1 = document.register.address_1;
		var city = document.register.m_city;
		var country = document.register.M_country;
		var postalcode = document.register.postalcode;
		var email = document.register.m_email;
//		var password = document.register.PASSWORD;
		var secretquestion = document.register.SECRETQUESTION;
		var secretanswer = document.register.SECRETANSWER;
		var result = true;
/*		if (title.value == "none")
		{
			result = false;
			alert("Please select a title before continuing.");
			title.focus();
		}
		else if (degree.value == "none")
		{
			result = false;
			alert("Please specify a degree.");
			degree.focus();
		}
*/
		if (name.value == "")
		{
			result = false;
			alert("Please enter your first name");
			name.focus();
		}
		else if (surname.value == "")
		{
			result = false;
			alert("Please enter your last name");
			surname.focus();
		}
		else if (speciality.value == "none")
		{
			result = false;
			alert("Please specify a speciality.");
			speciality.focus();
		}
/*		else if (organization.value == "")
		{
			result = false;
			alert("Please enter an organization, affiliation or institute.");
			organization.focus();
		}
*/
		else if (address1.value == "")
		{
			result = false;
			alert("You forgot your address!");
			address1.focus();
		}
		else if (city.value == "")
		{
			result = false;
			alert("Please indicate the city you live in");
			city.focus();
		}
		else if (country.value == "none")
		{
			result = false;
			alert("Please select a country from the list");
			country.focus();
		}
		else if (postalcode.value == "")
		{
			result = false;
			alert("Please enter your postal code.");
			postalcode.focus();
		}
		else if (email.value == "")
		{
			result = false;
			alert("Please enter a valid e-mail address.");
			email.focus();
		}
/*		else if (password.value == "")
		{
			result = false;
			alert("Your password may not be blank.\nPlease enter a password.");
			password.focus();
		}
*/
		else if (secretquestion.value == "")
		{
			result = false;
			alert("A secret question allows you to retrieve your password should you forget it.\nIt should not be blank.\nPlease specify a question.");
			secretquestion.focus();
		}
		else if (secretanswer.value == "")
		{
			result = false;
			alert("Your secret answer may not be blank.\nPlease specify an answer.");
			secretanswer.focus();
		}
		return result;
	}
	
	function verify_pwd()
	{
		var currentpwd = document.forms[0].currentpwd;
		var newpwd = document.forms[0].newpwd;
		var verifypwd = document.forms[0].confirmpwd;
		var result = true;
		if (currentpwd.value == ""){
			result = false;
			alert("You forgot to enter your current password.\nPlease do so before submitting this form.");
			currentpwd.focus();
		}
		else if (newpwd.value == ""){
			result = false;
			alert("Your new password cannot be blank.\nPlease enter a new password.");
			newpwd.focus();
		}
		else if (newpwd.value != verifypwd.value) {
			result = false;
			alert("Please enter the same password in \'new password\' and \'verify new password\'");
			newpwd.value = "";
			verifypwd.value = "";
			newpwd.focus();
		}
		return result;
	}

	function verify_send2colleague(){
		var fromname = document.send2colleague.fromName;
		var fromemail = document.send2colleague.fromEmail;
		var toemail = document.send2colleague.toEmail;
		var result = true;
		if (fromname.value == ""){
			result = false;
			alert("Please enter your name");
			fromname.focus();
		}
		else if (!IsEmailValid(fromemail.value)){
			result = false;
			alert("There seems to be a problem with your email address.\Please revise it and try again.");
			fromemail.focus();
		}
		else if (!IsEmailValid(toemail.value)){
			result = false;
			alert("There seems to be a problem with your colleagues email address.\Please revise it and try again.");
			fromemail.focus();
		
		}

		return result;
	
	}
	function verifyarticle()
	{
		var result = true;
		var publishday = document.articledetail.thisday;
		var publishmonth = document.articledetail.thismonth;
		var publishyear= document.articledetail.thisyear;
		var availableday = document.articledetail.thisday1;
		var availablemonth = document.articledetail.thismonth1;
		var availableyear= document.articledetail.thisyear1;
		if(publishday.value=="" || publishmonth.value=="" || publishyear.value==""){
			result =false;
			alert("Publishdate cannot be blank.\nPlease revise publishdate");
			publishday.focus();
		}
		else if (publishday.value=="" || publishday.value > 31 || publishday.value < 1){
			result = false;
			alert("Review publish date.\nDay seems incorrect.");
			publishday.focus();
		}
		else if (publishmonth.value=="" || publishmonth.value > 12 || publishmonth.value < 1){
			result = false;
			alert("Review publish date.\nMonth seems incorrect.");
			publishmonth.focus();
		}
		else if (publishyear.value=="" || publishyear.value < 1966){
			result = false;
			alert("Review publish date.\nYear seems incorrect.");
			publishyear.focus();
		}
		//copyValue();
		return result;
	}
	function verifyMailing(){
		var result = true;
		var mailsubject = document.mailingdetails.mailingsubject;
		if (mailsubject.value ==""){
			result = false;
			alert("Please enter a subject for your mailing");
			mailsubject.focus();
		}
/**/
/*		if (confirm("Have you saved the mailing?\n\nYou should save the mailing before continuing.\nClick 'cancel' if you did not save it.")){
			result = false;
		}
*/
		copyValue();
		return result;
	
	}
	
	function checkMembership(){
		var IDPriceRadio = document.membership.IDPrice;
		var result = true;
		if (checkRadio(IDPriceRadio)==false){
			alert("You did not yet select one of the options.\nPlease select your payment option and try again.");
			result = false;
		}
		return result;
	}
	
// ** END VERIFY FORM FUNCTIONS

	function dateValid(inputdate){
		var monthString = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
		var monthArray = monthString.split(",");
		var checkdate = inputdate;
		var result = true;
		if (checkdate != ""){
			var daylimit = checkdate.indexOf("/");
			var monthlimit = checkdate.lastIndexOf("/");
//		alert("checkdate=" + checkdate);
			var day = parseInt(checkdate.substring(0,daylimit));
			var month = parseInt(checkdate.substring(daylimit+1,monthlimit));
			var year = checkdate.slice(monthlimit+1);
			if (year.length < 4){
				//making year a full 4 digit number
				for(counter=1;year.length<3;counter++){
					year = "0" + year;
				}
				year = "2" + year;
			}
//			alert("month=" + month + " Day:" + day + " Year:" + year);
//			alert("textmonth=" + monthArray[month-1]);
			// creating valid date based on entered values
			var enteredDate = new Date(day + " " + monthArray[month-1] + " " +year);
//			alert ("entereddate=" + enteredDate);
			// checking date validity based on day of input day and existing day for this date
//			alert("day: " + enteredDate.getDate());
			if (enteredDate.getDate() != day){
				result = false;
			}
		}
		return result;
	}

function numberToString(inputNumber,base)
{
  var prefix = '';
  if (!base) base = 10;
  if (base=8) prefix = '0';
	if (base=16) prefix = '0x'
  return (prefix + inputNumber.toString(base));
}
function numberToString(inputNumber,base)
{
  var prefix = '';
  if (!base) base = 10;
  if (base=8) prefix = '0';
	if (base=16) prefix = '0x'
  return (prefix + inputNumber.toString(base));
}

// ** VERIFY EMAIL FUNCTION
	function IsEmailValid(checkThisEmail)
	{
	var myEMailIsValid = true;
	var myAtSymbolAt = checkThisEmail.indexOf('@');
	var myLastDotAt = checkThisEmail.lastIndexOf('.');
	var mySpaceAt = checkThisEmail.indexOf(' ');
	var myLength = checkThisEmail.length;
	
	// at least one @ must be present and not before position 2
	// @yellow.com : NOT valid
	// x@yellow.com : VALID
	
	if (myAtSymbolAt < 1 ) 
	 {myEMailIsValid = false}
	
	
	// at least one . (dot) afer the @ is required
	// x@yellow : NOT valid
	// x.y@yellow : NOT valid
	// x@yellow.org : VALID
	
	if (myLastDotAt < myAtSymbolAt) 
	 {myEMailIsValid = false}
	
	// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
	// x.y@yellow. : NOT valid
	// x.y@yellow.a : NOT valid
	// x.y@yellow.ca : VALID
	
	if (myLength - myLastDotAt <= 2) 
	 {myEMailIsValid = false}
	
	// no empty space " " is permitted (one may trim the email)
	// x.y@yell ow.com : NOT valid
	
	if (mySpaceAt != -1) 
	 {myEMailIsValid = false}
	
	
//	if (!myEMailIsValid == true)
//	 {alert("email is VALID")}
//	else
//	 {alert("Please check your e-mail address.")}
	
	
	return myEMailIsValid
	}
// ** END VERIFY EMAIL FUNCTION

// Change Region Function
	function changeCountry(){
		var country = document.all.regionList.value;
		document.location.href="http://localhost/BWH/cardiotrends_org/web/" + country;
	
	}
// END change Region Function