/**
 * "_common/scripts/main.js" JavaScripts
 * @version $Id: main.js 58 2010-07-01 23:14:55Z master $
 * @author $Author: master $
 * @package DayStar - CostaRicaDiscountHotels.Info
 */
/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=='undefined')var deconcept=new Object();
if(typeof deconcept.util=='undefined')deconcept.util=new Object();
if(typeof deconcept.SWFObjectUtil=='undefined')deconcept.SWFObjectUtil=new Object();
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a)
{
 if(!document.getElementById)return;
 this.DETECT_KEY=_a?_a:'detectflash';
 this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
 this.params=new Object();
 this.variables=new Object();
 this.attributes=new Array();
 if(_1)this.setAttribute('swf',_1);
 if(id)this.setAttribute('id',id);
 if(w)this.setAttribute('width',w);
 if(h)this.setAttribute('height',h);
 if(_5)this.setAttribute('version',new deconcept.PlayerVersion(_5.toString().split('.')));
 this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
 if(!window.opera&&document.all&&this.installedVer.major>7)deconcept.SWFObject.doPrepUnload=true;
 if(c)this.addParam('bgcolor',c);
 var q=_7?_7:'high';
 this.addParam('quality',q);
 this.setAttribute('useExpressInstall',false);
 this.setAttribute('doExpressInstall',false);
 var _c=(_8)?_8:window.location;
 this.setAttribute('xiRedirectUrl',_c);
 this.setAttribute('redirectUrl','');
 if(_9)this.setAttribute('redirectUrl',_9);
};
deconcept.SWFObject.prototype=
{
 useExpressInstall:function(_d)
 {
  this.xiSWFPath=!_d?'expressinstall.swf':_d;
  this.setAttribute('useExpressInstall',true);
 },
 setAttribute:function(_e,_f){this.attributes[_e]=_f;},
 getAttribute:function(_10){return this.attributes[_10];},
 addParam:function(_11,_12){this.params[_11]=_12;},
 getParams:function(){return this.params;},
 addVariable:function(_13,_14){this.variables[_13]=_14;},
 getVariable:function(_15){return this.variables[_15];},
 getVariables:function(){return this.variables;},
 getVariablePairs:function()
 {
  var _16=new Array();
  var key;
  var _18=this.getVariables();
  for(key in _18)_16[_16.length]=key+"="+_18[key];
  return _16;
 },
 getSWFHTML:function()
 {
  var _19='';
  if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length)
  {
   if(this.getAttribute('doExpressInstall'))
   {
    this.addVariable('MMplayerType','PlugIn');
    this.setAttribute('swf',this.xiSWFPath);
   }
   _19='<embed type="application/x-shockwave-flash" src="'+this.getAttribute('swf')+'" width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'"';
   if(this.getAttribute('style')!='')_19+=' style="'+this.getAttribute('style')+'"';
   _19+=' id="'+this.getAttribute('id')+'" name="'+this.getAttribute('id')+'" ';
   var _1a=this.getParams();
   for(var key1 in _1a)_19+=[key1]+'="'+_1a[key1]+'" ';
   var _1c=this.getVariablePairs().join('&');
   if(_1c.length>0)_19+='flashvars="'+_1c+'"';
   _19+='/>';
  }
  else
  {
   if(this.getAttribute('doExpressInstall'))
   {
    this.addVariable('MMplayerType','ActiveX');
    this.setAttribute('swf',this.xiSWFPath);
   }
   _19='<object id="'+this.getAttribute('id')+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'"';
   if(this.getAttribute('style')!='')_19+=' style="'+this.getAttribute('style')+'">';
   _19+='<param name="movie" value="'+this.getAttribute('swf')+'" />';
   var _1d=this.getParams();
   for(var key2 in _1d)_19+='<param name="'+key2+'" value="'+_1d[key2]+'" />';
   var _1f=this.getVariablePairs().join("&");
   if(_1f.length>0)_19+='<param name="flashvars" value="'+_1f+'" />';
   _19+='</object>';
  }
  return _19;
 },
 write:function(_20)
 {
  if(this.getAttribute('useExpressInstall'))
  {
   var _21=new deconcept.PlayerVersion([6,0,65]);
   if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute('version')))
   {
    this.setAttribute('doExpressInstall',true);
    this.addVariable('MMredirectURL',escape(this.getAttribute('xiRedirectUrl')));
    document.title=document.title.slice(0,47)+' - Flash Player Installation';
    this.addVariable('MMdoctitle',document.title);
   }
  }
  if(this.skipDetect||this.getAttribute('doExpressInstall')||this.installedVer.versionIsValid(this.getAttribute('version')))
  {
   var n=(typeof _20=='string')?document.getElementById(_20):_20;
   n.innerHTML=this.getSWFHTML();
   return true;
  }
  else if(this.getAttribute('redirectUrl')!='')document.location.replace(this.getAttribute('redirectUrl'));
  return false;
 }
};
deconcept.SWFObjectUtil.getPlayerVersion=function()
{
 var _23=new deconcept.PlayerVersion([0,0,0]);
 if(navigator.plugins&&navigator.mimeTypes.length)
 {
  var x=navigator.plugins['Shockwave Flash'];
  if(x&&x.description)_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,'').replace(/(\s+r|\s+b[0-9]+)/,'.').split('.'));
 }
 else
 {
  if(navigator.userAgent&&navigator.userAgent.indexOf('Windows CE')>=0)
  {
   var axo=1;
   var _26=3;
   while(axo)
   {
    try
    {
     _26++;
     axo=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.'+_26);
     _23=new deconcept.PlayerVersion([_26,0,0]);
    }catch(e){axo=null;}
   }
  }
  else
  {
   try{axo=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');}
   catch(e)
   {
    try
    {
     axo=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
     _23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess='always';
    }catch(e){if(_23.major==6)return _23;}
    try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
    catch(e){}
   }
   if(axo!=null)_23=new deconcept.PlayerVersion(axo.GetVariable('$version').split(' ')[1].split(','));
  }
 }
 return _23;
};
deconcept.PlayerVersion=function(_29)
{
 this.major=_29[0]!=null?parseInt(_29[0]):0;
 this.minor=_29[1]!=null?parseInt(_29[1]):0;
 this.rev=_29[2]!=null?parseInt(_29[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv)
{
 if(this.major<fv.major)return false;
 if(this.major>fv.major)return true;
 if(this.minor<fv.minor)return false;
 if(this.minor>fv.minor)return true;
 if(this.rev<fv.rev)return false;
 return true;
};
deconcept.util=
{
 getRequestParameter:function(_2b)
 {
  var q=document.location.search||document.location.hash;
  if(_2b==null)return q;
  if(q)
  {
   var _2d=q.substring(1).split('&');
   for(var i=0;i<_2d.length;i++)if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b)return _2d[i].substring((_2d[i].indexOf('=')+1));
  }
  return'';
 }
};
deconcept.SWFObjectUtil.cleanupSWFs=function()
{
 var _2f=document.getElementsByTagName('OBJECT');
 for(var i=_2f.length-1;i>=0;i--)
 {
  _2f[i].style.display='none';
  for(var x in _2f[i])if(typeof _2f[i][x]=='function')_2f[i][x]=function(){};
 }
};
if(deconcept.SWFObject.doPrepUnload)
{
 if(!deconcept.unloadSet)
 {
  deconcept.SWFObjectUtil.prepUnload=function()
  {
   __flash_unloadHandler=function(){};
   __flash_savedUnloadHandler=function(){};
   window.attachEvent('onunload',deconcept.SWFObjectUtil.cleanupSWFs);
  };
  window.attachEvent('onbeforeunload',deconcept.SWFObjectUtil.prepUnload);
  deconcept.unloadSet=true;
 }
}
if(!document.getElementById&&document.all)document.getElementById=function(id){return document.all[id];};
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;

/*var C_ROOT='http://www.costaricadiscounthotels.info/_dev/';*/
var C_ROOT='/';
if($('DIVheader'))
{
 var so=new SWFObject(C_ROOT+'_common/flash/main-header.swf','HLP','1002','384','8','#FFFFFF');
 //so.addVariable('menu_activo','');
 so.addParam('quality','high');
 so.addParam('menu','false');
 so.addParam('scale','noscale');
 so.addParam('wmode','transparent');
 so.addParam('base',C_ROOT);
 so.write('DIVheader');
}
/**
 * Main general funcs
 */
function $(objId)
{
 if(typeof(objId)=='string')
 {//OBJECT
  var obj=document.getElementById(objId);
  if(obj)return obj;
  else
  {//CLASS
   var r=[];
   var re=new RegExp("\\b"+objId+"\\b");
   var els=document.getElementsByTagName('*');
   for(var i=0,j=els.length;i<j;i++)if(re.test(els[i].className))r.push(els[i]);
   if(r.length==1)return r[0];
   else if(r.length>0)return r;
   else return false
  }
 }
 else
 {//EVENT
  objId=objId||window.event;
  return objId.target||objId.srcElement;
 }
}
function preventDefault(ev)
{
 if(!ev)ev=window.event;
 ev.cancelBubble=true;
 ev.returnValue=false;
 if(ev.stopPropagation)
 {
  ev.stopPropagation();
  ev.preventDefault();
 }
 return false;
}
function setTransparency(obj,per)
{
 if(typeof obj=='object')
 {
  if(document.all)obj.style.filter='alpha(opacity='+per+')';
  else obj.style.opacity=(per/100);
 }
}
function setClass(obj,c)
{
 if(obj)
 {
  obj.setAttribute('class',c);
  obj.setAttribute('className',c);
 }
}
function addEvent(el,ev,fn,useCapture)
{
 if(!el)return false;
 var r;
 if(useCapture==null)useCapture=false;
 if(el.addEventListener)
 {
  el.addEventListener(ev,fn,useCapture);
  r=true;
 }
 else if(el.attachEvent)
 {
  r=el.attachEvent('on'+ev,fn);
  EventCache.add(el,ev,fn);
 }
 else
 {
  elem['on'+evType]=fn;
  r=false;
 }
 return r;
}
var EventCache=function()
{
 var listEvents=[];
 return{
  listEvents:listEvents,
  add:function(node,sEventName,fHandler,bCapture){listEvents.push(arguments);},
  flush:function()
  {
   var i,item;
   for(i=listEvents.length-1;i>=0;i=i-1)
   {
    item=listEvents[i];
    if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);}
    if(item[1].substring(0,2)!='on'){item[1]='on'+item[1];}
    if(item[0].detachEvent){item[0].detachEvent(item[1],item[2]);}
    item[0][item[1]]=null;
   }
  }
 };
}();

function book(code,ev)
{
 var div=$('DIVbook');
 for(var i=0;i<div.childNodes.length;i++)if(div.childNodes[i].nodeType==1&&div.childNodes[i].nodeName=='DIV')div.childNodes[i].style.display='none';
 $('DIV'+code).style.display='block';
 var els=$('bookMenuOption');
 if(ev)
 {
  for(var j=0;j<els.length;j++)setClass(els[j],'bookMenuOption bookOff');
  setClass($(ev),'bookMenuOption bookOn');
 }
}

function popUp(url,width,height){window.open(url,'determined','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+',top=0,left=0');}

function init()
{
 $('DIVbahiaAzul').innerHTML='<iframe class="bookFrame" src="https://www.securesitecr.com/ishtar_rentals_v1/iframes/iframe_daystar.php?oper34jklfkador=14&idi243sdjkoma=2&ini=1" frameborder="0" scrolling="no" title="Bah&iacute;a Azul"></iframe>';
/*
 $('DIVpalomaBlanca').innerHTML='<iframe class="bookFrame" src="https://www.securesitecr.com/ishtar_rentals_v1/iframes/iframe_vertical.php?oper34jklfkador=16&amp;idi243sdjkoma=2" frameborder="0" scrolling="no" title="Paloma Blanca"></iframe>';
 $('DIVbahiaEncantada').innerHTML='<iframe class="bookFrame" src="https://www.securesitecr.com/ishtar_rentals_v1/iframes/iframe_vertical.php?oper34jklfkador=18&amp;idi243sdjkoma=2" frameborder="0" scrolling="no" title="Bah&iacute;a Encantada"></iframe>';
 $('DIVdiamanteDelSol').innerHTML='';
 $('DIVthePalms').innerHTML='';
*/
 var gaJsHost='https:'==document.location.protocol?'https://ssl.':'http://www.';
 $('DIVscripts').innerHTML=unescape('%3Cscript src="'+gaJsHost+'google-analytics.com/ga.js" type="text/javascript"%3E%3C/script%3E');
 //sets the rel="external" on each anchor element
 var anchors=document.getElementsByTagName('a');
 for(var j=0;j<anchors.length;j++)
 {
  var anchor=anchors[j];
  if(anchor.getAttribute('href')&&anchor.getAttribute('rel')=='external')anchor.target='_blank';
 }
 if($('DIVliveWeather'))
 {
  var so=new SWFObject('http://www.imn.ac.cr/images/portadaMap.swf','Flash Map','550','400','8','#FFFFFF');
  so.addParam('quality','high');
  so.addParam('menu','false');
  so.addParam('scale','noscale');
  so.write('DIVliveWeather');
 }
 if($('DIVbanner'))
 {
  var ba=new SWFObject(C_ROOT+'_common/flash/banners-3.swf','HLP','109','256','8','#FFFFFF');
  ba.addParam('quality','high');
  ba.addParam('menu','false');
  ba.addParam('scale','noscale');
  ba.addParam('wmode','transparent');
  ba.write('DIVbanner');
 }
 if($('DIVliveChat'))
 {
  var liveChatCode="\n";
  liveChatCode+='<!-- stardevelop.com Live Help International Copyright - All Rights Reserved -->'+"\n";
  liveChatCode+='<!-- BEGIN stardevelop.com Live Help Messenger Code - Copyright - NOT PERMITTED TO MODIFY IMAGE MAP/CODE/LINKS -->'+"\n";
  liveChatCode+='<map name="LiveHelpInitiateChatMap" id="LiveHelpInitiateChatMap">'+"\n";
  liveChatCode+=' <area shape="rect" coords="33,173,195,186" href="#" target="_blank" alt="stardevelop.com Live Help"/>'+"\n";
  liveChatCode+=' <area shape="rect" coords="58,146,142,169" href="#" onclick="openLiveHelp();acceptInitiateChat();return false" alt="Accept"/>'+"\n";
  liveChatCode+=' <area shape="rect" coords="150,146,229,169" href="#" onclick="declineInitiateChat();return false" alt="Decline"/>'+"\n";
  liveChatCode+=' <area shape="rect" coords="231,37,269,55" href="#" onclick="declineInitiateChat();return false" alt="Close"/>'+"\n";
  liveChatCode+='</map>'+"\n";
  liveChatCode+='<div id="floatLayer" style="position:absolute;left:10px;top:10px;visibility:hidden;z-index:5000">'+"\n";
  liveChatCode+=' <div class="centered"><img src="http://www.daystar.travel/livehelp/locale/en/images/initiate_dialog.gif" alt="stardevelop.com Live Help" width="377" height="238" border="0" usemap="#LiveHelpInitiateChatMap" /></div>'+"\n";
  liveChatCode+='</div>'+"\n";
  liveChatCode+='<!--  END stardevelop.com Live Help Messenger Code - Copyright - NOT PERMITTED TO MODIFY IMAGE MAP/CODE/LINKS -->'+"\n";
  $('DIVliveChat').innerHTML=liveChatCode;
 }
 if($('DIVliveChatLink'))
 {
  var liveChatLinkCode='<a href="#" rel="external"><img src="http://www.daystar.travel/livehelp/include/status.php" id="LiveHelpStatus" name="LiveHelpStatus" alt="Live Help" onload="statusImagesLiveHelp[statusImagesLiveHelp.length]=this"/></a>';
  $('DIVliveChatLink').innerHTML=liveChatLinkCode;
 }
 if($('galleryThumbImages'))galleryStart();
 if($('propertyVideosMain'))startLightBox();
 if($('FRMcontact'))addEvent($('FRMcontact'),'submit',startForm);
 if($('FRMtourRequestInfo'))addEvent($('FRMtourRequestInfo'),'submit',startForm);
 setTimeout(function()
 {
  try
  {
   var pageTracker=_gat._getTracker('UA-9811021-1');
   pageTracker._trackPageview();
  }catch(err){}
 },5000);
 if($('DIVbook'))book('bahiaAzul');
}
addEvent(window,'load',init);
addEvent(window,'unload',EventCache.flush);
/**
 * Contact forms
 * http://www.fuelframework.com
 */
var formValidations=[];
//Contact
formValidations['TXTfirstName']='First Name is required';
formValidations['TXTlastName']='Last Name is required';
formValidations['TXTemail']='Email Addressis required';
formValidations['TXTphone']='Phone Number is required';
formValidations['TXAcomments']='Comments are required';
//Request info
formValidations['TXTguestName']='Guest Name is required';
formValidations['TXTreservationNumber']='Reservation number is required';
formValidations['TXTcondoNumber']='Condo number is required';
formValidations['TXTdate']='Date is required';
formValidations['TXTpickUp']='Pick up place is required';
formValidations['TXAcomments']='Comments are required';
function startForm(ev)
{
 var error=false;
 var inputs=$('inputRequired');
 var parentDiv,innerDivs,message;
 for(var i=0;i<inputs.length;i++)
 {
  parentDiv=inputs[i].parentNode;
  do
  {
   parentDiv=parentDiv.parentNode;
   if(parentDiv.nodeName=='DIV')
   {
    innerDivs=parentDiv.getElementsByTagName('DIV');
    for(var j=0;j<innerDivs.length;j++)if(innerDivs[j].className=='contactError')
    {
     message='';
     if(inputs[i].value==''&&formValidations[inputs[i].id])
      {
       error=true;
       message='<strong>Error</strong>: '+formValidations[inputs[i].id]+'.';
       innerDivs[j].style.paddingTop='15px';
      }
     else
      {
       innerDivs[j].style.paddingTop='0';
       message='';
      }
     innerDivs[j].innerHTML=message;
     break;
    }
   }
  }
  while(parentDiv.nodeType!=1||parentDiv.nodeName!='DIV');
 }
 if(error)preventDefault(ev);
}
/**
 * Gallery
 * http://www.fuelframework.com
 */
var galleries=[];
function galleryStart()
{
 galleries['_currentId']='01';
 galleries['_currentPosition']=0;
 galleries['_totalThumbs']=0;
 galleries['_rectTop']=0;
 galleries['_rectRight']=500;
 galleries['_rectBottom']=60;
 galleries['_rectLeft']=0;
 galleries['_left']=0;
 galleries['_targetLeft']=0;
 galleries['_targetRectTop']=0;
 galleries['_targetRectRight']=0;
 galleries['_targetRectBottom']=0;
 galleries['_targetRectLeft']=0;
 galleries['_big']=[];
 galleries['_big']['type']='out';
 galleries['_big']['current']=100;
 galleries['_big']['end']=100;
 positionGallery();
 for(var i=0;i<$('galleryThumbImages').childNodes.length;i++)if($('galleryThumbImages').childNodes[i].nodeType==1&&$('galleryThumbImages').childNodes[i].nodeName=='A')
 {
  for(var k=0;k<$('galleryThumbImages').childNodes[i].childNodes.length;k++)if($('galleryThumbImages').childNodes[i].childNodes[k].nodeType==1&&$('galleryThumbImages').childNodes[i].childNodes[k].nodeName=='IMG')
  {
   var obj=$('galleryThumbImages').childNodes[i].childNodes[k];
   var objId=galleryGetId(obj);
   galleries[objId]=[];
   galleries[objId]['type']='out';
   galleries[objId]['obj']=obj;
   galleries[objId]['current']=100;
   galleries[objId]['end']=galleries['_currentId']==objId?100:50;
   galleries[objId]['big']=null;
   fade(obj);
   addEvent(obj,'mouseover',function(ev)
   {
    galleries[galleryGetId($(ev))]['type']='in';
    galleries[galleryGetId($(ev))]['end']=100;
    fade($(ev));
   });
   addEvent(obj,'mouseout',function(ev)
   {
    galleries[galleryGetId($(ev))]['type']='out';
    galleries[galleryGetId($(ev))]['end']=galleries['_currentId']==galleryGetId($(ev))?100:50;
    fade($(ev));
   });
   addEvent(obj,'click',function(ev)
   {
    if($(ev).nodeName=='IMG'&&galleries['_currentId']!=galleryGetId($(ev)))
    {
     if(galleries[galleryGetId($(ev))]['big']==null)$('galleryMain').style.background='url(\'../../_common/images/icons/loading_white.gif\') center no-repeat #FFF';
     else $('galleryMain').style.background='none';
     galleries['_big']['type']='out';
     galleries['_big']['end']=0;
     galleries['_big']['target']=new Image();
     galleries['_big']['target'].src=$(ev).src.toString().replace(/thumb-/g,'');
     galleryChangeBig();
    }
   });
   galleries['_totalThumbs']++;
  }
 }
}
function galleryChangeBig()
{
 if
 (
  (galleries['_big']['type']=='out'&&galleries['_big']['current']<=galleries['_big']['end'])||
  (galleries['_big']['type']=='in'&&galleries['_big']['current']>=galleries['_big']['end'])
 )
 {
  if(galleries['_big']['type']=='out')
  {
   setTransparency($('IMGbig'),galleries['_big']['end']);
   var targetId=galleryGetId(galleries['_big']['target']);
   if(galleries[targetId]['big']==null)
   {
    galleries[targetId]['big']=new Image();
    addEvent(galleries[targetId]['big'],'load',function(){setBigImage(targetId);});
    galleries[targetId]['big'].src=galleries['_big']['target'].src;
   }
   else setBigImage(targetId);
  }
 }
 else
 {
  setTimeout(function()
  {
   galleries['_big']['current']+=3*(galleries['_big']['type']=='out'?-1:1);
   setTransparency($('IMGbig'),galleries['_big']['current']);
   galleryChangeBig();
  },15);
 }
}
function setBigImage(targetId)
{
 galleries[galleries['_currentId']]['type']='out';
 galleries[galleries['_currentId']]['end']=50;
 fade(galleries[galleries['_currentId']]['obj']);
 $('IMGbig').src=galleries[targetId]['big'].src;
 galleries['_currentId']=targetId;
 galleries['_big']['type']='in';
 galleries['_big']['end']=100;
 galleryChangeBig();
 galleries[targetId]['type']='in';
 galleries[targetId]['end']=100;
 fade(galleries[targetId]['obj']);
}
function fade(obj)
{
 var objId=galleryGetId(obj);
 if
 (
  (galleries[objId]['type']=='out'&&galleries[objId]['current']<=galleries[objId]['end'])||
  (galleries[objId]['type']=='in'&&galleries[objId]['current']>=galleries[objId]['end'])
 )setTransparency(obj,galleries[objId]['end']);
 else
 {
  setTimeout(function()
  {
   galleries[objId]['current']+=3*(galleries[objId]['type']=='out'?-1:1);
   setTransparency(obj,galleries[objId]['current']);
   fade(obj);
  },15);
 }
}
function galleryGetId(obj){return obj.src.toString().replace(/[^0-9]*/g,'');}
function galleryPrevious()
{
 if(galleries['_currentPosition']>0)
 {
  galleries['_currentPosition']--;
  galleries['_targetLeft']=100;
  galleries['_targetRectRight']=-100;
  galleries['_targetRectLeft']=-100;
  animateGallery();
 }
}
function galleryNext()
{
 if((galleries['_currentPosition']+5)<galleries['_totalThumbs'])
 {
  galleries['_currentPosition']++;
  galleries['_targetLeft']=-100;
  galleries['_targetRectRight']=100;
  galleries['_targetRectLeft']=100;
  animateGallery();
 }
}
function animateGallery()
{
 setTimeout(function()
 {
  var move=20;
  if(galleries['_targetLeft']!=0)
  {
   galleries['_left']+=galleries['_targetLeft']<0?-move:move;
   galleries['_targetLeft']+=galleries['_targetLeft']<0?move:-move;
  }
  if(galleries['_targetRectTop']!=0)
  {
   galleries['_rectTop']+=galleries['_targetRectTop']<0?-move:move;
   galleries['_targetRectTop']+=galleries['_targetRectTop']<0?move:-move;
  }
  if(galleries['_targetRectRight']!=0)
  {
   galleries['_rectRight']+=galleries['_targetRectRight']<0?-move:move;
   galleries['_targetRectRight']+=galleries['_targetRectRight']<0?move:-move;
  }
  if(galleries['_targetRectBottom']!=0)
  {
   galleries['_rectBottom']+=galleries['_targetRectBottom']<0?-move:move;
   galleries['_targetRectBottom']+=galleries['_targetRectBottom']<0?move:-move;
  }
  if(galleries['_targetRectLeft']!=0)
  {
   galleries['_rectLeft']+=galleries['_targetRectLeft']<0?-move:move;
   galleries['_targetRectLeft']+=galleries['_targetRectLeft']<0?move:-move;
  }
  positionGallery();
  if(galleries['_targetLeft']!=0)animateGallery();
 },15);
}
function positionGallery()
{
 $('galleryThumbImages').style.display='block';
 $('galleryThumbImages').style.clip='rect('+galleries['_rectTop']+'px '+galleries['_rectRight']+'px '+galleries['_rectBottom']+'px '+galleries['_rectLeft']+'px)';
 $('galleryThumbImages').style.left=galleries['_left']+'px';
}
/**
 * LightBox
 * http://www.fuelframework.com
 */
var lightBox=[];
function startLightBox()
{
 lightBox['galleries']=[];
 var galleries=$('propertyVideosMain');
 if(!galleries.length)galleries=[galleries];
 for(var i in galleries)for(var j=0;j<galleries[i].childNodes.length;j++)if(galleries[i].childNodes[j].nodeType==1&&galleries[i].childNodes[j].nodeName=='A')
 {
  addEvent(galleries[i].childNodes[j],'click',function(ev){preventDefault(ev);showLightBox(ev);});
  if(!lightBox['galleries'][galleries[i].id])lightBox['galleries'][galleries[i].id]=[];
  lightBox['galleries'][galleries[i].id][lightBox['galleries'][galleries[i].id].length]=galleries[i].childNodes[j];
 }
 //Background
 var backgroundDiv=document.createElement('div');
 backgroundDiv.id='DIVlightboxBackground';
 document.getElementsByTagName('body')[0].appendChild(backgroundDiv);
 lightBox['stepTransparency']=15;
 lightBox['currentTransparency']=0;
 lightBox['directionTransparency']=null;
 addEvent(backgroundDiv,'click',function(){hideLightBox();});
 setClass($('DIVlightboxBackground'),'lightboxBackground');
 setTransparency(backgroundDiv,lightBox['currentTransparency']);
 //Toolbox
 lightBox['toolboxStep']=10;
 var toolboxDiv=document.createElement('div');
 toolboxDiv.id='DIVlightboxToolbox';
 document.getElementsByTagName('body')[0].appendChild(toolboxDiv);
 setClass($('DIVlightboxToolbox'),'lightboxToolbox');
 //Panel
 lightBox['panelStep']=10;
 var panelDiv=document.createElement('div');
 panelDiv.id='DIVlightboxPanel';
 document.getElementsByTagName('body')[0].appendChild(panelDiv);
 setClass($('DIVlightboxPanel'),'lightboxPanel');
 $('DIVlightboxToolbox').innerHTML='<img src="../_common/images/icons/player-previous.png" alt="Previous"/>';
 $('DIVlightboxToolbox').innerHTML+='<img src="../_common/images/icons/player-next.png" alt="Next"/>';
 $('DIVlightboxToolbox').innerHTML+='<img src="../_common/images/icons/player-close.png" alt="Close"/>';
}
function showLightBox(ev)
{
 var galleryContainer=$(ev);
 do
 {
  galleryContainer=galleryContainer.parentNode;
  if(galleryContainer.nodeName=='A')
   {
    lightBox['_showURL']=galleryContainer.href.toString();
    lightBox['_showId']=parseInt(galleryContainer.href.toString().replace(/[^0-9]*/g,''))-1;
   }
 }
 while(galleryContainer.nodeType!=1||galleryContainer.nodeName!='DIV'||galleryContainer.id=='');
 lightBox['_showGallery']=galleryContainer.id;
 $('DIVlightboxBackground').style.display='block';
 lightBox['endTransparency']=80;
 lightBox['directionTransparency']='show';
 lightBox['showInterval']=setInterval(function()
 {
  lightBox['currentTransparency']+=lightBox['stepTransparency'];
  if(lightBox['currentTransparency']>lightBox['endTransparency'])lightBox['currentTransparency']=lightBox['endTransparency'];
  setTransparency($('DIVlightboxBackground'),lightBox['currentTransparency']);
  if(lightBox['currentTransparency']==lightBox['endTransparency']||lightBox['directionTransparency']=='hide')
  {
   clearInterval(lightBox['showInterval']);
   showLightBoxPanel();
  }
 },45);
}
function showLightBoxPanel()
{
 lightBox['panelWidth']=350;
 lightBox['panelHeight']=250;
 lightBox['panelWidthEnd']=/Video/.test(lightBox['_showGallery'].toString())?482:420;
 lightBox['panelHeightEnd']=/Video/.test(lightBox['_showGallery'].toString())?314:300;
 lightBox['panelMarginLeft']=-175;
 lightBox['panelMarginTop']=-125;
 lightBox['panelMarginLeftEnd']=/Video/.test(lightBox['_showGallery'].toString())?-241:-210;
 lightBox['panelMarginTopEnd']=/Video/.test(lightBox['_showGallery'].toString())?-163:-150;
 $('DIVlightboxPanel').style.width=lightBox['panelWidth']+'px';
 $('DIVlightboxPanel').style.height=lightBox['panelHeight']+'px';
 $('DIVlightboxPanel').style.marginLeft=lightBox['panelMarginLeft']+'px';
 $('DIVlightboxPanel').style.marginTop=lightBox['panelMarginTop']+'px';
 $('DIVlightboxPanel').style.display='block';
 lightBox['panelInterval']=setInterval(function()
 {
  lightBox['panelWidth']+=lightBox['panelStep'];
  lightBox['panelHeight']+=lightBox['panelStep'];
  lightBox['panelMarginLeft']-=lightBox['panelStep']/2;
  lightBox['panelMarginTop']-=lightBox['panelStep']/2;
  if(lightBox['panelWidth']>lightBox['panelWidthEnd'])
  {
   lightBox['panelWidth']=lightBox['panelWidthEnd'];
   lightBox['panelMarginLeft']=lightBox['panelMarginLeftEnd'];
  }
  if(lightBox['panelHeight']>lightBox['panelHeightEnd'])
  {
   lightBox['panelMarginTop']=lightBox['panelMarginTopEnd'];
   lightBox['panelHeight']=lightBox['panelHeightEnd'];
  }
  $('DIVlightboxPanel').style.width=lightBox['panelWidth']+'px';
  $('DIVlightboxPanel').style.height=lightBox['panelHeight']+'px';
  $('DIVlightboxPanel').style.marginLeft=lightBox['panelMarginLeft']+'px';
  $('DIVlightboxPanel').style.marginTop=lightBox['panelMarginTop']+'px';
  if(lightBox['panelWidth']==lightBox['panelWidthEnd']&&lightBox['panelHeight']==lightBox['panelHeightEnd'])
  {
   clearInterval(lightBox['panelInterval']);
   lightBoxShow();
   showLightBoxToolbox();
  }
 },45);
}
function showLightBoxToolbox()
{
 var code='<div class="lightBoxToolboxNavigator" style="float:left">'+(lightBox['_showId']+1)+' of '+lightBox['galleries'][lightBox['_showGallery']].length+'</div>';
 code+='<div class="lightBoxToolboxTools" style="float:right">';
 if(lightBox['_showId']!=0)code+=' <a href="javascript:previousLightBox()"><img src="../_common/images/icons/player-previous.png" alt="Previous"/></a>';
 if(lightBox['_showId']+1!=lightBox['galleries'][lightBox['_showGallery']].length)code+=' <a href="javascript:nextLightBox()"><img src="../_common/images/icons/player-next.png" alt="Next"/></a>';
 code+=' <a href="javascript:hideLightBox()"><img src="../_common/images/icons/player-close.png" alt="Close"/></a>';
 code+='</div>';
 code+='<div class="clearer"></div>';
 $('DIVlightboxToolbox').innerHTML=code;
 lightBox['toolboxMarginTop']=120;
 lightBox['toolboxMarginTopEnd']=153;
 $('DIVlightboxToolbox').style.marginTop=lightBox['toolboxMarginTop']+'px';
 $('DIVlightboxToolbox').style.display='block';
 lightBox['toolboxInterval']=setInterval(function()
 {
  lightBox['toolboxMarginTop']+=lightBox['toolboxStep'];
  if(lightBox['toolboxMarginTop']>lightBox['toolboxMarginTopEnd'])lightBox['toolboxMarginTop']=lightBox['toolboxMarginTopEnd'];
  $('DIVlightboxToolbox').style.marginTop=lightBox['toolboxMarginTop']+'px';
  if(lightBox['toolboxMarginTop']==lightBox['toolboxMarginTopEnd'])clearInterval(lightBox['toolboxInterval']);
 },75);
}
function hideLightBoxToolbox()
{
 lightBox['toolboxMarginTop']=153;
 lightBox['toolboxMarginTopEnd']=120;
 $('DIVlightboxToolbox').style.marginTop=lightBox['toolboxMarginTop']+'px';
 lightBox['toolboxInterval']=setInterval(function()
 {
  lightBox['toolboxMarginTop']-=lightBox['toolboxStep'];
  if(lightBox['toolboxMarginTop']<lightBox['toolboxMarginTopEnd'])lightBox['toolboxMarginTop']=lightBox['toolboxMarginTopEnd'];
  $('DIVlightboxToolbox').style.marginTop=lightBox['toolboxMarginTop']+'px';
  if(lightBox['toolboxMarginTop']==lightBox['toolboxMarginTopEnd'])
  {
   lightBox['_showURL']=lightBox['galleries'][lightBox['_showGallery']][lightBox['_showId']];
   clearInterval(lightBox['toolboxInterval']);
   lightBoxShow();
   showLightBoxToolbox();
  }
 },75);
}
function hideLightBox()
{
 $('DIVlightboxPanel').innerHTML=$('DIVlightboxToolbox').innerHTML='';
 $('DIVlightboxPanel').style.display=$('DIVlightboxToolbox').style.display='none';
 lightBox['endTransparency']=0;
 lightBox['directionTransparency']='hide';
 lightBox['hideInterval']=setInterval(function()
 {
  lightBox['currentTransparency']-=lightBox['stepTransparency'];
  if(lightBox['currentTransparency']<lightBox['endTransparency'])lightBox['currentTransparency']=lightBox['endTransparency'];
  setTransparency($('DIVlightboxBackground'),lightBox['currentTransparency']);
  if(lightBox['currentTransparency']==lightBox['endTransparency']||lightBox['directionTransparency']=='show')
  {
   clearInterval(lightBox['hideInterval']);
   $('DIVlightboxBackground').style.display='none';
  }
 },45);
}
function lightBoxShow(){$('DIVlightboxPanel').innerHTML='<iframe class="virtualFrame" src="'+lightBox['_showURL']+'" frameborder="0" scrolling="no" title="Virtual Tour"></iframe>';}
function previousLightBox()
{
 $('DIVlightboxPanel').innerHTML='';
 lightBox['_showId']--;
 hideLightBoxToolbox();
}
function nextLightBox()
{
 $('DIVlightboxPanel').innerHTML='';
 lightBox['_showId']++;
 hideLightBoxToolbox();
}