function buildPhone(thisValue, thisTarget)
 {
  thisIndex = getIndex(thisTarget);
  thisTarget.value = thisValue.form[thisIndex + 1].value + thisValue.form[thisIndex + 2].value + thisValue.form[thisIndex + 3].value;
 }
function getIndex(input) 
 {
  var index = -1, i = 0, found = false;
  while (i < input.form.length && index == -1)
    if (input.form[i] == input)
      index = i;
    else 
      i++;
  return index;
 }
function virtualtour(url)
 { window.open("http://" + url + "/ViewFloorplan.html","_blank","width=900,height=700,status=no,directories=no,toolbar=no,scrollbars=auto,resizeable=no"); }
function virtualtour2(url)
 { window.open("http://" + url + "/Tour.html","_blank","width=900,height=700,status=no,directories=no,toolbar=no,scrollbars=yes,resizeable=no"); }
function killExclusive()
 {
  document.getElementById('exclusiveoffers').style.visibility='hidden';
  document.getElementById('exclusiveoffers').style.zindex='-1'                   
  document.getElementById('blackout').style.visibility='hidden';
  document.getElementById('blackout').style.zindex='-1';
  document.getElementById('Search').style.visibility = 'visible';
  document.getElementById('Bedrooms').style.visibility = 'visible';
  document.getElementById('CityRegion').style.visibility = 'visible';
 }

// GALLERY PAGE
function showgals(e,n) {
 swfobject.embedSWF("/i/photos/viewer.swf", "galgo", "620", "600", '8', "/js/expressInstall.swf",{width:"620",height:"600",xmlDataPath:"/i/photos/"+e+".xml"},{wmode:"transparent"});
 document.getElementById('nowplaying').innerHTML = n;
}

// COMMUNITY PAGE 
function showgalsh(e,n) {
  document.getElementById('commmap').style.display = 'none';
  document.getElementById('commvideo').style.display = 'none';
  if (document.getElementById('tour360'))
    document.getElementById('tour360').style.display = 'none';
  document.getElementById('contactform').style.display = 'none';
  document.getElementById('photos').style.display = 'block';
  swfobject.embedSWF("/i/photos/viewer2.swf", "photos", "750", "440", "8", "/js/expressInstall.swf",
                     { width:"650", height:"480", xmlDataPath:"/i/photos/"+e+".xml.php"}, {wmode:"transparent"});
  document.getElementById('photos').style.height = '410px';
  document.getElementById('photos').style.overflow = 'hidden';
}
function showvid2(e,n) {
  document.getElementById('photos').style.display = 'none';
  document.getElementById('contactform').style.display = 'none';
  document.getElementById('commmap').style.display = 'none';
  if (document.getElementById('tour360'))
    document.getElementById('tour360').style.display = 'none';
  document.getElementById('commvideo').style.display = 'block';
  document.getElementById('contactform').style.display = 'none';
  swfobject.embedSWF("/js/mediaplayer.swf", "commvideo", "750", "440", '9.0.98', "/js/expressInstall.swf",{width:"650",height:"440",autostart:"true",file:"http://"+e+"/i/video/video.f4v"},{allowfullscreen:"true",allowscriptingaccess:"true"});
 }
function showcommtour() {
  document.getElementById('photos').style.display = 'none';
  document.getElementById('commvideo').style.display = 'none';
  document.getElementById('contactform').style.display = 'none';
  document.getElementById('commmap').style.display = 'none';

  document.getElementById('tour360').style.display = 'block';
  document.getElementById('tour360').style.height = '440px';
  document.getElementById('tour360').style.overflow = 'auto';
 }
function showcontact() {
  document.getElementById('photos').style.display = 'none';
  document.getElementById('commmap').style.display = 'none';
  document.getElementById('commvideo').style.display = 'none';
  if (document.getElementById('tour360'))
    document.getElementById('tour360').style.display = 'none';

  document.getElementById('contactform').style.display = 'block';
  document.getElementById('contactform').style.height = '440px';
  document.getElementById('contactform').style.overflow = 'auto';
 }
function showmap(e) {
  document.getElementById('photos').style.display = 'none';
  document.getElementById('commvideo').style.display = 'none';
  document.getElementById('contactform').style.display = 'none';
  if (document.getElementById('tour360'))
    document.getElementById('tour360').style.display = 'none';
  document.getElementById('commmap').style.display = 'block';
  document.getElementById('commmap').style.height = '440px';
  document.getElementById('commmap').style.overflow = 'hidden';
  document.getElementById('commmap').innerHTML = '<iframe style="width: 100%; height: 420px" frameborder="0" src="http://www.dynamicone.cc/include/googlemaps/WR.php?auto='+e+'&height=408" scrollbars="no"></iframe>';
 }
function showmapimg(e,map) {
  document.getElementById('photos').style.display = 'none';
  document.getElementById('commvideo').style.display = 'none';
  document.getElementById('contactform').style.display = 'none';
  if (document.getElementById('tour360'))
    document.getElementById('tour360').style.display = 'none';
  document.getElementById('commmap').style.display = 'block';
  document.getElementById('commmap').style.height = '440px';
  document.getElementById('commmap').style.overflow = 'hidden';
  document.getElementById('commmap').innerHTML = '<img src="' + map + '" width="740" height="410" alt="Map" />';
 }

// VIDEO PAGE

function showvid(e,n) {
  swfobject.embedSWF("/js/mediaplayer.swf", "vidgo", "100%", "100%", '9.0.98', "/js/expressInstall.swf",{width:"620",height:"440",autostart:"true",file:"http://"+e+"/i/video/video.f4v"},{allowfullscreen:"true",allowscriptingaccess:"true"});
  document.getElementById('nowplaying').innerHTML = n;
  document.getElementById('thisvid').value=e;
  document.getElementById('thislabel').value=n;
 }
function change() {
  showvid(document.getElementById('thisvid').value,document.getElementById('thislabel').value);
 }

// DETECT FLASH DROP-INS

window.onload = function() {

// Insert Video (MCS Default)
  // Load Flash Sections
  if (document.getElementById("mainslide")) {
    swfobject.embedSWF("/i/WesternRimRotator.swf", "mainslide", "886", "445", '7', "/js/expressInstall.swf",{width:"886",height:"445",file:"/js/imagerotator.xml.php"},{wmode:"transparent"});
   }
  if (document.getElementById("gallery")) {
    swfobject.embedSWF("/i/WesternRimGallery.swf", "gallery", "666", "444", '7', "/js/expressInstall.swf",{width:"666",height:"444"},{wmode:"transparent"});
   }
  if (document.getElementById("victory")) {
    swfobject.embedSWF("/js/imagerotator.swf", "victory", "180", "126", '7', "/js/expressInstall.swf",{width:"180",height:"126",file:"/i/locations/victory.xml",shownavigation:"false",transition:"slowfade"});
   }
  if (document.getElementById("wall")) {
    swfobject.embedSWF("/WRWall.swf", "wall", "892", "540", '7', "/js/expressInstall.swf",{width:"892",height:"540"},{wmode:transparent});
   }
  else if (document.getElementById("header")) {
    swfobject.embedSWF("http://www.westernrim.com/i/Header.swf", "header", "892", "96", '7', "/js/expressInstall.swf",{width:"892",height:"96"},{wmode:"transparent"});
   }
 }
