(function($) {
	$.fn.superfish.defaults.onBeforeShow = function() {
		$(this).parents('ul').siblings('.sas7-link-details').hide();
		$(this).siblings('.sas7-link-details').show();
	};
	$.fn.superfish.defaults.onHide = function() {
		$(this).siblings('.sas7-link-details').hide();
	};
	$(document).ready(function() {
		$('.ajax-load').click(function() {
			$('#' + $(this).attr('rel')).empty().addClass('loading').slideDown(300).load($(this).attr('href'), function() {
				var div = this;
				$(this).removeClass('loading').prepend($('<a href=\"#\" class=\"hide\" onclick=\"return false;\">Hide Rooms & Rates</a>').click(function() {
					$(div).slideUp(300, function() {$(this).empty();});
					return false;
				}));
				Drupal.attachBehaviors(this);
			});
			return false;
		});
		$('#column-right-container .view-filters form, #column-right-container #sasrss-product-availability-form').each(function (){
			$('.form-submit', this).after($('<img class=\"loader\" src=\"/sites/all/themes/sas7/images/ajax-loader.gif\" width=\"34\" height=\"34\" />').hide());
		}).submit(function() {
			if(($('#edit-availability-rsscheckin', this).val() && $('#edit-availability-rsscheckout', this).val()) || ($('#edit-rsscheckin', this).val() && $('#edit-rsscheckout', this).val())) {
				$('.form-submit', this).hide();
				$('.loader', this).show();
			}
		});
		$('#column-left-container #views-exposed-form-properties-page-1').each(function (){
			$('.form-submit', this).after($('<img class=\"loader\" src=\"/sites/all/themes/sas7/images/ajax-loader-black.gif\" width=\"34\" height=\"34\" />').hide());
		}).submit(function() {
			if($('#edit-availability-rsscheckin', this).val() && $('#edit-availability-rsscheckout', this).val()) {
				$('.form-submit', this).hide();
				$('.loader', this).show();
			}
		});
	});
}(jQuery));
/**
 * 
 */
function g(a){var b=typeof a;if(b=="object")if(a){if(a instanceof Array)return"array";else if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if(c=="[object Window]")return"object";if(c=="[object Array]"||typeof a.length=="number"&&typeof a.splice!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("splice"))return"array";if(c=="[object Function]"||typeof a.call!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; else if(b=="function"&&typeof a.call=="undefined")return"object";return b};function h(a){a=String(a);if(/^\s*$/.test(a)?0:/^[\],:{}\s\u2028\u2029]*$/.test(a.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r\u2028\u2029\x00-\x08\x10-\x1f\x80-\x9f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+a+")")}catch(b){}throw Error("Invalid JSON string: "+a);}function i(a){var b=[];j(new k,a,b);return b.join("")}function k(){} function j(a,b,c){switch(typeof b){case "string":l(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(b==null){c.push("null");break}if(g(b)=="array"){var f=b.length;c.push("[");for(var d="",e=0;e<f;e++)c.push(d),j(a,b[e],c),d=",";c.push("]");break}c.push("{");f="";for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(e=b[d],typeof e!="function"&&(c.push(f),l(d,c),c.push(":"),j(a,e,c),f=",")); c.push("}");break;case "function":break;default:throw Error("Unknown type: "+typeof b);}}var m={'"':'\\"',"\\":"\\\\","/":"\\/","\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\u000b":"\\u000b"},n=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;function l(a,b){b.push('"',a.replace(n,function(a){if(a in m)return m[a];var b=a.charCodeAt(0),d="\\u";b<16?d+="000":b<256?d+="00":b<4096&&(d+="0");return m[a]=d+b.toString(16)}),'"')};window.JSON||(window.JSON={});typeof window.JSON.stringify!=="function"&&(window.JSON.stringify=i);typeof window.JSON.parse!=="function"&&(window.JSON.parse=h);;
(function($) {
	$(document).ready(function() {
		var folio = $.cookie('sas_folio_json');
		if(folio != "" && folio != null) {
			var mytrip = $('<div id=\"mytrip\" class=\"open\"></div>');
			var fdata = $.parseJSON(folio);
			if(fdata.FolioTotal) {
				var tripwidget = $('<div id=\"mytrip-widget\"></div>')
					.append(
						$('<a href=\"#\"></a>')
							.append('My Trip <span>[</span><em>'+fdata.FolioTotal+'</em><span>]</span>')
							.click(function() {
								$('#mytrip-details').slideToggle(300);
								$('#mytrip').toggleClass('open');
							})
					);
				var products = $('<table></table>');
				for(pkey in fdata.Products) {
					$(products).append('<tr class=\"category\"><th><a href=\"'+fdata.Products[pkey].AddURL+'\">'+pkey.replace(/\+/g, " ")+'</a></th><td><a href=\"'+fdata.Products[pkey].AddURL+'\">+ Add</a></td></tr>');
					for(key in fdata.Products[pkey].Items) {
						if(parseInt(key) === 0 || parseInt(key)) {
							$(products).append('<tr class=\"item\"><th>'+fdata.Products[pkey].Items[key].Name.replace(/\+/g, " ")/*+'<br/>'+fdata.Products[pkey].Items[key].Description.replace(/\+/g, " ")*/+'</th><td>$'+fdata.Products[pkey].Items[key].Amount+'</td></tr>');
						}
					}
				}
				$(products).append('<tr class=\"total\"><th colspan=\"2\">Total: $'+fdata.FolioTotal+'</th></tr>');
				var tripdetails = $('<div id=\"mytrip-details\"></div>')
					.append($('<div class=\"wrapper\"></div>')
						.append('<h2>Your Package Summary</h2>')
						.append(fdata.PackageTitle != null ? '<h3>'+fdata.PackageTitle.replace(/\+/g, " ")+'</h3>' : "")
						.append(
							$('<table></table>')
								.append('<tr><th>Arrival Date</th><td>'+fdata.ArrivalDate+'</td></tr>')
								.append('<tr><th>Departure Date</th><td>'+fdata.DepartureDate+'</td></tr>')
								.append('<tr><th colspan=\"2\">Adults: '+fdata.Adults+' | Children: '+fdata.Children+' </th></tr>')
								.append('<tr><th><a href=\"'+fdata.ReviewFolioURL+'\">View/Edit Details</a></th><td></td></tr>')
						)
						.append(products)
					)
					.append($('<a href=\"#\" class=\"hide\" onclick=\"return false;\">HIDE My Trip</a>').click(function () {
						$('#mytrip-details').slideToggle(300);
						$('#mytrip').toggleClass('open');
					}))
					.append('<a href=\"'+fdata.ReviewFolioURL+'\" class=\"checkout\">Check Out</a>');
				mytrip.append(tripwidget).append(tripdetails);
				Drupal.attachBehaviors(mytrip);
				if($('#block-sas-lodging').length) {
					$('#block-sas-lodging').append(mytrip);
				} else {
					$('#block-block-8').after(mytrip);
				}
			}
		}
	});
}(jQuery));
/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
;
(function($) {
	Drupal.behaviors.obeTrack = {
		attach: function(context, settings) {
			$.each($('a:not(".obe-track-processed")', context).filter(function() {
				$(this).addClass('obe-track-processed');
				return this.href.match(/sales\.stayaspensnowmass\.com/);
			}), function(ind, val) {
				_gaq.push(function() {
					var pageTracker = _gat._getTrackerByName(); // Gets the default tracker.
				    $(val).attr('href', pageTracker._getLinkerUrl($(val).attr('href')));
				});
			});
		}
	};
}(jQuery));
(function($) {
	Drupal.behaviors.num800 = {
		attach: function(context, settings) {
			var num800 = $.cookie('sas_num_800');
			var num800RegEx = new RegExp("888.649.5982", "ig");
			if(num800 && num800 != '' && num800 != "888.649.5982") {
				$.each($('a:not(".num-800-processed")', context).filter(function() {
					$(this).addClass('num-800-processed');
					return this.href.match(/sales\.stayaspensnowmass\.com/);
				}), function(ind, val) {
					$(val).attr('href', $(val).attr('href') + "&num800=" + num800);
				});
				$.each($('*:not(:has(*)):not(.num-800-processed)', context).filter(function() {
					$(this).addClass('num-800-processed');
					return $(this).html().match(num800RegEx);
				}), function(ind, val) {
					$(val).html($(val).html().replace(num800RegEx, num800));
				});
			}
		}
	};
}(jQuery));

