//bookmark this page
function bookmarkPage(siteName, bookmarkName) {
	if (bookmarkName != "") {bookmarkName = ' - ' + bookmarkName;}
 	if (navigator.userAgent.indexOf("MSIE") != -1) {
		window.external.AddFavorite(window.location.href,siteName + bookmarkName);
 	} else {
		alert('Press Control+D to bookmark this site.');
	}
}

//variables used to center pop-up windows
var width = screen.width;
var height = screen.height;
var popUpWidth = 0;
var popUpHeight = 0;
var positionTop = 0;
var positionLeft = 0;

function openWindow(pageURL,windowName,pWidth,pHeight,pResize,pScrollbars,pStatus)
{
 	positionTop = ((height/2) - (pHeight/2));
 	positionLeft = ((width/2) - (pWidth/2));
 	popup=window.open(pageURL,windowName, config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=' + pResize + ',menubar=0,location=0,directories=0,toolbar=0,scrollbars=' + pScrollbars + ',status=' + pStatus);
}

function closePopup(pageURL) {
	opener.location = pageURL;
	self.close();
}

function registerUser(from) {
	pWidth = 486;
	pHeight = 290;
	positionTop = ((height/2) - (pHeight/2));
	positionLeft = ((width/2) - (pWidth/2));
	popup=window.open('/registerUser.cfm?frPg='+from,'Registration', config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=0,menubar=0,location=0,directories=0,toolbar=0,scrollbars=0,status=0');
	popup.focus();
}

function openLogOffWindow() {
	pWidth = 486;
	pHeight = 290;
	positionTop = ((height/2) - (pHeight/2));
	positionLeft = ((width/2) - (pWidth/2));
	popup=window.open('/logoff.cfm','LogOff', config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=0,menubar=0,location=0,directories=0,toolbar=0,scrollbars=0,status=0');
	popup.focus();
}

function executeLogOff() {
	window.close();
	opener.location.href = '/index.cfm';
}

function checkEMail()
{
  //for email validation
  var emailaddress=document.registerform.DoctorEMail.value;
  //alert(emailaddress);
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  //alert(filter.test(emailaddress))
  if (filter.test(emailaddress))
  {
  	openWindow('/site_tools/subscribe_updates/PopupRegistration_thanks.cfm?email=' + emailaddress,'',486,290,0,0);
    return true;
  }
  else
  {
     alert("Please input a valid email address!")
	 document.registerform.DoctorEMail.focus();
     return false;
  }
}


function checkEMailCustomer_Service()
{
  if(document.registerform.DoctorEmail.value != document.registerform.DoctorEmail_confirm.value )
  {
    alert('Your Email addresses do not match. Please re-enter your email address.');
	document.registerform.DoctorEmail_confirm.focus();
	return false;
  }
  
  //for email validation
  var emailaddress=document.registerform.DoctorEmail.value;
  //alert(emailaddress);
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  //alert(filter.test(emailaddress))
  if (filter.test(emailaddress))
  {
  	document.registerform.submit();
    return true;
  }
  else
  {
     alert("Please input a valid email address!")
	 document.registerform.DoctorEmail.focus();
     return false;
  }
}

function checkRegistrationEMail()
{

	if(document.registerform.UserName.value.length  < 4 )
  {
    alert('The User Name you have chosen is less than 4 characters. The User Name should have atleast 4 characters.');
	document.registerform.UserName.focus();
	return false;
  }
  
  if(document.registerform.Password.value.length  < 6 )
  {
    alert('The Password you have chosen is less than 6 characters. The Password should have atleast 6 characters.');
	document.registerform.Password.focus();
	return false;
  }
  
  if(document.registerform.Password.value != document.registerform.Confirm_Password.value )
  {
    alert('Your passwords do not match. Please re-enter your passwords.');
	document.registerform.Confirm_Password.focus();
	return false;
  }
  
  //for email validation
  var emailaddress=document.registerform.EMail.value;
  //alert(emailaddress);
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  //alert(filter.test(emailaddress))
  if (filter.test(emailaddress))
  {
  	//openWindow('/site_tools/subscribe_updates/PopupRegistration_thanks.cfm?email=' + emailaddress,'',486,290,0,0);
	document.registerform.submit();
    return true;
  }
  else
  {
     alert("Please input a valid email address!")
	 document.registerform.EMail.focus();
     return false;
  }
}

function  checklogin()
{
	
	if(document.login.username.value.length == 0)
	{
	   		alert('Please enter your username');
			document.login.username.focus();
			return false;
	}
	
	if(document.login.password.value.length == 0)
	{
	   		alert('Please enter your password');
			document.login.password.focus();
			return false;
	}
	
    document.login.submit();
	return true;
}


function  checkadminlogin()
{
	
	if(document.adminlogin.adminusername.value.length == 0)
	{
	   		alert('Please enter your username');
			document.adminlogin.adminusername.focus();
			return false;
	}
	
	if(document.adminlogin.adminpassword.value.length == 0)
	{
	   		alert('Please enter your password');
			document.adminlogin.adminpassword.focus();
			return false;
	}
	
    document.adminlogin.submit();
	return true;
}

/*
var newwindow = '';

function popitup(url) {
	if (!newwindow.closed && newwindow.location) {
		newwindow.location.href = url;
	}
	else {
		newwindow=window.open(url,'name','height=200,width=150');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}

*/

function buyAdditionalModules() {
	pWidth = 486;
	pHeight = 290;
	positionTop = ((height/2) - (pHeight/2));
	positionLeft = ((width/2) - (pWidth/2));
	popup=window.open('/site_tools/popup/PopupSorryNotPurchased.cfm','Registration', config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=0,menubar=0,location=0,directories=0,toolbar=0,scrollbars=0,status=0');
	popup.focus();
}

function checkCreditCard()
	{
		//alert(whichModule);
		var ccinfo = registerform.CardNumber.value ;
		
		if(ccinfo == "1234-1234-1234-1234")
		{
		   registerform.submit();
		}
		else
		{
		  alert('Please enter the credit card number provided to you');
		  registerform.CardNumber.focus();
		  
		}
			
		
	}
	
/* Fix for Mozilla browser */	
function clickLink(url)
	{
		window.opener.location = url;
		window.close();
	}	
	
	
function checkForm(registerform)
{
	//alert(whichModule);
		
	if(_CF_checkregisterform(registerform))
	{
	   registerform.submit();
	}
		
	
}
