﻿//function onchangeTitle(obj)
//{
//  //alert("onchangeTitle START obj.options[obj.selectedIndex].value[" + obj.options[obj.selectedIndex].value + "]");
//  var _Split = (obj.options[obj.selectedIndex].value).split(":");
//  //alert("_Split(0)[" + _Split[0] + "]  _Split(1)[" + _Split[1] + "]");
//        
//  //if (_Split[1]=='TRUE')
//  if (_Split[1]=='FALSE')
//  {
//    // Title is non-gender specific e.g. "Prof" or "Dr" - so show the gender selector
//    showTableRow('Gender');
//  }
//  else
//  {
//    // Title is gender specific e.g. "Mr" or Mrs" - so hide the gender selector
//    document.getElementById('Gender').style.display='none';
//  }
//}



//function onchangeEmploymentStatus(obj)
//{
//  if ((obj.options[obj.selectedIndex].value=='E') || (obj.options[obj.selectedIndex].value=='S'))
//  {
//    // Employed so show the occupation/type of business selector
//    showTableRow('Occupation');
//  }
//  else
//  {
//    // Not employed so hide the occupation/type of business selector
//    document.getElementById('Occupation').style.display='none';
//  }
//}

//function onchangeTypeOfLicence(obj, rowid)
//{
//  if (obj.options[obj.selectedIndex].value == 'I')
//  {
//    // Employed so show the occupation/type of business selector
//    showTableRow(rowid);
//  }
//  else
//  {
//    // Not employed so hide the occupation/type of business selector
//    document.getElementById(rowid).style.display='none';
//  }
//}



//function onClickConvictions(obj)
//{
//  if (obj.value == 'RadioButtonYes')
//  {
//    // Show the conviction selector
//    //document.getElementById('Convictions').style.display='block';
//    showTable('Convictions');
//  }
//  else
//  {
//    // Hide the conviction selector
//    document.getElementById('Convictions').style.display='none';
//  }
//}



//function onClickClaims(obj)
//{
//  if (obj.value == 'RadioButtonYes')
//  {
//    // Show the claim selector
//    //document.getElementById('Claims').style.display='block';
//    showTable('Claims');
//  }
//  else
//  {
//    // Hide the claim selector
//    document.getElementById('Claims').style.display='none';
//  }
//}



//function showTableRow(id)
//{
////document.getElementById(id).style.display='block';
//  try
//  {
//    // For Firefox - will throw an exception if IE
//    document.getElementById(id).style.display='table-row';
//  }
//  catch (e)
//  {
//    document.getElementById(id).style.display='block';
//  }
//}



//function showTable(id)
//{
//  try
//  {
//    // For Firefox - will throw an exception if IE
//    document.getElementById(id).style.display='table-row';
//  }
//  catch (e)
//  {
//    document.getElementById(id).style.display='block';
//  }
//}

function openWindow(url, windowName, options, width, height )
{
  var x = null;
  var left = parseInt((screen.availWidth/2) - (width/2));
  var top = parseInt((screen.availHeight/2) - (height/2));
    
  x = window.open(url , windowName ,options + ",left=" + left + ",top=" + top); 
  x.focus;
 }
function closeWindow() 
{
  if (window.opener != null)
    {
        window.opener.focus();
    }
    self.close();
  }
function pausecomp(millis) 
{
  var date = new Date();
  var curDate = null;

  do { curDate = new Date(); } 
  while(curDate-date < millis);
}
function showFeature(panelid)
{
// debugger;
    var objPanel = $get(panelid);
    objPanel.style.display='block';
}
function hideFeature(panelid, objYesNoServer)
{
// debugger;
    var objPanel = $get(panelid);
    
    objPanel.style.display='none';
    
    if (objYesNoServer != null)
    {
      objYesNoServer.SetNoValues();
    }
}

function TogglePanel(panelID)
{
  var objPanel = $get(panelID);
  if (objPanel.style.display == "none")
  { 
  objPanel.style.display='inline';
  }
  else
  {
  objPanel.style.display='none';
  } 
}

function OpenVerisignWindow(url)
{
  openWindow(url,'VeriSign','height=500,width=575px, toolbar=0,status=0,location=0,scrollbars=1,resizable=1',575, 500);
}
function OpenSecureSiteWindow(staticHtmlFile) 
{
  var path = document.location.pathname.substr(1);
  
  path = path.substr(0,path.indexOf("/")+1);
  openWindow( document.location.protocol + '//' + document.location.host + '/' + path + staticHtmlFile, 'SecureSite','height=380,width=380px,top=2,left=2,toolbar=0,status=0,location=0,scrollbars=1,resizable=1', 380, 380);
}
function OpenResourceFile(staticPdfFile, Theme) 
{
  var path = document.location.pathname.substr(1);
  path = path.substr(0,path.indexOf("/")+1);
  openWindow( document.location.protocol + '//' + document.location.host + '/' + path + 'App_Themes/'+ Theme + '/Resources/' + staticPdfFile ,'SafetyNet','height=600,width=800px,top=2,left=2,toolbar=0,status=0,location=0,scrollbars=1,resizable=1',800,600);
}

function ResetRadioButtons(radioButtonListID)
{
                var radioButtonList = $get(radioButtonListID);
                var options = radioButtonList.getElementsByTagName('input');            
                this._clientShadow.value='';
                for(i=0; i<options.length;i++)
                {
                    var opt = options[i]               
                    if(opt!=null)
                    {                
                        opt.checked = false;
                    }
                }
}

//function showMarketingQuestion(me)
//{
//    //hideAllMarketingQuestions();

//    var objQuestion = $get(parentQuestion);

//    if (objQuestion != null)
//    {   
//        var hfValue = $get(hiddenFieldValueId);
//        var objPanel= $get(panelToDisplay);
//       // var objQuestionToHide = $get(objQuestionToHideId);
//       
//        var selectedValue = objQuestion.options[ objQuestion.selectedIndex ].value;

//        hfValue.value = selectedValue
//        
//        if (selectedValue != null)
//        {
//            var parts = selectedValue.split(":");
//            if( parts.length >= 2 )
//            {          
//                  if( parts[1] == "TRUE" )
//                  {
//                     objPanel.style.display='block';                    
//                  }
//                  else
//                  {
//                     objPanel.style.display='none';      
//                    // objQuestionToHide.selectedIndex = 0;                         
//                  }
//            }
//            else
//            {
//                objPanel.style.display='none';                        
//               // objQuestionToHide.selectedIndex = 0; 
//            } 
//        }
//        else
//        {
//            objPanel.style.display='none';
//            //objQuestionToHide.selectedIndex = 0; 
//        }
//    }
//}

function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}

function SetUniqueFeatureOption(nameregex, current, elementType)
{ 
    // debugger;
    //alert("SetUniqueFeatureOption START nameregex[" + nameregex + "] current[" + current + "] elementType[" + elementType + "]");
    var currentChecked = current.checked
    re = new RegExp(nameregex);
    
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    //alert("theForm[" + theForm + "] theForm.length[" + theForm.length + "]");

    for(i = 0; i < theForm.elements.length; i++)
    {
        elm = theForm.elements[i]
        //alert("i[" + i + "] elm.type.toUpperCase()[" + elm.type.toUpperCase() + "]");
        if (elm.type.toUpperCase() == elementType)
        {
            // debugger;
            if (re.test(elm.name.replace(/\$/g,'')))
            {
                // debugger;
                elm.checked = false;
                //alert(" *** elm.checked = false ***  i[" + i + "] elm.type.toUpperCase()[" + elm.type.toUpperCase() + "] theForm.elements.length[" + theForm.elements.length + "]");
            }
        }
    }
    current.checked = currentChecked;
    //alert("SetUniqueFeatureOption END");
}

/*Check add on options*/
function CheckAddonOptions(ctrlContinueID,strButtonId,ctrlRadioListId,continueCssClass)
{
var hasAllFeaturesOpted=false;
var iOptedCount=0;
var iTotalOptions=0;
var ctrlContinue=document.getElementById(ctrlContinueID);
var ctrlRadioList=document.getElementById(ctrlRadioListId);

    for(i = 0; i < document.forms[0].elements.length; i++)
    {
    var elmName="";
     elm = document.forms[0].elements[i]
     if (elm.type == 'radio')
         {
         elmName=elm.name;
           if (elmName.indexOf(strButtonId)>0)
            {
            iTotalOptions=iTotalOptions+1;
                if(elm.checked)
                {
                    iOptedCount=iOptedCount+1;
                }
            }
        }
    }
    if(iTotalOptions/2==iOptedCount)/*Consider 2 options for each add-ons */
    {
       ctrlContinue.className=continueCssClass;
       ctrlContinue.disabled=false; 
    }

}