if (top.location != location) 
{
  top.location.href = document.location.href; 
}
_spCode = "blAb";

function MM_findObj(n, d) 
{
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() 
{
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function fractionSize(str)
{
  var index = str.indexOf( '.' );
  if( index >= 0 )
    return str.length - index - 1;
  return 0;
}

function isDouble(str)
{
  if(!str) return false;
  var decPointFound = false;
  for(var i=0; i<str.length; i++)
  {
    var ch=str.charAt(i);
    if( ch == '.' )
    {
      if( decPointFound ) return false;
      else decPointFound = true;
    }
    if ('0123456789.'.indexOf(ch) ==-1) return false;
  }
  return true;
}

var DH_Waiting = false;
var DH_Timer;
var DH_Anchor;
var DH_Text;
var DH_ShiftX;
var DH_ShiftY;

function ShowHint( anchor, text )
{
  ShiftedHint( anchor, text, -270, 25 );
}

function DelayedHint( anchor, text, shiftX, shiftY )
{
  DH_Anchor = anchor;
  DH_Text = text;
  DH_ShiftX = shiftX;
  DH_ShiftY = shiftY;
  DH_Timer = window.setTimeout("OpenDelayedHint()",400);
  DH_Waiting = true;
}

function OpenDelayedHint()
{
  if( DH_Waiting )
    ShiftedHint( DH_Anchor, DH_Text, DH_ShiftX, DH_ShiftY );
  DH_Waiting = false;
}

function ShiftedHint( anchor, text, shiftX, shiftY )
{
  span = Find( 'HintText' );
  span.innerHTML = text

  div = Find( 'HintLayer' );
  div.style.left = GetLeftCoord( anchor ) + shiftX;
  div.style.top = GetTopCoord( anchor ) + shiftY;
  div.style.visibility="visible";
}

function HideHint()
{
  div = Find( 'HintLayer' );
  div.style.visibility="hidden";
  DH_Waiting = false;
}

function VSpace( pixels )
{
  return '<table width=\'100%\' height=' + pixels + ' border=0 cellpadding=0 cellspacing=0><tr><td></td></tr></table>';
}

function HLine( color )
{
  return '<table width=\'100%\' height=1 border=0 cellpadding=0 cellspacing=0 bgcolor=\'' + color + '\'><tr><td></td></tr></table>';
}

function Find( elemID ) { return (document.getElementById) ? document.getElementById(elemID) : ((document.all) ? document.all[elemID] : null); }

function GetLeftCoord(_holder) { return (_holder.offsetParent.tagName=="BODY")?(_holder.offsetLeft):(_holder.offsetLeft + GetLeftCoord(_holder.offsetParent)); }

function GetTopCoord(_holder) { return (_holder.offsetParent.tagName=="BODY")?(_holder.offsetTop):(_holder.offsetTop + GetTopCoord(_holder.offsetParent)); }

function ShowHelp( pageCode ){ wnd=window.open( '/Help.aspx?page=' + pageCode, 'IC_Hlp', 'toolbar=0,scrollbars=0,statusbar=0,menubar=0,resizable=0,width=390,height=430,left=' + (screen.availWidth/2) + ',top=' + (screen.availHeight/2 - 300) ); wnd.focus(); }


function CheckLength(field, e, maxlen)
{
  var characterCode  
  if(e && e.which) //NS4
  { 
	characterCode = e.which
  }
  else
  {							
	characterCode = event.keyCode //IE
  }
  
  if( characterCode == 13 )
    event.returnValue = false;
    
  if( field.value.length > maxlen - 1 ) 
  {
    if( characterCode != 8 && characterCode <= 32 || characterCode > 46 ) 
    {
      alert( "You have reached the " + maxlen + "-character limit for this marketing message." );
      event.returnValue = false;
    }
  }
}

amenityIconsByRow =
[
 [ 0, 1, 2, 3 ],
 [ 4, 5, 6, 7 ],
 [ 8, 9, 10, 11 ],
 [ 12, 13, -1, -1 ]
];
amenityIcons = 
[
 ['S','Smoking','icSmoke', 'Smoking permitted in designated areas.  Please check with the innkeeper for details.', 'Smoking is not permitted in the inn, but may be allowed outside.'],
 ['K','Kids','icKids', 'Children are welcome at this property.  Please ask the innkeeper about minimum ages.', 'Accommodations are not suitable for children.'],
 ['D','Pets','icPets', 'Pets are welcome, but prior approval is usually necessary.  Please check with the innkeeper for details.', 'This property is not suitable for pets.'],
 ['H','Handicap','icHandicap', 'Access for the disabled is available but may be limited.  Please check with the innkeeper for details.', 'This property has little or no access for the disabled.'],
 ['P','Parking','icParking', 'Parking is available at this property but may be limited.  Please check with the innkeeper for details.', 'Parking is not available at this property, but is usually available in a nearby garage.'],
 ['M','Swimming','icSwim', 'Swimming is available at or near this property.  Please check with the innkeeper for details.', 'Swimming is not available at or near this property.'],
 ['I','Internet','icInternet', 'Internet access is available at this property.', 'Internet access is not available at this property.'],
 ['B','Breakfast','icRestaurant', 'Breakfast is served at this property.', 'Breakfast is not served at this property.'],
 ['T','Tennis','icTennis', 'Tennis is available at or near this property.  Please check with the innkeeper for details.', 'Tennis is not available at or near this property.'],
 ['W','Hot Tub','icWhirlpool', 'Some guest rooms and/or common area have whirlpool or hot tubs.', 'There are no hot tubs or whirlpool tubs at this property.'],
 ['G','Golf','icGolf', 'Golf is available at or near this property.  Please check with the innkeeper for details.', 'Golf is not available at or near this property.'],
 ['F','Fireplace','icfireplace', 'Some guest rooms and/or common area have fireplaces.', 'There are no fireplaces at this property.'],
 ['E','Weddings','icWedding', 'Weddings are held at this property. Please check with the innkeeper for details.', 'Weddings are not held at this property.'],
 ['N','Telephone','icPhone', 'Telephone available in guest room or common area.', 'Telephones are not available.']
];

function PopupIcons( iconsOn, anchor )
{
  rows = "";
  for( line=0; line<4; line++ )
  {
    imageCells = "";
	labelCells = "";
    for( icon=0; icon<4; icon++ )
	{
	  index = amenityIconsByRow[line][icon];
	  if( index >= 0 )
	  {
	  alt = amenityIcons[index][4];
	  state = 'No';
	  if( iconsOn.indexOf( amenityIcons[index][0] ) >= 0 )
	  {
	    state = 'Yes';
	    alt = amenityIcons[index][3];
	  }
      imageCells += "<td align='center' class='tdTopPadding'><img src='img/" + amenityIcons[ index ][2] + state + ".gif' width='25' height='25' border='0' alt='" + alt + "'></td>";
	  labelCells += "<td class='tdIcon" + state + "'>" + amenityIcons[ index ][1] + "</td>";
	  }
	  else
	  {
      imageCells += "<td align='center' class='tdTopPadding'>&nbsp;</td>";
	  labelCells += "<td class='tdIcon" + state + "'>&nbsp;</td>";
	  }
	}
    rows += "<tr>" + imageCells + "</tr>";
    rows += "<tr>" + labelCells + "</tr>";
  }
  span = Find( "IconsGrid" );
  span.innerHTML = "<table cellpadding=0 cellspacing=2 class='tblWidthFull'>" + rows + "</table>";

  div = Find( "IcPopup" );
  div.style.left = GetLeftCoord( anchor ) - 300;
  div.style.top = GetTopCoord( anchor );
  div.style.visibility="visible";
}

function PClick( clickID )
{
  wnd = window.open( '/Open.aspx?id=' + clickID, 'IC_ListingHome', 'toolbar=1,scrollbars=1,statusbar=1,menubar=1,resizable=1,width=700,height=500,left=50,top=50' ); 
  wnd.focus();
}

function Prop( clickID, iconsOn )
{
  document.write( " <a href='/Open.aspx?id=" + clickID + "' target=_blank>more...</a>" );
  document.write( "</td>" );
  document.write( "</tr>" );
  document.write( "<tr>" );
  document.write( "<td>" ); 
  document.write( "<div id='ic" + clickID + "' class='icLayer'>"  );
  document.write( "<table cellpadding='0' class='tblPanelIcons'>" );
  document.write( "<tr>" );
  document.write( "<td width='99%'>" );
  for( i=0; i<14; i++ )
  {
	state = 'No';
	if( iconsOn.indexOf( amenityIcons[i][0] ) >= 0 )
	  state = 'Yes';
    document.write( "<table class='tblFloatIcon'>" );
    document.write( "<tr>" );
    document.write( "<td align='center'><img src='img/" + amenityIcons[i][2] + state + ".gif' width='25' height='25' border='0' title='" + amenityIcons[i][1] + "' alt='" + amenityIcons[i][1] + "'></td>" );
    document.write( "</tr>" );
    document.write( "</table>" );
  }
  document.write( "</td>" );
  document.write( "<td width='1%' class='tdIconsExpand' onClick=\"PopupIcons( '" + iconsOn + "', this )\">" );
  document.write( "<img src='img/btnPIOpenLitl.gif' alt='View all amenities' width='19' height='19' border='0'>" );
  document.write( "</td>" );
  document.write( "</tr>" );
  document.write( "</table>" );
  document.write( "</div>"  );
  document.write( "</td>" ); 
  document.write( "</tr>" );
  document.write( "<tr>" );
  document.write( "<td>" );
}

function Am( iconsOn )
{
  document.write( "<div class='icLayer'>"  );
  document.write( "<table cellpadding='0' class='tblPanelIcons'>" );
  document.write( "<tr>" );
  document.write( "<td width='99%'>" );
  for( i=0; i<14; i++ )
  {
	alt = amenityIcons[i][4];
	state = 'No';
	if( iconsOn.indexOf( amenityIcons[i][0] ) >= 0 )
	{
	  state = 'Yes';
	  alt = amenityIcons[i][3];
	}  
  
    document.write( "<table class='tblFloatIcon'>" );
    document.write( "<tr>" );
    document.write( "<td align='center'><img src='img/" + amenityIcons[i][2] + state + ".gif' width='25' height='25' border='0' alt='" + alt + "'></td>" );
    document.write( "</tr>" );
    document.write( "</table>" );
  }
  document.write( "</td>" );
  document.write( "<td width='1%' class='tdIconsExpand' onClick=\"PopupIcons( '" + iconsOn + "', this )\">" );
  document.write( "<img src='img/btnPIOpenLitl.gif' alt='View all amenities' width='19' height='19' border='0'>" );
  document.write( "</td>" );
  document.write( "</tr>" );
  document.write( "</table>" );
  document.write( "</div>"  );
}


div = Find( "t" + _spCode + "out" );
if( div )
{
  div.style.position = "absolute";
  div.style.clip = "rect(0 1 1 0)";
}

function changeNavigationMode( mode )
{
	var today = new Date();
    var date = new Date( today.getFullYear(), today.getMonth() + 6, today.getDate(), today.getHours(), today.getMinutes(), today.getSeconds() );
	setCookie( "IC_NAV_HASH", mode, date );
	window.location.reload();
}

function setCookie( name, value, expires, path, domain, secure ) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

//tracking script via js stuff
var clickThrouhLock = false;
var clickThroughImageID="xesclickThruxsw";

function SaveClickThru(params,propid)
{
    var url = INNS_COM +"/TrackInnClicks.aspx";
    seperator = "?";
    if (params)
    {
        url += seperator + params;
    }
    //send click to google
    var linkprefix;
    var RealPropID =-1;
    if (url.indexOf("PROP=") > 0)
    {
        if (url.indexOf("&") > 0)
        {
            RealPropID = url.substring(url.indexOf("PROP=") + 5,url.indexOf("&"));
        }
        else
        {
            RealPropID = url.substring(url.indexOf("PROP=") + 5);
        }
        if (url.indexOf("FLID") > 0)
            linkprefix = "IOTM";
        else if (url.indexOf("ALTR") > 0)
            linkprefix = "ALT_LISTING";
        else
            linkprefix = "LISTING";
    }
    else if (propid != 'undefined')
    {
        RealPropID = propid;
        linkprefix = "FPA";
    }
    var track = "/" + linkprefix + "/" + RealPropID;
    if (RealPropID != -1 && typeof(urchinTracker) !='undefined')
    {
         urchinTracker("/" + linkprefix + "/" + RealPropID);
    }

    SendTracking(url);   

}

function SendTracking(url)
{
    var jqueryIdName= "#" + clickThroughImageID;
    if (!($(jqueryIdName).length))
    {
        while(clickThrouhLock)
        {
        }
            clickThrouhLock = true;
            if(!($(jqueryIdName).length ))
                $("body").append('<img width="1" height="1" src="/img/blank.gif" id="' + clickThroughImageID + '" />');
            clickThrouhLock = false;
    }

        if (url.indexOf("?") < 0)
            url += "?rnd=" + Math.floor(Math.random()*5000000);
        else
            url += "&rnd=" + Math.floor(Math.random()*5000000);

    $(jqueryIdName).attr({src : url});
}

function SendOtherTracking(code) {
    var url = INNS_COM + "/TrackOtherClicks.aspx?evt=" + code;

    url += "&rnd=" + Math.floor(Math.random() * 5000000);

    var atLoadImage = new Image;
    atLoadImage.src = url;
}


//pop under code

//default global pop under
var placementID = 0;

function DoSearchWinWithPID(pid) {
    placementID = pid;
    DoSearchWin();
}

var noDblClick = false;
function DoSearchWin() {
    if (!noDblClick) {
        noDblClick = true;
        var searchDone = $.cookie('TAN_SearchWindow');
        if (searchDone != 'done' && placementID != 0) {
            tanPopUnder(placementID);
            window.focus();
            var expireTime = new Date();
            expireTime.setHours(23, 59, 59);
            $.cookie('TAN_SearchWindow', 'done', { expires: expireTime });
            SendOtherTracking('PU');
        }
    }
}
function tanSearchUnder(placementId, origAp, destAp, depDate, retDate, adult, children, kw) { if (destAp.length == 0 || placementId.length == 0) return; var popunder = "http://www.traveladvertising.com/Live/SearchAds.aspx?PlacementId=" + placementId + "&origAp=" + origAp + "&destAp=" + destAp + "&isAutoClick=true"; var winfeatures = "scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0"; var searchUnder = window.open(popunder, "TANSearchUnder", winfeatures); searchUnder.blur(); } function tanPopUnder(placementId) { if (placementId.length == 0) return; var popunder = "http://www.traveladvertising.com/Live/SearchAds.aspx?PlacementId=" + placementId + "&origAp=xxx&destAp=BOS&isAutoClick=true"; var winfeatures = "scrollbars=1,resizable=1,toolbar=1,location=1,menubar=1,status=1,directories=0,width=780,height=550"; var searchUnder = window.open(popunder, "TANSearchUnder", winfeatures); searchUnder.blur(); } 