﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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() { //v3.0
  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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);}
  


               
function openCalendar(FormElement){
               var calendarwindow;
               url = "calendar.html?formname=resform&formelement=" + FormElement;
               calendarwindow = window.open(url,"thewindow","toolbar=no,LEFT=300,TOP=250,WIDTH=170,HEIGHT=140,status=no,scrollbars=no,resize=no,menubar=no");
               calendarwindow.focus();
               }
               
function Form_Validator(theForm)
               {
                    
                              if (theForm.firstname.value.replace(/^\s+|\s+$/g,"") == "")
                              {
                                   alert("Please enter First Name.");
                                   theForm.firstname.focus();
                                   return (false);
                              }
                         
                              var fieldvalue105 = theForm.firstname.value;
                              if(fieldvalue105.length > 100)
                              {
                                   alert("Too many characters entered in First Name.  Please limit to 100 characters.");
                                   theForm.firstname.focus();
                                   return false;
                              }
                         
                              if (theForm.lastname.value.replace(/^\s+|\s+$/g,"") == "")
                              {
                                   alert("Please enter Last Name.");
                                   theForm.lastname.focus();
                                   return (false);
                              }
                         
                              var fieldvalue106 = theForm.lastname.value;
                              if(fieldvalue106.length > 100)
                              {
                                   alert("Too many characters entered in Last Name.  Please limit to 100 characters.");
                                   theForm.lastname.focus();
                                   return false;
                              }
                         
                              if (theForm.address.value.replace(/^\s+|\s+$/g,"") == "")
                              {
                                   alert("Please enter Street Address.");
                                   theForm.address.focus();
                                   return (false);
                              }
                         
                              var fieldvalue107 = theForm.address.value;
                              if(fieldvalue107.length > 255)
                              {
                                   alert("Too many characters entered in Street Address.  Please limit to 255 characters.");
                                   theForm.address.focus();
                                   return false;
                              }
                         
                              if (theForm.city.value.replace(/^\s+|\s+$/g,"") == "")
                              {
                                   alert("Please enter City.");
                                   theForm.city.focus();
                                   return (false);
                              }
                         
                              var fieldvalue109 = theForm.city.value;
                              if(fieldvalue109.length > 100)
                              {
                                   alert("Too many characters entered in City.  Please limit to 100 characters.");
                                   theForm.city.focus();
                                   return false;
                              }
                         
                              if (theForm.zip.value.replace(/^\s+|\s+$/g,"") == "")
                              {
                                   alert("Please enter Postal/Zip Code.");
                                   theForm.zip.focus();
                                   return (false);
                              }
                         
                              var fieldvalue111 = theForm.zip.value;
                              if(fieldvalue111.length > 20)
                              {
                                   alert("Too many characters entered in Postal/Zip Code.  Please limit to 20 characters.");
                                   theForm.zip.focus();
                                   return false;
                              }
                         
                              if (theForm.email.value.replace(/^\s+|\s+$/g,"") == "")
                              {
                                   alert("Please enter E-mail.");
                                   theForm.email.focus();
                                   return (false);
                              }
                         
                              validationPattern = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
                              if( theForm.email.value != "" &&
                                 !validationPattern.test(theForm.email.value)) {
                                   alert("E-mail entry is invalid.");
                                   theForm.email.focus();
                                   return false;
                              }
                         
                              var fieldvalue115 = theForm.email.value;
                              if(fieldvalue115.length > 100)
                              {
                                   alert("Too many characters entered in E-mail.  Please limit to 100 characters.");
                                   theForm.email.focus();
                                   return false;
                              }
                         
                              /*
                              var fieldvalue117 = theForm.Field117.value;
                              if(fieldvalue117.length > 1000)
                              {
                                   alert("Too many characters entered in My Request, Comments or Questions:.  Please limit to 1000 characters.");
                                   theForm.Field117.focus();
                                   return false;
                              }
                              */
                    return true;
               }
               
function newWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
// Blueprint Method
var newWindow = null
function makeNewWindow(URL,winname,features) {
     // open window with given name, bring it forward
     newWindow = window.open(URL,winname,features);
     newWindow.focus()
}
/* end.New Window Functions */

/* start.Detect Browser */
function BrowserDetectLite() {
     var ua = navigator.userAgent.toLowerCase(); 
     this.ua = ua;
     // browser name
     this.isGecko     = (ua.indexOf('gecko') != -1);
     this.isMozilla   = (this.isGecko && ua.indexOf("gecko/") + 14 == ua.length);
     this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
     this.isIE        = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ); 
     this.isOpera     = (ua.indexOf("opera") != -1); 
     this.isKonqueror = (ua.indexOf("konqueror") != -1); 
     this.isIcab      = (ua.indexOf("icab") != -1); 
     this.isAol       = (ua.indexOf("aol") != -1); 
     this.isWebtv     = (ua.indexOf("webtv") != -1); 
     this.isOmniweb   = (ua.indexOf("omniweb") != -1);
     this.isDreamcast   = (ua.indexOf("dreamcast") != -1);
     // spoofing and compatible browsers
     this.isIECompatible = ( (ua.indexOf("msie") != -1) && !this.isIE);
     this.isNSCompatible = ( (ua.indexOf("mozilla") != -1) && !this.isNS && !this.isMozilla);
     // browser version
     this.versionMinor = parseFloat(navigator.appVersion); 
     // correct version number for NS6+ 
     if (this.isNS && this.isGecko) {
          this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
     }
     // correct version number for IE4+ 
     else if (this.isIE && this.versionMinor >= 4) {
          this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
     }
     // correct version number for Opera 
     else if (this.isOpera) {
          if (ua.indexOf('opera/') != -1) {
               this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
          }
          else {
               this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
          }
     }
     // correct version number for Konqueror
     else if (this.isKonqueror) {
          this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
     }
     // correct version number for iCab 
     else if (this.isIcab) {
          if (ua.indexOf('icab/') != -1) {
               this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
          }
          else {
               this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
          }
     }
     // correct version number for WebTV
     else if (this.isWebtv) {
          this.versionMinor = parseFloat( ua.substring( ua.indexOf('webtv/') + 6 ) );
     }
     
     this.versionMajor = parseInt(this.versionMinor); 
     this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
     
     // platform
     this.isWin   = (ua.indexOf('win') != -1);
     this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1) );
     this.isMac   = (ua.indexOf('mac') != -1);
     this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('linux') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
     
     // specific browser shortcuts
     this.isNS4x = (this.isNS && this.versionMajor == 4);
     this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
     this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
     this.isNS4up = (this.isNS && this.versionMinor >= 4);
     this.isNS6x = (this.isNS && this.versionMajor == 6);
     this.isNS6up = (this.isNS && this.versionMajor >= 6);
     this.isIE4x = (this.isIE && this.versionMajor == 4);
     this.isIE4up = (this.isIE && this.versionMajor >= 4);
     this.isIE5x = (this.isIE && this.versionMajor == 5);
     this.isIE55 = (this.isIE && this.versionMinor == 5.5);
     this.isIE5up = (this.isIE && this.versionMajor >= 5);
     this.isIE6x = (this.isIE && this.versionMajor == 6);
     this.isIE6up = (this.isIE && this.versionMajor >= 6);
     this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetectLite();
/* end.Detect Browser */

/* start.Display PNG */
function OpacityObject(divId, strPath) {
     this.id = divId;
     this.path = strPath;
     if (ns){
          if (browserVersion>=5) {
               this.layerObject = document.getElementById(divId).style;
          } else {
               this.layerObject = eval("document."+divId);
          }
     } else {
          this.layerObject = eval(divId + ".style");
     }
     this.setBackground = od_object_setBackground;
}

function od_object_setBackground() {    
     if (pngAlpha) {
          this.layerObject.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.path+".png', sizingMethod='scale')";
     } else if (pngNormal) {
          this.layerObject.backgroundImage = 'url('+this.path+'.png)';
     } else {
          this.layerObject.backgroundImage = 'url('+this.path+'.gif)';
     }
}

function od_displayImage(strId, strPath, intWidth, intHeight, strClass, strAlt) {    
     if (pngAlpha) {
          document.write('<div style="height:'+intHeight+'px;width:'+intWidth+'px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+strPath+'.png\', sizingMethod=\'scale\')" id="'+strId+'" class="'+strClass+'"></div>');
     } else if (pngNormal) {
          document.write('<img src="'+strPath+'.png" width="'+intWidth+'" height="'+intHeight+'" name="'+strId+'" border="0" class="'+strClass+'" alt="'+strAlt+'" />');
     } else {
          document.write('<img src="'+strPath+'.gif" width="'+intWidth+'" height="'+intHeight+'" name="'+strId+'" border="0" class="'+strClass+'" alt="'+strAlt+'" />');
     }
}

if ((browser.isIE55 || browser.isIE6up) && browser.isWin32) {
     var pngAlpha = true;
     var strExt = ".png";

} else if ((browser.isGecko) || (browser.isIE5up && browser.isMac) || (browser.isOpera && browser.isWin && browser.versionMajor >= 6) || (browser.isOpera && browser.isUnix && browser.versionMajor >= 6) || (browser.isOpera && browser.isMac && browser.versionMajor >= 5) || (browser.isOmniweb && browser.versionMinor >= 3.1) || (browser.isIcab && browser.versionMinor >= 1.9) || (browser.isWebtv) || (browser.isDreamcast)) {
     var pngNormal = true;
     var strExt = ".png";

} else {
     var strExt = ".gif";
}

var ns = (document.all)?false:true;
var browserVersion = parseFloat(navigator.appVersion );

/* start.Rollover Script */
function setimage(name, source)
{document.images[name].src = source; return true;}
/* end.Rollover Script */

/* start.Pulldown Navigation */
// Same Window
function Navigo() {
     var popup = eval("document.NavigotronForm.elements['Navigotron']");
     var dest  = popup[popup.selectedIndex].value;
     if (dest == '') popup.selectedIndex = 0;
     else window.open(dest, '_top');
}
// New Window
function NavigoNew() {
     var popup = eval("document.NavigotronForm.elements['Navigotron']");
     var dest  = popup[popup.selectedIndex].value;
     if (dest == '') popup.selectedIndex = 0;
     else window.open(dest, '_blank');

}
/* end.Pulldown Navigation */

/* start.Flash */
function flashINIT(v)
{
     MM_FlashCanPlay = 0;
     MM_contentVersion = v;
     var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
     if ( plugin ) {
               var words = navigator.plugins["Shockwave Flash"].description.split(" ");
               for (var i = 0; i < words.length; ++i)
               {
               if (isNaN(parseInt(words[i])))
               continue;
               var MM_PluginVersion = words[i]; 
               }
          MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
     }
     else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
          document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
          document.write('on error resume next \n');
          document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
          document.write('</SCR' + 'IPT\> \n');
     }
}

function writeFlashVersionDetect(flashName,flashSource,imgSource,w,h,v,vars,map)
{

  if(!map){
       var useMap = "";
  }else{
       var useMap = map;  
  }
  
  flashINIT(v);
  if (MM_FlashCanPlay) 
  {
    writeFlash(flashName,flashSource,imgSource,w,h,v,vars);
  }else{
       if(useMap != ""){
          document.write('<img src="'+ imgSource +'" width="'+ w +'" height="'+ h +'" border=0 usemap="#'+useMap+'">');  
       }else{
          document.write('<a href="http://www.macromedia.com/go/getflashplayer" target="_blank"><img src="'+ imgSource +'" width="'+ w +'" height="'+ h +'" border=0></a>');
       }
  }
}

function writeFlash(flashName,flashSource,imgSource,w,h,v,vars)//straight flash write no detection
{
          document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
          document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+ v +',0,0,0" ');
          document.write(' ID="'+ flashName +'" WIDTH="'+ w +'" HEIGHT="'+ h +'" ALIGN="">');
          document.write(' <PARAM NAME=movie VALUE="'+ flashSource +'?'+ vars +'"><PARAM NAME=quality VALUE=high><param name=wmode value=transparent><PARAM NAME=menu VALUE=false>');
          document.write(' <EMBED src="'+ flashSource +'?'+ vars +'" quality=high menu="false" wmode="transparent"');
          document.write(' swLiveConnect=FALSE WIDTH="'+ w +'" HEIGHT="'+ h +'" NAME="'+ flashName +'" ALIGN=""');
          document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
          document.write(' </EMBED>');
          document.write(' </OBJECT>');
}
/* end.Flash */

/* start.Show or Hide Image By Layout Height */
function publishImageByHeight(elementID,idHeight,imgpath,imgname) {
     var layerHeight = document.getElementById(elementID).offsetHeight;
     if (layerHeight >= idHeight) { setimage(imgname,imgpath); }
     else {  }
}
/* end.Show or Hide Image By Layout Height */


function correctPNG() {
     for(var i=0; i<document.images.length; i++) {
          var img = document.images[i]
          var imgName = img.src.toUpperCase()
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
               var imgID = (img.id) ? "id='" + img.id + "' " : ""
               var imgClass = (img.className) ? "class='" + img.className + "' " : ""
               var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
               var imgStyle = "display:inline-block;" + img.style.cssText 
               if (img.align == "left") imgStyle = "float:left;" + imgStyle
               if (img.align == "right") imgStyle = "float:right;" + imgStyle
               if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle      
               var strNewHTML = "<span " + imgID + imgClass + imgTitle
               + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
               + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
               + "(src=\'" + img.src + "\', sizingMethod='scale'); visibility:visible\"></span>" 
               img.outerHTML = strNewHTML
               i = i-1
          }
     }
}

// Note: This function only renders the beginning DIV tag. You need to input the content and the close DIV tag.
function renderPNGBG(name,path,style,repeat,transform) {
     alert('como?');
     document.write('<div id="' + name + '" style="' + style);
     if (pngAlpha) { document.write('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + path + name + '.png\', sizingMethod=\'' + transform + '\');'); }
     else { document.write('background:url(' + path + name + '.png) left top ' + repeat + ';'); }
     document.write('">');
}

function adjustDivs(firstID,secondID,firstPadding,secondPadding,firstIDset,secondIDset)
{
     var fHeight = xHeight(firstID);
     var fHeightAdd = (firstPadding);
     var fHeightNew = (parseInt(fHeight) + parseInt(fHeightAdd));
     var sHeight = xHeight(secondID);
     var sHeightAdd = (secondPadding);
     var sHeightNew = (parseInt(sHeight) + parseInt(sHeightAdd));
     var maxHeight = Math.max(fHeightNew,sHeightNew);

     xHeight(firstIDset, maxHeight);
     xHeight(secondIDset, maxHeight);
}

(function($){
     $(function(){
     
     $("a[href='http://www.facebook.com/brownhotel']").attr('onClick', 'dcsMultiTrack("WT.ac", "Facebook");') 
     $("a[href='http://twitter.com/TheBrownHotel']").attr('onClick', 'dcsMultiTrack("WT.ac", "Twitter");') 
     });
})(jQuery);     

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=90');");
}

$(document).ready(function() {
var galID = 0;


$(".widgetPhotoGallery").each(function(){      
          
     $(this).append("<ul style='padding: 0;'></ul>").addClass("shadowBoxGallery").attr({ id: "gallery" + galID});

     $(this).find(".galleryImgThumb").each(function(){
     

          var thumbnailSrc = $(this).css('backgroundImage');
          var thumbnailSrc = thumbnailSrc.replace('url(', '').replace(')', '');
          

          var largeImg = $(this).attr("href");
          

          var imgDesc = $(this).attr("title")
          
          $("#gallery" + galID + " ul").append("<li class='shadowBoxThumbs'><a title='" + imgDesc + "' href=" + largeImg + " rel='shadowbox[gallery" + galID + "]'><img src=" + thumbnailSrc + " /></a></li>");
          

     });

galID += 1;

});

$(".shadowBoxThumbs").css({"list-style-type" : "none", "display" : "inline"});

$(".galleryImgFullShell, .imgDescriptionShell, .imgPreviousNextShell, .imgThumbnailsOuterShell").remove();

Shadowbox.setup();



});
