
   function shareQuestion_showDiv ( divId ) {
	   var div = document.getElementById ( divId );
	   if ( div ) {
		   div.style.display = "block";
	   }
   }

   function shareQuestion_hideDiv ( divId ) {
	   var div = document.getElementById ( divId );
	   if ( div ) {
		   div.style.display = "none";
	   }
   }

   function shareQuestion_setFieldToBlank ( fieldId ) {
	   var field = document.getElementById ( fieldId );
	   if ( field ) {
		   try {
			   field.value = "";
		   } catch ( exchideifwrongtype ) {
		   }
	   }
   }


function shareQuestion_createEmailListArray ( originalEmailFieldValue ) {
  
   var addressesArray = null;
		
	if ( originalEmailFieldValue.indexOf ( ";" ) > 0 ) {
		addressesArray = originalEmailFieldValue.split (";");
		// addressesArray = addresses.
	} else if ( originalEmailFieldValue.indexOf ( "," ) > 0 ) {
		addressesArray = originalEmailFieldValue.split (",");
	} else {
		addressesArray = originalEmailFieldValue.split (" ");
	}

	
	
	return addressesArray;
}


function shareQuestion_createCommaSeparatedEmailList ( originalEmailFieldValue ) {

//alert ( "create comma sep email list input: " + originalEmailFieldValue );

   var addresses = null;
   
   var addressesArray = shareQuestion_createEmailListArray ( originalEmailFieldValue );
		
	addresses = addressesArray.join ( ", " );
	
	return addresses;
}

function shareQuestion_validateSendGameToFriend () {
	
	try {
		var sendGameToEmail = document.getElementById ( "shareQuestion_shareQuestionInviteEmailsList" );
		var sendGameFromEmail = document.getElementById ( "shareQuestion_fromEmailAddress" );

		var sendGameToEmailValue = sendGameToEmail.value;
		var sendGameFromEmailValue = sendGameFromEmail.value;
		//var sendGameMessageValue = sendGameMessage.value;

        if ( !_private_shareQuestion_stringIsBlank(sendGameToEmailValue) ) {
			var toEmailAddresses = createEmailListArray ( sendGameToEmailValue );
			
			for ( var idx = 0; idx < toEmailAddresses.length; idx++ ) { 
			   var oneEmailAddress = toEmailAddresses[idx];
			  // alert ( " oneEmailAddress: " + oneEmailAddress );
			   if ( !_private_shareQuestion_isEmailValid ( oneEmailAddress ) ) {
				   shareQuestion_showOverallError ( "One of the hand-entered email addresses is invalid" );
				  return false;
			   }
			}
		}
	
	//alert ( " sendGameFromEmailValue: " + sendGameFromEmailValue );
	
	    if ( !_private_shareQuestion_stringIsBlank(sendGameFromEmailValue) ) {
			if ( !_private_shareQuestion_isEmailValid ( sendGameFromEmailValue ) ) {
				shareQuestion_showOverallError ( "From email address is invalid" );
				//sendGameFromEmail.className = "dialogFieldError";
				//sendGameFormError.innerHTML = "From email address is invalid.";
				
		//alert ( "THINKS IS INVALID" );
		
				return false;
			}
			
		}
		
		
	} catch ( exc ) {
		alert ( "EXC: " + exc );
	}

	return true;
}


/**
* START OF GAME-SPECIFIC STUFF
*/

   function shareQuestion_showShareQuestionScreen () 
   {      
	   try 
	   {
	   var dialogBoxesDiv = document.getElementById ( "dialogBoxesDiv" );
	   dialogBoxesDiv.style.display = "block";
	   
	   var shareQuestion_shareQuestionDialog = document.getElementById ("shareQuestion_shareQuestionDialog");
	   shareQuestion_shareQuestionDialog.style.display = "block";

       var shareQuestion_shareQuestionCompletePage = document.getElementById ("shareQuestion_shareQuestionCompletePage");
	   shareQuestion_shareQuestionCompletePage.style.display = "none";
	   shareQuestion_shareQuestionCompletePage.style.zIndex  = 10;
	   
       var shareQuestion_shareQuestionInvitePage = document.getElementById ("shareQuestion_shareQuestionInvitePage");
	   shareQuestion_shareQuestionInvitePage.style.display = "block";
	   shareQuestion_shareQuestionInvitePage.style.zIndex  = 20;	
	   
       var shareQuestion_shareQuestionWebMailDiv = document.getElementById ( "shareQuestion_shareQuestionWebMailDiv" );
	   shareQuestion_shareQuestionWebMailDiv.style.display = "none";
	   
	   //shareQuestion_setFieldToBlank ( "shareQuestion_fromEmailAddress" );
	   //shareQuestion_setFieldToBlank ( "shareQuestion_shareQuestionInviteWebMailAddress" );
	   //shareQuestion_setFieldToBlank ( "shareQuestion_shareQuestionInviteWebMailPassword" );
	   //shareQuestion_setFieldToBlank ( "shareQuestion_shareQuestionInviteEmailsList" );
	   //shareQuestion_setFieldToBlank ( "shareQuestion_shareQuestionOptionalMessage" );
	   
	   //shareQuestion_shareQuestionWebMailDiv = document.getElementById ("shareQuestion_shareQuestionWebMailContactsDiv");
	   //shareQuestion_shareQuestionWebMailDiv.style.display = "block";
	   
	   /**
	   var shareQuestion_shareQuestionWebMailContactsDiv = document.getElementById ("shareQuestion_shareQuestionWebMailContactsDiv");
	   shareQuestion_shareQuestionWebMailContactsDiv.innerHTML = "";
	   shareQuestion_shareQuestionWebMailContactsDiv.style.display = "none";
       **/
	   
	   
	   var shareQuestion_selectAndContinueButton = document.getElementById ( "shareQuestion_selectAndContinueButton" );
	   shareQuestion_selectAndContinueButton.style.display = "block";

       var loggedInUserEmailAddress = getPlayerEmailAddress ();
		
	   if ( loggedInUserEmailAddress != null ) 
	   {
           var shareQuestion_fromEmailAddress = document.getElementById ("shareQuestion_fromEmailAddress");
		   shareQuestion_fromEmailAddress.value = loggedInUserEmailAddress;
		   
           var shareQuestion_shareQuestionInviteWebMailAddress = document.getElementById ("shareQuestion_shareQuestionInviteWebMailAddress");
		   shareQuestion_shareQuestionInviteWebMailAddress.value = loggedInUserEmailAddress;		   
	   }
	   
	   } 
	   catch ( exc ) 
	   {
		   alert ( "EXC: " + exc );
	   }
	   
	  // alert ( "SHOWING?" );
   }

   function shareQuestion_hideShareQuestionScreen () {


	   var shareQuestion_shareQuestionDialog = document.getElementById ("shareQuestion_shareQuestionDialog");
	   
//alert ( " shareQuestion_shareQuestionDialog: " + shareQuestion_shareQuestionDialog );
	   shareQuestion_shareQuestionDialog.style.display = "none";
//alert ( "HIDDEN?" );

	   var dialogBoxesDiv = document.getElementById ( "dialogBoxesDiv" );
	   dialogBoxesDiv.style.display = "none";


   }

/**
* END OF GAME-SPECIFIC STUFF
*/
   
   function _private_shareQuestion_stringIsBlank ( str ) {
		var blankRE=/^[\s]+$/
		if ( str == "" || blankRE.test(str) ) {
			return true;
		} else {
			return false;
		}
   }
   
   function _private_shareQuestion_isEmailValid ( _email ) {
		
		var isValid = false;
		
		var containsAt = (_email.indexOf ( "@" ) > 0);
		var containsDot = (_email.indexOf ( "." ) > 0);
		var idxEndOfEmailPart = _email.lastIndexOf( "." );
		var idxOfAt = _email.indexOf( "@" );
		
		if ( containsAt && containsDot && ( idxOfAt < (idxEndOfEmailPart - 1) ) && idxEndOfEmailPart < ( _email.length - 1 ) ) {
			isValid = true;
		}
		
		return isValid;
   }   

   var m_shareQuestion_spinnerDiv = null;

   function _private_shareQuestion_showSpinner () {
		
	   _private_shareQuestion_hideSpinner ();
	   
	   var spinnerDiv = document.createElement ( "div" );
	   spinnerDiv.style.width = "60px";
	   spinnerDiv.style.height = "60px";
	   //toolTipDiv.style.backgroundColor = "#ff0000";
	   spinnerDiv.style.position = "absolute";
	   spinnerDiv.style.top = 150 + "px";
	   spinnerDiv.style.left = 290 + "px";
	   spinnerDiv.id = "spinnerDiv";
	   spinnerDiv.setAttribute ( "id", "spinnerDiv" );
	   
	   var parentPage = document.getElementById ( "shareQuestion_shareQuestionPodContainer" );
	   parentPage.appendChild ( spinnerDiv );
	   
	   m_shareQuestion_spinnerDiv = spinnerDiv;
	   
		
	
	   var swfContentPath = "spinnerAnimation.swf"; 
	   
	   var so = new SWFObject( swfContentPath, "shareQuestion_spinner", "100%", "100%", "9" ); //, backColor );
	   so.addParam("quality", "high");
       so.addParam("wmode", "transparent" ); 
       so.addParam("allowScriptAccess", "always");
       so.addParam("salign", "tl" ); //tl");
	   so.write( "spinnerDiv" );
	   
	   // alert ( "SPINNER SHOUDL BE SHOWING" );
	   	
	}  
	
   
   function _private_shareQuestion_hideSpinner () {
	  if ( m_shareQuestion_spinnerDiv ) {
	     m_shareQuestion_spinnerDiv.parentNode.removeChild(m_shareQuestion_spinnerDiv);
		 m_shareQuestion_spinnerDiv = null;
	  }
   }
	

   
   
   
   // shareQuestion_page1RegistrationFormError
   
   function shareQuestion_validateWebMailInformation () {
	   
	   
	   var email = document.getElementById ( "shareQuestion_shareQuestionInviteWebMailAddress" );
	   var password = document.getElementById ( "shareQuestion_shareQuestionInviteWebMailPassword" ); 
	   
	   if ( _private_shareQuestion_stringIsBlank ( email.value ) ) {
		   shareQuestion_showOverallError ( "Please enter you web email address." );
		   return false;
	   }
	   
	   if ( !_private_shareQuestion_isEmailValid ( email.value ) ) {
		   shareQuestion_showOverallError ( "Please enter a valid web email address." );
		   return false;
	   }
	   
	   if ( _private_shareQuestion_stringIsBlank ( password.value ) ) {
		   shareQuestion_showOverallError ( "Please enter your web email password." );
		   return false;
	   }
	   
	   
	   
	   return true;
   }
   
   function shareQuestion_showWebMailFormError ( errorText ) {
	   var shareQuestion_webEmailFormError = document.getElementById ( "shareQuestion_webEmailFormError" );
	   shareQuestion_webEmailFormError.style.display = "block";
	   shareQuestion_webEmailFormError.innerHTML = errorText;
   }

   function shareQuestion_showOverallError ( errorText ) {
	   var shareQuestion_overallShareError = document.getElementById ( "shareQuestion_overallShareError" );
	   shareQuestion_overallShareError.style.display = "block";
	   shareQuestion_overallShareError.innerHTML = errorText;
   }

   function shareQuestion_hideOverallError () {
	   var shareQuestion_overallShareError = document.getElementById ( "shareQuestion_overallShareError" );
	   shareQuestion_overallShareError.style.display = "none";
   }
   
   function shareQuestion_getWebMailContactsFromBackEnd () {
	   _private_shareQuestion_showSpinner ();
	   
	   setTimeout ( shareQuestion_webContactsAvailable, 2000 );
   }
   
   function shareQuestion_webContactsAvailable () {
	   
	   _private_shareQuestion_hideSpinner ();
	
      var shareQuestion_shareQuestionWebMailDiv = document.getElementById ( "shareQuestion_shareQuestionWebMailDiv" );
	  shareQuestion_shareQuestionWebMailDiv.style.display = "none";
	  
	  var shareQuestion_shareQuestionWebMailContactsDiv = document.getElementById ( "shareQuestion_shareQuestionWebMailContactsDiv" );
	  shareQuestion_shareQuestionWebMailContactsDiv.style.display = "block";
	  
	  var data = new Object ();
	  data.contacts = new Object ();
	  data.contacts.contacts = m_dummyContacts;
	  
	  try {
	  shareQuestion_handleContactsFetched ( data, null );
	  } catch ( exc ) {
	     alert ( "EXC: " + exc );
	  }
	
/*	   
         var shareQuestion_registrationPage1 = document.getElementById ( "shareQuestion_registrationPage1" );
	     shareQuestion_registrationPage1.style.display = "none";

         var shareQuestion_registrationInvitePage = document.getElementById ( "shareQuestion_registrationInvitePage" );
	     shareQuestion_registrationInvitePage.style.display = "block";
*/	   
   }
   
   function shareQuestion_sendInviteFriendsMessageToBackEnd () {
	   _private_shareQuestion_showSpinner ();
	   
	   setTimeout ( shareQuestion_inviteFriendsServiceCallComplete, 2000 );
   }

   function shareQuestion_inviteFriendsServiceCallComplete () {
	   
	   _private_shareQuestion_hideSpinner ();
	   
      var shareQuestion_shareQuestionInvitePage = document.getElementById ( "shareQuestion_shareQuestionInvitePage" );
	  shareQuestion_shareQuestionInvitePage.style.display = "none";
	  shareQuestion_shareQuestionInvitePage.style.zIndex  = 10;	   

      var shareQuestion_shareQuestionCompletePage = document.getElementById ( "shareQuestion_shareQuestionCompletePage" );
	  shareQuestion_shareQuestionCompletePage.style.display = "block";
	  shareQuestion_shareQuestionCompletePage.style.zIndex  = 20;	   
   }

   function shareQuestion_registerDoInvite () {
	
	   toolTips_hideToolTip  ();
       shareQuestion_hideOverallError ();

	   if ( shareQuestion_validateSendGameToFriend () ) {
		   try 
		   {
			   var shareQuestion_selectAndContinueButton = document.getElementById ( "shareQuestion_selectAndContinueButton" );
			   shareQuestion_selectAndContinueButton.style.display = "none";
		       shareQuestion_sendShareQuestionMessageToBackEnd ();
		   } 
		   catch (exc ) 
		   {
			   alert ( "EXC: " + exc );
			   shareQuestion_selectAndContinueButton.style.display = "inline";
		   }
	   }
      //shareQuestion_sendInviteFriendsMessageToBackEnd ();
	  
   }
   
   function shareQuestion_sendShareQuestionMessageToBackEnd () {
	  // alert ( "share question" );

	   var sendQuestionToEmail = document.getElementById ( "shareQuestion_shareQuestionInviteEmailsList" );
	   var sendQuestionFromEmail = document.getElementById ( "shareQuestion_fromEmailAddress" );
	   var sendQuestionMessage = document.getElementById ( "shareQuestion_shareQuestionOptionalMessage" );

	   var sendQuestionToEmailValue = sendQuestionToEmail.value;
	   var sendQuestionFromEmailValue = sendQuestionFromEmail.value;
	   var sendQuestionMessageValue = sendQuestionMessage.value;

       var fromEmailValue = ""; 
	   var toEmailValueEnteredByHand = "";
	   var anyToAddressesEnteredByHand = false;
	   
       if ( !_private_shareQuestion_stringIsBlank(sendQuestionFromEmailValue) ) {
		   fromEmailValue = sendQuestionFromEmailValue;
	   }

       if ( !_private_shareQuestion_stringIsBlank(sendQuestionToEmailValue) ) {
		   toEmailValueEnteredByHand = shareQuestion_createCommaSeparatedEmailList (sendQuestionToEmailValue);
		   anyToAddressesEnteredByHand = true;
	   }

       var arraySelectedWebMailContacts = new Array ();
	   
	   for ( var idx = 0; idx < m_shareQuestion_contactsList.length; idx++ ) {
		   var contactObject = m_shareQuestion_contactsList[idx];
		   if ( contactObject.isSelected == true ) {
              arraySelectedWebMailContacts.push(contactObject.contact.emailAddress);
		   }
	   }
	   
	   var allToAddresses = sendQuestionToEmailValue;
	   var webMailToAddresses = "";
	   if ( arraySelectedWebMailContacts.length > 0 ) {
		   webMailToAddresses = arraySelectedWebMailContacts.join("," );
		   if ( anyToAddressesEnteredByHand ) {
			   allToAddresses += ", " + webMailToAddresses;
		   } else {
			   allToAddresses = webMailToAddresses;
		   }
	   }
    //   alert ( "from: " + fromEmailValue );
	//   alert ( "allToAddresses: " + allToAddresses );
	
	   try {
		   _private_shareQuestion_showSpinner ();
		//   DataServiceBackEnd.DUMMY_DATA = true;
		   dataService_emailQuestion ( shareQuestion_handleShareQuestionCompleted, m_currentQuestionObject.id, fromEmailValue, allToAddresses, sendQuestionMessageValue );
		  //  DataServiceBackEnd.DUMMY_DATA = false;
	   } catch ( excData ) {
		   alert ( "DATA ERROR: " + excData );
		   _private_shareQuestion_hideSpinner ();
	   }

   }
   
   function shareQuestion_handleShareQuestionCompleted ( data, xml ) {
	   
	 //  alert ( "DID IT" );
	   _private_shareQuestion_hideSpinner ();
	   
	  // alert ( "SHARED QUESTION SENT" );
	   var shareQuestion_shareQuestionInvitePage = document.getElementById ( "shareQuestion_shareQuestionInvitePage" );
	   shareQuestion_shareQuestionInvitePage.style.display = "none";
	   shareQuestion_shareQuestionInvitePage.style.zIndex  = 10;	   

	   var shareQuestion_shareQuestionCompletePage = document.getElementById ( "shareQuestion_shareQuestionCompletePage" );
	   shareQuestion_shareQuestionCompletePage.style.display = "block";
	   shareQuestion_shareQuestionCompletePage.style.zIndex  = 20;	   
   }
   
   function shareQuestion_handleRegistrationEmailProviderSelected () {
      var shareQuestion_shareQuestionInviteEmailProvider = document.getElementById ( "shareQuestion_shareQuestionInviteEmailProvider" );
	  var selectedProvider = shareQuestion_shareQuestionInviteEmailProvider.value;
	  //alert ( "SELECTED: " + selectedProvider );
	  
	  var shareQuestion_shareQuestionInvitePageEmailMessage = document.getElementById ( "shareQuestion_shareQuestionInvitePageEmailMessage" );
	  var shareQuestion_shareQuestionInviteWebMailPasswordLabel = document.getElementById ( "shareQuestion_shareQuestionInviteWebMailPasswordLabel" );
	  
	  switch ( selectedProvider ) {
	     case "yahoo":
		    shareQuestion_shareQuestionInvitePageEmailMessage.innerHTML = 
			   "Enter your Yahoo details below.  Then click \"Get Contacts\" to chooser from your Yahoo email contacts.";
			shareQuestion_shareQuestionInviteWebMailPasswordLabel.innerHTML = "Yahoo password:";
		    break;
	
	     case "hotmail":
		    shareQuestion_shareQuestionInvitePageEmailMessage.innerHTML = 
			   "Enter your Hotmail details below.  Then click \"Get Contacts\" to chooser from your Hotmail email contacts.";
			   shareQuestion_shareQuestionInviteWebMailPasswordLabel.innerHTML = "Hotmail password:";
		    break;
			
	     case "gmail":
		    shareQuestion_shareQuestionInvitePageEmailMessage.innerHTML = 
			   "Enter your Gmail details below.  Then click \"Get Contacts\" to chooser from your Gmail email contacts.";
			   shareQuestion_shareQuestionInviteWebMailPasswordLabel.innerHTML = "Gmail password:";
		    break;
			
		 case "aol":
		    shareQuestion_shareQuestionInvitePageEmailMessage.innerHTML = 
			   "Enter your AOL details below.  Then click \"Get Contacts\" to chooser from your AOL email contacts.";
			   shareQuestion_shareQuestionInviteWebMailPasswordLabel.innerHTML = "AOL password:";
		    break;

		 case "other":
		    shareQuestion_shareQuestionInvitePageEmailMessage.innerHTML = 
			   "Enter your web email details below.  Then click \"Get Contacts\" to chooser from your web email contacts.";
			   shareQuestion_shareQuestionInviteWebMailPasswordLabel.innerHTML = "Email password:";
		    break;
			
	     
	  }
   }
   
   /**
   * This fetches the contacts list from the user's web email.
   */
   function shareQuestion_fetchContactList () {
    //  return;
	
	//alert ( "CALELD shareQuestion_fetchContactList: " );
	
      var youWebEmailAddress = document.getElementById ( "shareQuestion_shareQuestionInviteWebMailAddress" );
	  var youWebEmailAddressValue = youWebEmailAddress.value;
	  
	  var youWebEmailPassword = document.getElementById ( "shareQuestion_shareQuestionInviteWebMailPassword" );
	  var youWebEmailPasswordValue = youWebEmailPassword.value;
	  
	 // alert ( "ABOUT TO CALL BACK END" );
	  try {
	     getEmailContactList ( shareQuestion_handleContactsFetched, youWebEmailAddressValue, youWebEmailPasswordValue ); 
	  } catch ( exc ) {
	    alert ( "EXC: " + exc );
	  } 
	 //alert ( "youWebEmailAddress: " + youWebEmailAddressValue + "  youWebEmailPasswordValue: " + youWebEmailPasswordValue );
   }
   
   var m_shareQuestion_contactsList = Array ();
   
   function shareQuestion_toggleCheckBox ( idx ) {
   
  // alert ( "TOGGLE" );
   
      var contactObject = m_shareQuestion_contactsList[Number(idx)];
      var checkBoxId = "checkbox" + idx;
      var checkbox = document.getElementById ( checkBoxId );
	  if ( checkbox.checked ) {
	     checkbox.checked = false;
	  } else {
	     checkbox.checked = true;
	  }
	  if ( checkbox.checked ) {
	     contactObject.isSelected = true;
	  } else {
	     contactObject.isSelected = false;
	  }
	  
   }
   
   function shareQuestion_handleCheckBoxChanged ( idx ) {
      var contactObject = m_shareQuestion_contactsList[Number(idx)];
      var checkBoxId = "checkbox" + idx;
      var checkbox = document.getElementById ( checkBoxId );
	  if ( checkbox.checked ) {
	     contactObject.isSelected = true;
	  } else {
	     contactObject.isSelected = false;
	  }
	//  alert ( "NOW IS CHECKED: " + checkbox.checked );
   }
   
   function shareQuestion_deselectAllContacts () {
      for ( var idx = 0; idx < m_shareQuestion_contactsList.length; idx++ ) {
	     var contactObject = m_shareQuestion_contactsList[idx];
		 contactObject.isSelected = false;
		 var checkBoxId = "checkbox" + idx;
		 var checkbox = document.getElementById ( checkBoxId );
		 checkbox.checked = false;
	  }
   }
   
   function shareQuestion_selectAllContacts () {
      for ( var idx = 0; idx < m_shareQuestion_contactsList.length; idx++ ) {
	     var contactObject = m_shareQuestion_contactsList[idx];
		 contactObject.isSelected = true;
		 var checkBoxId = "checkbox" + idx;
		 var checkbox = document.getElementById ( checkBoxId );
		 checkbox.checked = true;
	  }
   }
   
   
   var m_dummyContacts = [
      { contactName:"arnie", emailAddress:"arnie@aol.com" },
      { contactName:"Aardvark", emailAddress:"Aardvark@yahoo.com" },
      { contactName:"April", emailAddress:"April@yahoo.com" },
      { contactName:"Aziz", emailAddress:"Aziz@yahoo.com" },
      { contactName:"Barney", emailAddress:"Barney@yahoo.com" },
      { contactName:"betty", emailAddress:"betty@yahoo.com" },
      { contactName:"bill", emailAddress:"bill@yahoo.com" },
      { contactName:"carrie", emailAddress:"carrie@yahoo.com" },
      { contactName:"catherine", emailAddress:"catherine@yahoo.com" },
      { contactName:"candice", emailAddress:"candice@yahoo.com" },
      { contactName:"canola_oil", emailAddress:"canola_oil@yahoo.com" },
      { contactName:"david", emailAddress:"david@yahoo.com" },
      { contactName:"derick", emailAddress:"derick@yahoo.com" }
   ];
   

  
   function shareQuestion_handleContactsFetched ( data, xml ) {
	  
	 // alert ( "FETCHED" );
	 // alert ( "data: " + data );
	  
	  if ( data.code == "GET_EMAIL_CONTACT_LIST_ERROR" ) {
		    _private_shareQuestion_hideSpinner ();
		  //alert ( " ERROR: " + data.errorMessage );
		  shareQuestion_showOverallError ( data.errorMessage  );
		  return;
	  }
	  
	  var shareQuestion_shareQuestionWebMailContactsDiv = document.getElementById ( "shareQuestion_shareQuestionWebMailContactsDiv" );
	  
	  var contacts = data.contacts.contacts;
	  
	  shareQuestion_shareQuestionWebMailContactsDiv.innerHTML = contacts.length + " Contacts Found";
	  
	  m_shareQuestion_contactsList = new Array ();
	  var strHTML = "";
	  
	  
	  if ( contacts.length > 0 ) {
		  
	     strHTML += "<div style='padding:4px; padding-top:10px; margin-bottom:2px;'><a style='color:#222222;' href='JavaScript:shareQuestion_selectAllContacts()'/>Select All</a>&nbsp;&nbsp;<a style='color:#222222;' href='JavaScript:shareQuestion_deselectAllContacts()'/>De-Select All</a></div>";
		  
	     for ( var idx = 0; idx < contacts.length; idx++ ) {
		    var contact = contacts[idx];
			var contactObject = new Object ();
			contactObject.contact = contact;
			contactObject.isSelected = true;
			m_shareQuestion_contactsList.push(contactObject);
		
		    var checkboxId = "checkbox" + idx;
			
		    var contactHTML = "<div style='padding:4px; margin-bottom:2px;'><input id='" + checkboxId + "' onclick=\"shareQuestion_handleCheckBoxChanged('" + idx + "')\" type='checkbox' checked='true' style='padding:0; margin:0;' /> <span style='padding:10px; cursor:pointer;' onclick=\"shareQuestion_toggleCheckBox('" + idx + "')\" >" + contact.contactName + " - " + contact.emailAddress + "</span></div>";
			strHTML += 	contactHTML;
		 }
		 
		 strHTML += "<div style='padding:4px; padding-top:10px; margin-bottom:2px;'><a style='color:#222222;' href='JavaScript:shareQuestion_selectAllContacts()'/>Select All</div>";
		 
	  }
	  
	  shareQuestion_shareQuestionWebMailContactsDiv.innerHTML = strHTML;
	  
	   _private_shareQuestion_hideSpinner ();
	
      var shareQuestion_shareQuestionWebMailDiv = document.getElementById ( "shareQuestion_shareQuestionWebMailDiv" );
	  shareQuestion_shareQuestionWebMailDiv.style.display = "none";
	  
	  var shareQuestion_shareQuestionWebMailContactsDiv = document.getElementById ( "shareQuestion_shareQuestionWebMailContactsDiv" );
	  shareQuestion_shareQuestionWebMailContactsDiv.style.display = "block";
	  	  
   }
   

   
   function shareQuestion_shareQuestionGetWebMailContacts () {
	   
	   toolTips_hideToolTip  ();
	   
	  // alert ( " shareQuestion_shareQuestionGetWebMailContacts called" );
	   
	   try {
	  if ( shareQuestion_validateWebMailInformation () ) {
		  
		  
		   shareQuestion_hideOverallError ();
		   
		  
		  try {
			  _private_shareQuestion_showSpinner ();
		  shareQuestion_fetchContactList ();
		  } catch ( exc ) {
			   alert ( "EXC: " + exc );
		  }
		  //shareQuestion_getWebMailContactsFromBackEnd ();
	  }
	   } catch ( excouter ) {
		    alert ( "EXCOUTER: " + excouter );
	   }
 
   }
   
   function shareQuestion_initRegistrationPage () {
	   
//alert ( "INIT REG PAGE CALLED" );
try {
      shareQuestion_initToolTips ();
} catch ( exc ) {
	alert ( "EXC: " + exc );
}
   }
   
   function shareQuestion_initToolTips () {
	   
	  
	  var shareQuestion_shareQuestionInviteWebMailAddress = document.getElementById ( "shareQuestion_shareQuestionInviteWebMailAddress" );
	  shareQuestion_shareQuestionInviteWebMailAddress.onmouseover = function () { 
	     toolTips_showToolTip ( "shareQuestion_shareQuestionInvitePage", "shareQuestion_shareQuestionInviteWebMailAddress", 
		    "We need to use this email address to access your web mail contacts.  We don't store this address.",
			 420, 20 );
	  }
	  shareQuestion_shareQuestionInviteWebMailAddress.onmouseout = toolTips_hideToolTip;
	 // shareQuestion_shareQuestionInviteWebMailAddress.onclick = toolTips_hideToolTip;
	  
	  var shareQuestion_shareQuestionInviteWebMailPassword = document.getElementById ( "shareQuestion_shareQuestionInviteWebMailPassword" );
	  shareQuestion_shareQuestionInviteWebMailPassword.onmouseover = function () { 
	     toolTips_showToolTip ( "shareQuestion_shareQuestionInvitePage", "shareQuestion_shareQuestionInviteWebMailPassword", 
		    "We need to temporarily use this password to access your web mail contacts.  We don't store this password.",
			 420, 50 );
	  }
	  shareQuestion_shareQuestionInviteWebMailPassword.onmouseout = toolTips_hideToolTip;
	 // shareQuestion_shareQuestionInviteWebMailPassword.onclick = toolTips_hideToolTip;
	  
	  var shareQuestion_shareQuestionInviteEmailsList = document.getElementById ( "shareQuestion_shareQuestionInviteEmailsList" );
	  shareQuestion_shareQuestionInviteEmailsList.onmouseover = function () { 
	     toolTips_showToolTip ( "shareQuestion_shareQuestionInvitePage", "shareQuestion_shareQuestionInviteEmailsList", 
		    "If you would like, you can enter your friends' email addresses into this field.  Comma-delimited please!",
			 540, 120 );
	  }
	  shareQuestion_shareQuestionInviteEmailsList.onmouseout = toolTips_hideToolTip;
	  shareQuestion_shareQuestionInviteEmailsList.onclick = toolTips_hideToolTip;
	  
	  var shareQuestion_shareQuestionOptionalMessage = document.getElementById ( "shareQuestion_shareQuestionOptionalMessage" );
	  shareQuestion_shareQuestionOptionalMessage.onmouseover = function () { 
	     toolTips_showToolTip ( "shareQuestion_shareQuestionInvitePage", "shareQuestion_shareQuestionOptionalMessage", 
		    "You can enter your own message here to be sent along with the question.",
			 540, 220 );
	  }
	  shareQuestion_shareQuestionOptionalMessage.onmouseout = toolTips_hideToolTip;
	  shareQuestion_shareQuestionOptionalMessage.onclick = toolTips_hideToolTip;
	  
	  
   }
   
   var m_shareQuestion_afterRegistrationCallback = null;
   
   function shareQuestion_setAfterRegistrationCallback ( _callback ) {
	   m_shareQuestion_afterRegistrationCallback = _callback;
   }
   
	/**
	* The URL of the "register" service for VideoJax.com
	*/		
	//var registerUrl = "./dummyData/dummyRegisterResponse.html"; ///videocube/login.htm";
    var m_shareQuestion_registerUrl = "/videocube/login.htm";

	/**
	* Sends the registration data to the VideoJax.com back end using an HTTP POST.  If there is an error returned by the
	* back end, it will be displayed in the registration form.  If no error is returned, then the registration form will go
	* away and the user will be "logged in" and the "You are logged in as ..." form will show in the upper right of the screen.
	*/
	function shareQuestion_postRegistrationData () {
	
	    var strURL = m_shareQuestion_registerUrl;
		
		//strURL += ( "&uniqueCallId=" + getNextUniqueCallId () );
		
		var xmlHttpReq = false;
		var self = this;
		// Mozilla/Safari
		if (window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}
		// IE
		else if (window.ActiveXObject) {
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function() {

			if (self.xmlHttpReq.readyState == 4) {
				//alert ( "READY STATE 4" );
				if ( self.xmlHttpReq.responseText.indexOf ( "class=\"error\"" ) > 0 ) {
				   var indexOfErrorDiv = self.xmlHttpReq.responseText.indexOf ( "class=\"error\"" );
				   var indexOfLiStart =  self.xmlHttpReq.responseText.indexOf ( "<li>", indexOfErrorDiv );
				   var indexOfLiEnd =  self.xmlHttpReq.responseText.indexOf ( "</li>", indexOfLiStart );
				   
				   var registrationErrorString = self.xmlHttpReq.responseText.substring(indexOfLiStart + 4,indexOfLiEnd);
				   
				   shareQuestion_handleRegistrationError ( registrationErrorString );
				   
				   
				} else {
									
				   var pjuid = null;
				   var pjuidIdxStart = self.xmlHttpReq.responseText.indexOf ("EASY_TO_FIND_PJUID=");
				   
				   if ( pjuidIdxStart >= 0 ) {
				      pjuidIdxStart += "EASY_TO_FIND_PJUID=\"".length;
				      var pjuidIdxEnd = self.xmlHttpReq.responseText.indexOf ("\"", pjuidIdxStart+1);
				      pjuid = self.xmlHttpReq.responseText.substr(pjuidIdxStart, (pjuidIdxEnd - pjuidIdxStart) );
				   }					

                   shareQuestion_handleRegistrationWithBackEndComplete (pjuid);

				}
				//m_currentlyLoggingInOrOut = false;
				
				// alert ( " RESP: " + self.xmlHttpReq.responseText );
			}
		}
		self.xmlHttpReq.send(shareQuestion_getRegistrationFormData());
	}
	
	

