  var jsStateContainer = new Array();
  var jsCityContainer = new Array();
  var jsNames = new Array();
  var othersString = "others";
    
 //this function is to seperate the place 
 function PlaceSeperator(placeValue,countryValue,stateValue,cityValue)
 {
    var jsSplitedParentValue=placeValue.split(",");
    var jsCountryContainer=new Array();
    var oldCountryId="";
    var oldStateId="";
    var oldCityId="";
    var CountryIndex=1;
    var StateIndex=1;
    var CityIndex=1;
	var countryOthersName = "";
    var countryOthersValue = "";
	var othersFlag = true;
	var othersIndex = 0;
	var countryCounter = 1;
    var countryCombo=document.getElementById(countryValue);

	//setting names in array
    jsNames[0]=countryValue;
    jsNames[1]=stateValue;
    jsNames[2]=cityValue;

    //this is for splitting values from the full formed line  
    for(var parentIndex=0;parentIndex<jsSplitedParentValue.length;parentIndex++)
    {
      var jsSplitedChildValue=jsSplitedParentValue[parentIndex].split("|");
      
      for(var childIndex=0;childIndex<jsSplitedChildValue.length;childIndex++)
      {
         //this is for setting country object      
         if(!(jsSplitedChildValue[0]==oldCountryId))
         {
           jsCountryContainer[CountryIndex]=jsSplitedChildValue[0]+","+jsSplitedChildValue[1];
           CountryIndex++;
         }
         //this is for setting state object
          if(!(jsSplitedChildValue[2]==oldStateId))
          {
            jsStateContainer[StateIndex]=jsSplitedChildValue[0]+","+jsSplitedChildValue[2]+","+jsSplitedChildValue[3];
            StateIndex++;
          }
          //this fo loading the city object
          if(!(jsSplitedChildValue[4]==oldCityId))
          {
            jsCityContainer[CityIndex]=jsSplitedChildValue[2]+","+jsSplitedChildValue[4]+","+jsSplitedChildValue[5];
            CityIndex++;
          }
         oldCountryId=jsSplitedChildValue[0];
         oldStateId=jsSplitedChildValue[2];
         oldCityId=jsSplitedChildValue[4];
      } 
    }
    
  //creating combo object for country
   for(var index=0;index<jsCountryContainer.length;index++)
   {
	  othersFlag = true; 
      if(index==0)
      {
        countryCombo.options[0]=new Option("--Select--","");
      }
      else
      {
      var jsCountrySplit=jsCountryContainer[index].split(",");
	  //others seperate operation goes here
		  if(jsCountrySplit[1].toLowerCase() == othersString)
		  {
			 countryOthersName = jsCountrySplit[1];
			 countryOthersValue = jsCountrySplit[0];
			 othersFlag = false;
		  }
			  if(othersFlag == true)
			  {
				 countryCombo.options[countryCounter]=new Option(jsCountrySplit[1],jsCountrySplit[0]);
				 countryCounter++;
			  }
		}
		//collecting the index value in variable
		
     }

     countryCombo.options[countryCounter]=new Option(countryOthersName,countryOthersValue); 
     
	
          
 }


 //this is the dynamic combo for state
 function stateDynamicCombo(cityId,stateValue)
 {
	 
   var jsStateSplitter="";
   var jsStateCombo=document.getElementById(stateValue);
   var jsCityCombo=document.getElementById(jsNames[2]);
   jsStateCombo.options.length=0;
   var combocounter=1;
   var othersstateFlag = true;
   var othersStateName = "";
   var othersStateValue = "";


   for(var index=0;index<jsStateContainer.length;index++)
   {
       
        othersstateFlag = true;
        if(index==0)
        {
           jsStateCombo.options[0]=new Option("--Select--","");
		   cityDynamicCombo('',jsNames[2]);

        }
        else
        {
          jsStateSplitter=jsStateContainer[index].split(",");
          if(jsStateSplitter[0]==cityId & jsStateSplitter[2]!='null')
          {
			if(jsStateSplitter[2].toLowerCase() == othersString)
			{
			   othersStateName = jsStateSplitter[2];
               othersStateValue = jsStateSplitter[1];
               othersstateFlag = false;
			}
			if(othersstateFlag == true)
			{
              jsStateCombo.options[combocounter]=new Option(jsStateSplitter[2],jsStateSplitter[1]);
              combocounter++;
			}
          }
        }
   }
     
    jsStateCombo.options[combocounter]=new Option(othersStateName,othersStateValue);
    

	//this is to remove white space in city combo
    var jsCityCombo=document.getElementById(jsNames[2]);
    for(var index = 0 ;index<jsCityCombo.length;index++)
	{
		if(jsCityCombo.options[index].text=="")
		{
			jsCityCombo.remove(index);
			
		}

	}
	
	
	//this is to remove white space in state combo
    var jsStateCombo=document.getElementById(jsNames[1]);
    for(var index = 0 ;index<jsStateCombo.length;index++)
	{
		if(jsStateCombo.options[index].text=="")
		{
			jsStateCombo.remove(index);
			
		}

	}
 }  
 
  //this is the dynamic combo for city
 function cityDynamicCombo(stateId,stateValue)
 {
    var jsCityCombo=document.getElementById(stateValue);
    jsCityCombo.options.length=0;
    var jsCitySplitter="";
    var combocounter=1;
	var otherCityFlag = true;
	var otherCityName = "";
	var otherCityValue = "";
    for(var index=0;index<jsCityContainer.length;index++)
    {
		otherCityFlag = true;
        if(index==0)
        {
           jsCityCombo.options[0]=new Option("--Select--","");
        }
        else
        {
          jsCitySplitter=jsCityContainer[index].split(",");
          if(jsCitySplitter[0]==stateId & jsCitySplitter[1]!='null')
          {
			    if(jsCitySplitter[2].toLowerCase() == othersString)
			    {
                  otherCityName = jsCitySplitter[2];
                  otherCityValue = jsCitySplitter[1];
                  otherCityFlag = false;
			    }
				if(otherCityFlag == true)
				{
					jsCityCombo.options[combocounter]=new Option(jsCitySplitter[2],jsCitySplitter[1]);
					combocounter++;
				}
          }
        }
     
    }
    //others operation goes here
    jsCityCombo.options[combocounter]=new Option(otherCityName,otherCityValue);
    
    //this is to remove white space in state combo
    var jsStateCombo=document.getElementById(jsNames[1]);
    for(var index = 0 ;index<jsStateCombo.length;index++)
	{
		if(jsStateCombo.options[index].text=="")
		{
			jsStateCombo.remove(index);
			
		}

	}
	
	//this is to remove white space in city combo
    var jsCityCombo=document.getElementById(jsNames[2]);
    for(var index = 0 ;index<jsCityCombo.length;index++)
	{
		if(jsCityCombo.options[index].text=="")
		{
			jsCityCombo.remove(index);
			
		}

	}
    
 }
 
