﻿var DropDownBox;

function GetCities(pDropBox, pCityDrop)
{
    var DropBox = pDropBox;
    DropDownBox = pCityDrop;
    if(DropBox.value >= 0)
    {
        Intel.BX.Helper.AJAXHelper.CitiesOfState(DropBox.value, SucceededCallback, FailedCallback, pCityDrop);
    }
}

function SucceededCallback(result, eventArgs)
{
    var item;
    var Target = document.getElementById(eventArgs);
    for (i = Target.options.length-1; i > -1; i--)
        Target.options[i] = null;
    if(result != "" || result != '')
    {
        item = new Option('-- Select --', -1, false, false);
        Target.options[Target.options.length] = item;
        var Source = result.split("%");
        for(i = 0; i < Source.length; i++)
        {
            item = new Option(Source[i].split("^")[1], Source[i].split("^")[0], false, false);
            Target.options[Target.options.length] = item;
        }
        item = new Option('Other', 0, false, false);
        Target.options[Target.options.length] = item;
    }
    else
    {
        item = new Option('-- Select --', -1, false, false);
        Target.options[Target.options.length] = item;
        item = new Option('Other', 0, false, false);
        Target.options[Target.options.length] = item;
    }
}

function FailedCallback(error)
{
    var item;
    var Target = document.getElementById(DropDownBox);
    for (i = Target.options.length-1; i > -1; i--)
        Target.options[i] = null;
    item = new Option('-- Select --', -1, false, false);
    Target.options[Target.options.length] = item;
    item = new Option('Other', 0, false, false);
    Target.options[Target.options.length] = item;
}

function GetCitiesNoOther(pDropBox, pCityDrop)
{
    var DropBox = pDropBox;
    DropDownBox = pCityDrop;
    if(DropBox.value >= 0)
    {
        Intel.BX.Helper.AJAXHelper.CitiesOfState(DropBox.value, SucceededCallbackNoOther, FailedCallbackNoOther, pCityDrop);
    }
}

function SucceededCallbackNoOther(result, eventArgs)
{
    var item;
    var Target = document.getElementById(eventArgs);
    for (i = Target.options.length-1; i > -1; i--)
        Target.options[i] = null;
    if(result != "" || result != '')
    {
        item = new Option('-- Select --', 0, false, false);
        Target.options[Target.options.length] = item;
        var Source = result.split("%");
        for(i = 0; i < Source.length; i++)
        {
            item = new Option(Source[i].split("^")[1], Source[i].split("^")[0], false, false);
            Target.options[Target.options.length] = item;
        }
    }
    else
    {
        item = new Option('-- Select --', 0, false, false);
        Target.options[Target.options.length] = item;
    }
}

function FailedCallbackNoOther(error)
{
    var item;
    var Target = document.getElementById(DropDownBox);
    for (i = Target.options.length-1; i > -1; i--)
        Target.options[i] = null;
    item = new Option('-- Select --', 0, false, false);
    Target.options[Target.options.length] = item;
}



//Rohit Start
//Getfulladdress


var plbladd1;
var plblstate1;
var plblcity1;
var plblzip1;
var plbltel1;
var ddladdress;
var hidaddVal;


function testrohit(paddress,plblstate)
{
ddladdress=document.getElementById(paddress);
plblstate1=document.getElementById(plblstate);
plblstate1.innerHTML="Testing rohit";

}




function Getfulladdress(paddress,pProfileid, plbladd,plblstate,plblcity,plblzip,plbltel,hidadd)
{

ddladdress=document.getElementById(paddress).options[document.getElementById(paddress).selectedIndex].text;
var ddladdressid=document.getElementById(paddress).options[document.getElementById(paddress).selectedIndex].value;


//alert('rohit');

plbladd1=document.getElementById(plbladd); 
plblstate1=document.getElementById(plblstate); 
plblcity1=document.getElementById(plblcity); 
plblzip1=document.getElementById(plblzip); 
plbltel1=document.getElementById(plbltel); 
hidaddVal=document.getElementById(hidadd);
if (ddladdressid=="-1")
{
    plbladd1.innerHTML="";
    plblstate1.innerHTML="";
    plblcity1.innerHTML="";
    plblzip1.innerHTML="";
    plbltel1.innerHTML="";
    
}
else
{
Intel.BX.Helper.AJAXHelper.Getfulladdress(pProfileid ,ddladdressid,SucceededCallbackGetSol_sec, FailedCallbackNoOther_sec)
}



}


function FailedCallbackNoOther_sec(error)
{
    plbladd1.innerHTML="";
    plblstate1.innerHTML="";
    plblcity1.innerHTML="";
    plblzip1.innerHTML="";
    plbltel1.innerHTML="";
}


function SucceededCallbackGetSol_sec(result,eventArgs)
{  
 

  if((result != "") || (result != ''))
    {
    var arr=new Array();
      arr=result.split("~");
  
    //alert('rohit');
    hidaddVal.value=result;
  
  
    plbladd1.innerHTML=ddladdress;
    plblstate1.innerHTML=arr[2];
    plblcity1.innerHTML=arr[0];
    plblzip1.innerHTML=arr[1];
    plbltel1.innerHTML=arr[3];

    }
}


//rohit End

//JASPAL SINGH popup Transaction

function SavePopUpTransaction(pSessionId, pPTId)
{
  
        Intel.BX.Helper.AJAXHelper.SavePopUpTransaction(pSessionId,pPTId, SucceededCallbackPopUp, FailedCallbackPopUp);

}

function SucceededCallbackPopUp(result, eventArgs)
{
   
}

function FailedCallbackPopUp(error)
{
    
}

////End

if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();