function explodeArray(item,delimiter) 
{
  tempArray=new Array(1);
  var Count=0;
  var tempString=new String(item);

  while (tempString.indexOf(delimiter)>0) 
  {
    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
    tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1); 
    Count=Count+1
  }

  tempArray[Count]=tempString;
  return tempArray;
}


function openDirections()
{
   // win = window.open ("index3.html", "Hahaindex3", "height=400",width="300");
   // win = window.open ("index3.html", "Hahaindex3");
   // need to build the parameter for mapquest here
   // properties are Case-Sensitive be very careful
   
   kctext1 = "http://www.mapquest.com/cgi-bin/mqtrip?link=btwn%2Ftwn-d";
   kctext2 = "dir_na_basic_main&uid=ucc5zak1p3y4vbvd%3Aznga8wlaa&oabgcderr=&d";
   kctext3 = "abgcderr=&avoid_ferry=&avoid_lmTD_access=&avoid_toll_roads=";
   kctext4 = "&route_type=&results_display_mode=&LangOpt=&AB_LABELS=&WORK=";
   // start collecting customer value from AddressForm
   // kcStreet and kcCity may need to be modify will use tempStreetPlus and
   // tempCityPlus because mapquest.com need + sign in between word 
      kcStreet = document.AddressForm.Street.value;
      //kcStreet = "love you everyday Ann"
      kcCity = document.AddressForm.City.value;
      kcState = document.AddressForm.State.value;
      kcZip = document.AddressForm.Zip.value;
      var tempArray=explodeArray(kcStreet," ");
      //alert(tempArray[0]);
      //alert(tempArray[1]);
      //alert(tempArray[2]);
      //alert(tempArray.length);
   
      tempStreetPlus = "";
      for (Count=0; Count <=(tempArray.length -1); Count++)
      {
          tempStreetPlus += tempArray[Count];
	      if (Count <= (tempArray.length -2))
          {
	         tempStreetPlus += "+";
	      }
      }
      //alert(tempStreetPlus);
   
       var tempArray=explodeArray(kcCity," ");
	   
       tempCityPlus = "";
       for (Count=0; Count <=(tempArray.length -1); Count++)
       {
           tempCityPlus += tempArray[Count];
    	   if (Count <= (tempArray.length -2))
	       {
	          tempCityPlus += "+";
	       }
       }
       //alert(tempCityPlus);

   kctext5 = "&CCNA=&ADDR_0=" + tempStreetPlus;
   //alert (kctext5);
   
   kctext6 = "&OPC=null&CITY_0=" + tempCityPlus;
   //alert (kctext6);
   
   kctext7 = "&STATE_0=" + kcState;
   kctext8 = "&ZIP_0=" + kcZip;  
   kctext9 = "&CC_0=US&ADDR_1=11525+HAYNES+BRIDGE+RD&DPC=null&CITY_1=ALPHARETTA&STATE_1=GA&ZIP_1=30009-4821&CC_1=US&POIRad=2.0&dir.x=81&dir.y=10";

   kcURL = kctext1 + kctext2 + kctext3 + kctext4 +kctext5 + kctext6 +kctext7 + kctext8 +kctext9; 
   //alert (kcURL);
   //kctextOriginal = "http://www.mapquest.com/cgi-bin/mqtrip?link=btwn%2Ftwn-ddir_na_basic_main&uid=ucc5zak1p3y4vbvd%3Aznga8wlaa&oabgcderr=&dabgcderr=&avoid_ferry=&avoid_lmTD_access=&avoid_toll_roads=&route_type=&results_display_mode=&LangOpt=&AB_LABELS=&WORK=&CCNA=&ADDR_0=1950+Rock+Mill+Rd&OPC=null&CITY_0=Alpharetta&STATE_0=GA&ZIP_0=30022&CC_0=US&ADDR_1=11525+HAYNES+BRIDGE+RD&DPC=null&CITY_1=ALPHARETTA&STATE_1=GA&ZIP_1=30004-4821&CC_1=US&POIRad=2.0&dir.x=81&dir.y=10";

   // win = window.open ("http://www.mapquest.com/cgi-bin/mqtrip?link=btwn%2Ftwn-ddir_na_basic_main&uid=ucc5zak1p3y4vbvd%3Aznga8wlaa&oabgcderr=&dabgcderr=&avoid_ferry=&avoid_lmTD_access=&avoid_toll_roads=&route_type=&results_display_mode=&LangOpt=&AB_LABELS=&WORK=&CCNA=&ADDR_0=1950+Rock+Mill+Rd&OPC=null&CITY_0=Alpharetta&STATE_0=GA&ZIP_0=30022&CC_0=US&ADDR_1=11525+HAYNES+BRIDGE+RD&DPC=null&CITY_1=ALPHARETTA&STATE_1=GA&ZIP_1=30004-4821&CC_1=US&POIRad=2.0&dir.x=81&dir.y=10", "Hahaindex3");
   win = window.open (kcURL, "newwinkc");
   //win.creator = self;
}


