eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('4 6;7 D(8,r,9){a(6&&6.1b==m){6.S();6=l.C(8,r,9);6.p()}g{6=l.C(8,r,9);6.p()}}7 z(8,b,c){4 9;a((b==\'\')||(c==\'\')){9="I=5,d=5,B=5,J=5,H=5,G=h,K=h,P=j,M=j,w=Q,v=R"}g{b+=F;c+=F;9="I=5,d=5,B=5,J=5,H=5,G=h,K=h,P=j,M=j,w="+b+",v="+c}D(8,\'T\',9);6.p()}7 16(8,b,c){z(8,b,c);f m}7 17(N){4 y=l.d.15.13(1);4 n=y.L("&");14(4 i=0;i<n.q;i++){4 o=n[i].L("=");a(o[0]==N){f o[1]}}f}7 1a(){4 3=18.19.W(\'X.U\');a(3!=V&&3!=""){a(3.O(\'"\')==0&&3.Y(\'"\')==3.q-1){3=3.11(1,3.q-2)}}g{3=""}f 3}7 12(u){4 e=d.s;a(e.O(\'?\')>-1)e+=\'&x=\'+u;g e+=\'?x=\'+u;d.s=e}7 Z(k){4 t=$(k).E(\'t\');4 A=$(k).E(\'s\');$(k).10(t,A);f m}',62,74,'|||mediaCode|var|no|objChildWindow|function|strURL|strOptions|if|intWidth|intHeight|location|url|return|else|yes||100|aTag|window|false|vars|pair|focus|length|objWin|href|title|lang|height|width|language_switch|query|openNewWin|link|directories|open|doChildWindow|attr|45|scrollbars|menubar|toolbar|status|resizable|split|top|variable|indexOf|left|615|345|close|child_window|sourceCode|null|cookie|bose|lastIndexOf|openPopupLayer|OpenPopup|substr|getURLForSwitchLanguage|substring|for|search|openNewWindow|getQueryVariable|Bose|statistics|getMediaCode|closed'.split('|'),0,{}))
// ***
// PopupLayer Plug-in function
// ***
$.fn.OpenPopup = function(title, link) {
	//read settings or take defaults
	var w = 800;
	var h = 600;
	var modal = true;
	var drag = true;
	var linkText = '';
	var linkUrl = '#';
	var popupDestroy = false;
	var pagination = 0;

	//Check if popup already exists (and reopen)
	var uniqueId = escape(link);
	var dialog = $("[rel='" + uniqueId  + "']");
	if (dialog.size() > 0) {

		dialog.find('.pagination > a').each(function() {
		 if ($(this).text() == 1) {$(this).click(); return;}
		});
		
		if (dialog.find('.ui-extraborder.fix').size() > 0) {
			h = dialog.find('.ui-extraborder.fix').css('height');
			h = h.substring(0,h.length - 2)*1;
			dialog.find('.ui-extraborder.fix').css('height', (h-35) + 'px').removeClass('fix');
		}
		dialog.dialog('open');
		//fix size layout issue (prevent the middle white block from being too long when the width is very small)
		dialog.find('.ui-extraborder').parent().css('height','auto');
		return false;
	}
	
	//Create new popup
	$('body').append('<div class="popup_layer display-none" rel="' + uniqueId + '"><div class="ui-extraborder"></div></div>');
	$("[rel="+uniqueId+"] .ui-extraborder").load(link, {popup:1}, function(response, status, xhr) {
	
		if (status == "error") {
 			$(this).html(xhr.status + " " + xhr.statusText);
			w=300;h=300;
		}

		//Determine title
		if ($(this).find(".popupTitle").size() > 0) {
			title = $(this).find(".popupTitle").text();
			$(this).find(".popupTitle").remove();
		}

		//Determine style
		var style = 'default';
		if ($(this).find(".popup-style").size() > 0) {
			style = $(this).find(".popup-style").text();
		}
		
		//determine overrules settings
		if ($(this).find(".popup-height").size() > 0) {
			h = $(this).find(".popup-height").text() * 1;}
		if ($(this).find(".popup-width").size() > 0) {
			w = $(this).find(".popup-width").text() * 1;}
		if ($(this).find(".popup-modal").size() > 0) {
			modal = ($(this).find(".popup-modal").text() == 1);}
		if ($(this).find(".popup-draggable").size() > 0) {
			drag = ($(this).find(".popup-draggable").text() == 1);}

		if ($(this).find(".link-text").size() > 0) {
			linkText = $(this).find(".link-text").text();}
		if ($(this).find(".link-url").size() > 0) {
			linkUrl = $(this).find(".link-url").text();}
		if ($(this).find(".popup-destroy").size() > 0) {
			popupDestroy = $(this).find(".popup-destroy").text() == "true";}
		if ($(this).find(".pagination").size() > 0) {
			pagination = $(this).find(".pagination").text() * 1;}

		$(this).css('height', (h-60) + 'px');
		
		//Open dialog
		$(this).parent().dialog({
			title: title,
			height: h, 
			width: w, 
			modal: modal,
			autoOpen: true, 
			resizable: false, 
			draggable: drag,
			destroy: popupDestroy,
			close: function(event, ui) {
				if (popupDestroy) {
				   $(this).dialog("destroy");
				   $(this).remove();
				}
			            }
		});
		
		//fix size layout issue (prevent the middle white block from being too long when the width is very small)
		var dialog = $("[rel='" + uniqueId  + "']");
		dialog.find('.ui-extraborder').parent().css('height','auto');
		
		if (title == "") {
		dialog.find('.ui-extraborder').parent().parent().find('span.ui-dialog-title').css('display', 'none');
		}

		var parentNode = $(this).parent().parent();
		parentNode.addClass('popup-style-' + style);
		if (linkText.length > 0) {
			parentNode.append('<div class="ui-call-to-action"><div class="btn_holder btn"><span class="btn_inner"><a href="' + linkUrl + '">' + linkText + '</a></span></div></div>');
			$(this).addClass('fix');
		}

		if (pagination > 0) {
			$(this).ApplyPagination(pagination);
		}

	}); 
};

$.fn.PopupLink = function() {
	this.live('click', function() {
		var title = $(this).attr('title');
		var link = $(this).attr('href');
		
		$(this).OpenPopup(title, link);
		
		//to prevent visiting link as a page.
		return false;
	});
};

// ***
// 'Show more info' button  functions
// ***
$.fn.MoreInfo = function() {
    this.live('click', function(){
      $(this).parent().prev().toggleClass('display-none');
      $(this).toggleClass('more_active');
      return false;
    });
};

$.fn.ConvertToMoreInfo= function() {
   this.addClass("display-none floatstop");
   this.removeClass("readmore");
   this.after('<p><a href="#" title="' + BoseLabels.readmore + '" class="more_info"><span class="more">' + BoseLabels.readmore + '</span><span class="less">' + BoseLabels.minimize + '</span></a></p>');
};

// ***
// Pagination Plug-in function
// ***
$.fn.ApplyPagination = function(items_per_pg) {
	//function that copies a part of the data from hidden div to visible div
	var fnShowItems = function(page_index, jq) {
		var start_index = page_index * items_per_pg;
		var max_index = start_index + items_per_pg;
					
		jq.parent().find('.visible_items').empty();
		var visibleItemsContainer = jq.parent().find('.visible_items');
		for(var i=start_index;i<max_index;i++) {
			visibleItemsContainer.append(jq.parent().find('div.review_container div.review_item:eq('+i+')').clone());
		}
		return false;
	}

	// count entries inside the hidden content
	var num_entries = this.find('div.review_container div.review_item').length;
	
	// skip pagination if element count < items per page
	if (num_entries <= items_per_pg ) {
		fnShowItems(0, this.find(".pagination_container"));
		return false;
	}
	
	//create pagination
	this.find(".pagination_container").pagination(num_entries, {
		items_per_page: items_per_pg,
		num_display_entries: 10,
		next_text : 'Next >',
		next_show_always: true,
		prev_text: '< Previous',
		prev_show_always: true,
		num_edge_entries: 4,
		ellipse_text: '...',
		callback: fnShowItems 
	});
};

// ***
// Hide AVBs Plug-in function
// ***
$.fn.limitAvbBlocks = function(maxCount) {
  var avbs = this.find(".inner .header-avb-block");
  avbs.each(function(index, value) {
	if (index == (maxCount - 1)) {
		$(this).find(".horizontal_divider").remove();
	} else if (index + 1 > maxCount) {
		$(this).remove();
	} else if (index + 1 == avbs.size()) {
		 $(this).find(".horizontal_divider").remove();
	}
  }); 
};
