var regionNames = [];
regionNames['ca_sandiego']        = "San Diego, CA";
regionNames['ca_orangecounty']    = "Orange County, CA";
regionNames['ca_losangeles']      = "Los Angeles, CA";
regionNames['ca_temecula']        = "Temecula, CA";
regionNames['ca_pomona']          = "Pomona, CA";
regionNames['ca_palmsprings']     = "Palm Springs, CA";
regionNames['ca_santabarbara']    = "Santa Barbara, CA";
regionNames['ca_santacruz']       = "Santa Cruz, CA";
regionNames['ca_sanfrancisco']    = "San Francisco, CA";
regionNames['ca_crescentcity']    = "Crescent City, CA";
regionNames['ca_monterey']        = "Monterey, CA";
regionNames['nv_lasvegas']        = "Las Vegas, NV";
regionNames['fl_palmbeachcounty'] = "Florida";
regionNames['nm_albuquerque']     = "Albuquerque, NM";
regionNames['nc_jacksonville']    = "Jacksonville/Camp Lejeune/New River, NC";
regionNames['sc_beaufort']        = "Beaufort, SC";
regionNames['oh_findlay']         = "Findlay, OH";
regionNames['wa_seattle']         = "Seattle, WA";
regionNames['co_fortcollins']     = "Fort Collins, CO";
regionNames['mn_stpaul']          = "St. Paul, MN";
regionNames['tn_nashville']       = "Nashville, TN";

$(document).ready(function(){
 $('.curvyBox').curvy("10px");
 $('#regionselect').jqm();

 var region = $.cookie('region');
 /* rewrite region to new format */
      if (region == 'sandiego')     { region = 'ca_sandiego';        }
 else if (region == 'orangecounty') { region = 'ca_orangecounty';    }
 else if (region == 'temecula')     { region = 'ca_temecula';        }
 else if (region == 'riverside')    { region = 'ca_temecula';        }
 else if (region == 'pomona')       { region = 'ca_pomona';          }
 else if (region == 'palmsprings')  { region = 'ca_palmsprings';     }
 else if (region == 'santabarbara') { region = 'ca_santabarbara';    }
 else if (region == 'santacruz')    { region = 'ca_santacruz';       }
 else if (region == 'sanfrancisco') { region = 'ca_sanfrancisco';    }
 else if (region == 'crescentcity') { region = 'ca_crescentcity';    }
 else if (region == 'lasvegas')     { region = 'nv_lasvegas';        }
 else if (region == 'florida')      { region = 'fl_palmbeachcounty'; }
 else if (region == 'newmexico')    { region = 'nm_albuquerque';     }

      if (region == null                 ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'ca_crescentcity'    ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'ca_losangeles'      ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'ca_monterey'        ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'ca_pomona'          ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'ca_sanfrancisco'    ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'ca_santabarbara'    ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'ca_santacruz'       ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'fl_palmbeachcounty' ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'nc_jacksonville'    ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'nm_albuquerque'     ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'nv_lasvegas'        ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'oh_findlay'         ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else if (region == 'sc_beaufort'        ) { setRegionNoCookie('ca_sandiego'); changeMap('us'); $('#regionselect').jqmShow();}
 else {
  setRegion(region);
 }
});

function setRegion(region)
{
 $('#regionselect').jqmHide();
 $.cookie('region', region, {expires: 1000, path: '/'});
 changeMap(region);

 /* load video/slideshow based on region for index */
 if (document.getElementById('index_slideshow')) {
  if (region == 'sandiego') {
   $('div#index_slideshow').load("video.html");
  } else {
   /* $('div#index_slideshow').load("slideshow.html"); */
   $('div#index_slideshow').load("video.html");
  }
 }

 /* load video/slideshow based on region for index */
 if (document.getElementById('about_slideshow')) {
  if (region == 'sandiego') {
   $('div#about_slideshow').load("slideshow.html");
  }
 }

 /* set rest of region specific content */
 setRegionNoCookie(region);
}

function setRegionNoCookie(region)
{
 /* change name in region */
 if (document.getElementById('regionname')) {
  document.getElementById('regionname').innerHTML = regionNames[region];
 }

 if (document.getElementById('siteheader')) {
  document.getElementById('siteheader').innerHTML = "Welcome to Dogs On The Run - " + regionNames[region];
 }

 /* turn off any region specific content */
 if (region != 'ca_sandiego'        ) { $('.ca_sandiego'        ).hide();}
 if (region != 'ca_orangecounty'    ) { $('.ca_orangecounty'    ).hide();}
 if (region != 'ca_losangeles'      ) { $('.ca_losangeles'      ).hide();}
 if (region != 'ca_temecula'        ) { $('.ca_temecula'        ).hide();}
 if (region != 'ca_pomona'          ) { $('.ca_pomona'          ).hide();}
 if (region != 'ca_palmsprings'     ) { $('.ca_palmsprings'     ).hide();}
 if (region != 'ca_santabarbara'    ) { $('.ca_santabarbara'    ).hide();}
 if (region != 'ca_santacruz'       ) { $('.ca_santacruz'       ).hide();}
 if (region != 'ca_sanfrancisco'    ) { $('.ca_sanfrancisco'    ).hide();}
 if (region != 'ca_crescentcity'    ) { $('.ca_crescentcity'    ).hide();}
 if (region != 'ca_monterey'        ) { $('.ca_monterey'        ).hide();}
 if (region != 'nv_lasvegas'        ) { $('.nv_lasvegas'        ).hide();}
 if (region != 'fl_palmbeachcounty' ) { $('.fl_palmbeachcounty' ).hide();}
 if (region != 'nm_albuquerque'     ) { $('.nm_albuquerque'     ).hide();}
 if (region != 'nc_jacksonville'    ) { $('.nc_jacksonville'    ).hide();}
 if (region != 'sc_beaufort'        ) { $('.sc_beaufort'        ).hide();}
 if (region != 'oh_findlay'         ) { $('.oh_findlay'         ).hide();}
 if (region != 'wa_seattle'         ) { $('.wa_seattle'         ).hide();}
 if (region != 'co_fortcollins'     ) { $('.co_fortcollins'     ).hide();}
 if (region != 'mn_stpaul'          ) { $('.mn_stpaul'          ).hide();}
 if (region != 'tn_nashville'       ) { $('.tn_nashville'       ).hide();}

 /* turn on any region specific content */
 if (region == 'ca_sandiego'        ) { $('.ca_sandiego'        ).show();}
 if (region == 'ca_orangecounty'    ) { $('.ca_orangecounty'    ).show();}
 if (region == 'ca_losangeles'      ) { $('.ca_losangeles'      ).show();}
 if (region == 'ca_temecula'        ) { $('.ca_temecula'        ).show();}
 if (region == 'ca_pomona'          ) { $('.ca_pomona'          ).show();}
 if (region == 'ca_palmsprings'     ) { $('.ca_palmsprings'     ).show();}
 if (region == 'ca_santabarbara'    ) { $('.ca_santabarbara'    ).show();}
 if (region == 'ca_santacruz'       ) { $('.ca_santacruz'       ).show();}
 if (region == 'ca_sanfrancisco'    ) { $('.ca_sanfrancisco'    ).show();}
 if (region == 'ca_crescentcity'    ) { $('.ca_crescentcity'    ).show();}
 if (region == 'ca_monterey'        ) { $('.ca_monterey'        ).show();}
 if (region == 'nv_lasvegas'        ) { $('.nv_lasvegas'        ).show();}
 if (region == 'fl_palmbeachcounty' ) { $('.fl_palmbeachcounty' ).show();}
 if (region == 'nm_albuquerque'     ) { $('.nm_albuquerque'     ).show();}
 if (region == 'nc_jacksonville'    ) { $('.nc_jacksonville'    ).show();}
 if (region == 'sc_beaufort'        ) { $('.sc_beaufort'        ).show();}
 if (region == 'oh_findlay'         ) { $('.oh_findlay'         ).show();}
 if (region == 'wa_seattle'         ) { $('.wa_seattle'         ).show();}
 if (region == 'co_fortcollins'     ) { $('.co_fortcollins'     ).show();}
 if (region == 'mn_stpaul'          ) { $('.mn_stpaul'          ).show(); $('.not_mn_stpaul'      ).hide();}
 if (region == 'tn_nashville'       ) { $('.tn_nashville'       ).show(); $('.not_tn_nashville'   ).hide();}

}

function changeMap(region)
{
 document.getElementById('regionselectmap').src = "/images/map/" + region + ".png";
}

