var SBS={
  _fs: "s",
  init: function(){
    this._fs = (jQuery.cookie('fs') == 'undefined')?"s":jQuery.cookie('fs');
    if(this._fs == "l"){
      this.increase();
    }else{
      $("img#fs").attr("src", baseUrl + "/web/images/icon-font_s.png");
    }
  },
  changeFontSize:function(){
    if(this._fs == "s"){
      this.increase();
      this._fs = "l";
    }else{
      this.reduce();
      this._fs = "s";
    }
    jQuery.cookie('fs', this._fs, 365);
  },
  increase: function(){
    $("img#fs").attr("src", baseUrl + "/web/images/icon-font_l.png");
    this.switching($(".acs"), "acs", "acs_b");
    this.switching($(".acs14"), "acs14", "acs14_b");
    this.switching($(".acs18"), "acs18", "acs18_b");
    this.switching($(".acs24"), "acs24", "acs24_b");
  },
  reduce:function(){
    $("img#fs").attr("src", baseUrl + "/web/images/icon-font_s.png");
    this.switching($(".acs_b"), "acs_b", "acs");
    this.switching($(".acs14_b"), "acs14_b", "acs14");
    this.switching($(".acs18_b"), "acs18_b", "acs18");
    this.switching($(".acs24_b"), "acs24_b", "acs24");
  },
  switching:function(elm, cls_f, cls_t){
    elm.removeClass(cls_f);
    elm.addClass(cls_t);
  },
  apply:function(elm, dct){
    if(elm.length == 0){
      return;
    }

/*
    var fs = parseInt(elm.css("font-size").substr(0,2));
    var ln = parseInt(elm.css("line-height").substr(0,2));
    var fs_ = (dct)?fs+2:fs-2;
    var ln_ = (dct)?ln+2:ln-2;
    elm.css("font-size", fs_ + "px");
    elm.css("line-height", ln_ + "px");
*/
    var fs_ = (dct)?"120%":"100%";
    elm.css("font-size", fs_);
//    elm.css("line-height", ln_);
  },

  printPage: function(baseUrl, print_type, item_id, page) {
	/**
	 * put whatever call you'd like in here, but here's a starter
	 */
	var w = 680;
	var h = 600; 
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	
	var printUrl = baseUrl + '/print/' + print_type + '/';
	if (item_id != null) {
		printUrl = printUrl + item_id + '/';
		
		if (page != null) {
			printUrl = printUrl + 'page/' + page + '/';
		}		
	}

	window.open(printUrl, 'print_view','width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',resizable=yes,scrollbars=yes');
  },
  
  display: function(elm, thum){
    var src = thum.children().attr("src");
    elm.attr("src", src);
    thum.children().addClass("selected");
    thum.addClass("selected_li");
  },
  
  toggleCommentForms: function(elm){
	$('#comment-' + elm).toggle();
	recordStats(siteUrl + 'toggle_commentform/commentid/' + elm);
  },
  
  removeCommentForms: function(elm){
	$('#comment_container').find('.comment-form').html('');
  },
  
  showCommentForm: function(elm){
	$('#form-master').clone().appendTo('#comment-' + elm);
	$('#comment-' + elm).find('.hidden-field').val(elm);
	$('#comment-' + elm).find('action').val(elm);
  }
};

/**
 * parseUri 1.2.1
 * (c) 2007 Steven Levithan <stevenlevithan.com>
 * MIT License
 */
function parseUri (str) {
    var o = parseUri.options,
        m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
        uri = {},
        i   = 14;

    while (i--) uri[o.key[i]] = m[i] || "";

    uri[o.q.name] = {};
    uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
        if ($1) uri[o.q.name][$1] = $2;
    });

    return uri;
};

parseUri.options = {
    strictMode: false,
    key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
    q:   {
        name:   "queryKey",
        parser: /(?:^|&)([^&=]*)=?([^&]*)/g
    },
    parser: {
        strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
        loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
    }
};
