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 3;7 w(5,k,6){f(3&&3.M==o){3.N();3=m.G(5,k,6);3.l()}p{3=m.G(5,k,6);3.l()}}7 v(5,9,8){4 6;f((9==\'\')||(8==\'\')){6="L=2,a=2,K=2,I=2,u=2,B=d,y=d,A=c,C=c,z=P,x=O"}p{9+=H;8+=H;6="L=2,a=2,K=2,I=2,u=2,B=d,y=d,A=c,C=c,z="+9+",x="+8}w(5,\'X\',6);3.l()}7 Y(5,9,8){v(5,9,8);g o}7 10(D){4 E=m.a.S.R(1);4 h=E.F("&");Q(4 i=0;i<h.V;i++){4 j=h[i].F("=");f(j[0]==D){g j[1]}}g}7 T(n){4 b=a.q;f(b.U(\'?\')>-1)b+=\'&J=\'+n;p b+=\'?J=\'+n;a.q=b}7 Z(e){4 r=$(e).t(\'r\');4 s=$(e).t(\'q\');$(e).W(r,s);g o}',62,63,'||no|objChildWindow|var|strURL|strOptions|function|intHeight|intWidth|location|url|100|yes|aTag|if|return|vars||pair|objWin|focus|window|lang|false|else|href|title|link|attr|menubar|openNewWin|doChildWindow|height|resizable|width|left|scrollbars|top|variable|query|split|open|45|status|language_switch|directories|toolbar|closed|close|345|615|for|substring|search|getURLForSwitchLanguage|indexOf|length|OpenPopup|child_window|openNewWindow|openPopupLayer|getQueryVariable'.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 = '#';

	//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();}

		$(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
		});
		
		//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');
		}
	}); 
};

$.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();
		for(var i=start_index;i<max_index;i++) {
			jq.parent().find('.visible_items').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();
	}
  }); 
};
