/*----------Property.cs------------------*/

//functions for sending WC Travel the search bar information to the hotel search
function sendinfo(){
		href = "http://www.res99.com/nexres/search/search_results.cgi?interstitial=done&zip=&src_aid=&unps=y&&tab=tab0&t1_addr=&t3_landmark=&airport=&distance=15&src=10025013&avail=Y&currency_id=USD"
		//rooms
		href = href + "&num_rooms=" + document.getElementById("rooms").value + "&num_adults=" + document.getElementById("adults").value + "&num_children=" + document.getElementById("children").value;
		//date of arrival
		doa_str = document.getElementById("checkin").value;
		doa = doa_str.split("-");
		a_mm = doa[0]; a_dd = doa[1]; a_yy = doa[2];
		href = href + "&doa_mm=" + a_mm + "&doa_dd=" + a_dd + "&doa_yy=" + a_yy;
		//date of departure
		d_dd = a_dd;
		d_mm = a_mm;
		d_yy = a_yy;
		if (a_dd < 24) {
			d_dd = Number(a_dd) + 4;
		}else {
			if (a_mm < 12){
				d_mm = Number(a_mm) + 1;
			}else{
				d_mm = 1;
				d_yy = Number(a_yy) + 1;
			}
			d_dd = 1;
		}		
		href = href + "&dod_mm=" + d_mm + "&dod_dd=" + d_dd + "&dod_yy=" + d_yy;
		//location
		index = getCollectionIndex();
		if (index == -1){
			href = "http://www.res99.com/nexres/search/search_results.cgi?src=10025013";
		}else {
			st = getState(collectionState[index]);
			country = getCountryCode(collectionCountry[index]);
			href = href + "&city=" + collectionCity[index] + "&state=" + st + "&country=" + country;
			
		}
		window.location = href;
	}
	function getCollectionIndex(){
		index = getCollectionCountryIndex();
		
		if (index == -1)
			index = getCollectionStateIndex();
		
		if (index == -1)
			index = getCollectionCityIndex();		
		if (index == -1)
			index = getCollectionNameIndex();	
		return index;
	}
	function getCollectionNameIndex(){
		c = document.getElementById("property").value
		//search by resort name
		for (i=0; i<collection.length;i++){
		  if (c.toLowerCase() == collection[i].toLowerCase())
			return i;
		}
		return -1;
		
	}
	function getCollectionCityIndex(){
		c = document.getElementById("property").value
		for (i=0; i<collectionCity.length;i++){	
		  if (c.toLowerCase() == collectionCity[i].toLowerCase())	
		  return i;
		}
		return -1;
	}
	function getCollectionStateIndex(){
		c = document.getElementById("property").value
		for (i=0; i<collectionState.length;i++){
		  if (c.toLowerCase() == collectionState[i].toLowerCase())	
		  return i;
		}
		return -1;
	}
	function getCollectionCountryIndex(){
		c = document.getElementById("property").value
		for (i=0; i<collectionCountry.length;i++){	
		  if (c.toLowerCase() == collectionCountry[i].toLowerCase())	
		  return i;
		}
		return -1;
	}
/*----------------------DateFormat.js---------------*/

/*
 * Date Format 1.2.2
 * (c) 2007-2008 Steven Levithan <stevenlevithan.com>
 * MIT license
 * Includes enhancements by Scott Trenda <scott.trenda.net> and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */
var dateFormat = function () {
	var	token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
		timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (val, len) {
			val = String(val);
			len = len || 2;
			while (val.length < len) val = "0" + val;
			return val;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask, utc) {
		var dF = dateFormat;

		// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
		if (arguments.length == 1 && (typeof date == "string" || date instanceof String) && !/\d/.test(date)) {
			mask = date;
			date = undefined;
		}

		// Passing date through Date applies Date.parse, if necessary
		date = date ? new Date(date) : new Date();
		if (isNaN(date)) throw new SyntaxError("invalid date");

		mask = String(dF.masks[mask] || mask || dF.masks["default"]);

		// Allow setting the utc argument via the mask
		if (mask.slice(0, 4) == "UTC:") {
			mask = mask.slice(4);
			utc = true;
		}

		var	_ = utc ? "getUTC" : "get",
			d = date[_ + "Date"](),
			D = date[_ + "Day"](),
			m = date[_ + "Month"](),
			y = date[_ + "FullYear"](),
			H = date[_ + "Hours"](),
			M = date[_ + "Minutes"](),
			s = date[_ + "Seconds"](),
			L = date[_ + "Milliseconds"](),
			o = utc ? 0 : date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
				S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
			};

		return mask.replace(token, function ($0) {
			return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":      "ddd mmm dd yyyy HH:MM:ss",
	shortDate:      "m/d/yy",
	mediumDate:     "mmm d, yyyy",
	longDate:       "mmmm d, yyyy",
	fullDate:       "dddd, mmmm d, yyyy",
	shortTime:      "h:MM TT",
	mediumTime:     "h:MM:ss TT",
	longTime:       "h:MM:ss TT Z",
	isoDate:        "yyyy-mm-dd",
	isoTime:        "HH:MM:ss",
	isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
	isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
	return dateFormat(this, mask, utc);
};

	
/* ----------------CalendarControl.js --------------------*/

function positionInfo(object) {

  var p_elm = object;

  this.getElementLeft = getElementLeft;
  function getElementLeft() {
    var x = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      x+= elm.offsetLeft;
      elm = elm.offsetParent;
    }
    return parseInt(x);
  }

  this.getElementWidth = getElementWidth;
  function getElementWidth(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetWidth);
  }

  this.getElementRight = getElementRight;
  function getElementRight(){
    return getElementLeft(p_elm) + getElementWidth(p_elm);
  }

  this.getElementTop = getElementTop;
  function getElementTop() {
    var y = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      y+= elm.offsetTop;
      elm = elm.offsetParent;
    }
    return parseInt(y);
  }

  this.getElementHeight = getElementHeight;
  function getElementHeight(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetHeight);
  }

  this.getElementBottom = getElementBottom;
  function getElementBottom(){
    return getElementTop(p_elm) + getElementHeight(p_elm);
  }
}

function CalendarControl() {

  var calendarId = 'CalendarControl';
  var currentYear = 0;
  var currentMonth = 0;
  var currentDay = 0;

  var selectedYear = 0;
  var selectedMonth = 0;
  var selectedDay = 0;

  var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  var dateField = null;

  function getProperty(p_property){
    var p_elm = calendarId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if (elm != null){
      if(elm.style){
        elm = elm.style;
        if(elm[p_property]){
          return elm[p_property];
        } else {
          return null;
        }
      } else {
        return null;
      }
    }
  }

  function setElementProperty(p_property, p_value, p_elmId){
    var p_elm = p_elmId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if((elm != null) && (elm.style != null)){
      elm = elm.style;
      elm[ p_property ] = p_value;
    }
  }

  function setProperty(p_property, p_value) {
    setElementProperty(p_property, p_value, calendarId);
  }

  function getDaysInMonth(year, month) {
    return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
  }

  function getDayOfWeek(year, month, day) {
    var date = new Date(year,month-1,day)
    return date.getDay();
  }

  this.clearDate = clearDate;
  function clearDate() {
    dateField.value = '';
    hide();
  }

  this.setDate = setDate;
  function setDate(year, month, day) {
    if (dateField) {
      if (month < 10) {month = "0" + month;}
      if (day < 10) {day = "0" + day;}

      var dateString = month+"-"+day+"-"+year;
      dateField.value = dateString;
      hide();
    }
    return;
  }

  this.changeMonth = changeMonth;
  function changeMonth(change) {
    currentMonth += change;
    currentDay = 0;
    if(currentMonth > 12) {
      currentMonth = 1;
      currentYear++;
    } else if(currentMonth < 1) {
      currentMonth = 12;
      currentYear--;
    }

    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  this.changeYear = changeYear;
  function changeYear(change) {
    currentYear += change;
    currentDay = 0;
    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  function getCurrentYear() {
    var year = new Date().getYear();
    if(year < 1900) year += 1900;
    return year;
  }

  function getCurrentMonth() {
    return new Date().getMonth() + 1;
  } 

  function getCurrentDay() {
    return new Date().getDate();
  }

  function calendarDrawTable() {

    var dayOfMonth = 1;
    var validDay = 0;
    var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
    var daysInMonth = getDaysInMonth(currentYear, currentMonth);
    var css_class = null; //CSS class for each day

    var table = "<table cellspacing='0' cellpadding='0' border='0'>";
    table = table + "<tr class='header'>";
    table = table + "  <td colspan='2' class='previous'><a href='javascript:changeCalendarControlMonth(-1);'>&lt;</a> <a href='javascript:changeCalendarControlYear(-1);'>&laquo;</a></td>";
    table = table + "  <td colspan='3' class='title'>" + months[currentMonth-1] + "<br>" + currentYear + "</td>";
    table = table + "  <td colspan='2' class='next'><a href='javascript:changeCalendarControlYear(1);'>&raquo;</a> <a href='javascript:changeCalendarControlMonth(1);'>&gt;</a></td>";
    table = table + "</tr>";
    table = table + "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>";

    for(var week=0; week < 6; week++) {
      table = table + "<tr>";
      for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) {
        if(week == 0 && startDayOfWeek == dayOfWeek) {
          validDay = 1;
        } else if (validDay == 1 && dayOfMonth > daysInMonth) {
          validDay = 0;
        }

        if(validDay) {
          if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
            css_class = 'current';
          } else if (dayOfWeek == 0 || dayOfWeek == 6) {
            css_class = 'weekend';
          } else {
            css_class = 'weekday';
          }

          table = table + "<td><a class='"+css_class+"' href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\">"+dayOfMonth+"</a></td>";
          dayOfMonth++;
        } else {
          table = table + "<td class='empty'>&nbsp;</td>";
        }
      }
      table = table + "</tr>";
    }

    table = table + "<tr class='header'><th colspan='7' style='padding: 3px;'><a href='javascript:clearCalendarControl();'>Clear</a> | <a href='javascript:hideCalendarControl();'>Close</a></td></tr>";
    table = table + "</table>";

    return table;
  }

  this.show = show;
  function show(field) {
    can_hide = 0;
  
    // If the calendar is visible and associated with
    // this field do not do anything.
    if (dateField == field) {
      return;
    } else {
      dateField = field;
    }

    if(dateField) {
      try {
        var dateString = new String(dateField.value);
        var dateParts = dateString.split("-");
        
        selectedMonth = parseInt(dateParts[0],10);
        selectedDay = parseInt(dateParts[1],10);
        selectedYear = parseInt(dateParts[2],10);
      } catch(e) {}
    }

    if (!(selectedYear && selectedMonth && selectedDay)) {
      selectedMonth = getCurrentMonth();
      selectedDay = getCurrentDay();
      selectedYear = getCurrentYear();
    }

    currentMonth = selectedMonth;
    currentDay = selectedDay;
    currentYear = selectedYear;

    if(document.getElementById){

      calendar = document.getElementById(calendarId);
      calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);

      setProperty('display', 'block');

      var fieldPos = new positionInfo(dateField);
      var calendarPos = new positionInfo(calendarId);

      var x = fieldPos.getElementLeft();
      var y = fieldPos.getElementBottom();

      setProperty('left', x + "px");
      setProperty('top', y + "px");
 
      if (document.all) {
        setElementProperty('display', 'block', 'CalendarControlIFrame');
        setElementProperty('left', x + "px", 'CalendarControlIFrame');
        setElementProperty('top', y + "px", 'CalendarControlIFrame');
        setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
        setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
      }
    }
  }

  this.hide = hide;
  function hide() {
    if(dateField) {
      setProperty('display', 'none');
      setElementProperty('display', 'none', 'CalendarControlIFrame');
      dateField = null;
    }
  }

  this.visible = visible;
  function visible() {
    return dateField
  }

  this.can_hide = can_hide;
  var can_hide = 0;
}

var calendarControl = new CalendarControl();

function showCalendarControl(textField) {
  // textField.onblur = hideCalendarControl;
  calendarControl.show(textField);
}

function clearCalendarControl() {
  calendarControl.clearDate();
}

function hideCalendarControl() {
  if (calendarControl.visible()) {
    calendarControl.hide();
  }
}

function setCalendarControlDate(year, month, day) {
  calendarControl.setDate(year, month, day);
}

function changeCalendarControlYear(change) {
  calendarControl.changeYear(change);
}

function changeCalendarControlMonth(change) {
  calendarControl.changeMonth(change);
}

document.write("<iframe id='CalendarControlIFrame' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>");
document.write("<div id='CalendarControl'></div>");


/*-----------------------default.js -------------------------------------*/
//Not Used

/*----------------------------MM_Image.js ------------------------------*/
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_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_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];}
}

/*-----------------------flyout.js -----------------------------*/

var DDSPEED = 10;
var DDTIMER = 15;
var OFFSET = -2;
var ZINT = 100;

function ddMenu(id,d){
  var browserName=navigator.appName; 
  if (browserName=="Microsoft Internet Explorer"){
  if(IsNumeric(id)){
    if(d == 1){
     document.getElementById('I_wrapper').style.display = 'none';
     }
    else {
     document.getElementById('I_wrapper').style.display = 'inline';
     }
   }
  }
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearInterval(c.timer);
  if(d == 1){
    clearTimeout(h.timer);
    c.style.display = 'block';
    if(c.maxh && c.maxh <= c.offsetHeight){return}
    else if(!c.maxh){
      c.style.left = (h.offsetWidth + OFFSET) + 'px';
      c.style.height = 'auto';
      c.maxh = c.offsetHeight;
      c.style.height = '0px';
    }
    ZINT = ZINT + 1;
    c.style.zIndex = ZINT;
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }else{
    h.timer = setTimeout(function(){ddCollapse(c)},50);
  }
}

function ddCollapse(c){
  c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}

function cancelHide(id){
  var browserName=navigator.appName; 
  if (browserName=="Microsoft Internet Explorer"){
  if(IsNumeric(id)){
      document.getElementById('I_wrapper').style.display = 'none';
     }    
  }
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  clearTimeout(h.timer);
  clearInterval(c.timer);
  if(c.offsetHeight < c.maxh){
    c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
  }
}

function ddSlide(c,d){
  var currh = c.offsetHeight;
  var dist;
  if(d == 1){
    dist = Math.round((c.maxh - currh) / DDSPEED);
  }else{
    dist = Math.round(currh / DDSPEED);
  }
  if(dist <= 1 && d == 1){
    dist = 1;
  }
  c.style.height = currh + (dist * d) + 'px';
  c.style.opacity = currh / c.maxh;
  c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  if(currh > (c.maxh - 2) && d == 1){
    clearInterval(c.timer);
  }else if(dist < 1 && d != 1){
    clearInterval(c.timer);
    c.style.display = 'none';
  }
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


/* -----------------------------jd.gallery.js------------------------------*/

/*
    This file is part of JonDesign's SmoothGallery v2.1beta1.

    JonDesign's SmoothGallery is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    JonDesign's SmoothGallery is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with JonDesign's SmoothGallery; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

    Main Developer: Jonathan Schemoul (JonDesign: http://www.jondesign.net/)
    Contributed code by:
    - Christian Ehret (bugfix)
	- Nitrix (bugfix)
	- Valerio from Mad4Milk for his great help with the carousel scrolling and many other things.
	- Archie Cowan for helping me find a bugfix on carousel inner width problem.
	- Tomocchino from #mootools for the preloader class
	Many thanks to:
	- The mootools team for the great mootools lib, and it's help and support throughout the project.
	- Harald Kirschner (digitarald: http://digitarald.de/) for all his great libs. Some used here as plugins.
*/
function startGallery() {
	var myGallery = new gallery($('myGallery'), {
		timed: true
		
	});
}
/* some quirks to circumvent broken stuff in mt1.2 */
function isBody(element){
	return (/^(?:body|html)$/i).test(element.tagName);
};
Element.implement({
	getPosition: function(relative){
		if (isBody(this)) return {x: 0, y: 0};
		var el = this, position = {x: 0, y: 0};
		while (el){
			position.x += el.offsetLeft;
			position.y += el.offsetTop;
			el = el.offsetParent;
		}
		var rpos = (relative) ? $(relative).getPosition() : {x: 0, y: 0};
		return {x: position.x - rpos.x, y: position.y - rpos.y};
	}
});

// declaring the class
var gallery = {
	Implements: [Events, Options],
	options: {
		showArrows: true,
		showCarousel: true,
		showInfopane: true,
		embedLinks: true,
		fadeDuration: 500,
		timed: false,
		delay: 9000,
		preloader: true,
		preloaderImage: true,
		preloaderErrorImage: true,
		/* Data retrieval */
		manualData: [],
		populateFrom: false,
		populateData: true,
		destroyAfterPopulate: true,
		elementSelector: "div.imageElement",
		titleSelector: "h3",
		subtitleSelector: "p",
		linkSelector: "a.open",
		imageSelector: "img.full",
		thumbnailSelector: "img.thumbnail",
		defaultTransition: "fade",
		/* InfoPane options */
		slideInfoZoneOpacity: 0.7,
		slideInfoZoneSlide: true,
		/* Carousel options */
		carouselMinimizedOpacity: 0.4,
		carouselMinimizedHeight: 20,
		carouselMaximizedOpacity: 0.9,
		thumbHeight: 75,
		thumbWidth: 100,
		thumbSpacing: 10,
		thumbIdleOpacity: 0.2,
		textShowCarousel: 'Best Travel Source',
		showCarouselLabel: true,
		thumbCloseCarousel: true,
		useThumbGenerator: false,
		thumbGenerator: 'resizer.php',
		useExternalCarousel: false,
		carouselElement: false,
		carouselHorizontal: true,
		activateCarouselScroller: true,
		carouselPreloader: true,
		textPreloadingCarousel: 'Loading...',
		/* CSS Classes */
		baseClass: 'jdGallery',
		withArrowsClass: 'withArrows',
		/* Plugins: HistoryManager */
		useHistoryManager: false,
		customHistoryKey: false,
		/* Plugins: ReMooz */
		useReMooz: false
	},
	initialize: function(element, options) {
		this.setOptions(options);
		this.fireEvent('onInit');
		this.currentIter = 0;
		this.lastIter = 0;
		this.maxIter = 0;
		this.galleryElement = element;
		this.galleryData = this.options.manualData;
		this.galleryInit = 1;
		this.galleryElements = Array();
		this.thumbnailElements = Array();
		this.galleryElement.addClass(this.options.baseClass);
		
		if (this.options.useReMooz&&(this.options.defaultTransition=="fade"))
			this.options.defaultTransition="crossfade";
		
		this.populateFrom = element;
		if (this.options.populateFrom)
			this.populateFrom = this.options.populateFrom;		
		if (this.options.populateData)
			this.populateData();
		element.style.display="block";
		
		if (this.options.useHistoryManager)
			this.initHistory();
		
		if ((this.options.embedLinks)|(this.options.useReMooz))
		{
			this.currentLink = new Element('a').addClass('open').setProperties({
				href: '#',
				title: ''
			}).injectInside(element);
			if ((!this.options.showArrows) && (!this.options.showCarousel))
				this.galleryElement = element = this.currentLink;
			else
				this.currentLink.setStyle('display', 'none');
		}
		
		this.constructElements();
		if ((this.galleryData.length>1)&&(this.options.showArrows))
		{
			var leftArrow = new Element('a').addClass('left').addEvent(
				'click',
				this.prevItem.bind(this)
			).injectInside(element);
			var rightArrow = new Element('a').addClass('right').addEvent(
				'click',
				this.nextItem.bind(this)
			).injectInside(element);
			this.galleryElement.addClass(this.options.withArrowsClass);
		}
		this.loadingElement = new Element('div').addClass('loadingElement').injectInside(element);
		if (this.options.showInfopane) this.initInfoSlideshow();
		if (this.options.showCarousel) this.initCarousel();
		this.doSlideShow(1);
	},
	populateData: function() {
		currentArrayPlace = this.galleryData.length;
		options = this.options;
		var data = $A(this.galleryData);
		data.extend(this.populateGallery(this.populateFrom, currentArrayPlace));
		this.galleryData = data;
		this.fireEvent('onPopulated');
	},
	populateGallery: function(element, startNumber) {
		var data = [];
		options = this.options;
		currentArrayPlace = startNumber;
		element.getElements(options.elementSelector).each(function(el) {
			elementDict = $H({
				image: el.getElement(options.imageSelector).getProperty('src'),
				number: currentArrayPlace,
				transition: this.options.defaultTransition
			});
			if ((options.showInfopane) | (options.showCarousel))
				elementDict.extend({
					title: el.getElement(options.titleSelector).innerHTML,
					description: el.getElement(options.subtitleSelector).innerHTML
				});
			if ((options.embedLinks) | (options.useReMooz))
				elementDict.extend({
					link: el.getElement(options.linkSelector).href||false,
					linkTitle: el.getElement(options.linkSelector).title||false,
					linkTarget: el.getElement(options.linkSelector).getProperty('target')||false
				});
			if ((!options.useThumbGenerator) && (options.showCarousel))
				elementDict.extend({
					thumbnail: el.getElement(options.thumbnailSelector).getProperty('src')
				});
			else if (options.useThumbGenerator)
				elementDict.extend({
					thumbnail: options.thumbGenerator + '?imgfile=' + elementDict.image + '&max_width=' + options.thumbWidth + '&max_height=' + options.thumbHeight
				});
			
			data.extend([elementDict]);
			currentArrayPlace++;
			if (this.options.destroyAfterPopulate)
				el.dispose();
		});
		return data;
	},
	constructElements: function() {
		el = this.galleryElement;
		if (this.options.embedLinks && (!this.options.showArrows))
			el = this.currentLink;
		this.maxIter = this.galleryData.length;
		var currentImg;
		for(i=0;i<this.galleryData.length;i++)
		{
			var currentImg = new Fx.Morph(
				new Element('div').addClass('slideElement').setStyles({
					'position':'absolute',
					'left':'0px',
					'right':'0px',
					'margin':'0px',
					'padding':'0px',
					'backgroundPosition':"center center",
					'opacity':'0'
				}).injectInside(el),
				{duration: this.options.fadeDuration}
			);
			if (this.options.preloader)
			{
				currentImg.source = this.galleryData[i].image;
				currentImg.loaded = false;
				currentImg.load = function(imageStyle, i) {
					if (!imageStyle.loaded)	{
						this.galleryData[i].imgloader = new Asset.image(imageStyle.source, {
		                            'onload'  : function(img, i){
													img.element.setStyle(
													'backgroundImage',
													"url('" + img.source + "')")
													img.loaded = true;
													img.width = this.galleryData[i].imgloader.width;
													img.height = this.galleryData[i].imgloader.height;
												}.pass([imageStyle, i], this)
						});
					}
				}.pass([currentImg, i], this);
			} else {
				currentImg.element.setStyle('backgroundImage',
									"url('" + this.galleryData[i].image + "')");
			}
			this.galleryElements[parseInt(i)] = currentImg;
		}
	},
	destroySlideShow: function(element) {
		var myClassName = element.className;
		var newElement = new Element('div').addClass('myClassName');
		element.parentNode.replaceChild(newElement, element);
	},
	startSlideShow: function() {
		this.fireEvent('onStart');
		this.loadingElement.style.display = "none";
		this.lastIter = this.maxIter - 1;
		this.currentIter = 0;
		this.galleryInit = 0;
		this.galleryElements[parseInt(this.currentIter)].set({opacity: 1});
		if (this.options.showInfopane)
			this.showInfoSlideShow.delay(1000, this);
		if (this.options.useReMooz)
			this.makeReMooz.delay(1000, this);
		var textShowCarousel = formatString(this.options.textShowCarousel, this.currentIter+1, this.maxIter);
		if (this.options.showCarousel&&(!this.options.carouselPreloader)&&(!this.options.useExternalCarousel))
			this.carouselBtn.set('html', textShowCarousel).setProperty('title', textShowCarousel);
		this.prepareTimer();
		if (this.options.embedLinks)
			this.makeLink(this.currentIter);
	},
	nextItem: function() {
		this.fireEvent('onNextCalled');
		this.nextIter = this.currentIter+1;
		if (this.nextIter >= this.maxIter)
			this.nextIter = 0;
		this.galleryInit = 0;
		this.goTo(this.nextIter);
	},
	prevItem: function() {
		this.fireEvent('onPreviousCalled');
		this.nextIter = this.currentIter-1;
		if (this.nextIter <= -1)
			this.nextIter = this.maxIter - 1;
		this.galleryInit = 0;
		this.goTo(this.nextIter);
	},
	goTo: function(num) {
		this.clearTimer();
		if(this.options.preloader)
		{
			this.galleryElements[num].load();
			if (num==0)
				this.galleryElements[this.maxIter - 1].load();
			else
				this.galleryElements[num - 1].load();
			if (num==(this.maxIter - 1))
				this.galleryElements[0].load();
			else
				this.galleryElements[num + 1].load();
				
		}
		if (this.options.embedLinks)
			this.clearLink();
		if (this.options.showInfopane)
		{
			this.slideInfoZone.clearChain();
			this.hideInfoSlideShow().chain(this.changeItem.pass(num, this));
		} else
			this.currentChangeDelay = this.changeItem.delay(500, this, num);
		if (this.options.embedLinks)
			this.makeLink(num);
		this.prepareTimer();
		/*if (this.options.showCarousel)
			this.clearThumbnailsHighlights();*/
	},
	changeItem: function(num) {
		this.fireEvent('onStartChanging');
		this.galleryInit = 0;
		if (this.currentIter != num)
		{
			for(i=0;i<this.maxIter;i++)
			{
				if ((i != this.currentIter)) this.galleryElements[i].set({opacity: 0});
			}
			gallery.Transitions[this.galleryData[num].transition].pass([
				this.galleryElements[this.currentIter],
				this.galleryElements[num],
				this.currentIter,
				num], this)();
			this.currentIter = num;
			if (this.options.useReMooz)
				this.makeReMooz();
		}
		var textShowCarousel = formatString(this.options.textShowCarousel, num+1, this.maxIter);
		if ((this.options.showCarousel)&&(!this.options.useExternalCarousel))
			this.carouselBtn.set('html', textShowCarousel).setProperty('title', textShowCarousel);
		this.doSlideShow.bind(this)();
		this.fireEvent('onChanged');
	},
	clearTimer: function() {
		if (this.options.timed)
			$clear(this.timer);
	},
	prepareTimer: function() {
		if (this.options.timed)
			this.timer = this.nextItem.delay(this.options.delay, this);
	},
	doSlideShow: function(position) {
		if (this.galleryInit == 1)
		{
			imgPreloader = new Image();
			imgPreloader.onload=function(){
				this.startSlideShow.delay(10, this);
			}.bind(this);
			imgPreloader.src = this.galleryData[0].image;
			if(this.options.preloader)
				this.galleryElements[0].load();
		} else {
			if (this.options.showInfopane)
			{
				if (this.options.showInfopane)
				{
					this.showInfoSlideShow.delay((500 + this.options.fadeDuration), this);
				} else
					if ((this.options.showCarousel)&&(this.options.activateCarouselScroller))
						this.centerCarouselOn(position);
			}
		}
	},
	createCarousel: function() {
		var carouselElement;
		if (!this.options.useExternalCarousel)
		{
			var carouselContainerElement = new Element('div').addClass('carouselContainer').injectInside(this.galleryElement);
			this.carouselContainer = new Fx.Morph(carouselContainerElement, {transition: Fx.Transitions.Expo.easeOut});
			this.carouselContainer.normalHeight = carouselContainerElement.offsetHeight;
			this.carouselContainer.set({'opacity': this.options.carouselMinimizedOpacity, 'top': (this.options.carouselMinimizedHeight - this.carouselContainer.normalHeight)});
			this.carouselBtn = new Element('a').addClass('carouselBtn').setProperties({
				title: this.options.textShowCarousel
			}).injectInside(carouselContainerElement);
			if(this.options.carouselPreloader)
				this.carouselBtn.set('html', this.options.textPreloadingCarousel);
			else
				this.carouselBtn.set('html', this.options.textShowCarousel);
			this.carouselBtn.addEvent(
				'click',
				function () {
					this.carouselContainer.cancel();
					this.toggleCarousel();
				}.bind(this)
			);
			this.carouselActive = false;
	
			carouselElement = new Element('div').addClass('carousel').injectInside(carouselContainerElement);
			this.carousel = new Fx.Morph(carouselElement);
		} else {
			carouselElement = $(this.options.carouselElement).addClass('jdExtCarousel');
		}
		this.carouselElement = new Fx.Morph(carouselElement, {transition: Fx.Transitions.Expo.easeOut});
		this.carouselElement.normalHeight = carouselElement.offsetHeight;
		if (this.options.showCarouselLabel)
			this.carouselLabel = new Element('p').addClass('label').injectInside(carouselElement);
		carouselWrapper = new Element('div').addClass('carouselWrapper').injectInside(carouselElement);
		this.carouselWrapper = new Fx.Morph(carouselWrapper, {transition: Fx.Transitions.Expo.easeOut});
		this.carouselWrapper.normalHeight = carouselWrapper.offsetHeight;
		this.carouselInner = new Element('div').addClass('carouselInner').injectInside(carouselWrapper);
		if (this.options.activateCarouselScroller)
		{
			this.carouselWrapper.scroller = new Scroller(carouselWrapper, {
				area: 100,
				velocity: 0.2
			})
			
			this.carouselWrapper.elementScroller = new Fx.Scroll(carouselWrapper, {
				duration: 400,
				onStart: this.carouselWrapper.scroller.stop.bind(this.carouselWrapper.scroller),
				onComplete: this.carouselWrapper.scroller.start.bind(this.carouselWrapper.scroller)
			});
		}
	},
	fillCarousel: function() {
		this.constructThumbnails();
		this.carouselInner.normalWidth = ((this.maxIter * (this.options.thumbWidth + this.options.thumbSpacing + 2))+this.options.thumbSpacing) + "px";
		if (this.options.carouselHorizontal)
			this.carouselInner.style.width = this.carouselInner.normalWidth;
	},
	initCarousel: function () {
		this.createCarousel();
		this.fillCarousel();
		if (this.options.carouselPreloader)
			this.preloadThumbnails();
	},
	flushCarousel: function() {
		this.thumbnailElements.each(function(myFx) {
			myFx.element.dispose();
			myFx = myFx.element = null;
		});
		this.thumbnailElements = [];
	},
	toggleCarousel: function() {
		if (this.carouselActive)
			this.hideCarousel();
		else
			this.showCarousel();
	},
	showCarousel: function () {
		this.fireEvent('onShowCarousel');
		this.carouselContainer.start({
			'opacity': this.options.carouselMaximizedOpacity,
			'top': 0
		}).chain(function() {
			this.carouselActive = true;
			this.carouselWrapper.scroller.start();
			this.fireEvent('onCarouselShown');
			this.carouselContainer.options.onComplete = null;
		}.bind(this));
	},
	hideCarousel: function () {
		this.fireEvent('onHideCarousel');
		var targetTop = this.options.carouselMinimizedHeight - this.carouselContainer.normalHeight;
		this.carouselContainer.start({
			'opacity': this.options.carouselMinimizedOpacity,
			'top': targetTop
		}).chain(function() {
			this.carouselActive = false;
			this.carouselWrapper.scroller.stop();
			this.fireEvent('onCarouselHidden');
			this.carouselContainer.options.onComplete = null;
		}.bind(this));
	},
	constructThumbnails: function () {
		element = this.carouselInner;
		for(i=0;i<this.galleryData.length;i++)
		{
			var currentImg = new Fx.Morph(new Element ('div').addClass("thumbnail").setStyles({
					backgroundImage: "url('" + this.galleryData[i].thumbnail + "')",
					backgroundPosition: "center center",
					backgroundRepeat: 'no-repeat',
					marginLeft: this.options.thumbSpacing + "px",
					width: this.options.thumbWidth + "px",
					height: this.options.thumbHeight + "px"
				}).injectInside(element), {duration: 200}).start({
					'opacity': this.options.thumbIdleOpacity
				});
			currentImg.element.addEvents({
				'mouseover': function (myself) {
					myself.cancel();
					myself.start({'opacity': 0.99});
					if (this.options.showCarouselLabel)
						$(this.carouselLabel).set('html', '<span class="number">' + (myself.relatedImage.number + 1) + "/" + this.maxIter + ":</span> " + myself.relatedImage.title);
				}.pass(currentImg, this),
				'mouseout': function (myself) {
					myself.cancel();
					myself.start({'opacity': this.options.thumbIdleOpacity});
				}.pass(currentImg, this),
				'click': function (myself) {
					this.goTo(myself.relatedImage.number);
					if (this.options.thumbCloseCarousel&&(!this.options.useExternalCarousel))
						this.hideCarousel();
				}.pass(currentImg, this)
			});
			
			currentImg.relatedImage = this.galleryData[i];
			this.thumbnailElements[parseInt(i)] = currentImg;
		}
	},
	log: function(value) {
		if(console.log)
			console.log(value);
	},
	preloadThumbnails: function() {
		var thumbnails = [];
		for(i=0;i<this.galleryData.length;i++)
		{
			thumbnails[parseInt(i)] = this.galleryData[i].thumbnail;
		}
		this.thumbnailPreloader = new Preloader();
		if (!this.options.useExternalCarousel)
			this.thumbnailPreloader.addEvent('onComplete', function() {
				var textShowCarousel = formatString(this.options.textShowCarousel, this.currentIter+1, this.maxIter);
				this.carouselBtn.set('html', textShowCarousel).setProperty('title', textShowCarousel);
			}.bind(this));
		this.thumbnailPreloader.load(thumbnails);
	},
	clearThumbnailsHighlights: function()
	{
		for(i=0;i<this.galleryData.length;i++)
		{
			this.thumbnailElements[i].cancel();
			this.thumbnailElements[i].start(0.2);
		}
	},
	changeThumbnailsSize: function(width, height)
	{
		for(i=0;i<this.galleryData.length;i++)
		{
			this.thumbnailElements[i].cancel();
			this.thumbnailElements[i].element.setStyles({
				'width': width + "px",
				'height': height + "px"
			});
		}
	},
	centerCarouselOn: function(num) {
		if (!this.carouselWallMode)
		{
			var carouselElement = this.thumbnailElements[num];
			var position = carouselElement.element.offsetLeft + (carouselElement.element.offsetWidth / 2);
			var carouselWidth = this.carouselWrapper.element.offsetWidth;
			var carouselInnerWidth = this.carouselInner.offsetWidth;
			var diffWidth = carouselWidth / 2;
			var scrollPos = position-diffWidth;
			this.carouselWrapper.elementScroller.start(scrollPos,0);
		}
	},
	initInfoSlideshow: function() {
		/*if (this.slideInfoZone.element)
			this.slideInfoZone.element.remove();*/
		this.slideInfoZone = new Fx.Morph(new Element('div').addClass('slideInfoZone').injectInside($(this.galleryElement))).set({'opacity':0});
		var slideInfoZoneTitle = new Element('h2').injectInside(this.slideInfoZone.element);
		var slideInfoZoneDescription = new Element('p').injectInside(this.slideInfoZone.element);
		this.slideInfoZone.normalHeight = this.slideInfoZone.element.offsetHeight;
		this.slideInfoZone.element.setStyle('opacity',0);
	},
	changeInfoSlideShow: function()
	{
		this.hideInfoSlideShow.delay(10, this);
		this.showInfoSlideShow.delay(500, this);
	},
	showInfoSlideShow: function() {
		this.fireEvent('onShowInfopane');
		this.slideInfoZone.cancel();
		element = this.slideInfoZone.element;
		element.getElement('h2').set('html', this.galleryData[this.currentIter].title);
		element.getElement('p').set('html', this.galleryData[this.currentIter].description);
		if(this.options.slideInfoZoneSlide)
			this.slideInfoZone.start({'opacity': [0, this.options.slideInfoZoneOpacity], 'height': [0, this.slideInfoZone.normalHeight]});
		else
			this.slideInfoZone.start({'opacity': [0, this.options.slideInfoZoneOpacity]});
		if (this.options.showCarousel)
			this.slideInfoZone.chain(this.centerCarouselOn.pass(this.currentIter, this));
		return this.slideInfoZone;
	},
	hideInfoSlideShow: function() {
		this.fireEvent('onHideInfopane');
		this.slideInfoZone.cancel();
		if(this.options.slideInfoZoneSlide)
			this.slideInfoZone.start({'opacity': 0, 'height': 0});
		else
			this.slideInfoZone.start({'opacity': 0});
		return this.slideInfoZone;
	},
	makeLink: function(num) {
		this.currentLink.setProperties({
			href: this.galleryData[num].link,
			title: this.galleryData[num].linkTitle
		})
		if (!((this.options.embedLinks) && (!this.options.showArrows) && (!this.options.showCarousel)))
			this.currentLink.setStyle('display', 'block');
	},
	clearLink: function() {
		this.currentLink.setProperties({href: '', title: ''});
		if (!((this.options.embedLinks) && (!this.options.showArrows) && (!this.options.showCarousel)))
			this.currentLink.setStyle('display', 'none');
	},
	makeReMooz: function() {
		this.currentLink.setProperties({
			href: '#'
		});
		this.currentLink.setStyles({
			'display': 'block'
		});
		
		this.galleryElements[this.currentIter].element.set('title', this.galleryData[this.currentIter].title + ' :: ' + this.galleryData[this.currentIter].description);
		this.ReMooz = new ReMooz(this.galleryElements[this.currentIter].element, {
			link: this.galleryData[this.currentIter].link,
			shadow: false,
			dragging: false,
			addClick: false,
			resizeOpacity: 1
		});
		var img = this.galleryElements[this.currentIter];
		var coords = img.element.getCoordinates();
		delete coords.right;
		delete coords.bottom;
		
		widthDiff = coords.width - img.width;
		heightDiff = coords.height - img.height;
		
		coords.width = img.width;
		coords.height = img.height;
		
		coords.left += Math.ceil(widthDiff/2)+1;
		coords.top += Math.ceil(heightDiff/2)+1;
		
		this.ReMooz.getOriginCoordinates = function(coords) {
			return coords;
		}.bind(this, coords);
		this.currentLink.onclick = function () {
			this.ReMooz.open.bind(this.ReMooz)();
			return false;
		}.bind(this);
	},
	/* To change the gallery data, those two functions : */
	flushGallery: function() {
		this.galleryElements.each(function(myFx) {
			myFx.element.dispose();
			myFx = myFx.element = null;
		});
		this.galleryElements = [];
	},
	changeData: function(data) {
		this.galleryData = data;
		this.clearTimer();
		this.flushGallery();
		if (this.options.showCarousel) this.flushCarousel();
		this.constructElements();
		if (this.options.showCarousel) this.fillCarousel();
		if (this.options.showInfopane) this.hideInfoSlideShow();
		this.galleryInit=1;
		this.lastIter=0;
		this.currentIter=0;
		this.doSlideShow(1);
	},
	/* Plugins: HistoryManager */
	initHistory: function() {
		this.fireEvent('onHistoryInit');
		this.historyKey = this.galleryElement.id + '-picture';
		if (this.options.customHistoryKey)
			this.historyKey = this.options.customHistoryKey;
		
		this.history = new History.Route({
			defaults: [1],
			pattern: this.historyKey + '\\((\\d+)\\)',
			generate: function(values) {
				return [this.historyKey, '(', values[0], ')'].join('')
			}.bind(this),
			onMatch: function(values, defaults) {
				if (parseInt(values[0])-1 < this.maxIter)
					this.goTo(parseInt(values[0])-1);
			}.bind(this)
		});
		this.addEvent('onChanged', function(){
			this.history.setValue(0, this.currentIter+1);
			this.history.defaults=[this.currentIter+1];
		}.bind(this));
		this.fireEvent('onHistoryInited');
	}
};
gallery = new Class(gallery);

gallery.Transitions = new Hash ({
	fade: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
		oldFx.options.duration = newFx.options.duration = this.options.fadeDuration;
		if (newPos > oldPos) newFx.start({opacity: 1});
		else
		{
			newFx.set({opacity: 1});
			oldFx.start({opacity: 0});
		}
	},
	crossfade: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
		oldFx.options.duration = newFx.options.duration = this.options.fadeDuration;
		newFx.start({opacity: 1});
		oldFx.start({opacity: 0});
	},
	fadebg: function(oldFx, newFx, oldPos, newPos){
		oldFx.options.transition = newFx.options.transition = Fx.Transitions.linear;
		oldFx.options.duration = newFx.options.duration = this.options.fadeDuration / 2;
		oldFx.start({opacity: 0}).chain(newFx.start.pass([{opacity: 1}], newFx));
	}
});

/* All code copyright 2007 Jonathan Schemoul */

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Follows: Preloader (class)
 * Simple class for preloading images with support for progress reporting
 * Copyright 2007 Tomocchino.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

var Preloader = new Class({
  
  Implements: [Events, Options],

  options: {
    root        : '',
    period      : 100
  },
  
  initialize: function(options){
    this.setOptions(options);
  },
  
  load: function(sources) {
    this.index = 0;
    this.images = [];
    this.sources = this.temps = sources;
    this.total = this. sources.length;
    
    this.fireEvent('onStart', [this.index, this.total]);
    this.timer = this.progress.periodical(this.options.period, this);
    
    this.sources.each(function(source, index){
      this.images[index] = new Asset.image(this.options.root + source, {
        'onload'  : function(){ this.index++; if(this.images[index]) this.fireEvent('onLoad', [this.images[index], index, source]); }.bind(this),
        'onerror' : function(){ this.index++; this.fireEvent('onError', [this.images.splice(index, 1), index, source]); }.bind(this),
        'onabort' : function(){ this.index++; this.fireEvent('onError', [this.images.splice(index, 1), index, source]); }.bind(this)
      });
    }, this);
  },
  
  progress: function() {
    this.fireEvent('onProgress', [Math.min(this.index, this.total), this.total]);
    if(this.index >= this.total) this.complete();
  },
  
  complete: function(){
    $clear(this.timer);
    this.fireEvent('onComplete', [this.images]);
  },
  
  cancel: function(){
    $clear(this.timer);
  }
  
});

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Follows: formatString (function)
 * Original name: Yahoo.Tools.printf
 * Copyright Yahoo.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

function formatString() {
	var num = arguments.length;
	var oStr = arguments[0];
	for (var i = 1; i < num; i++) {
		var pattern = "\\{" + (i-1) + "\\}"; 
		var re = new RegExp(pattern, "g");
		oStr = oStr.replace(re, arguments[i]);
	}
	return oStr; 
}

/* -------------jd.gallery.set.js -----------------------------------*/

/*
    This file is part of JonDesign's SmoothGallery v2.1beta1.

    JonDesign's SmoothGallery is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    JonDesign's SmoothGallery is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with JonDesign's SmoothGallery; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

    Main Developer: Jonathan Schemoul (JonDesign: http://www.jondesign.net/)
*/

var gallerySet = new Class({
	Extends: gallery,
	initialize: function(element, options) {
		this.setOptions({
			manualSetData: [],
			gallerySelector: "div.galleryElement",
			galleryTitleSelector: "h2",
			textGallerySelector: 'Galleries',
			textShowGallerySelector: 'Other Galleries',
			textGalleryInfo: '{0} pictures',
			startWithSelector: true,
			/* Changing default options */
			textShowCarousel: '{0}/{1} Pictures',
			carouselPreloader: false
		});
		this.setOptions(options);
		this.gallerySet = this.options.manualSetData;
		this.addEvent('onPopulated', this.createGallerySelectorTab.bind(this));
		this.addEvent('onPopulated', this.createGallerySelector.bind(this));
		this.startWithSelectorFn = this.toggleGallerySelector.pass(true, this);
		if (this.options.startWithSelector)
			this.addEvent('onGallerySelectorCreated', this.startWithSelectorFn);
		this.parent(element, this.options);
	},
	populateData: function() {
		options = this.options;
		var data = $A(this.gallerySet);
		this.populateFrom.getElements(options.gallerySelector).each(function (galEl) {
			currentGalArrayPlace = 0;
			galleryDict = {
				title: galEl.getElement(options.galleryTitleSelector).innerHTML,
				elements: []
			}
			galleryDict.elements.extend(this.populateGallery(galEl, 0));
			data.extend([galleryDict]);
			if (this.options.destroyAfterPopulate)
				galEl.dispose();
		}, this);
		this.gallerySet = data;
		this.galleryData = data[0].elements;
		this.currentGallery = 0;
		this.fireEvent('onPopulated');
	},
	changeGallery: function(number)
	{
		if (number!=this.currentGallery)
		{
			this.changeData(this.gallerySet[number].elements);
			this.maxIter = this.gallerySet[number].elements.length;
			this.currentGallery = number;
			this.gallerySelectorBtn.set('html', this.gallerySet[number].title);
			this.fireEvent('onGalleryChanged');
		}
		this.toggleGallerySelector(false);
	},
	createGallerySelectorTab: function() {
		this.gallerySelectorBtn = new Element('a').addClass('gallerySelectorBtn').setProperties({
			title: this.options.textShowGallerySelector
		}).set('html', this.options.textShowGallerySelector).addEvent(
			'click',
			function(){ this.toggleGallerySelector(true); }.bind(this)
		).injectInside(this.galleryElement);
		this.addEvent('onShowCarousel', function(){this.gallerySelectorBtn.setStyle('zIndex', 10)}.bind(this));
		this.addEvent('onCarouselHidden', function(){this.gallerySelectorBtn.setStyle('zIndex', 15)}.bind(this));
	},
	createGallerySelector: function() {
		this.gallerySelector = new Fx.Morph(
			new Element('div').addClass(
				'gallerySelector'
			).injectInside(
				this.galleryElement
			).setStyles({
				'display': 'none',
				'opacity': '0'
			})
		);
		this.gallerySelectorTitle = 
			new Element('h2').set('html', 
				this.options.textGallerySelector
			).injectInside(this.gallerySelector.element);
		var gallerySelectorHeight = this.galleryElement.offsetHeight - 50 - 10 - 2;
		this.gallerySelectorWrapper = new Fx.Morph(
			new Element('div').addClass(
				'gallerySelectorWrapper'
			).setStyle(
				'height',
				gallerySelectorHeight + "px"
			).injectInside(this.gallerySelector.element)
		);
		this.gallerySelectorInner =	new Element('div').addClass('gallerySelectorInner').injectInside(this.gallerySelectorWrapper.element);
		this.gallerySelectorWrapper.scroller = new Scroller(this.gallerySelectorWrapper.element, {
			area: 100,
			velocity: 0.3
		}).start();
		this.createGalleryButtons();
		this.fireEvent('onGallerySelectorCreated');
	},
	createGalleryButtons: function () {
		var galleryButtonWidth =
			((this.galleryElement.offsetWidth - 30) / 2) - 14;
		this.gallerySet.each(function(galleryItem, index){
			var button = new Element('div').addClass('galleryButton').injectInside(
				this.gallerySelectorInner
			).addEvents({
				'mouseover': function(myself){
					myself.button.addClass('hover');
				}.pass(galleryItem, this),
				'mouseout': function(myself){
					myself.button.removeClass('hover');
				}.pass(galleryItem, this),
				'click': function(myself, number){
					this.changeGallery.pass(number,this)();
				}.pass([galleryItem, index], this)
			}).setStyle('width', galleryButtonWidth);
			galleryItem.button = button;
			var thumbnail = "";
			if (this.options.showCarousel)
				thumbnail = galleryItem.elements[0].thumbnail;
			else
				thumbnail = galleryItem.elements[0].image;
			new Element('div').addClass('preview').setStyle(
				'backgroundImage',
				"url('" + thumbnail + "')"
			).injectInside(button);
			new Element('h3').set('html', galleryItem.title).injectInside(button);
			new Element('p').addClass('info').set('html', formatString(this.options.textGalleryInfo, galleryItem.elements.length)).injectInside(button);
		}, this);
		new Element('br').injectInside(this.gallerySelectorInner).setStyle('clear','both');
	},
	toggleGallerySelector: function(state) {
		if (state)
			this.gallerySelector.start({'opacity' : 1}).element.setStyle('display','block');
		else
			this.gallerySelector.start({'opacity' : 0});
	},
	initHistory: function() {
		this.fireEvent('onHistoryInit');
		this.historyKey = this.galleryElement.id + '-gallery';
		if (this.options.customHistoryKey)
			this.historyKey = this.options.customHistoryKey();
		this.history = new History.Route({
			defaults: [1,1],
			pattern: this.historyKey + '\\((\\d+)\\)-picture\\((\\d+)\\)',
			generate: function(values) {
				return [this.historyKey, '(', values[0], ')', '-picture','(', values[1], ')'].join('');
			}.bind(this),
			onMatch: function(values, defaults) {
				this.changeGallery.pass(parseInt(values[0]) - 1, this).delay(10);
				if(this.gallerySelector)
					this.toggleGallerySelector.pass(false, this).delay(500);
				this.goTo.pass(parseInt(values[1]) - 1, this).delay(100);
			}.bind(this)
		});
		updateHistory = function(){
			this.history.setValues([this.currentGallery + 1, this.currentIter + 1]);
			this.history.defaults=[this.currentGallery + 1, this.currentIter + 1];
		}.bind(this);		
		
		this.addEvent('onChanged', updateHistory);
		this.addEvent('onGalleryChanged', updateHistory);
		this.fireEvent('onHistoryInited');
	}
});

/* -------------------------------locales.js -------------------------------*/
/**
 * This script looks up the country origin of hostnames which contain two letter country codes
 */
 function getState(stateName){
		var st = "";
		
		st = stateName;
		a = st.split(".");
		st = a[0];
		st = st.toUpperCase();
		if (st.length == 2)
			return st;
		switch (st) {
			case "ALABAMA":
				st = "AL";
				break;
			case "ALASKA":
				st = "AK";
				break;
			case "AMERICAN SAMOA":
				st = "AS";
				break;
			case "ARIZONA":
				st = "AZ";
				break;
			case "ARKANSAS":
				st = "AR";
				break;
			case "CALIFORNIA":
				st = "CA";
				break;
			case "COLORADO":
				st = "CO";
				break;
			case "CONNECTICUT":
				st = "CT";
				break;
			case "DELAWARE":
				st = "DE";
				break;
			case "DISTRICT OF COLUMBIA":
				st = "DC";
				break;
			case "FEDERATED STATES OF MICRONESIA":
				st = "FM";
				break;
			case "FLORIDA":
				st = "FL";
				break;
			case "GEORGIA":
				st = "GA";
				break;
			case "GUAM":
				st = "GU";
				break;
			case "HAWAII":
				st = "HI";
				break;
			case "IDAHO":
				st = "ID";
				break;
			case "ILLINOIS":
				st = "IL";
				break;
			case "INDIANA":
				st = "IN";
				break;
			case "IOWA":
				st = "IA";
				break;
			case "KANSAS":
				st = "KS";
				break;
			case "KENTUCKY":
				st = "KY";
				break;
			case "LOUISIANA":
				st = "LA";
				break;
			case "MAINE":
				st = "ME";
				break;
			case "MARSHALL ISLANDS":
				st = "MH";
				break;
			case "MARYLAND":
				st = "MD";
				break;
			case "MASSACHUSETTS":
				st = "MA";
				break;
			case "MICHIGAN":
				st = "MI";
				break;
			case "MINNESOTA":
				st = "MN";
				break;
			case "MISSISSIPPI":
				st = "MS";
				break;
			case "MISSOURI":
				st = "MO";
				break;
			case "MONTANA":
				st = "MT";
				break;
			case "NEBRASKA":
				st = "NE";
				break;
			case "NEVADA":
				st = "NV";
				break;
			case "NEW HAMPSHIRE":
				st = "NH";
				break;	
			case "NEW JERSEY":
				st = "NJ";
				break;
			case "NEW MEXICO":
				st = "NM";
				break;
			case "NEW YORK":
				st = "NY";
				break;
			case "NORTH CAROLINA":
				st = "NC";
				break;
			case "NORTH DAKOTA":
				st = "ND";
				break;
			case "NORTHERN MARIANA ISLANDS":
				st = "MP";
				break;
			case "OHIO":
				st = "OH";
				break;
			case "OKLAHOMA":
				st = "OK";
				break;
			case "OREGON":
				st = "OR";
				break;
			case "PALAU":
				st = "PW";
				break;
			case "PENNSYLVANIA":
				st = "PA";
				break;
			case "PUERTO RICO":
				st = "PR";
				break;
			case "RHODE ISLAND":
				st = "RI";
				break;
			case "SOUTH CAROLINA":
				st = "SC";
				break;
			case "SOUTH DAKOTA":
				st = "SD";
				break;
			case "TENNESSEE":
				st = "TN";
				break;
			case "TEXAS":
				st = "TX";
				break;
			case "UTAH":
				st = "UT";
				break;
			case "VERMONT":
				st = "VT";
				break;
			case "VIRGIN ISLANDS":
				st = "VI";
				break;
			case "VIRGINIA":
				st = "VA";
				break;
			case "WASHINGTON":
				st = "WA";
				break;
			case "WEST VIRGINIA":
				st = "WV";
				break;
			case "WISCONSIN":
				st = "WI";
				break;
			case "WYOMING":
				st = "WY";
				break;
			default:
				st = "";
				break;
		}
		return st;
	}
 
function getCountry (code) {
	switch (code.toUpperCase()) {
	   case "AC": code = "Ascension Island"; break;
       case "AD": code = "Andorra"; break;
       case "AE": code = "United Arab Emirates"; break;
	   case "AF": code = "Afghanistan"; break;
       case "AG": code = "Antigua and Barbuda"; break;
       case "AI": code = "Anguilla"; break;
	   case "AL": code = "Albania"; break;
       case "AM": code = "Armenia"; break;
       case "AN": code = "Netherlands Antilles"; break;
	   case "AO": code = "Angola"; break;
       case "AQ": code = "Antarctica"; break;
       case "AR": code = "Argentina"; break;
	   case "AS": code = "American Samoa"; break;
       case "AT": code = "Austria"; break;
       case "AU": code = "Australia"; break;
	   case "AW": code = "Aruba"; break;
       case "AZ": code = "Azerbaijan"; break;
       case "BA": code = "Bosnia and Herzegovina"; break;
	   case "BB": code = "Barbados"; break;
       case "BD": code = "Bangladesh"; break;
       case "BE": code = "Belgium"; break;
	   case "BF": code = "Burkina Faso"; break;
       case "BG": code = "Bulgaria"; break;
       case "BH": code = "Bahrain"; break;
	   case "BI": code = "Burundi"; break;
       case "BJ": code = "Benin"; break;
	   case "BM": code = "Bermuda"; break;
       case "BN": code = "Brunei"; break;
       case "BO": code = "Bolivia"; break;
	   case "BR": code = "Brazil"; break;
       case "BS": code = "Bahamas"; break;
	   case "BT": code = "Bhutan"; break;
       case "BV": code = "Bouvet Island"; break;
       case "BW": code = "Botswana"; break;
	   case "BY": code = "Belarus"; break;
       case "BZ": code = "Belize"; break;
	   case "CA": code = "Canada"; break;
       case "CC": code = "Cocos (Keeling) Islands"; break;
       case "CD": code = "Congo, Democratic People's Republic"; break;
	   case "CF": code = "Central African Republic"; break;
       case "CG": code = "Congo, Republic of"; break;
	   case "CH": code = "Switzerland"; break;
       case "CI": code = "C&ocirc;te d'Ivoire"; break;
       case "CK": code = "Cook Islands"; break;
	   case "CL": code = "Chile"; break;
       case "CM": code = "Cameroon"; break;
	   case "CN": code = "China"; break;
       case "CO": code = "Colombia"; break;
       case "CR": code = "Costa Rica"; break;
	   case "CU": code = "Cuba"; break;
       case "CV": code = "Cape Verde"; break;
	   case "CX": code = "Christmas Island"; break;
       case "CY": code = "Cyprus"; break;
       case "CZ": code = "Czech Republic"; break;
	   case "DE": code = "Germany"; break;
       case "DJ": code = "Djibouti"; break;
	   case "DK": code = "Denmark"; break;
       case "DM": code = "Dominica"; break;
       case "DO": code = "Dominican Republic"; break;
	   case "DZ": code = "Algeria"; break;
       case "EC": code = "Ecuador"; break;
	   case "EE": code = "Estonia"; break;
       case "EG": code = "Egypt"; break;
       case "EH": code = "Western Sahara"; break;
	   case "ER": code = "Eritrea"; break;
       case "ES": code = "Spain"; break;
	   case "ET": code = "Ethiopia"; break;
       case "FI": code = "Finland"; break;
       case "FJ": code = "Fiji"; break;
	   case "FK": code = "Falkland Islands (Malvina)"; break;
       case "FM": code = "Micronesia, Federal State of"; break;
	   case "FO": code = "Faroe Islands"; break;
       case "FR": code = "France"; break;
       case "GA": code = "Gabon"; break;
	   case "GD": code = "Grenada"; break;
       case "GE": code = "Georgia"; break;
	   case "GF": code = "French Guiana"; break;
       case "GG": code = "Guernsey"; break;
       case "GH": code = "Ghana"; break;
	   case "GI": code = "Gibraltar"; break;
       case "GL": code = "Greenland"; break;
	   case "GM": code = "Gambia"; break;
       case "GN": code = "Guinea"; break;
       case "GP": code = "Guadeloupe"; break;
	   case "GQ": code = "Equatorial Guinea"; break;
       case "GR": code = "Greece"; break;
	   case "GS": code = "South Georgia and the South Sandwich Islands"; break;
       case "GT": code = "Guatemala"; break;
       case "GU": code = "Guam"; break;
	   case "GW": code = "Guinea-Bissau"; break;
       case "GY": code = "Guyana"; break;
	   case "HK": code = "Hong Kong"; break;
       case "HM": code = "Heard and McDonald Islands"; break;
       case "HN": code = "Honduras"; break;
	   case "HR": code = "Croatia/Hrvatska"; break;
       case "HT": code = "Haiti"; break;
	   case "HU": code = "Hungary"; break;
       case "ID": code = "Indonesia"; break;
       case "IE": code = "Ireland"; break;
	   case "IL": code = "Israel"; break;
       case "IM": code = "Isle of Man"; break;
	   case "IN": code = "India"; break;
       case "IO": code = "British Indian Ocean Territory"; break;
       case "IQ": code = "Iraq"; break;
	   case "IR": code = "Iran"; break;
       case "IS": code = "Iceland"; break;
	   case "IT": code = "Italy"; break;
       case "JE": code = "Jersey"; break;
       case "JM": code = "Jamaica"; break;
	   case "JO": code = "Jordan"; break;
       case "JP": code = "Japan"; break;
	   case "KE": code = "Kenya"; break;
       case "KG": code = "Kyrgyzstan"; break;
       case "KH": code = "Cambodia"; break;
	   case "KI": code = "Kiribati"; break;
       case "KM": code = "Comoros"; break;
	   case "KN": code = "Saint Kitts and Nevis"; break;
       case "KP": code = "North Korea"; break;
       case "KR": code = "South Korea"; break;
	   case "KW": code = "Kuwait"; break;
       case "KY": code = "Cayman Islands"; break;
	   case "KZ": code = "Kazakstan"; break;
       case "LA": code = "Laos"; break;
       case "LB": code = "Lebanon"; break;
	   case "LC": code = "Saint Lucia"; break;
       case "LI": code = "Liechtenstein"; break;
	   case "LK": code = "Sri Lanka"; break;
       case "LR": code = "Liberia"; break;
       case "LS": code = "Lesotho"; break;
	   case "LT": code = "Lithuania"; break;
       case "LU": code = "Luxembourg"; break;
	   case "LV": code = "Latvia"; break;
       case "LY": code = "Lybia"; break;
       case "MA": code = "Morocco"; break;
	   case "MC": code = "Monaco"; break;
       case "MD": code = "Modolva"; break;
	   case "MG": code = "Madagascar"; break;
       case "MH": code = "Marshall Islands"; break;
       case "MK": code = "Macedonia, Former Yugoslav Republic"; break;
	   case "ML": code = "Mali"; break;
       case "MM": code = "Myanmar"; break;
	   case "MN": code = "Mongolia"; break;
       case "MO": code = "Macau"; break;
       case "MP": code = "Northern Mariana Islands"; break;
	   case "MQ": code = "Martinique"; break;
       case "MR": code = "Mauritania"; break;
	   case "MS": code = "Montserrat"; break;
       case "MT": code = "Malta"; break;
       case "MU": code = "Mauritius"; break;
	   case "MV": code = "Maldives"; break;
       case "MW": code = "Malawi"; break;
	   case "MX": code = "Mexico"; break;
       case "MY": code = "Maylaysia"; break;
       case "MZ": code = "Mozambique"; break;
	   case "NA": code = "Namibia"; break;
       case "NC": code = "New Caledonia"; break;
	   case "NE": code = "Niger"; break;
       case "NF": code = "Norfolk Island"; break;
       case "NG": code = "Nigeria"; break;
	   case "NI": code = "Nicaragua"; break;
       case "NL": code = "Netherlands"; break;
	   case "NO": code = "Norway"; break;
       case "NP": code = "Nepal"; break;
       case "NR": code = "Nauru"; break;
	   case "NU": code = "Niue"; break;
       case "NZ": code = "New Zealand"; break;
	   case "OM": code = "Oman"; break;
       case "PA": code = "Panama"; break;
       case "PE": code = "Peru"; break;
	   case "PF": code = "French Polynesia"; break;
       case "PG": code = "Papua New Guinea"; break;
	   case "PH": code = "Philippines"; break;
       case "PK": code = "Pakistan"; break;
       case "PL": code = "Poland"; break;
	   case "PM": code = "St. Pierre and Miquelon"; break;
       case "PN": code = "Pitcairn Island"; break;
	   case "PR": code = "Puerto Rico"; break;
       case "PS": code = "Palestinian Territories"; break;
       case "PT": code = "Portugal"; break;
	   case "PW": code = "Palau"; break;
       case "PY": code = "Paraguay"; break;
	   case "QA": code = "Qatar"; break;
       case "RE": code = "Reunion"; break;
       case "RO": code = "Romania"; break;
	   case "RU": code = "Russian Federation"; break;
       case "RW": code = "Twanda"; break;
	   case "SA": code = "Saudi Arabia"; break;
       case "SB": code = "Solomon Islands"; break;
       case "SC": code = "Seychelles"; break;
	   case "SU": code = "Sudan"; break;
       case "SE": code = "Sweden"; break;
	   case "SG": code = "Singapore"; break;
       case "SH": code = "St. Helena"; break;
       case "SI": code = "Slovenia"; break;
	   case "SJ": code = "Svalbard and Jan Mayan Islands"; break;
       case "SK": code = "Slovakia"; break;
	   case "SL": code = "Sierra Leone"; break;
       case "SM": code = "San Marino"; break;
       case "SN": code = "Senegal"; break;
	   case "SO": code = "Somalia"; break;
       case "SR": code = "Suriname"; break;
	   case "ST": code = "S&atilde;o Tome and Principe"; break;
       case "SV": code = "El Salvador"; break;
       case "SY": code = "Syria"; break;
	   case "SZ": code = "Swaziland"; break;
       case "TC": code = "Turks and Ciacos Islands"; break;
	   case "TD": code = "Chad"; break;
       case "TF": code = "French Southern Territories"; break;
       case "TG": code = "Togo"; break;
	   case "TH": code = "Thailand"; break;
       case "TJ": code = "Tajikistan"; break;
	   case "TK": code = "Tokelau"; break;
       case "TM": code = "Turkmenistan"; break;
       case "TN": code = "Tunisia"; break;
	   case "TO": code = "Tonga"; break;
       case "TP": code = "East Timor"; break;
	   case "TR": code = "Turkey"; break;
       case "TT": code = "Trinidad and Tobago"; break;
       case "TV": code = "Tuvalu"; break;
	   case "TW": code = "Taiwan"; break;
       case "TZ": code = "Tanzania"; break;
	   case "UA": code = "Ukraine"; break;
       case "UG": code = "Uganda"; break;
       case "UK": code = "United Kingdom"; break;
	   case "UM": code = "US Minor Outlying Islands"; break;
       case "US": code = "United States of America"; break;
	   case "UY": code = "Uruguay"; break;
       case "UZ": code = "Uzbekistan"; break;
       case "VA": code = "Vatican City"; break;
	   case "VC": code = "Saint Vincent and the Grenadines"; break;
       case "VE": code = "Venezuela"; break;
	   case "VG": code = "British Virgin Islands"; break;
       case "VI": code = "US Virgin Islands"; break;
       case "VN": code = "Vietnam"; break;
	   case "VU": code = "Vanuatu"; break;
       case "WF": code = "Wallis and Futuna Islands"; break;
	   case "WS": code = "Western Samoa"; break;
       case "YE": code = "Yemen"; break;
       case "YT": code = "Mayotte"; break;
	   case "YU": code = "Yugoslavia"; break;
       case "ZA": code = "South Africa"; break;
	   case "ZM": code = "Zambia"; break;
       case "ZR": code = "Zaire"; break;
       case "ZW": code = "Zimbabwe"; break;
	   default:   code = "No Country Corresponds to that Code";
	 }
	return code;
}
  
  
/**
 * This script looks up the country origin of hostnames which contain two letter country codes
 */
function getCountryCode (country) {
	switch (country.toLowerCase()) {
	   case "ascension island": country = "AC"; break;
       case "andorra": country = "AD"; break;
       case "united arab emirates": country = "AE"; break;
	   case "afghanistan": country = "AF"; break;
       case "antigua and barbuda": country = "AG"; break;
       case "anguilla": country = "AI"; break;
	   case "albania": country = "AL"; break;
	   case "armenia": country = "AM"; break;
       case "netherlands antilles": country = "AN"; break;
	   case "angola": country = "AO"; break;
       case "antarctica": country = "AQ"; break;

       case "argentina": country = "AR"; break;
	   case "american samoa": country = "AS"; break;
       case "austria": country = "AT"; break;
       case "australia": country = "AU"; break;
	   case "aruba": country = "AW"; break;
       case "azerbaijan": country = "AZ"; break;
       case "bosnia and herzegovina": country = "BA"; break;
	   case "barbados": country = "BB"; break;
       case "bangladesh": country = "BD"; break;
       case "belgium": country = "BE"; break;
	   case "burkina faso": country = "BF"; break;
       case "bulgaria": country = "BG"; break;
       case "bahrain": country = "BH"; break;
	   case "burundi": country = "BI"; break;
       case "benin": country = "BJ"; break;
	   case "bermuda": country = "BM"; break;
       case "brunei": country = "BN"; break;
       case "bolivia": country = "BO"; break;
	   case "brazil": country = "BR"; break;
	   case "bahamas": country = "BS"; break;
	   case "bhutan": country = "BT"; break;
	   case "bouvet island": country = "BV"; break;
	   case "botswana": country = "BW"; break;
	   case "belarus": country = "BY"; break;
	   case "belize": country = "BZ"; break;
	   case "canada": country = "CA"; break;
	   case "cocos (keeling) islands": country = "CC"; break;
	   case "congo, democratic people's republic": country = "CD"; break;
	   case "central African republic": country = "CF"; break;
	   case "congo, republic of": country = "CG"; break;
	   case "switzerland": country = "CH"; break;
	   case "c&ocirc;te d'ivoire": country = "CI"; break;
	   case "cook islands": country = "CK"; break;
	   case "chile": country = "CL"; break;
	   case "cameroon": country = "CM"; break;
	   case "china": country = "CN"; break;
	   case "colombia": country = "CO"; break;
	   case "costa rica": country = "CR"; break;
	   case "cuba": country = "CU"; break;
	   case "cape Verde": country = "CV"; break;
	   case "christmas island": country = "CX"; break;
	   case "cyprus": country = "CY"; break;
	   case "czech republic": country = "CZ"; break;
	   case "germany": country = "DE"; break;
	   case "djibouti": country = "DJ"; break;
	   case "denmark": country = "DK"; break;
	   case "dominica": country = "DM"; break;
	   case "dominican republic": country = "DO"; break;
	   case "algeria": country = "DZ"; break;
	   case "ecuador": country = "EC"; break;
	   case "estonia": country = "EE"; break;
	   case "egypt": country = "EG"; break;
	   case "western sahara": country = "EH"; break;
	   case "eritrea": country = "ER"; break;
	   case "spain": country = "ES"; break;
	   case "ethiopia": country = "ET"; break;
	   case "finland": country = "FI"; break;
	   case "fiji": country = "FJ"; break;
	   case "falkland islands (malvina)": country = "FK"; break;
	   case "nicronesia, federal state of": country = "FM"; break;
	   case "faroe islands": country = "FO"; break;
	   case "france": country = "FR"; break;
	   case "gabon": country = "GA"; break;
	   case "grenada": country = "GD"; break;
	   case "georgia": country = "GE"; break;
	   case "french guiana": country = "GF"; break;
	   case "guernsey": country = "GG"; break;
	   case "ghana": country = "GH"; break;
	   case "gibraltar": country = "GI"; break;
	   case "greenland": country = "GL"; break;
	   case "gambia": country = "GM"; break;
	   case "guinea": country = "GN"; break;
	   case "guadeloupe": country = "GP"; break;
	   case "equatorial guinea": country = "GQ"; break;
	   case "greece": country = "GR"; break;
	   case "south georgia and the south sandwich islands": country = "GS"; break;
	   case "guatemala": country = "GT"; break;
	   case "guam": country = "GU"; break;
	   case "guinea-bissau": country = "GW"; break;
	   case "guyana": country = "GY"; break;
	   case "hong kong": country = "HK"; break;
	   case "heard and mcdonald islands": country = "HM"; break;
	   case "honduras": country = "HN"; break;
	   case "croatia": country = "HR"; break;
	   case "haiti": country = "HT"; break;
	   case "hungary": country = "HU"; break;
	   case "indonesia": country = "ID"; break;
	   case "ireland": country = "IE"; break;
	   case "israel": country = "IL"; break;
	   case "isle of man": country = "IM"; break;
	   case "india": country = "IN"; break;
	   case "british indian ocean territory": country = "IO"; break;
	   case "iraq": country = "IQ"; break;
	   case "iran": country = "IR"; break;
	   case "iceland": country = "IS"; break;
	   case "italy": country = "IT"; break;
	   case "jersey": country = "JE"; break;
	   case "jamaica": country = "JM"; break;
	   case "jordan": country = "JO"; break;
	   case "japan": country = "JP"; break;
	   case "kenya": country = "KE"; break;
	   case "kyrgyzstan": country = "KG"; break;
	   case "cambodia": country = "KH"; break;
	   case "kiribati": country = "KI"; break;
	   case "comoros": country = "KM"; break;
	   case "saint kitts and nevis": country = "KN"; break;
	   case "north korea": country = "KP"; break;
	   case "south korea": country = "KR"; break;
	   case "kuwait": country = "KW"; break;
	   case "cayman islands": country = "KY"; break;
	   case "kazakstan": country = "KZ"; break;
	   case "laos": country = "LA"; break;
	   case "lebanon": country = "LB"; break;
	   case "saint Lucia": country = "LC"; break;
	   case "liechtenstein": country = "LI"; break;
	   case "sri Lanka": country = "LK"; break;
	   case "liberia": country = "LR"; break;
	   case "lesotho": country = "LS"; break;
	   case "lithuania": country = "LT"; break;
	   case "luxembourg": country = "LU"; break;
	   case "latvia": country = "LV"; break;
	   case "lybia": country = "LY"; break;
	   case "morocco": country = "MA"; break;
	   case "monaco": country = "MC"; break;
	   case "modolva": country = "MD"; break;
	   case "madagascar": country = "MG"; break;
	   case "marshall islands": country = "MH"; break;
	   case "macedonia, former yugoslav republic": country = "MK"; break;
	   case "mali": country = "ML"; break;
	   case "myanmar": country = "MM"; break;
	   case "mongolia": country = "MN"; break;
	   case "macau": country = "MO"; break;
	   case "northern mariana islands": country = "MP"; break;
	   case "martinique": country = "MQ"; break;
	   case "mauritania": country = "MR"; break;
	   case "montserrat": country = "MS"; break;
	   case "malta": country = "MT"; break;
	   case "mauritius": country = "MU"; break;
	   case "maldives": country = "MV"; break;
	   case "malawi": country = "MW"; break;
	   case "mexico": country = "MX"; break;
	   case "maylaysia": country = "MY"; break;
	   case "mozambique": country = "MZ"; break;
	   case "namibia": country = "NA"; break;
	   case "new caledonia": country = "NC"; break;
	   case "niger": country = "NE"; break;
	   case "norfolk island": country = "NF"; break;
	   case "nigeria": country = "NG"; break;
	   case "nicaragua": country = "NI"; break;
	   case "netherlands": country = "NL"; break;
	   case "norway": country = "NO"; break;
	   case "nepal": country = "NP"; break;
	   case "nauru": country = "NR"; break;
	   case "niue": country = "NU"; break;
	   case "new zealand": country = "NZ"; break;
	   case "oman": country = "OM"; break;
	   case "panama": country = "PA"; break;
	   case "peru": country = "PE"; break;
	   case "french polynesia": country = "PF"; break;
	   case "papua new guinea": country = "PG"; break;
	   case "philippines": country = "PH"; break;
	   case "pakistan": country = "PK"; break;
	   case "poland": country = "PL"; break;
	   case "st. pierre and miquelon": country = "PM"; break;
	   case "pitcairn island": country = "PN"; break;
	   case "puerto rico": country = "PR"; break;
	   case "palestinian territories": country = "PS"; break;
	   case "portugal": country = "PT"; break;
	   case "palau": country = "PW"; break;
	   case "paraguay": country = "PY"; break;
	   case "qatar": country = "QA"; break;
	   case "reunion": country = "RE"; break;
	   case "romania": country = "RO"; break;
	   case "russian federation": country = "RU"; break;
	   case "rwanda": country = "RW"; break;
	   case "saudi Arabia": country = "SA"; break;
	   case "solomon islands": country = "SB"; break;
	   case "seychelles": country = "SC"; break;
	   case "sudan": country = "SU"; break;
	   case "sweden": country = "SE"; break;
	   case "singapore": country = "SG"; break;
	   case "st. helena": country = "SH"; break;
	   case "slovenia": country = "SI"; break;
	   case "svalbard and jan mayan islands": country = "SJ"; break;
	   case "slovakia": country = "SK"; break;
	   case "sierra leone": country = "SL"; break;
	   case "san marino": country = "SM"; break;
	   case "senegal": country = "SN"; break;
	   case "somalia": country = "SO"; break;
	   case "suriname": country = "SR"; break;
	   case "s&atilde;o tome and principe": country = "ST"; break;
	   case "el Salvador": country = "SV"; break;
	   case "syria": country = "SY"; break;
	   case "swaziland": country = "SZ"; break;
	   case "turks and ciacos islands": country = "TC"; break;
	   case "chad": country = "TD"; break;
	   case "french southern territories": country = "TF"; break;
	   case "togo": country = "TG"; break;
	   case "thailand": country = "TH"; break;
	   case "tajikistan": country = "TJ"; break;
	   case "tokelau": country = "TK"; break;
	   case "turkmenistan": country = "TM"; break;
	   case "tunisia": country = "TN"; break;
	   case "tonga": country = "TO"; break;
	   case "east timor": country = "TP"; break;
	   case "turkey": country = "TR"; break;
	   case "trinidad and tobago": country = "TT"; break;
	   case "tuvalu": country = "TV"; break;
	   case "taiwan": country = "TW"; break;
	   case "tanzania": country = "TZ"; break;
	   case "ukraine": country = "UA"; break;
	   case "uganda": country = "UG"; break;
	   case "united kingdom": country = "UK"; break;
	   case "us minor outlying islands": country = "UM"; break;
	   case "united states of america": case "united states": country = "US"; break;
	   case "uruguay": country = "UY"; break;
	   case "uzbekistan": country = "UZ"; break;
	   case "vatican city": country = "VA"; break;
	   case "saint vincent and the grenadines": country = "VC"; break;
	   case "venezuela": country = "VE"; break;
	   case "british virgin islands": country = "VG"; break;
	   case "us virgin islands": country = "VI"; break;
	   case "vietnam": country = "VN"; break;
	   case "vanuatu": country = "VU"; break;
	   case "wallis and futuna islands": country = "WF"; break;
	   case "western samoa": country = "WS"; break;
	   case "yemen": country = "YE"; break;
	   case "nayotte": country = "YT"; break;
	   case "yugoslavia": country = "YU"; break;
	   case "south africa": country = "ZA"; break;
	   case "zambia": country = "ZM"; break;
	   case "zaire": country = "ZR"; break;
	   case "zimbabwe": country = "ZW"; break;
	   default: country = "??";
	 }
	return country;
}

/* ------------------------mootools-1.2.1-core-yc.js ---------------------*/




/* ------------------mootools-1.2-more.js ----------------------------------*/
//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2008 Valerio Proietti, <http://mad4milk.net>, MIT Style License.

Fx.Slide=new Class({Extends:Fx,options:{mode:"vertical"},initialize:function(B,A){this.addEvent("complete",function(){this.open=(this.wrapper["offset"+this.layout.capitalize()]!=0);
if(this.open&&Browser.Engine.webkit419){this.element.dispose().inject(this.wrapper);}},true);this.element=this.subject=$(B);this.parent(A);var C=this.element.retrieve("wrapper");
this.wrapper=C||new Element("div",{styles:$extend(this.element.getStyles("margin","position"),{overflow:"hidden"})}).wraps(this.element);this.element.store("wrapper",this.wrapper).setStyle("margin",0);
this.now=[];this.open=true;},vertical:function(){this.margin="margin-top";this.layout="height";this.offset=this.element.offsetHeight;},horizontal:function(){this.margin="margin-left";
this.layout="width";this.offset=this.element.offsetWidth;},set:function(A){this.element.setStyle(this.margin,A[0]);this.wrapper.setStyle(this.layout,A[1]);
return this;},compute:function(E,D,C){var B=[];var A=2;A.times(function(F){B[F]=Fx.compute(E[F],D[F],C);});return B;},start:function(B,E){if(!this.check(arguments.callee,B,E)){return this;
}this[E||this.options.mode]();var D=this.element.getStyle(this.margin).toInt();var C=this.wrapper.getStyle(this.layout).toInt();var A=[[D,C],[0,this.offset]];
var G=[[D,C],[-this.offset,0]];var F;switch(B){case"in":F=A;break;case"out":F=G;break;case"toggle":F=(this.wrapper["offset"+this.layout.capitalize()]==0)?A:G;
}return this.parent(F[0],F[1]);},slideIn:function(A){return this.start("in",A);},slideOut:function(A){return this.start("out",A);},hide:function(A){this[A||this.options.mode]();
this.open=false;return this.set([-this.offset,0]);},show:function(A){this[A||this.options.mode]();this.open=true;return this.set([0,this.offset]);},toggle:function(A){return this.start("toggle",A);
}});Element.Properties.slide={set:function(B){var A=this.retrieve("slide");if(A){A.cancel();}return this.eliminate("slide").store("slide:options",$extend({link:"cancel"},B));
},get:function(A){if(A||!this.retrieve("slide")){if(A||!this.retrieve("slide:options")){this.set("slide",A);}this.store("slide",new Fx.Slide(this,this.retrieve("slide:options")));
}return this.retrieve("slide");}};Element.implement({slide:function(D,E){D=D||"toggle";var B=this.get("slide"),A;switch(D){case"hide":B.hide(E);break;case"show":B.show(E);
break;case"toggle":var C=this.retrieve("slide:flag",B.open);B[(C)?"slideOut":"slideIn"](E);this.store("slide:flag",!C);A=true;break;default:B.start(D,E);
}if(!A){this.eliminate("slide:flag");}return this;}});Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(B,A){this.element=this.subject=$(B);
this.parent(A);var D=this.cancel.bind(this,false);if($type(this.element)!="element"){this.element=$(this.element.getDocument().body);}var C=this.element;
if(this.options.wheelStops){this.addEvent("start",function(){C.addEvent("mousewheel",D);},true);this.addEvent("complete",function(){C.removeEvent("mousewheel",D);
},true);}},set:function(){var A=Array.flatten(arguments);this.element.scrollTo(A[0],A[1]);},compute:function(E,D,C){var B=[];var A=2;A.times(function(F){B.push(Fx.compute(E[F],D[F],C));
});return B;},start:function(C,H){if(!this.check(arguments.callee,C,H)){return this;}var E=this.element.getSize(),F=this.element.getScrollSize();var B=this.element.getScroll(),D={x:C,y:H};
for(var G in D){var A=F[G]-E[G];if($chk(D[G])){D[G]=($type(D[G])=="number")?D[G].limit(0,A):A;}else{D[G]=B[G];}D[G]+=this.options.offset[G];}return this.parent([B.x,B.y],[D.x,D.y]);
},toTop:function(){return this.start(false,0);},toLeft:function(){return this.start(0,false);},toRight:function(){return this.start("right",false);},toBottom:function(){return this.start(false,"bottom");
},toElement:function(B){var A=$(B).getPosition(this.element);return this.start(A.x,A.y);}});Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(B,A){this.elements=this.subject=$$(B);
this.parent(A);},compute:function(G,H,I){var C={};for(var D in G){var A=G[D],E=H[D],F=C[D]={};for(var B in A){F[B]=this.parent(A[B],E[B],I);}}return C;
},set:function(B){for(var C in B){var A=B[C];for(var D in A){this.render(this.elements[C],D,A[D],this.options.unit);}}return this;},start:function(C){if(!this.check(arguments.callee,C)){return this;
}var H={},I={};for(var D in C){var F=C[D],A=H[D]={},G=I[D]={};for(var B in F){var E=this.prepare(this.elements[D],B,F[B]);A[B]=E.from;G[B]=E.to;}}return this.parent(H,I);
}});var Drag=new Class({Implements:[Events,Options],options:{snap:6,unit:"px",grid:false,style:true,limit:false,handle:false,invert:false,preventDefault:false,modifiers:{x:"left",y:"top"}},initialize:function(){var B=Array.link(arguments,{options:Object.type,element:$defined});
this.element=$(B.element);this.document=this.element.getDocument();this.setOptions(B.options||{});var A=$type(this.options.handle);this.handles=(A=="array"||A=="collection")?$$(this.options.handle):$(this.options.handle)||this.element;
this.mouse={now:{},pos:{}};this.value={start:{},now:{}};this.selection=(Browser.Engine.trident)?"selectstart":"mousedown";this.bound={start:this.start.bind(this),check:this.check.bind(this),drag:this.drag.bind(this),stop:this.stop.bind(this),cancel:this.cancel.bind(this),eventStop:$lambda(false)};
this.attach();},attach:function(){this.handles.addEvent("mousedown",this.bound.start);return this;},detach:function(){this.handles.removeEvent("mousedown",this.bound.start);
return this;},start:function(C){if(this.options.preventDefault){C.preventDefault();}this.fireEvent("beforeStart",this.element);this.mouse.start=C.page;
var A=this.options.limit;this.limit={x:[],y:[]};for(var D in this.options.modifiers){if(!this.options.modifiers[D]){continue;}if(this.options.style){this.value.now[D]=this.element.getStyle(this.options.modifiers[D]).toInt();
}else{this.value.now[D]=this.element[this.options.modifiers[D]];}if(this.options.invert){this.value.now[D]*=-1;}this.mouse.pos[D]=C.page[D]-this.value.now[D];
if(A&&A[D]){for(var B=2;B--;B){if($chk(A[D][B])){this.limit[D][B]=$lambda(A[D][B])();}}}}if($type(this.options.grid)=="number"){this.options.grid={x:this.options.grid,y:this.options.grid};
}this.document.addEvents({mousemove:this.bound.check,mouseup:this.bound.cancel});this.document.addEvent(this.selection,this.bound.eventStop);},check:function(A){if(this.options.preventDefault){A.preventDefault();
}var B=Math.round(Math.sqrt(Math.pow(A.page.x-this.mouse.start.x,2)+Math.pow(A.page.y-this.mouse.start.y,2)));if(B>this.options.snap){this.cancel();this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop});
this.fireEvent("start",this.element).fireEvent("snap",this.element);}},drag:function(A){if(this.options.preventDefault){A.preventDefault();}this.mouse.now=A.page;
for(var B in this.options.modifiers){if(!this.options.modifiers[B]){continue;}this.value.now[B]=this.mouse.now[B]-this.mouse.pos[B];if(this.options.invert){this.value.now[B]*=-1;
}if(this.options.limit&&this.limit[B]){if($chk(this.limit[B][1])&&(this.value.now[B]>this.limit[B][1])){this.value.now[B]=this.limit[B][1];}else{if($chk(this.limit[B][0])&&(this.value.now[B]<this.limit[B][0])){this.value.now[B]=this.limit[B][0];
}}}if(this.options.grid[B]){this.value.now[B]-=(this.value.now[B]%this.options.grid[B]);}if(this.options.style){this.element.setStyle(this.options.modifiers[B],this.value.now[B]+this.options.unit);
}else{this.element[this.options.modifiers[B]]=this.value.now[B];}}this.fireEvent("drag",this.element);},cancel:function(A){this.document.removeEvent("mousemove",this.bound.check);
this.document.removeEvent("mouseup",this.bound.cancel);if(A){this.document.removeEvent(this.selection,this.bound.eventStop);this.fireEvent("cancel",this.element);
}},stop:function(A){this.document.removeEvent(this.selection,this.bound.eventStop);this.document.removeEvent("mousemove",this.bound.drag);this.document.removeEvent("mouseup",this.bound.stop);
if(A){this.fireEvent("complete",this.element);}}});Element.implement({makeResizable:function(A){return new Drag(this,$merge({modifiers:{x:"width",y:"height"}},A));
}});Drag.Move=new Class({Extends:Drag,options:{droppables:[],container:false},initialize:function(C,B){this.parent(C,B);this.droppables=$$(this.options.droppables);
this.container=$(this.options.container);if(this.container&&$type(this.container)!="element"){this.container=$(this.container.getDocument().body);}C=this.element;
var D=C.getStyle("position");var A=(D!="static")?D:"absolute";if(C.getStyle("left")=="auto"||C.getStyle("top")=="auto"){C.position(C.getPosition(C.offsetParent));
}C.setStyle("position",A);this.addEvent("start",function(){this.checkDroppables();},true);},start:function(B){if(this.container){var D=this.element,J=this.container,E=J.getCoordinates(D.offsetParent),F={},A={};
["top","right","bottom","left"].each(function(K){F[K]=J.getStyle("padding-"+K).toInt();A[K]=D.getStyle("margin-"+K).toInt();},this);var C=D.offsetWidth+A.left+A.right,I=D.offsetHeight+A.top+A.bottom;
var H=[E.left+F.left,E.right-F.right-C];var G=[E.top+F.top,E.bottom-F.bottom-I];this.options.limit={x:H,y:G};}this.parent(B);},checkAgainst:function(B){B=B.getCoordinates();
var A=this.mouse.now;return(A.x>B.left&&A.x<B.right&&A.y<B.bottom&&A.y>B.top);},checkDroppables:function(){var A=this.droppables.filter(this.checkAgainst,this).getLast();
if(this.overed!=A){if(this.overed){this.fireEvent("leave",[this.element,this.overed]);}if(A){this.overed=A;this.fireEvent("enter",[this.element,A]);}else{this.overed=null;
}}},drag:function(A){this.parent(A);if(this.droppables.length){this.checkDroppables();}},stop:function(A){this.checkDroppables();this.fireEvent("drop",[this.element,this.overed]);
this.overed=null;return this.parent(A);}});Element.implement({makeDraggable:function(A){return new Drag.Move(this,A);}});Hash.Cookie=new Class({Extends:Cookie,options:{autoSave:true},initialize:function(B,A){this.parent(B,A);
this.load();},save:function(){var A=JSON.encode(this.hash);if(!A||A.length>4096){return false;}if(A=="{}"){this.dispose();}else{this.write(A);}return true;
},load:function(){this.hash=new Hash(JSON.decode(this.read(),true));return this;}});Hash.Cookie.implement((function(){var A={};Hash.each(Hash.prototype,function(C,B){A[B]=function(){var D=C.apply(this.hash,arguments);
if(this.options.autoSave){this.save();}return D;};});return A;})());var Color=new Native({initialize:function(B,C){if(arguments.length>=3){C="rgb";B=Array.slice(arguments,0,3);
}else{if(typeof B=="string"){if(B.match(/rgb/)){B=B.rgbToHex().hexToRgb(true);}else{if(B.match(/hsb/)){B=B.hsbToRgb();}else{B=B.hexToRgb(true);}}}}C=C||"rgb";
switch(C){case"hsb":var A=B;B=B.hsbToRgb();B.hsb=A;break;case"hex":B=B.hexToRgb(true);break;}B.rgb=B.slice(0,3);B.hsb=B.hsb||B.rgbToHsb();B.hex=B.rgbToHex();
return $extend(B,this);}});Color.implement({mix:function(){var A=Array.slice(arguments);var C=($type(A.getLast())=="number")?A.pop():50;var B=this.slice();
A.each(function(D){D=new Color(D);for(var E=0;E<3;E++){B[E]=Math.round((B[E]/100*(100-C))+(D[E]/100*C));}});return new Color(B,"rgb");},invert:function(){return new Color(this.map(function(A){return 255-A;
}));},setHue:function(A){return new Color([A,this.hsb[1],this.hsb[2]],"hsb");},setSaturation:function(A){return new Color([this.hsb[0],A,this.hsb[2]],"hsb");
},setBrightness:function(A){return new Color([this.hsb[0],this.hsb[1],A],"hsb");}});function $RGB(C,B,A){return new Color([C,B,A],"rgb");}function $HSB(C,B,A){return new Color([C,B,A],"hsb");
}function $HEX(A){return new Color(A,"hex");}Array.implement({rgbToHsb:function(){var B=this[0],C=this[1],J=this[2];var G,F,H;var I=Math.max(B,C,J),E=Math.min(B,C,J);
var K=I-E;H=I/255;F=(I!=0)?K/I:0;if(F==0){G=0;}else{var D=(I-B)/K;var A=(I-C)/K;var L=(I-J)/K;if(B==I){G=L-A;}else{if(C==I){G=2+D-L;}else{G=4+A-D;}}G/=6;
if(G<0){G++;}}return[Math.round(G*360),Math.round(F*100),Math.round(H*100)];},hsbToRgb:function(){var C=Math.round(this[2]/100*255);if(this[1]==0){return[C,C,C];
}else{var A=this[0]%360;var E=A%60;var F=Math.round((this[2]*(100-this[1]))/10000*255);var D=Math.round((this[2]*(6000-this[1]*E))/600000*255);var B=Math.round((this[2]*(6000-this[1]*(60-E)))/600000*255);
switch(Math.floor(A/60)){case 0:return[C,B,F];case 1:return[D,C,F];case 2:return[F,C,B];case 3:return[F,D,C];case 4:return[B,F,C];case 5:return[C,F,D];
}}return false;}});String.implement({rgbToHsb:function(){var A=this.match(/\d{1,3}/g);return(A)?hsb.rgbToHsb():null;},hsbToRgb:function(){var A=this.match(/\d{1,3}/g);
return(A)?A.hsbToRgb():null;}});var Group=new Class({initialize:function(){this.instances=Array.flatten(arguments);this.events={};this.checker={};},addEvent:function(B,A){this.checker[B]=this.checker[B]||{};
this.events[B]=this.events[B]||[];if(this.events[B].contains(A)){return false;}else{this.events[B].push(A);}this.instances.each(function(C,D){C.addEvent(B,this.check.bind(this,[B,C,D]));
},this);return this;},check:function(C,A,B){this.checker[C][B]=true;var D=this.instances.every(function(F,E){return this.checker[C][E]||false;},this);if(!D){return ;
}this.checker[C]={};this.events[C].each(function(E){E.call(this,this.instances,A);},this);}});var Asset=new Hash({javascript:function(F,D){D=$extend({onload:$empty,document:document,check:$lambda(true)},D);
var B=new Element("script",{src:F,type:"text/javascript"});var E=D.onload.bind(B),A=D.check,G=D.document;delete D.onload;delete D.check;delete D.document;
B.addEvents({load:E,readystatechange:function(){if(["loaded","complete"].contains(this.readyState)){E();}}}).setProperties(D);if(Browser.Engine.webkit419){var C=(function(){if(!$try(A)){return ;
}$clear(C);E();}).periodical(50);}return B.inject(G.head);},css:function(B,A){return new Element("link",$merge({rel:"stylesheet",media:"screen",type:"text/css",href:B},A)).inject(document.head);
},image:function(C,B){B=$merge({onload:$empty,onabort:$empty,onerror:$empty},B);var D=new Image();var A=$(D)||new Element("img");["load","abort","error"].each(function(E){var F="on"+E;
var G=B[F];delete B[F];D[F]=function(){if(!D){return ;}if(!A.parentNode){A.width=D.width;A.height=D.height;}D=D.onload=D.onabort=D.onerror=null;G.delay(1,A,A);
A.fireEvent(E,A,1);};});D.src=A.src=C;if(D&&D.complete){D.onload.delay(1);}return A.setProperties(B);},images:function(D,C){C=$merge({onComplete:$empty,onProgress:$empty},C);
if(!D.push){D=[D];}var A=[];var B=0;D.each(function(F){var E=new Asset.image(F,{onload:function(){C.onProgress.call(this,B,D.indexOf(F));B++;if(B==D.length){C.onComplete();
}}});A.push(E);});return new Elements(A);}});var Slider=new Class({Implements:[Events,Options],options:{onTick:function(A){if(this.options.snap){A=this.toPosition(this.step);
}this.knob.setStyle(this.property,A);},snap:false,offset:0,range:false,wheel:false,steps:100,mode:"horizontal"},initialize:function(E,A,D){this.setOptions(D);
this.element=$(E);this.knob=$(A);this.previousChange=this.previousEnd=this.step=-1;this.element.addEvent("mousedown",this.clickedElement.bind(this));if(this.options.wheel){this.element.addEvent("mousewheel",this.scrolledElement.bindWithEvent(this));
}var F,B={},C={x:false,y:false};switch(this.options.mode){case"vertical":this.axis="y";this.property="top";F="offsetHeight";break;case"horizontal":this.axis="x";
this.property="left";F="offsetWidth";}this.half=this.knob[F]/2;this.full=this.element[F]-this.knob[F]+(this.options.offset*2);this.min=$chk(this.options.range[0])?this.options.range[0]:0;
this.max=$chk(this.options.range[1])?this.options.range[1]:this.options.steps;this.range=this.max-this.min;this.steps=this.options.steps||this.full;this.stepSize=Math.abs(this.range)/this.steps;
this.stepWidth=this.stepSize*this.full/Math.abs(this.range);this.knob.setStyle("position","relative").setStyle(this.property,-this.options.offset);C[this.axis]=this.property;
B[this.axis]=[-this.options.offset,this.full-this.options.offset];this.drag=new Drag(this.knob,{snap:0,limit:B,modifiers:C,onDrag:this.draggedKnob.bind(this),onStart:this.draggedKnob.bind(this),onComplete:function(){this.draggedKnob();
this.end();}.bind(this)});if(this.options.snap){this.drag.options.grid=Math.ceil(this.stepWidth);this.drag.options.limit[this.axis][1]=this.full;}},set:function(A){if(!((this.range>0)^(A<this.min))){A=this.min;
}if(!((this.range>0)^(A>this.max))){A=this.max;}this.step=Math.round(A);this.checkStep();this.end();this.fireEvent("tick",this.toPosition(this.step));return this;
},clickedElement:function(C){var B=this.range<0?-1:1;var A=C.page[this.axis]-this.element.getPosition()[this.axis]-this.half;A=A.limit(-this.options.offset,this.full-this.options.offset);
this.step=Math.round(this.min+B*this.toStep(A));this.checkStep();this.end();this.fireEvent("tick",A);},scrolledElement:function(A){var B=(this.options.mode=="horizontal")?(A.wheel<0):(A.wheel>0);
this.set(B?this.step-this.stepSize:this.step+this.stepSize);A.stop();},draggedKnob:function(){var B=this.range<0?-1:1;var A=this.drag.value.now[this.axis];
A=A.limit(-this.options.offset,this.full-this.options.offset);this.step=Math.round(this.min+B*this.toStep(A));this.checkStep();},checkStep:function(){if(this.previousChange!=this.step){this.previousChange=this.step;
this.fireEvent("change",this.step);}},end:function(){if(this.previousEnd!==this.step){this.previousEnd=this.step;this.fireEvent("complete",this.step+"");
}},toStep:function(A){var B=(A+this.options.offset)*this.stepSize/this.full*this.steps;return this.options.steps?Math.round(B-=B%this.stepSize):B;},toPosition:function(A){return(this.full*Math.abs(this.min-A))/(this.steps*this.stepSize)-this.options.offset;
}});var Scroller=new Class({Implements:[Events,Options],options:{area:20,velocity:1,onChange:function(A,B){this.element.scrollTo(A,B);}},initialize:function(B,A){this.setOptions(A);
this.element=$(B);this.listener=($type(this.element)!="element")?$(this.element.getDocument().body):this.element;this.timer=null;this.coord=this.getCoords.bind(this);
},start:function(){this.listener.addEvent("mousemove",this.coord);},stop:function(){this.listener.removeEvent("mousemove",this.coord);this.timer=$clear(this.timer);
},getCoords:function(A){this.page=(this.listener.get("tag")=="body")?A.client:A.page;if(!this.timer){this.timer=this.scroll.periodical(50,this);}},scroll:function(){var B=this.element.getSize(),A=this.element.getScroll(),E=this.element.getPosition(),D={x:0,y:0};
for(var C in this.page){if(this.page[C]<(this.options.area+E[C])&&A[C]!=0){D[C]=(this.page[C]-this.options.area-E[C])*this.options.velocity;}else{if(this.page[C]+this.options.area>(B[C]+E[C])&&B[C]+B[C]!=A[C]){D[C]=(this.page[C]-B[C]+this.options.area-E[C])*this.options.velocity;
}}}if(D.y||D.x){this.fireEvent("change",[A.x+D.x,A.y+D.y]);}}});

/*-----------------------------orlandocollection.js -----------------------*/
// JScript File
orlandocollection = ['Lake Buena Vista Resort Village & Spa','Bahama Bay Resort (Near Disney)','Star Island Resort (Kissimmee)','Caribe Cove Resort-Kissimmee (Near Disney)','Cypress Pointe Grand Villas Resort','The Fountains Resort-Orlando','Coral Cay Resort-Kissimmee','Liki Tiki Village Resort (Near Orlando)','Westgate Palace Resort-Orlando','Regal Sun Resort-Lake Buena Vista (Near Disney)','Holiday Inn Club Vacations Orlando-Orange Lake Resort','Summer Bay (Clermont)'];


/*-----------------------------------------MS_liveMap.js----------------------------------*/

        var map = null;

         var LA 

         var pinPoint = null;
         var pinPixel = null;
                  
         function GetMap(aLat, aLong, sAvailable)
         {
            if (sAvailable == 'true'  && aLat != null && aLong != null)
            {
                LA = new VELatLong(aLat, aLong);
                map = new VEMap('myMap');
                map.LoadMap(LA, 14, VEMapStyle.Hybrid, false, VEMapMode.Mode2D, true, 1);

                AddPin();
            }
         }

         function getInfo()
         {
            var info;

            if (map.IsBirdseyeAvailable())
            {
                var be = map.GetBirdseyeScene();

                info  = "ID: "          + be.GetID() + "\n";
                info += "orientation: " + be.GetOrientation()+ "\n";
                info += "height: "      + be.GetHeight() + "\n";
                info += "width: "       + be.GetWidth() + "\n";

                var pixel = be.LatLongToPixel(map.GetCenter(), map.GetZoomLevel());

                info += "LatLongToPixel: " + pixel.x + ", " + pixel.y + "\n";

                // Check to see if the current birdseye view contains the pushpin pixel point.
                info += "contains pixel " + pinPixel.x + ", " + pinPixel.y + ": " + 
                        be.ContainsPixel(pinPixel.x, pinPixel.y, map.GetZoomLevel()) + "\n";
                
                // Check to see if the current view contains the pushpin LatLong.
                info += "contains latlong " + pinPoint + ": " + be.ContainsLatLong(pinPoint) + "\n";
                
                // This method may return null, depending on the selected view and map style.
                info += "latlong: " + map.PixelToLatLong(pixel);

                alert(info);
            }
            else
            {
                var center = map.GetCenter();

                info  = "Zoom level:\t" + map.GetZoomLevel() + "\n";
                info += "Latitude:\t"   + center.Latitude    + "\n";
                info += "Longitude:\t"  + center.Longitude;

                alert(info);
            }
         }
         
         function AddPin()
         {
            // Add a new pushpin to the center of the map.
            pinPoint = map.GetCenter();
            pinPixel = map.LatLongToPixel(pinPoint);
            map.AddPushpin(pinPoint);
         }
