function htmlspecialchars_decode (string, quote_style) {
  // http://kevin.vanzonneveld.net
  // +   original by: Mirek Slugen
  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  // +   bugfixed by: Mateusz "loonquawl" Zalega
  // +      input by: ReverseSyntax
  // +      input by: Slawomir Kaniecki
  // +      input by: Scott Cariss
  // +      input by: Francois
  // +   bugfixed by: Onno Marsman
  // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
  // +      input by: Ratheous
  // +      input by: Mailfaker (http://www.weedem.fr/)
  // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
  // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
  // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
  // *     returns 1: '<p>this -> &quot;</p>'
  // *     example 2: htmlspecialchars_decode("&amp;quot;");
  // *     returns 2: '&quot;'
  var optTemp = 0,
    i = 0,
    noquotes = false;
  if (typeof quote_style === 'undefined') {
    quote_style = 2;
  }
  string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
  var OPTS = {
    'ENT_NOQUOTES': 0,
    'ENT_HTML_QUOTE_SINGLE': 1,
    'ENT_HTML_QUOTE_DOUBLE': 2,
    'ENT_COMPAT': 2,
    'ENT_QUOTES': 3,
    'ENT_IGNORE': 4
  };
  if (quote_style === 0) {
    noquotes = true;
  }
  if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
    quote_style = [].concat(quote_style);
    for (i = 0; i < quote_style.length; i++) {
      // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
      if (OPTS[quote_style[i]] === 0) {
        noquotes = true;
      } else if (OPTS[quote_style[i]]) {
        optTemp = optTemp | OPTS[quote_style[i]];
      }
    }
    quote_style = optTemp;
  }
  if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
    string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
    // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
  }
  if (!noquotes) {
    string = string.replace(/&quot;/g, '"');
  }
  // Put this in last place to avoid escape being double-decoded
  string = string.replace(/&amp;/g, '&');

  return string;
}

function social_slider(params) {
	this.params = params;
	this.params.width = parseInt(this.params.width);
	this.params.height = parseInt(this.params.height);
	this.params.padding = parseInt(this.params.padding);
	var obj_show = {};
	obj_show[this.params.side] = "0px";
	var obj_hide = {};
	obj_hide[this.params.side] = - this.params.width - this.params.padding * 2 + "px";
	if (this.params.side == "left") {
		this.params.backside = "right";
	} else {
		this.params.backside = "left";
	}
	var me = this;
	this.create = function () {
		jQuery("#" + this.params.id).remove();
		jQuery("body").append("<div id='" + this.params.id + "' class='slider-box-container'></div>");
		this.element = jQuery("#" + this.params.id);var pos_obj = {};
		var radius = this.params.radius + "px";
		pos_obj["border-top-" + this.params.backside + "-radius"] = radius;
		pos_obj["-moz-border-radius-top" + this.params.backside] = radius;
		pos_obj["border-bottom-" + this.params.backside + "-radius"] = radius;
		pos_obj["-moz-border-radius-bottom" + this.params.backside] = radius;
		this.element.css({
			position: "fixed", 
			top: this.params.top + "px", 
			width: this.params.width + this.params.padding * 2 + "px", 
			height: this.params.height + this.params.padding * 2 + "px", 
			'z-index': "99"
		});
		this.element.css(obj_hide);
		this.element.append("<div id='" + this.params.id + "_world'></div>");
		if(parseInt(this.params.add_background)){
			this.element_world = jQuery("#" + this.params.id + "_world").html("<div style='background-color: white;'>" + this.params.content + "</div>");
		}else{
			this.element_world = jQuery("#" + this.params.id + "_world").html(this.params.content);
		}
		if (this.params.side == "left"){
			this.element_world.css({
				position: "absolute", 
				width: this.params.width + "px", 
				height: this.params.height + 4 + "px", 
				'border-radius': '0 0 ' + radius + ' 0',
				'background-color': "#" + this.params.color, 
				padding: this.params.padding + "px", 
				'z-index': 2
			});
		}else{
			this.element_world.css({
				position: "absolute", 
				width: this.params.width + "px", 
				height: this.params.height + 4 + "px", 
				'border-radius': '0 0 0  ' + radius,
				'background-color': "#" + this.params.color, 
				padding: this.params.padding + "px", 
				'z-index': 2
			});
		}
		if (this.params.shadow == 1) {
			this.element.append("<div id='" + this.params.id + "_shadow'></div>");
			if (this.params.side == "left"){
				jQuery("#" + this.params.id + "_shadow").css({
					position: "absolute", 
					top: 5, 
					left: 10,
					'background-color': "black", 
					'border-radius': '0 0 ' + radius + ' 0',
					opacity: "0.2", 
					width: this.params.width - 10 + "px", 
					height: this.params.height + 4 + "px", 
					padding: this.params.padding + "px", 
					'z-index': 1
				});
			}else{
				jQuery("#" + this.params.id + "_shadow").css({
					position: "absolute", 
					top: 5,
					right: 10,
					'background-color': "black", 
					'border-radius': '0 0 0  ' + radius,
					opacity: "0.2", 
					width: this.params.width - 10 + "px", 
					height: this.params.height + 4 + "px", 
					padding: this.params.padding + "px", 
					'z-index': 1
				});
			}
		}
		this.element.append("<div id=\"" + this.params.id + "_front\"></div>");
		this.front = jQuery("#" + this.params.id + "_front");
		this.front.css({
			position: "absolute", 
			'z-index': 4, 
			width: "40px", 
			height: this.params.tabheight, 
			top: this.params.topbox + "px", 
		});
		pos_obj[this.params.side] = this.params.width + this.params.padding * 2 + 5 + "px";
		this.front.css(pos_obj);
		if (this.params.shadow == 1) {
			this.element.append("<div id=\"" + this.params.id + "_front_shadow\"></div>");
			this.front_shadow = jQuery("#" + this.params.id + "_front_shadow");
			this.front_shadow.css({
				position: "absolute", 
				'z-index': 1, 
				width: "40px", 
				height: this.params.tabheight, 
				top: parseInt(this.params.topbox) + 5 + "px", 
				'background-color': "black", 
				opacity: "0.2"
			});
			this.front_shadow.css(pos_obj);
		}
		this.front.append("<div id=\"" + this.params.id + "_front_front\" class=\"front_front\">" + ( this.params.caption !== undefined ? "<span>" + this.params.caption + "</span>" : '' ) + "</div>");
		if (this.params.side == "left"){
			jQuery("#" + this.params.id + "_front_front").css({
				position: "absolute", 
				top: "0px", 
				left: "-5px",
				width: "100%", 
				height: "100%", 
//				'background-image': "url(plugins/slider/tab_" + this.params.id + ".png)",
				'background-position': "2px 10px",
				'background-repeat': "no-repeat",		
				
			});
		}else{
			jQuery("#" + this.params.id + "_front_front").css({
				position: "absolute", 
				top: "0px", 
				right: "-5px",
				width: "100%", 
				height: "100%", 
				'background-image': "url(plugins/slider/tab_" + this.params.id + ".png)",
				'background-position': "center top",
				'background-repeat': "no-repeat",
			});
		}
		pos_obj[this.params.side] = null;
		jQuery("#" + this.params.id + "_front_front").css(pos_obj);
	};
    
	this.bind = function () {
		this.params.speed = parseInt(this.params.speed);
		jQuery(this.element).find('.front_front').data('hidden', true);
		$(this.element).find('.front_front').click(function () {
			jQuery(this).stop();
			if( jQuery(this).data('hidden') ){
				jQuery(this).closest('.slider-box-container').animate(obj_show, me.params.speed, function () {});
			} else{
				jQuery(this).closest('.slider-box-container').animate(obj_hide, me.params.speed, function () {});
			}
			jQuery(this).data('hidden', !jQuery(this).data('hidden') );
		});
	};
	this.create();
	this.bind();
}

jQuery(document).ready(function(){
	if( social_wiggets_facebook == 1 ) social_slider({'id':'facebook','content':'<iframe src="//www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2F'+social_wiggets_facebook_username+'&amp;width=250&amp;height=290&amp;show_faces=true&amp;colorscheme=light&amp;stream=false&amp;border_color=%23fff&amp;header=true" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:290px;" allowTransparency="true"></iframe>','top':'110','side':'right','topbox':'0','color':'0072D0','width':'252','height':'292','tabheight':'43px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'1'});
	if( social_wiggets_googleplus == 1 ) social_slider({'id':'googleplus','content':htmlspecialchars_decode( social_wiggets_googleplus_code ),'top':'160','side':'right','topbox':'0','color':'ffffff','width':'305','height':'140','tabheight':'43px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'0'});
	if( social_wiggets_pinterest == 1 ) social_slider({'id':'pinterest','content':'<a data-pin-do="embedBoard" href="'+social_wiggets_pinterest_link+'"></a><script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>','top':'210','side':'right','topbox':'0','color':'c9232d','width':'300','height':'261','tabheight':'43px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'0','add_background':'0'});
	if( social_wiggets_twitter == 1 ) social_slider({'id':'twitter','content':htmlspecialchars_decode( social_wiggets_twitter_code ),'top':'260','side':'right','topbox':'0','color':'60B9DC','width':'236','height':social_wiggets_twitter_height,'tabheight':'43px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'0'});
	if( social_wiggets_youtube == 1 ) social_slider({'id':'youtube','content':'<iframe id="fr" frameborder="0" scrolling="no" style="border: 0 none;height: 104px;overflow: hidden;width: 276px;" src="http://www.youtube.com/subscribe_widget?p='+social_wiggets_youtube_username+'">','top':'310','side':'right','topbox':'0','color':'2e2e2e','width':'277','height':'106','tabheight':'43px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'1'});
	if( social_wiggets_gadugadu == 1 ) social_slider({'id':'gadugadu','content':'<iframe width="230" height="320" frameborder="0" src="'+social_wiggets_gadugadu_id+'">','top':'360','side':'right','topbox':'0','color':'C4C4C4','width':'236','height':'325','tabheight':'43px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'0'});
	if( $('#basket-small-container').length > 0 ) social_slider({'id':'basketslider','caption':lang_your_basket,'content':'<div id="basket-small-container">'+$('#basket-small-container').html()+'</div>','top':'130','side':'left','topbox':'0','color':'ffffff','width':'317','tabheight':'159px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'1'});
	$('#column #basket-small-container').remove();
	if( $('#column #basket-fast-container').length > 0 ) social_slider({'id':'fastbasketslider','caption':lang_fast_basket,'content':'<div id="basket-fast-container">'+$('#basket-fast-container').html()+'</div>','top':'300','side':'left','topbox':'0','color':'ffffff','width':'360','tabheight':'204px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'1'});
	$('#column #basket-fast-container').remove();
	if( $('#column #filter').length > 0 ) social_slider({'id':'filterslider','caption':lang_filter,'content':'<form id="filter-slider" action="" method="get">'+$('#filter').html()+'</form>','top':'160','side':'left','topbox':'0','color':'ffffff','width':'320','tabheight':'180px','padding':'2','speed':'1000','shadow':'1','radius':'0','add_background':'1'});
});