﻿var allDivs = new Array();
allDivs[0] = "IMPD";
allDivs[1] = "portfolio";
allDivs[2] = "playbook";
allDivs[3] = "pocketbook";
allDivs[4] = "imfirstprinciples";
allDivs[5] = "hootnhooler";


  function Dropdownotheroption(DropDownctrl,txtctrl)
      {
    	var dropProfession=document.getElementById(DropDownctrl);
    	  if(dropProfession!=null)
    	    {
    	        var txtothers=document.getElementById(txtctrl);
    	            if(txtothers!=null)
    	            {
    	              var selectedvalue=dropProfession.options[dropProfession.selectedIndex].value
    	                var myindex  = dropProfession.selectedIndex
                       selectedvalue = dropProfession.options[myindex].text;
    	              if(selectedvalue.toUpperCase()=="OTHERS")
    	                {
    	                    txtothers.style.display = 'Block';
    	                }
    	                else
    	                {
    	                txtothers.style.display = 'none';
    	                }
    	           }
    	        }
    }
    
    function hideDivs()
    {
    for (i=0;i<allDivs.length;i++)
        {
            document.getElementById(allDivs[i] + 'Div').style.display="none";
        }
    document.getElementById( "defaultDiv" ).style.display = "";
    }

function showAltDiv( Text, oElement )
{

hideDivs();
document.getElementById( "DefaultDiv" ).style.display = "none";
document.getElementById( Text + 'Div').style.display = "";

if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    }
    
}

function findPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
    
  } else {
    return [ oElement.x, oElement.y ];
    
  }
}
 function UserRegistrationValidate()
 {
    var termsnconditions=document.getElementById("chktermsandcondition");
        if(termsnconditions!=null)
          { 
           if(termsnconditions.checked==true)
            return true;
            else
             {
             alert("Terms and conditions are not checked");
             return false;
             }
          }
       else
       return true;
 }

 function IsValidUnsignedNumber(sender, args)
  {
          if (!(/^\d+$/.test(args.Value)))
                {
                args.IsValid=false;
           
                return;
                }
              args.IsValid=true;
          }
          
  function IsValidDOB(sender,args)
       {
         if(!(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.test(args.Value)))
          {
             args.IsValid=false;
             return;
          }
          var DOB=args.Value.split("/");
         if(DOB.length!=3)
         {
         args.IsValid=false;
         return;
         }
         var Day=DOB[0];
         if(Day>31)
         {
         args.IsValid=false;
         return;
         }
         var Month=DOB[1];
         if(Month>12 || Month<1)
               {
                    args.IsValid=false;
                    return;
               }
          args.IsValid=true;
             
      }
      function IsValidIncome(sender,args)
      {
      
      if (!(/(^(0|[1-9][0-9]*)$)|((^(0?|[1-9][0-9]*)\.(0*[1-9][0-9]*)$)|(^[1-9]+[0-9]*\.0+$)|(^0\.0+$))/.test(args.Value)))
                {
                args.IsValid=false;
           
                return;
                }
              args.IsValid=true;
      }
      
      function DropdownProfessonChange()
      {
    	var dropProfession=document.getElementById('<% =drpprofession.ClientID %>');
    	  if(dropProfession!=null)
    	    {
    	        var txtothers=document.getElementById('<%=txtProfessionOthers.ClientID %>');
    	            if(txtothers!=null)
    	            {
    	              var selectedvalue=dropProfession.options[dropProfession.selectedIndex].value
    	                var myindex  = dropProfession.selectedIndex
                       selectedvalue = dropProfession.options[myindex].text;
    	              if(selectedvalue.toUpperCase()=="OTHERS")
    	                {
    	                    txtothers.style.display = 'Block';
    	                }
    	                else
    	                {
    	                txtothers.style.display = 'none';
    	                }
    	           }
    	        }
    }
    function CheckBoxListMediaSelect(chkBoxctrl,txtctrl)
            {    
          
           var chkBoxList = document.getElementById(chkBoxctrl);
           if(chkBoxList!=null)
             {
              var chkBoxCount= chkBoxList.getElementsByTagName("input");
              var chkBoxLabelCount= chkBoxList.getElementsByTagName("label"); 
             
                    for(var i=0;i<chkBoxCount.length;i++) 
                    {
                        
                         if(chkBoxLabelCount[i].innerText.toUpperCase()=="OTHERS")
                         {
                         
                           var txtOthers=document.getElementById(txtctrl);
                           
                           if(txtOthers!=null)
                           {
                            if(chkBoxCount[i].checked ==false)
                             {
                                txtOthers.style.display = 'none';
                             }
                             else
                             {
                               txtOthers.style.display = 'Block';
                             }
                          }
                    }
            }
        }
        }
