﻿// Customer Info Onload

function cust_onload()
{
    
}
function cust_onload_callback(res)
{
}

function custAgree()
{

}
function custAgree_CallBack(res)
{

}

function chkCallstatus(ctrlID)
{
    var txt = document.getElementById(ctrlID).value;
    AjaxClasses.getCallStatus(txt,chkCallstatus_back);
}

function chkCallstatus_back(res)
{
    if(res!=null)
    {
        if(res.value!='In Queue')
        {
            document.getElementById('lblStatus').innerText= res.value;
        }
    }
}

function AdCampaign(frommonth,fromday,fromyear,tomonth,today,toyear)
{
   var startdate=document.getElementById(frommonth).value+"/"+document.getElementById(fromday).value+"/"+document.getElementById(fromyear).value;   
   var enddate=document.getElementById(tomonth).value+"/"+document.getElementById(today).value+"/"+document.getElementById(toyear).value;         
   var response=AjaxClasses.getDateAdCampaign(startdate,enddate);
   return response;
}



function digiExists(ctrlId)
{
      //    var txt = document.getElementById('ctl00$MainContent$txtDigiID').value;
       //    CustomerInfo.DigiExistFn(txt,digiExistsCall_back);
        var txt = document.getElementById(ctrlId).value;
           AjaxClasses.DigiExistFn(txt,digiExistsCall_back);
}

function digiExistsCall_back(res)
{
    var hh = document.getElementById('ctl00_MainContent_hfDigiID');
   // alert(res.value);
   if(res.value)
   {
        alert('The DigiClick ID you selected is already in use. Please select another DigiClick ID.');
        document.getElementById('ctl00_MainContent_txtDigiID').focus();
   }
       document.getElementById('ctl00_MainContent_hfDigiID').value=res.value; 
   // alert(hh.value);
}

function EmailExists(ctrlId)
{

         var txt = document.getElementById(ctrlId).value;
         AjaxClasses.EmailExistFn(txt,emailExistsCall_back);
         
//        var txt = document.getElementById('ctl00$MainContent$txtEmailID').value;
//        CustomerInfo.EmailExistFn(txt,emailExistsCall_back);
}

function emailExistsCall_back(res)
{
    var hh = document.getElementById('ctl00_MainContent_hfEmailID');
  //Salert(res.value);
   if(res.value)
   {
     alert('This email address is already in use by another DigiClick ID. Please select another email address, or log in via our login form in the top-right corner of this webpage to continue.') ;
     //   alert('The Email Address you provided is already in use. Please select another Email Address.');
      document.getElementById('ctl00_MainContent_txtEmailID').focus();
   }
   
   document.getElementById('ctl00_MainContent_hfEmailID').value=res.value;
   
   //alert(document.getElementById('ctl00$MainContent$hfEmailID').value);
}

/* this is for myprofile page   start here */

var txtEmail='';
function EmailExistsProfile(ctrlId)
{
        txtEmail = ctrlId
         var txt = document.getElementById(ctrlId).value;
         AjaxClasses.EmailExistFn(txt,emailExistsProfileCall_back);
      
//        var txt = document.getElementById('ctl00$MainContent$txtEmailID').value;
//        CustomerInfo.EmailExistFn(txt,emailExistsCall_back);
}

function emailExistsProfileCall_back(res)
{
    var hh = document.getElementById(txtEmail);
   
   if(res.value)
   {
     alert('This email address is already in use by another DigiClick ID. Please select another email address, or log in via our login form in the top-right corner of this webpage to continue.') ;
     //   alert('The Email Address you provided is already in use. Please select another Email Address.');
     
        document.getElementById(txtEmail).focus();
     // return false;
   }
  // return true;
   //document.getElementById('ctl00$MainContent$hfEmailID').value=res.value;
   
   //alert(document.getElementById('ctl00$MainContent$hfEmailID').value);
}

/* End here */




function sameAddress(chk)
{
    if(chk.checked)
    {
      //  alert('hi');
        CreditInfo.sameAddress(same_add);
    }
    else
    {
        document.getElementById('ctl00$MainContent$txtFirstName').value="";
        document.getElementById('ctl00$MainContent$txtLastName').value="";
        document.getElementById('ctl00$MainContent$txtAddress1').value="";
        document.getElementById('ctl00$MainContent$txtAddress2').value="";
        document.getElementById('ctl00$MainContent$txtCity').value="";
        document.getElementById('ctl00$MainContent$txtZip').value="";
        var drp = document.getElementById('ctl00$MainContent$drpState');
    drp.options[0].selected=true;
    }
}


function same_add(res)
{
     var mystr = res.value;
    var myarr = mystr.split(",");
    document.getElementById('ctl00$MainContent$txtFirstName').value=myarr[0];
    document.getElementById('ctl00$MainContent$txtLastName').value=myarr[1];
    document.getElementById('ctl00$MainContent$txtAddress1').value=myarr[2];
    document.getElementById('ctl00$MainContent$txtAddress2').value=myarr[3];
    document.getElementById('ctl00$MainContent$txtCity').value=myarr[4];
    if(myarr[5]!="0")
        document.getElementById('ctl00$MainContent$txtZip').value=myarr[5];
    else
        document.getElementById('ctl00$MainContent$txtZip').value="";
    //alert(parseInt(myarr[6]));
    var drp = document.getElementById('ctl00$MainContent$drpState');
    for(i=0;i<drp.length;i++)
    {
     if(drp.options[i].value==myarr[6])
     {
        drp.options[i].selected=true;
     }
    }
}



function sameAddressUCI(chk)
{
    if(chk.checked)
    {
      //  alert('hi');
        UpgradeCCInfo.sameAddress(same_addUCI);
    }
    else
    {
        document.getElementById('ctl00$MainContent$txtFirstName').value="";
        document.getElementById('ctl00$MainContent$txtLastName').value="";
        document.getElementById('ctl00$MainContent$txtAddress1').value="";
        document.getElementById('ctl00$MainContent$txtAddress2').value="";
        document.getElementById('ctl00$MainContent$txtCity').value="";
        document.getElementById('ctl00$MainContent$txtZip').value="";
        var drp = document.getElementById('ctl00$MainContent$drpState');
    drp.options[0].selected=true;
    }
}


function same_addUCI(res)
{
     var mystr = res.value;
    var myarr = mystr.split(",");
    document.getElementById('ctl00$MainContent$txtFirstName').value=myarr[0];
    document.getElementById('ctl00$MainContent$txtLastName').value=myarr[1];
    document.getElementById('ctl00$MainContent$txtAddress1').value=myarr[2];
    document.getElementById('ctl00$MainContent$txtAddress2').value=myarr[3];
    document.getElementById('ctl00$MainContent$txtCity').value=myarr[4];
    if(myarr[5]!="0")
        document.getElementById('ctl00$MainContent$txtZip').value=myarr[5];
    else
        document.getElementById('ctl00$MainContent$txtZip').value="";
    //alert(parseInt(myarr[6]));
    var drp = document.getElementById('ctl00$MainContent$drpState');
    for(i=0;i<drp.length;i++)
    {
     if(drp.options[i].value==myarr[6])
     {
        drp.options[i].selected=true;
     }
    }
}

function sameAddressUBI(chk)
{
    if(chk.checked)
    {
      
        UpdateBillingInformation.sameAddress(sameadd_CallBack);
    }
    else
    {
        document.getElementById('ctl00$MainContent$txtFirstName').value="";
        document.getElementById('ctl00$MainContent$txtLastName').value="";
        document.getElementById('ctl00$MainContent$txtAddress1').value="";
        document.getElementById('ctl00$MainContent$txtAddress2').value="";
        document.getElementById('ctl00$MainContent$txtCity').value="";
        document.getElementById('ctl00$MainContent$txtZip').value="";
        var drp = document.getElementById('ctl00$MainContent$ddlState');
    drp.options[0].selected=true;
    }
}


function sameadd_CallBack(res)
{
     var mystr = res.value;
    var myarr = mystr.split(",");
    document.getElementById('ctl00$MainContent$txtFirstName').value=myarr[0];
    document.getElementById('ctl00$MainContent$txtLastName').value=myarr[1];
    document.getElementById('ctl00$MainContent$txtAddress1').value=myarr[2];
    document.getElementById('ctl00$MainContent$txtAddress2').value=myarr[3];
    document.getElementById('ctl00$MainContent$txtCity').value=myarr[4];
    if(myarr[5]!="0")
        document.getElementById('ctl00$MainContent$txtZip').value=myarr[5];
    else
        document.getElementById('ctl00$MainContent$txtZip').value="";
    //alert(parseInt(myarr[6]));
    var ddl = document.getElementById('ctl00$MainContent$ddlState');
    for(i=0;i<ddl.length;i++)
    {
     if(ddl.options[i].value==myarr[6])
     {
        ddl.options[i].selected=true;
     }
    }
}

