

function loadCities( cityObjId, countryObjId, selectedCity, productId )
{
   var cityObj                      = document.getElementById( cityObjId );
   var productTypeObj               = document.getElementById( 'collectiontype_producttype' );
   var countryObj                   = document.getElementById( countryObjId );
   var searchCriteriaObj            = document.getElementById( "searchcriteria" );
   var searchCriteriaHeadingObj     = document.getElementById( "searchcriteria_heading" );
   var zipcodeObj                   = document.getElementById( "pc" );
   
   var country = countryObj.options[countryObj.selectedIndex].value;
   
   // enable / disable cities and counties
   if ( country == 'IT' )
   {
        try
        {
            document.getElementById( "cityContainer" ).style.display = "none";
            document.getElementById( "countyContainer" ).style.display = "block";
        }
        catch (e)
        {
            //
        }
   }
   else
   {
        try
        {
            document.getElementById( "cityContainer" ).style.display = "block";
            document.getElementById( "countyContainer" ).style.display = "none";
        }
        catch (e)
        {
            //
        }
   }
   
   if ( cityObj && countryObj  )
   {
      cityObj.disabled = true;
      cityObj.options.length = 1;
      searchCriteriaObj.style.display  = 'none';
      if ( searchCriteriaHeadingObj )
      {
         searchCriteriaHeadingObj.style.display = 'none';
      }
      
      
         
      if ( country )
      {
         var hostname = document.location.host;
         var objHTTP = null;
         if ( window.XMLHttpRequest )
         {
            objHTTP = new XMLHttpRequest()
         }
         else if (window.ActiveXObject)
         {
            objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
         }

         if ( objHTTP )
         {
            objHTTP.open("GET", "/xml/cities.asp?country=" + country + "&product=" + (productId || ""), false);
            //document.location = "/xml/cities.asp?country=" + country + "&product=" + (productId || "");
            
            objHTTP.send(null); 
            var doc = objHTTP.responseXML.documentElement;
            if ( doc )
            {
               var cities = doc.getElementsByTagName( "city" );
               if ( cities && cities.length > 0 )
               {
                  for ( var x=0; x < cities.length; x++ )
                  {
                     if (cities[x] && cities[x].childNodes[0] )
                     {
                        var city = cities[x].text || cities[x].textContent || cities[x].innerText || cities[x].childNodes[0].nodeValue;
                        var opt = new Option( city, city );
                        var idx = cityObj.options.length;
                        cityObj.options[idx] = opt;                     
                        if ( selectedCity == city )
                        {
                           cityObj.options[idx].selected = true;
                        }
                     }
                  }
               }
               else
               {
                  //
               }
                  
               var showSearchCriteria = "false";
               if ( doc && doc.getAttribute( 'zipcodes' ) )
               {
                  showSearchCriteria = doc.getAttribute( 'zipcodes' );
               }
               if ( showSearchCriteria == "true" )
               {
                  searchCriteriaObj.style.display = 'block';
                  if ( searchCriteriaHeadingObj )
                  {
                     searchCriteriaHeadingObj.style.display = 'block';
                  }
               }
               else
               {
                  if ( zipcodeObj )
                  {
                     zipcodeObj.value = '';
                  }
               }
            }
            else
            {
               //
            }
         }
         else
         {
            //
         }
      }
      cityObj.disabled = false;
   }
   
   if ( productTypeObj && countryObj  )
   {
      productTypeObj.disabled = true;
      //productTypeObj.options.length = 0;
      
      var selectedProdType = null;
         var tmp = document.getElementById( "selected_collectiontype_producttype" );
         if ( tmp && tmp.value )
         {
            selectedProdType = tmp.value;
         }
      
      var country = countryObj.options[countryObj.selectedIndex].value;
         
      if ( country )
      {
         var hostname = document.location.host;
         var objHTTP = null;
         if ( window.XMLHttpRequest )
         {
            objHTTP = new XMLHttpRequest()
         }
         else if (window.ActiveXObject)
         {
            objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
         }

         if ( objHTTP )
         {
	         objHTTP.open( "GET", "/xml/produkttypes.asp?country=" + country, false );
            objHTTP.send(); 
            var doc = objHTTP.responseXML.documentElement;
            if ( doc )
            {
               var producttypes = doc.getElementsByTagName( "producttype" );
               if ( producttypes && producttypes.length > 0 )
               {
                  for ( var x=0; x < producttypes.length; x++ )
                  {
                     /*var name = producttypes[x].text || producttypes[x].textContent || producttypes[x].childNodes[0].nodeValue;
                     var value = producttypes[x].getAttribute( 'value' );
                     var opt = new Option( name, value );
                     
                     //alert( 'value:' + producttypes[x].value );
                     
                     //alert( 'text:' + producttypes[x].text ); // IE 5, 5.5, 6 & 7
                     //alert( 'textContent:' + producttypes[x].textContent ); // FF 1.5 & 2.0, SAFARI 3                  
                     //alert( 'childNodes[0].nodeValue:' + producttypes[x].childNodes[0].nodeValue ); // IE 5, 5.5, 6 & 7, FF 1.5 & 2.0, SAFARI 1 & 2 (mac)
                     
                     var idx = productTypeObj.options.length;
                     productTypeObj.options[idx] = opt;                     
                     if ( selectedProdType == value )
                     {
                        productTypeObj.options[idx].selected = true;
                     }*/
                  }
                  productTypeObj.disabled = false;
               }
               else
               {
                  //
               }
            }
            else
            {
               //
            }
         }
         else
         {
            //
         }
      }
   }
}

function loadCounties( countyObjId, countryObjId, selectedCounty )
{
   var countyObj                    = document.getElementById( countyObjId );
   var productTypeObj               = document.getElementById( 'collectiontype_producttype' );
   var countryObj                   = document.getElementById( countryObjId );
   var searchCriteriaObj            = document.getElementById( "searchcriteria" );
   var searchCriteriaHeadingObj     = document.getElementById( "searchcriteria_heading" );
   var zipcodeObj                   = document.getElementById( "pc" );
   
   if ( countyObj && countryObj  )
   {
      countyObj.disabled = true;
      countyObj.options.length = 1;
      searchCriteriaObj.style.display  = 'none';
      if ( searchCriteriaHeadingObj )
      {
         searchCriteriaHeadingObj.style.display = 'none';
      }
      
      var country = countryObj.options[countryObj.selectedIndex].value;

      if (country)
      {
         var hostname = document.location.host;
         var objHTTP = null;
         if ( window.XMLHttpRequest )
         {
            objHTTP = new XMLHttpRequest()
         }
         else if (window.ActiveXObject)
         {
            objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
         }

         if ( objHTTP )
         {
	        objHTTP.open( "GET", "/xml/counties.asp?country=" + country, false );
            objHTTP.send(null); 
            var doc = objHTTP.responseXML.documentElement;
            if ( doc )
            {
               var counties = doc.getElementsByTagName( "county" );
               if ( counties && counties.length > 0 )
               {
                  for ( var x=0; x < counties.length; x++ )
                  {
                     if (counties[x] && counties[x].childNodes[0] )
                     {
                        var county = counties[x].text || counties[x].textContent || counties[x].innerText || counties[x].childNodes[0].nodeValue;
                        var opt = new Option( county, county );
                        var idx = countyObj.options.length;
                        countyObj.options[idx] = opt;                     
                        if ( selectedCounty == county )
                        {
                           countyObj.options[idx].selected = true;
                        }
                     }
                  }
               }
               else
               {
                  //
               }
                  
               var showSearchCriteria = "false";
               if ( doc && doc.getAttribute( 'zipcodes' ) )
               {
                  showSearchCriteria = doc.getAttribute( 'zipcodes' );
               }
               if ( showSearchCriteria == "true" )
               {
                  searchCriteriaObj.style.display = 'block';
                  if ( searchCriteriaHeadingObj )
                  {
                     searchCriteriaHeadingObj.style.display = 'block';
                  }
               }
               else
               {
                  if ( zipcodeObj )
                  {
                     zipcodeObj.value = '';
                  }
               }
            }
            else
            {
               //
            }
         }
         else
         {
            //
         }
      }
      countyObj.disabled = false;
   }
   
   if ( productTypeObj && countryObj  )
   {
      //productTypeObj.disabled = true;
      //productTypeObj.options.length = 0;
      
      var selectedProdType = null;
         var tmp = document.getElementById( "selected_collectiontype_producttype" );
         if ( tmp && tmp.value )
         {
            selectedProdType = tmp.value;
         }
      
      var country = countryObj.options[countryObj.selectedIndex].value;
         
      if (country )
      {
         var hostname = document.location.host;
         var objHTTP = null;
         if ( window.XMLHttpRequest )
         {
            objHTTP = new XMLHttpRequest()
         }
         else if (window.ActiveXObject)
         {
            objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
         }

         if ( objHTTP )
         {
	        objHTTP.open( "GET", "/xml/produkttypes.asp?country=" + country, false );
            objHTTP.send(); 
            var doc = objHTTP.responseXML.documentElement;
            if ( doc )
            {
               var producttypes = doc.getElementsByTagName( "producttype" );
               if ( producttypes && producttypes.length > 0 )
               {
                  for ( var x=0; x < producttypes.length; x++ )
                  {
                     var name = producttypes[x].text || producttypes[x].textContent || producttypes[x].childNodes[0].nodeValue;
                     var value = producttypes[x].getAttribute( 'value' );
                     var opt = new Option( name, value );
                     
                     //alert( 'value:' + producttypes[x].value );
                     //alert( 'text:' + producttypes[x].text ); // IE 5, 5.5, 6 & 7
                     //alert( 'textContent:' + producttypes[x].textContent ); // FF 1.5 & 2.0, SAFARI 3                  
                     //alert( 'childNodes[0].nodeValue:' + producttypes[x].childNodes[0].nodeValue ); // IE 5, 5.5, 6 & 7, FF 1.5 & 2.0, SAFARI 1 & 2 (mac)
                     
                     var idx = productTypeObj.options.length;
                     productTypeObj.options[idx] = opt;                     
                     if ( selectedProdType == value )
                     {
                        productTypeObj.options[idx].selected = true;
                     }
                  }
                  productTypeObj.disabled = false;
               }
               else
               {
                  //
               }
            }
            else
            {
               //
            }
         }
         else
         {
            //
         }
      }
   }
}
