
// Front Page Video Display

function showvid() {
  if (document.getElementById('rotatorinner')) {
     swfobject.embedSWF('/js/mediaplayer.swf', 'rotatorinner', '620', '360', '9.0.98', "/js/expressInstall.swf", 
                           {allowfullscreen:"true",file:"/i/video/video.f4v",stretching:"fill",autostart:"true",skin:"/js/modieus-WR.swf",title:"Video Tour",width:"620",height:"320",controlbarsize:"false",shownavigation:"true"}, 
                           {allowfullscreen:"true",allowscriptaccess:"always",wmode:"transparent"}, 
                           {id:"mediaplayer",name:"mediaplayer"});
   }  
 }

// Floorplans Page Selection DOM Commands

function fp(n,e,p,v,f) {
  thisRequest = "fp"+n;
  lastRequest = document.getElementById('fpc').value;
  if (lastRequest!="0") {
    document.getElementById(lastRequest).style.display = 'none';
    if (document.getElementById(lastRequest+'img'))
      document.getElementById(lastRequest+'img').style.display = 'none';
   }
  document.getElementById('eid').value = e;
  document.getElementById('vid').value = v;
  document.getElementById('pid').value = p;
  document.getElementById('fid').value = f;
  document.getElementById('fpc').value = thisRequest;
  document.getElementById(thisRequest).style.display = 'block';
  document.getElementById('fpo').style.display = 'block';
  document.getElementById('fpe').style.display = (e!=0? 'block' : 'none');
  document.getElementById('fpv').style.display = (v.length>1? 'block' : 'none');
  document.getElementById('fpf').style.display = (f.length>1? 'block' : 'none');
  document.getElementById('fpp').style.display = (p.length>1? 'block' : 'none');
  if (p.length > 1) {
    document.getElementById('fpp').style.display = 'block';
    var l = document.getElementById('fp'+n+'img');
    if (l) { l.style.display='block'; }
   }
 }

// Tell a Friend Feature
function fle() { 
  e = document.getElementById('eid').value;
  return Lightbox.show("/include/_tellafriend.php?id="+e+"&criteria=body",'Tell a Friend','width=759,height=680,showcaption=1,scrolling=1');
 }
// Launch Virtual Tour (Old Style)
function flv() {
  e = document.getElementById('vid').value;
  if (e.charAt(0) == "/")
    return Lightbox.show(e,'Virtual Tour','width=900,height=506,showcaption=1');
  else
    return Lightbox.show('/360s.php?name='+e,'Virtual Tour','width=800,height=450,showcaption=1');
 }
// Launch Photos
function flp() {

 }
// Launch Furniture Planner 
function flf() {
  e = document.getElementById('fid').value;
  f = document.getElementById('dstheme').value;
  return Lightbox.show('http://www.easyroomplanner.com/app/app.php?fp='+e+'&theme='+f,'','width=1024,height=768,showcaption=1');  
 }

// Online Application Functions

function validateInfo(thisForm)
 {
  if (thisForm.residente1.value != 'E-mail Address' && !emailCheck(thisForm.residente1.value))
   {
    thisForm.residente1.focus();
    thisForm.residente1.select();
    alert("Please enter a valid e-mail address.");
   }
  else if (thisForm.resident1.value != 'Prospective Resident' && thisForm.resident1.value.length > 2)
   {
    document.getElementById('appformtext').style.display = 'none';
    ajaxSubmit(thisForm,'ApplicationConfirmation.php','hiddentext');
    document.getElementById('rentapp').submit();
   }
  else
    alert("Please enter at least 1 prospective resident.");
 }

function pr(e) {
  if(e.value == "Prospective Resident")
    e.value = '';
  else if (e.value == "")
    e.value = 'Prospective Resident';
 }
function pre(f) {
  if(f.value == "E-mail Address")
    f.value = '';
  else if (f.value == "")
    f.value = 'E-mail Address';
 }
// Virtual Tour Functions

 function hotspot(thisVirtual)
  {
   document.getElementById('VRWindow').style.display = 'block';
   document.getElementById('VRWindow').style.height = '800px';
   document.getElementById('panospot').innerHTML = '<iframe id="vframe" allowtransparency="true" style="background: transparent; width: 99%; height: 520px; margin: 4px auto" src="/include/vr/360.php?filename=' + 
                                                   thisVirtual  + '&viewer=' + document.getElementById('viewer').value + '" frameborder="0" scrolling="no"></iframe>';
  }
 function hidewindow()
  {
   document.getElementById('VRWindow').style.display = 'none';
   document.getElementById('panospot').innerHTML = '';
  } function showvrthm(id,lastitem) {
   document.getElementById('tour'+lastitem).style.display = 'none';
   document.getElementById('tour'+id).style.display = 'block';
   lastviewed = id;
  }
 function View360(name)
  {
   if (name != 0) w360 = window.open("ViewFloorplan.html?name=" + name,"_blank","width=828,height=700,status=no,directories=no,toolbar=no,resizeable=no,scrollbars=auto");
   else w360 = window.open("ViewFloorplan.html","_blank","width=828,height=700,status=no,directories=no,toolbar=no,scrollbars=auto,resizeable=no");
   w360.focus;
  }

// Ajax Functions

 function xmlhttpPost(outputTo,strURL,params) 
  {
   if (document.getElementById(outputTo).innerHTML != '' && params=='')
     document.getElementById(outputTo).innerHTML = '';
   else
    {
     document.getElementById(outputTo).innerHTML = 'Loading...';
     var xmlHttpReq = false;
     var self = this;
     if (window.XMLHttpRequest)        // Mozilla/Safari
       self.xmlHttpReq = new XMLHttpRequest();
     else if (window.ActiveXObject)    // IE
       self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
     self.xmlHttpReq.open('POST', strURL, true);
     self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     self.xmlHttpReq.onreadystatechange = function() 
      { 
       if (self.xmlHttpReq.readyState == 4) 
        updatePage(outputTo, self.xmlHttpReq.responseText); 
      }
     self.xmlHttpReq.send('activeDiv=' + outputTo + '&' + params);
    }
  }

 function updatePage(outputTo,value)
  {
   document.getElementById(outputTo).innerHTML = value;
  }
 function ajaxSubmit(fobj,submitTo,outputTo)
  {
   var getstr = '';
   for (i=0; i < fobj.elements.length; i++) 
    {
     var el = fobj.elements[i];
     switch(el.type)
      {
       case "textarea":
       case "hidden":
       case "text":
       case "password":
         getstr += encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value) + "&";
         break;
       case "select-one":
         if (el.options[el.selectedIndex].value)
           getstr += encodeURIComponent(el.name) + "=" + encodeURIComponent(el.options[el.selectedIndex].value) + "&";
         else if (el.options[el.selectedIndex].text)
           getstr += encodeURIComponent(el.name) + "=" + encodeURIComponent(el.options[el.selectedIndex].text) + "&";
         break;
       case "select-multiple":
         var selLen = el.options.length;
         for (var j=0; j < selLen; j++)
           if (el.options[j].selected)
             getstr += encodeURIComponent(el.name+"[]") + "=" + encodeURIComponent(el.options[j].value) + "&";
         break;
       case "checkbox":
       case "radio":
         if(el.checked)
           getstr += encodeURIComponent(el.name) + "=" + encodeURIComponent(el.value) + "&";
         break;                
      }
    }
   xmlhttpPost(outputTo,submitTo,getstr);
  }

window.onload = function() {

  if (document.getElementById('leasingspecial')) {
    Lightbox.open([["/SpecialOffer.html","","width=700,height=600"]],0);
   }

  if (document.getElementById('multiterms')) {
    xmlhttpPost('multiterms','/include/wrps/MultiFamily.php','');
   }
  if (document.getElementById('seniorterms')) {
    xmlhttpPost('seniorterms','/include/wrps/Senior.php','');
   }
  
// new adaptive style
  if (document.getElementById('rotatorinner')) {
    swfobject.embedSWF("/js/imagerotator.swf", "rotatorinner", "100%", "358", "9.0.0", "/js/expressInstall.swf",  
                       { paramXMLPath: "param.xml", initialURL: escape(document.location), width: "100%", height: "358" }, 
                       { base: ".", quality: "best", bgcolor: "#ECEAD3", allowfullscreen: "true" });
   }
  else if (document.getElementById('videotourespanol')) {
     swfobject.embedSWF('/js/mediaplayer.swf', 'videotourespanol', '620', '360', '9.0.98', "/js/expressInstall.swf", 
                           {allowfullscreen:"true",file:"/i/video/video2.f4v",stretching:"fill",autostart:"true",skin:"/js/modieus-WR.swf",title:"Video Tour",width:"620",height:"320",controlbarsize:"false",shownavigation:"true"}, 
                           {allowfullscreen:"true",allowscriptaccess:"always",wmode:"transparent"}, 
                           {id:"mediaplayer",name:"mediaplayer"});
   }  
// old style

  else if (document.getElementById('rotator')) {
    var flashvars = { paramXMLPath: "param.xml", initialURL: escape(document.location), width: "616", height: "356" }
    var params = { base: ".", quality: "best", bgcolor: "#ECEAD3", allowfullscreen: "true" }                
    var attributes = {}
    swfobject.embedSWF("/js/imagerotator.swf", "rotator", "100%", "616", "9.0.0", "/js/expressInstall.swf", flashvars, params, attributes);
   }


  if (document.getElementById('videotour')) {
    swfobject.embedSWF('/js/mediaplayer.swf', 'videotour', '616', '356', '9.0.98', "/js/expressInstall.swf", 
                       {allowfullscreen:"true",file:"/i/video/video.f4v",stretching:"fill",autostart:"false",image:"/i/ss/01.jpg",skin:"/js/modieus-WR.swf",title:"Video Tour",width:"616",height:"320",controlbarsize:"false",shownavigation:"true"}, 
                       {allowfullscreen:"true",allowscriptaccess:"always",wmode:"transparent"}, 
                       {id:"mediaplayer",name:"mediaplayer"});
   }

 }