/*
* File Name	:      routing_queue.js
* Created By:      Sarvesh Borkar
* Created On:      8 Dec 2009
* Last Modified By:
* Last modified On:
* Purpose: JS functions used for routing queue
*/


/*######################################## START QUEUE1 PAGE JS #######################################*/

/*=====================================================
* Function Name    :    fnValidateQueuePage()
* Created By: sarvesh borkar
* Created On: 8th Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : Validate the queue form
* Parameters: frm: form object
*=====================================================
*/
function fnValidateQueuePage(frm)
{
  with(frm)
  {
	    var intSelectedCountryId         = optCountryId.value;
	    var intSelectedEthnicityId       = optEthnicityId.value;
	    var intSelectedHouseholdIncomeId = optAnnualHouseholdIncomeId.value;
	    
	    var intUSCountryId        = hdUnitedStatesCountryId.value;
	    var intCanadaCountryId    = hdCanadaCountryId.value;
	    var intLanguageId         = hdSelectedLanguageId.value;
	    var intEnglishLanguageId  = hdEnglishLanguageId.value;
	    var intEmailSettings      = hdEmailSettings.value;
	    
	    /*JS Alert Messages*/
	    var strQ1JSAlert1 = hdQ1JSAlert1.value;
	    var strQ1JSAlert2 = hdQ1JSAlert2.value;
	    var strQ1JSAlert3 = hdQ1JSAlert3.value;
	    var strQ1JSAlert4 = hdQ1JSAlert4.value;
	    var strQ1JSAlert5 = hdQ1JSAlert5.value;
	    var strQ1JSAlert6 = hdQ1JSAlert6.value;
	    var strQ1JSAlert7 = hdQ1JSAlert7.value;
	    var strQ1JSAlert8 = hdQ1JSAlert8.value;    
	    /*End*/    
	    
	    /*Country Dropdown validation*/
	    if(intSelectedCountryId == '')
	    {
	      alert(strQ1JSAlert1);
	      optCountryId.focus();
	      return false;
	    }
	    /*End*/	    
	    
	    /*Zip Code validation*/
	    if((intSelectedCountryId == intUSCountryId || intSelectedCountryId == intCanadaCountryId) && (intLanguageId == intEnglishLanguageId))
	    {
		    if(!IsEmpty(txtZipCode,'Please enter valid zip code.'))
		    {	  
			  return false;
		    }
		    else
		    {
		      if(intSelectedCountryId == intUSCountryId)
		      {
			        if(isNaN(Trim(txtZipCode.value)))
			        {
			           alert('Please enter numbers only for zip code.');
			           txtZipCode.focus();
			           return false;
			        }
			        
			        if(parseInt(txtZipCode.value.length) !=5)
			        {
			           alert('United States zipcodes have 5 digits only.');
			           txtZipCode.focus();
			           return false;
			        }
		      }
		      else if(intSelectedCountryId == intCanadaCountryId)
		      {	        
			       var regex = /[^0-9a-zA-Z' ']/;
			       if(regex.test(txtZipCode.value))
			       {
			          alert('Please enter valid zip code');
			          txtZipCode.focus();
			          return false;
			       }
		      }
		    }
		  }		
	    /*End*/
	    
	    
	    /*Birth Date Validation*/
	    var Month = optMonthId.value;
		var Day   = optDayId.value;
		var Year  = optYearId.value;
		
		if(intSelectedCountryId == intUSCountryId)
		{		
			if(Month == '')
			{
			  alert(strQ1JSAlert2);
			  optMonthId.focus();
			  return false;
			}
			
			if(Day == '')
			{
			  alert(strQ1JSAlert3);
			  optDayId.focus();
			  return false;
			}
	    }
	    else
	    {
	       if(Day == '')
			{
			  alert(strQ1JSAlert3);
			  optDayId.focus();
			  return false;
			}
			
		   if(Month == '')
			{
			  alert(strQ1JSAlert2);
			  optMonthId.focus();
			  return false;
			}
	    }
			
		if(Year == '')
		{
		  alert(strQ1JSAlert4);
		  optYearId.focus();
		  return false;
		}			
		
		if(!fnCheckValidDate(Year,Month,Day))
		{
		   alert(strQ1JSAlert5);
		   optDayId.focus();
		   return false;	  
		}
		/*End*/
	    
	    /*Gender Validation*/
	    boolMaleGender   = document.getElementById('rdMaleGender').checked;
	    boolFemaleGender = document.getElementById('rdFemaleGender').checked;
	    
	    if(boolMaleGender == false && boolFemaleGender == false)
	    {
	      alert(strQ1JSAlert6);
	      document.getElementById('rdMaleGender').focus();
	      return false;
	    }
	    /*End*/
	    
	    /*Ethnicity and Household income validation*/
	    if((intSelectedCountryId == intUSCountryId) && (intLanguageId == intEnglishLanguageId))
	    {
		      if(intSelectedEthnicityId == '')
		      {
		        alert('Please select the ethnicity.');
		        optEthnicityId.focus();
		        return false;
		      }
		      
		      if(intSelectedHouseholdIncomeId == '')
		      {
		        alert('Please select the household income.');
		        optAnnualHouseholdIncomeId.focus();
		        return false;
		      }	      
	    }
	    /*End*/
	    
	    /*Non-member Email validation*/
	    if(intEmailSettings == 1)
	    {	    
		    if(!IsEmpty(txtNonMemberEmail,strQ1JSAlert7))
		    {	  
			  return false;
		    }
		    
		    if(!IsEmail(txtNonMemberEmail,strQ1JSAlert8))
	        {
	            return false;
	        }
	    }
	    /*End*/         
       
        frm.action = "routing_queue_handler.php";          
        fnDisableButtonOnSubmit(frm); 
        frm.submit();     
  }
}

/*=====================================================
* Function Name    :    fnSwitchDOBDropdowns()
* Created By: sarvesh borkar
* Created On: 8th Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : Switch DOB dropdowns
* Parameters: intSelectedCountryId: selected country Id
*=====================================================
*/
function fnSwitchDOBDropdowns(intSelectedCountryId)
{
  var intUSCountryId = document.getElementById('hdUnitedStatesCountryId').value;
  
  if(intSelectedCountryId != intUSCountryId)
  {
    document.getElementById('idMonthPlaceHolder').appendChild(document.getElementById('idDayDropdown'));
    document.getElementById('idDayPlaceHolder').appendChild(document.getElementById('idMonthDropdown'));
  }
  else
  {
    document.getElementById('idMonthPlaceHolder').appendChild(document.getElementById('idMonthDropdown'));
    document.getElementById('idDayPlaceHolder').appendChild(document.getElementById('idDayDropdown'));
  }
}

/*=====================================================
* Function Name    :    fnShowHideUSSpecificDropdowns()
* Created By: sarvesh borkar
* Created On: 8th Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : Switch US Specific Dropdowns
* Parameters: intSelectedCountryId: selected country Id
*=====================================================
*/
function fnShowHideUSSpecificDropdowns(intSelectedCountryId)
{
  var intUSCountryId       = document.getElementById('hdUnitedStatesCountryId').value;
  var intLanguageId        = document.getElementById('hdSelectedLanguageId').value;
  var intEnglishLanguageId = document.getElementById('hdEnglishLanguageId').value;
  
  if((intSelectedCountryId == intUSCountryId) && intLanguageId == intEnglishLanguageId)
  {
    document.getElementById('idEthnicityTR').style.display = '';
    document.getElementById('idHouseHoldIncomeTR').style.display = '';
  }
  else
  {
    document.getElementById('idEthnicityTR').style.display = 'none';
    document.getElementById('idHouseHoldIncomeTR').style.display = 'none';
  }  
}

/*=====================================================
* Function Name    :    fnShowHideZipCodeBox()
* Created By: sarvesh borkar
* Created On: 8th Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : Show hide zip code box for US/Canada and other countries for english language
* Parameters: intSelectedCountryId -- country id
*=====================================================
*/
function fnShowHideZipCodeBox(intSelectedCountryId)
{
  var intUSCountryId       = document.getElementById('hdUnitedStatesCountryId').value;
  var intCanadaCountryId   = document.getElementById('hdCanadaCountryId').value;
  var intLanguageId        = document.getElementById('hdSelectedLanguageId').value;
  var intEnglishLanguageId = document.getElementById('hdEnglishLanguageId').value;
  
  if((intSelectedCountryId == intUSCountryId || intSelectedCountryId == intCanadaCountryId) && intLanguageId == intEnglishLanguageId)
  {
    document.getElementById('idZipCodeTR').style.display = '';
  }
  else
  {
    document.getElementById('idZipCodeTR').style.display = 'none';
  }
  
}

/*=====================================================
* Function Name    :    fnShowHideEmailAddrBox()
* Created By: sarvesh borkar
* Created On: 8th Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : Show hide email code box depending on E value
* Parameters: 
*=====================================================
*/
function fnShowHideEmailAddrBox(intEmailSettings)
{
  
  if(intEmailSettings == 1)
   {
	 document.getElementById('idEmailAddrTR').style.display = '';
   }
   else
   {
     document.getElementById('idEmailAddrTR').style.display = 'none';    
   } 
}

/*=====================================================
* Function Name    :    fnClickLanguage()
* Created By: sarvesh borkar
* Created On: 10th Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : Store the language selected on click of a language
* Parameters: frm: form object
*=====================================================
*/
function fnClickLanguage(strLanguageName)
{
  document.getElementById('hdSelectedLanguageName').value = strLanguageName;
  fnDisableButtonOnSubmit(document.frmRouterQueue);
  document.frmRouterQueue.submit();  
}

/*=====================================================
* Function Name    :    fnCheckFlashCookieValidity()
* Created By: sarvesh borkar
* Created On: 23rd Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : To check the validity of the flash cookie (60 days)
* Parameters: flashCookieVal
*=====================================================
*/
function fnCheckFlashCookieValidity(flashCookieVal)
{
  $.post("routing_queue_handler.php", 
	   { "flashCookieVal" : flashCookieVal,"hdAction": 'FCValidity' },
			  
	     function(data)
	      {			   
			intFlashCookieValid = data;	
			
			if(intFlashCookieValid == 1)			  
			  location.replace('routing_queue_handler.php?hdAction=FCAvailable&FC='+flashCookieVal);
			else
			  document.getElementById('mainTable').style.visibility = 'visible';			  				  			
				  
	      },'text');		
}

/*######################################## END QUEUE1 PAGE JS #######################################*/

/*######################################## START QUEUE 2 PAGE JS #######################################*/

/*=====================================================================
* Function Name    :   fnShowHideQueue2Details
* Created By: Gauri Sawaikar
* Created On: 28 Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : to show and hide industry/job/role dropdowns on Queue2 page
* Parameters: optEmploymentStatusId : Employment status id
*======================================================================
*/
function fnShowHideQueue2Details(optEmploymentStatusId)
{
  	var intRetiredEmplStatusId    = document.getElementById('hdRetiredEmplStatusId').value;
	var intStudentEmplStatusId    = document.getElementById('hdStudentEmplStatusId').value;
	var intHomemakerEmplStatusId  = document.getElementById('hdHomemakerEmplStatusId').value;
	var intUnemployedEmplStatusId = document.getElementById('hdUnemployedEmplStatusId').value;
	
	if(optEmploymentStatusId!=intRetiredEmplStatusId && optEmploymentStatusId!=intStudentEmplStatusId && optEmploymentStatusId!=intHomemakerEmplStatusId && optEmploymentStatusId!=intUnemployedEmplStatusId)
	{
		document.getElementById('industry_tr').style.display="";
		document.getElementById('job_tr').style.display="";
		document.getElementById('role_tr').style.display="";			
	}
	else
	{
		document.getElementById('industry_tr').style.display="none";
		document.getElementById('optIndustryId').selectedIndex ="";
		document.getElementById('job_tr').style.display="none";
		document.getElementById('optJobTitleId').selectedIndex ="";
		document.getElementById('role_tr').style.display="none";
		document.getElementById('optRoleId').selectedIndex ="";
	}
}

/*====================================================================
* Function Name    :    fnValidateQueue2Page()
* Created By: Gauri Sawaikar
* Created On:28 Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : to validate Queue2 page
* Parameters: form
*======================================================================
*/
function fnValidateQueue2Page(frm)
{
    with(frm)
    {
		if(optEducationLevelId.value=="")
		{
			alert("Please select your education status.");
			optEducationLevelId.focus();
			return false;
		}
		
		if(optEmploymentStatusId.value=="")
		{
			 alert("Please select your employment status.");
			 optEmploymentStatusId.focus();
			 return false;
		}
		
		if(optEmploymentStatusId.value!="")
		{		
			if((optEmploymentStatusId.value!=hdRetiredEmplStatusId.value) && (optEmploymentStatusId.value!=hdStudentEmplStatusId.value) && (optEmploymentStatusId.value!=hdHomemakerEmplStatusId.value) && (optEmploymentStatusId.value!=hdUnemployedEmplStatusId.value))
			{
				if(optIndustryId.value=="")
				{
				   alert("Please select your industry.");
				   optIndustryId.focus();
				   return false;
				}		
				
				if(optRoleId.value=="")
				{
				   alert("Please select your role.");
				   optRoleId.focus();
				   return false;
				}		
				
				if(optJobTitleId.value=="")
				{
				   alert("Please select your job title.");
				   optJobTitleId.focus();
				   return false;
				}
			}			
		}
		
		if(optMaritalStatusId.value=="")
		{
			alert("Please select your marital status.");
			optMaritalStatusId.focus();
			return false;
		}		
		
		var children_under_18_radio_choice = false;
		for (counter = 0; counter < rdChildrenUnder18.length; counter++)
		{
			if (rdChildrenUnder18[counter].checked)
			children_under_18_radio_choice = true; 
		}
			
		if(children_under_18_radio_choice==false)
		{
			alert("Please select whether there are childern under 18 or no.");
			rdChildrenUnder18[0].focus();
			return false;
		}
		/*validating Child Info*/
		if(!fnValidateChildInfoQueue2())
			return false;	
	}
    frm.action = "routing_queue_handler.php";          
    fnDisableButtonOnSubmit(frm); 
    frm.submit();	
}

/*==========================================================
* Function Name :  fnValidateChildInfoQueue2
* Created By: Gauri Sawaikar
* Created On: 28 Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : To validate child details for Queue2 Page
* Parameters: 
*==========================================================
*/
function fnValidateChildInfoQueue2()
{
	var cntChild = parseInt(document.getElementById('hdChildCount').value);
	
	for(i=1;i<=cntChild;i++)
	{
		validate = 1;
		//Validate the Child Info when 	- More than 1 Child Info Cards are added 	- When user enters any data in the Child Info Card
		if(cntChild == 1)
		{
		  //When No data is entered for Child 1, Do not validate Child Info
		  if(document.getElementById('optYearId_'+i).value=='' && document.getElementById('optMonthId_'+i).value=='' && document.getElementById('optDayId_'+i).value=='' &&
			document.getElementById('male_'+i).checked!=true && document.getElementById('female_'+i).checked!=true)
				validate = 0;
		}
		if(validate && document.getElementById('male_'+i))
		{
			// Check that Date Year/Month/Date is entered by user
			if(document.getElementById('optYearId_'+i).value=='')
			{
				alert("Please select valid birth date for Child "+i);
				document.getElementById('optYearId_'+i).focus();
				return false;
			}
			else if(document.getElementById('optMonthId_'+i).value=='')
			{
				alert("Please select valid birth date for Child "+i);
				document.getElementById('optMonthId_'+i).focus();
				return false;				
			}
			else if(document.getElementById('optDayId_'+i).value=='')
			{
				alert("Please select valid birth date for Child "+i);
				document.getElementById('optDayId_'+i).focus();
				return false;				
			}
			if(!fnCheckValidDate(document.getElementById('optYearId_'+i).value,
								document.getElementById('optMonthId_'+i).value,
								document.getElementById('optDayId_'+i).value))
			{
				alert("Please select valid birth date for Child "+i);
				document.getElementById('optDayId_'+i).focus();
				return false;	
			}
			
			if(document.getElementById('male_'+i).checked!=true && document.getElementById('female_'+i).checked!=true)
			{
				alert("Please specify gender for Child "+i);
				document.getElementById('male_'+i).focus();
				return false;
			}
			
			var today = new Date();
			// Check that calculated age is not more than 18 years.
			if(
				   (parseInt(today.getFullYear(),10) - parseInt(document.getElementById('optYearId_'+i).value,10) == 18 
				&& parseInt(today.getMonth(),10)+1 > parseInt(document.getElementById('optMonthId_'+i).value,10))
			   ||
				   (parseInt(today.getFullYear(),10) - parseInt(document.getElementById('optYearId_'+i).value,10) == 18 
				&& parseInt(today.getMonth(),10)+1 == parseInt(document.getElementById('optMonthId_'+i,10).value)
				&& parseInt(today.getDate(),10) >= parseInt(document.getElementById('optDayId_'+i).value,10))
			   )
			{
				alert("Child "+i+" is not under 18 years. Please either remove this child info or change the birth date.");
				document.getElementById('optYearId_'+i).focus();
				return false;
			}
			// Check that birthdate is not a future date
			if(
				   (parseInt(today.getFullYear(),10) == parseInt(document.getElementById('optYearId_'+i).value,10)
			   && parseInt(today.getMonth(),10)+1 < parseInt(document.getElementById('optMonthId_'+i).value,10))
			||
				   (parseInt(today.getFullYear(),10) == parseInt(document.getElementById('optYearId_'+i).value,10) 
				&& parseInt(today.getMonth(),10)+1 == parseInt(document.getElementById('optMonthId_'+i,10).value)
				&& parseInt(today.getDate(),10) < parseInt(document.getElementById('optDayId_'+i).value,10))
			)
			{
				alert("Birth Date of Child "+i+" cannot be a future date");
				document.getElementById('optYearId_'+i).focus();
				return false;
			}
		}		
	}
	return true;
}
/*======================================================================
* Function Name :  fnRemoveChildInfoDOMQueue2
* Created By: Gauri Sawaikar
* Created On: 28 Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : To remove child info from DOM
* Parameters: position : Child Index to be Removed
*======================================================================
*/
function fnRemoveChildInfoDOMQueue2(position)
{
	var cntChild = parseInt(document.getElementById('hdChildCount').value)
	var position = parseInt(position);
	
	if(!confirm("Are you sure you want to remove info of child "+position))
		return false;
	
	for(i=position;i<=cntChild;i++)
	{
		var iNext=(parseInt(i)+1);
		
		if(document.getElementById('male_'+iNext))
		{
			document.getElementById('male_'+i).checked = document.getElementById('male_'+iNext).checked;
			document.getElementById('female_'+i).checked = document.getElementById('female_'+iNext).checked;
			
			document.getElementById('optDayId_'+i).selectedIndex = document.getElementById('optDayId_'+iNext).selectedIndex;
			document.getElementById('optMonthId_'+i).selectedIndex = document.getElementById('optMonthId_'+iNext).selectedIndex;
			document.getElementById('optYearId_'+i).selectedIndex = document.getElementById('optYearId_'+iNext).selectedIndex;			
		}
		else
		{
			document.getElementById('tdChildInfo').removeChild(document.getElementById('table_'+i).parentNode);
			document.getElementById('hdChildCount').value=cntChild-1;
			if(cntChild-1 == 0)
			{
				fnShowHideDOMChildInfo('HIDE');
				document.getElementById('rdChildrenUnder18_N').checked='checked';
			}
		}
	}
}

/*===========================================================================
* Function Name :  fnShowHideDOMChildInfoQueue2
* Created By: Gauri Sawaikar
* Created On: 28 Dec 2009
* Last Modified By: 
* Last modified On: 
* Purpose : To show/hide the area for child info inputs for Queue2 Page
* Parameters: Action = Show / Hide
*===========================================================================
*/
function fnShowHideDOMChildInfoQueue2(strAction)
{
	var TD = document.getElementById('tdChildInfo');
	var TR = document.getElementById('trChildInfo');
	
	if(strAction=='SHOW' && TD.style.display=="none")
	{
		ajaxGetChildInfoDOM('US','Queue2');
		TD.style.display="";
		TR.style.display="";
	}
	else if(strAction=='HIDE' && TD.style.display=="")
	{
		if( document.getElementById('hdChildCount').value!=0 && confirm("The information regarding children under 18 in your household will be lost. Do you want to continue?"))
		{
			TD.innerHTML='';
			TD.style.display="none";
			TR.style.display="none";
			document.getElementById('hdChildCount').value=0;
		}
		else
		{
			document.getElementById('rdChildrenUnder18_Y').checked='checked';	
		}
	}
}

/*######################################## END QUEUE 2 PAGE JS #######################################*/


/*######################################## START QUEUE 3 PAGE JS #######################################*/

/*===========================================================================
* Function Name :  fnPopulateHiddenAnsCount
* Created By: Sarvesh Borkat
* Created On: 5 JAN 2009
* Last Modified By: 
* Last modified On: 
* Purpose : To increase the selected Question count so that we can 
* Parameters: pointer -- this (pointer)
*===========================================================================
*/
function fnPopulateHiddenAnsCount(pointer,intQuestionId)
{  
    
  var count = parseInt(document.getElementById('QA_Count_'+intQuestionId).value);
  
  if(pointer.type == "checkbox" || pointer.type == "radio")
  {
     if(pointer.checked)
      document.getElementById('QA_Count_'+intQuestionId).value = count+1;
     else
      document.getElementById('QA_Count_'+intQuestionId).value = count-1;
    
  }
  else if(pointer.type == "select-one")
  {    
    if(parseInt(pointer.value))
      document.getElementById('QA_Count_'+intQuestionId).value = count+1;   
    else
      document.getElementById('QA_Count_'+intQuestionId).value = 0;
    
  }
  
}

/*===========================================================================
* Function Name :  fnValidateQueue3Page
* Created By: Sarvesh Borkat
* Created On: 5 JAN 2009
* Last Modified By: 
* Last modified On: 
* Purpose : To validate Q3 Page
* Parameters: pointer -- frm
*===========================================================================
*/
function fnValidateQueue3Page(frm)
{
  with(frm)
  {
     var strQuestionId = document.getElementById('Q_ID').value;
         arrQuestionId = strQuestionId.split('=>');
     var intArrQuesLength = arrQuestionId.length;
     
    /*JS Alert Messages*/
	var strQ3JSAlert1 = hdQ3JSAlert1.value;     
    /*End*/
    
     for(i=0;i<intArrQuesLength;i++)
     {
        var intQuestionId = arrQuestionId[i];       
        var count = parseInt(document.getElementById('QA_Count_'+intQuestionId).value);
        
        if(count == 0)
        {
          alert(strQ3JSAlert1);
          return false;
        } 
     }
     
     frm.action = "routing_queue_handler.php";          
     fnDisableButtonOnSubmit(frm); 
     frm.submit();   
  }
}

/*######################################## END QUEUE 3 PAGE JS #######################################*/


/*######################################## START QUEUE 4 PAGE JS #######################################*/

function fnGetCaptchaData()
{
	var strTimeStamp = new Date().getTime();
   	
   	document.getElementById("trPageLoadingImg").style.display = "";
   	document.getElementById("btStartSuvey").disabled = "disabled";
   	$.post("routing_queue_handler.php", {"hdAction" : "getCaptchaValue" , "timestamp" : strTimeStamp},
	function(data)
	{
		document.getElementById("hdCaptchaValue").value = data;
		document.getElementById("trPageLoadingImg").style.display = "none";
		document.getElementById("btStartSuvey").disabled = "";
	},'text');
	clearInterval(setIntervalId);
}
/*===========================================================================
* Function Name :  fnGetCaptchaValue
* Created By: Gauri Sawaikar
* Created On: 4 Jan 2010
* Last Modified By: 
* Last modified On: 
* Purpose : To get captcha value by Ajax & set in hidden field
* Parameters: 
*===========================================================================
*/
function fnGetCaptchaValue()
{
	setIntervalId = setInterval ("fnGetCaptchaData()", 1000);
}
/*===========================================================================
* Function Name :  fnGetNewCaptcha
* Created By: Gauri Sawaikar
* Created On: 16 Aug 2010
* Last Modified By: 
* Last modified On: 
* Purpose : To get new captcha value
* Parameters: 
*===========================================================================
*/
function fnGetNewCaptcha()
{
	document.getElementById('captcha_image').src='secure_image_show.php?sid=' + Math.random();
	fnGetCaptchaValue();
	return false;
}
/*===========================================================================
* Function Name :  fnSubmitQueue4Page
* Created By: Gauri Sawaikar
* Created On: 4 Jan 2010
* Last Modified By: 
* Last modified On: 
* Purpose : To submit Queue4 form
* Parameters: frm : form
*===========================================================================
*/
function fnSubmitQueue4Page(frm)
{
    with(frm)
    {
		/*Validate Captcha*/

		//If captcha value has not been got through ajax, return false
		if(hdCaptchaValue.value == "NULL") 
		 return false

		//If captcha value is empty
		var strCaptchaVal = Trim(txtQueueCaptcha.value);
	   	if(strCaptchaVal == 0 || strCaptchaVal == "")
	   	{
	   		alert(hdQ4JSAlert1.value);
	   		txtQueueCaptcha.value = "";
	   		txtQueueCaptcha.focus();
	   		return false;
	   	}

		//If captcha value is not empty
	   	strCaptchaVal = strCaptchaVal.toLowerCase();
	   	if( strCaptchaVal!=hdCaptchaValue.value)
	   	{
	   		fnGetNewCaptcha();
	   		document.getElementById("trInvalidCaptchaMsg").style.display = "";
	   		txtQueueCaptcha.value = "";
	   		txtQueueCaptcha.focus();
	   		return false;
	   	}
	   	/*End*/

    	frm.action = "routing_queue_handler.php";          
    	fnDisableButtonOnSubmit(frm);
    	var d = new Date();
    	var strPageName = "queue4"+d.getTime();
    	frm.target=strPageName
    	window.open('',strPageName);   	
    	frm.submit();    	    		
	}
    location.replace('queue_survey_redirect.php');
}

/*######################################## END QUEUE 4 PAGE JS #######################################*/


/*######################################## START QUEUE 5 PAGE JS #######################################*/
/*===========================================================================
* Function Name :  fnSubmitQueue5Page
* Created By: Gauri Sawaikar
* Created On: 8 Jan 2010
* Last Modified By: 
* Last modified On: 
* Purpose : To submit Queue5 form
* Parameters: frm : form
*===========================================================================
*/
function fnSubmitQueue5Page(frm,strAction)
{
    with(frm)
    {
    	frm.action = "routing_queue_handler.php";
    	frm.hdAction.value = strAction;          
    	fnDisableButtonOnSubmit(frm);
    	if(strAction == "Login_Now" || strAction == "Register_Now")
    	{
    	   var d = new Date();
    	   var strPageName = "queue5"+d.getTime();
    	   frm.target=strPageName;
    	   window.open('',strPageName);
    	}
    	frm.submit();	
	}

}

/*######################################## END QUEUE 5 PAGE JS #######################################*/