var sbp = _7BP.augment({
	emphasize: {'class': 'highlight'},
	deemphasize: {'class': 'reduce'}
}).deferredApply();

var sbpWI = _7BP.augment({
	emphasize: {'class': 'highlight', behavior: _7BP.behavior.wrapInner},
	deemphasize: {'class': 'reduce', behavior: _7BP.behavior.wrapInner}
}).deferredApply();

var sbpW = _7BP.augment({
	emphasize: {'class': 'highlight', behavior: _7BP.behavior.wrap},
	deemphasize: {'class': 'reduce', behavior: _7BP.behavior.wrap}
}).deferredApply();

var sbpWD = _7BP.augment({
	emphasize: {'class': 'highlight', behavior: _7BP.behavior.wrap, data: "<div>"},
	deemphasize: {'class': 'reduce', behavior: _7BP.behavior.wrap, data: "<div>"}
}).deferredApply();

var sbp_panel = _7BP.augment({
	emphasize: {'class': 'highlight'},
	deemphasize: {behavior: _7BP.behavior.panelize, data: {content: {collapsed: {style: {position: "absolute", top: "-600"}}}}}
}).deferredApply();

// --- booking page ---
if (/hirecars\.co\.uk(:\d+)?\/.*\/booking\.php\?book=/.test(document.location.href)) {
	_7BP.augment({
		process: {behavior: function(elem) {
		  _7BP.jQuery(elem).each(function(idx){
				_7BP.jQuery(this).addClass('highlight').find('.sbp_step_img').show();
			});
		}},
		balanced: {behavior: function(elem) {
		  _7BP.jQuery(elem).each(function(idx){
				_7BP.jQuery(this).addClass('highlight').find('.sbp_step_img').show();
			});
		}}
	}).deferredApplyAll().presentation(".sbp_steps");

	_7BP.augment({
		safety: {behavior: function(elem) {
		  _7BP.jQuery(elem).before('<div id="sbp_lock_banner">This page and all transactions are secure.<img src="/images/7bp/lock.gif"</div>');
		}}
	}).deferredApplyAll().motivation("#cookieTrail");
	
	_7BP.augment({
		other: {behavior: function(elem) {
		  _7BP.jQuery(elem).attr('src', '/images/7bp/click_to_book_narrow.gif').up(2).addClass('highlight');
		}},
		balanced: {behavior: function(elem) {
		  _7BP.jQuery(elem).attr('src', '/images/7bp/click_to_book_narrow.gif').up(2).addClass('highlight');
		}},
		"self": {behavior: function(elem) {
		  _7BP.jQuery(elem).attr('src', '/images/7bp/book_your_car.gif');  
		}}
	}).deferredApplyAll().decision("#bookButton>a>img");

	_7BP.augment({
		"self": {behavior: function(elem) {
		  _7BP.jQuery('#bookingReviewsContainer>img').prependTo(_7BP.jQuery(elem).addClass('reduce'));
			_7BP.jQuery(elem).find('img:first').after('<img src="/wp-content/themes/hirecars/images/review3.gif"/>');
		}}
	}).deferredApplyAll().decision("#sbp_bottomreviews");

	_7BP.augment({
		other: {behavior: function(elem) {
			var img_loc = "/images/7bp/yellownote_2.gif";
			var sbp_port = _7BP.WebLegend.portrait().toLowerCase();
			if(sbp_port) {
				if(sbp_port == 'alex' || sbp_port == 'darshan') {
					img_loc = "/images/7bp/new_postit_promo.gif";
				}
			}
			_7BP.jQuery(elem).addClass('highlight').before('<img id="sbp_postit_bottom" src="'+img_loc+'"/>');
		}},
		balanced: {behavior: function(elem) {
			_7BP.jQuery(elem).addClass('highlight').before('<img id="sbp_postit_bottom" src="/images/7bp/new_postit_promo.gif"/>');
		}}
	}).deferredApplyAll().decision("#priceContainer");

	_7BP.augment({
		safety: {behavior: function(elem) {
		  _7BP.jQuery(elem).text('Secure Payment Details');
		}},
		balanced: {behavior: function(elem) {
		  _7BP.jQuery(elem).text('Secure Payment Details');
		}}
	}).deferredApplyAll().motivation(".sbp_steps>span:contains('Payment details')");

	_7BP.augment({
		choice: {behavior: function(elem) {
		  _7BP.jQuery(elem).text('Choose your rental extras.');
		}},
		balanced: {behavior: function(elem) {
		  _7BP.jQuery(elem).text('Choose your rental extras.');
		}}
	}).deferredApplyAll().presentation(".sbp_steps>span:contains('Rental Extras')");

	_7BP.augment({
		other: {behavior: function(elem) {
		  _7BP.jQuery(elem).addClass("highlight")
		}},
		"self": {behavior: function(elem) {
		  _7BP.jQuery(elem).addClass("reduce");
		}},
		balanced: {behavior: function(elem) {
		  _7BP.jQuery(elem).addClass("reduce");
		}}
	}).deferredApplyAll().decision("#sbp_postitreviews");

  _7BP.augment({
  	process: {behavior: function(elem) {
  	  _7BP.jQuery(elem).addClass("highlight")
  	}},
  	choice: {behavior: function(elem) {
  	  _7BP.jQuery(elem).addClass("reduce");
  	}},
  	balanced: {behavior: function(elem) {
  	  _7BP.jQuery(elem).addClass("balanced");
  	}}
  }).deferredApplyAll().presentation("#sbp_postitsteps");

  _7BP.augment({
  	opportune: {behavior: function(elem) {
  	  _7BP.jQuery(elem).addClass("highlight")
  	}},
  	safety: {behavior: function(elem) {
  	  _7BP.jQuery(elem).addClass("reduce");
  	}},
  	balanced: {behavior: function(elem) {
  	  _7BP.jQuery(elem).addClass("balanced");
  	}}
  }).deferredApplyAll().motivation("#sbp_postitopp");

} else 	if (/www\.hirecars\.co\.uk(:\d+)?\/(#|$|\?.*)/.test(document.location.href)) {
	
	_7BP.augment({
		emphasize: {behavior: function(elem) {
		  _7BP.jQuery(elem).addClass('sbp_s');
		}},
		deemphasize: {behavior: function(elem) {
			_7BP.jQuery(elem).addClass('sbp_o');
		}}
	}).deferredApplyAll().search("#page");

	_7BP.augment({
		self: {behavior: function(elem) {
		  _7BP.jQuery(elem).wrap('<div style="text-align:center; width:828px;"></div>');
		}}
	}).deferredApplyAll().decision("#sbp_banner_img");

	_7BP.augment({
		emphasize: {behavior: function(elem) {
		  var item = _7BP.jQuery(elem);
			item.css({'width': '824px', 'background-image': 'url('+ _7BP.urlForClientResource('/images/7bp/booking_form_wide_bg.png') + ')', 'font-size': '12px'});
			item.find('div.form_left').css('margin-left', '129px');
			item.find('#searchBtn').css({'width':'149px', 'height':'29px', 'margin-right':'242px'});
			item.find('#searchBtn>input').attr('src', _7BP.urlForClientResource('/images/7bp/searchbutton_arrow.gif'));
		}},
		deemphasize: {behavior: function(elem) {}}
	}).deferredApplyAll().search("#form_left");

	_7BP.augment({
		self: {behavior: function(elem) {
		  _7BP.jQuery(elem).hide();
		}},
    other: {behavior: function(elem) {
			var port = _7BP.WebLegend.portrait().toLowerCase();
			var img_name = "";
			if(port == 'darshan' || port == 'fiona') {
			  img_name = "hc_hp_postit_darshan.png";
			} else {
			  img_name = "hc_hp_postit_evan.png";
			}
			if (img_name != "") {
 		    _7BP.jQuery(elem).css("background-image", "url(" + _7BP.urlForClientResource("/images/7bp/") + img_name + ")");
 		    _7BP.jQuery("#sbp_reviews_header").hide();
 		  }
 		  else {
 		    _7BP.jQuery(elem).hide();
 		  }
		}},
    balanced: {behavior: function(elem) {
	    _7BP.jQuery(elem).css("background-image", "url(" + _7BP.urlForClientResource("/images/7bp/hc_hp_postit_evan.png") + ")");
	    _7BP.jQuery("#sbp_reviews_header").hide();
		}}
	}).deferredApplyAll().decision("#postit");

	_7BP.augment({
		emphasize: {behavior: function(elem) {
			_7BP.jQuery(elem).before('<div id="sbp_secure"><img src="' + _7BP.urlForClientResource('/images/7bp/secure_logos.gif') + '"/></div>');
			_7BP.jQuery('#secureHome>img').prependTo('#sbp_secure');
		}},
		deemphasize: {behavior: function(elem) {}}
	}).deferredApplyAll().search("#content.sbp_mod_content>div.post");

	_7BP.augment({
		emphasize: {behavior: function(elem) {
			_7BP.jQuery(elem).show();
		}},
		deemphasize: {behavior: function(elem) {
			_7BP.jQuery(elem).up(1).find('#sbp_under_promo_rachel').show();
		}}
	}).deferredApplyAll().steps("#sbp_under_promo_leo");

	_7BP.augment({
		emphasize: {behavior: function(elem) {
			_7BP.jQuery(elem).show();
		}},
		deemphasize: {behavior: function(elem) {}}
	}).deferredApplyAll().search("#sbp_under_promo");
	
} else if (/hirecars\.co\.uk(:\d+)?\/.*\/search\.php/.test(document.location.href)) {
	_7BP.augment({
		self: {behavior: function(elem) {
			var item = _7BP.jQuery(elem);
		  var txt = item.text();
			txt = txt.replace(/^We.*have/, 'You Decide:');
			txt = txt.replace(/\.$/, ' meet your criteria.');
			item.text(txt);
		}}
	}).deferredApplyAll().decision("#barSmallText");

	_7BP.augment({
		other: {behavior: function(elem) {
		  var e = _7BP.jQuery(elem);
			e.css({width: "318px", overflow: "hidden"});
			e.before("<div class='sbp_browse_review'><img src='" + _7BP.urlForClientResource("/images/7bp/customer_jane_narrow.gif") + "'></div>");
			_7BP.jQuery("#searchResultsMap>iframe").attr("width", "318");
		}}
	}).deferredApplyAll().decision("#searchResultsMap");
	
	_7BP.augment({
		self: {behavior: function(elem) {
		  _7BP.jQuery(elem).text("Which Deal is Right for You?");
	  }},
		other: {behavior: function(elem) {
		  _7BP.jQuery(elem).text("Deals for You");
		}},
		balanced: {behavior: function(elem) {
		  _7BP.jQuery(elem).text("Which Deal is Right for You?");
		}}
	}).deferredApplyAll().decision("#sbp_browse_deals");

	_7BP.augment({
		choice: {behavior: function(elem) {
		  _7BP.jQuery(elem).attr("src", _7BP.urlForClientResource("/images/7bp/choose_button.gif"));
		}},
		balanced: {behavior: function(elem) {
		  _7BP.jQuery(elem).attr("src", _7BP.urlForClientResource("/images/7bp/choose_button.gif"));
		}}
	}).deferredApplyAll().presentation("img[src*=book.gif]");

	_7BP.augment({
		other: {behavior: function(elem) {
			_7BP.jQuery('#sbp_cust_fav').show();
		}},
		self: {behavior: function(elem) {
			_7BP.jQuery('#sbp_best_deal').show();
		}},
		balanced: {behavior: function(elem) {
			_7BP.jQuery('#sbp_best_deal').show();
		}}	
	}).deferredApplyAll().decision("table.cars>tbody");
	
}

