	$.fn.sh = function(options) {
		var op = $.extend({
			h: false,
			time: 2500,
			start: 0
		}, options);
		return this.each(function() {
			var obj = $(this);
			var p = op.h?{0:{left:obj.width(),top:0},1:{left:0},2:{left:-obj.width()-10},3:{left: obj.width()}}:{0:{top: obj.height(),left:0},1:{top:0},2:{top:-obj.height()-10},3:{top:obj.height()}};
			var time = op.time;
			var start = op.start;
			var len = obj.children().length;
			if(len<2) return;
			if(start<0){
				start = Math.floor(Math.random()*len);
			}
			var r = function () {
				obj.children('li').eq(start).animate(p[2],'slow', function() {
					$(this).css(p[3]);
				});
				start = ++start % len; 
				obj.children('li').eq(start).show().animate(p[1],'slow');
			};
			obj.hover(function() {
				clearInterval(Interval);
				Interval=null;
			}, function() {
				if(!Interval)Interval = setInterval(r,time);
			});
			obj.css({position: 'relative', overflow: 'hidden'}).children().css({position: 'absolute', width:obj.width()}).css(p[0]).eq(start).css(p[1]);
			var Interval = setInterval(r,time);
		});
	};

$.fn.reorder = function() {
	var randOrd = function () { return(Math.round(Math.random())-0.5);};
	return($(this).each(function() {
    var $this = $(this);
    var $children = $this.children();
    var childCount = $children.length;
     if (childCount > 1) {
      $children.remove();
       var indices = new Array();
      for (i=0;i<childCount;i++) { indices[indices.length] = i; }
      indices = indices.sort(randOrd);
      $.each(indices,function(j,k) { $this.append($children.eq(k)); });
	}
  }));
};


function updateBookmarks(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			if(this.hash=='#top'){
				$('html,body').animate({scrollTop: 0}, 700);
				return false;			
			}
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 700);
				return false;
			}
		}
	});
}
function bookmark_us(url, title){
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function popUp(s,page,w,h,sc,rs){
s = document.all?s:0;
	if(s){
		return window.showModalDialog(page,null,"dialogHeight:"+h+"px;dialogWidth:"+w+"px;status:no;resizable:"+rs+";scroll:"+sc+";help:no;center:yes")
	}else{
		var cW = window.open(page,'OPBYMY'+w+'_'+h,"height="+h+",width="+w+",left=200,top=150,status=no,toolbar=no,menubar=no,location=no,resizable="+rs+",scrollbars="+sc+",directories=no,titlebar=no");
		cW.window.focus();
	}
}
function l_go(o){
	for (k in o)document.forms.l_f[k].value=o[k];
	document.forms.l_f.submit();
}
function l_pop(o,w){
	var x='';
	$('#l_f :input').each(function(k){x+='&'+this.name+'='+(o[this.name]?o[this.name]:this.value)});
	popUp(w['s'],'?'+x.substr(1),w['w'],w['h'],1,0);
//	popUp(0,'?'+x.substr(1),330,480,1,0);
}
$.fn.fillSelect = function(d, options){
	var op = $.extend({
		value: false,
		blank: false,
		title: true,
		range: false
	}, options);
	return this.each(function() {
		var r = '', v=op.value;
		if(v=='H')v = $(this).html();
		
		if(op.blank)
			r+= '<option></option>';
		if(op.range)
			for(var i=d[0]; i<=d[1]; i++)r+= '<option value="'+i+'"'+(i===v?' selected':'')+'>'+i+'</option>';
		else if(op.title)
			for(var i in d)if(d[i]!=null)r+= '<option value="'+i+'"'+(i===v?' selected':'')+'>'+d[i]+'</option>';
		else
			for(var i in d)if(d[i]!=null)r+= '<option value="'+d[i]+'"'+(d[i]===v?' selected':'')+'>'+d[i]+'</option>';
		
		$(this).html(r).prop('disabled', false);//IE6 .val(op.value)
	});
}


Number.prototype.format = function(p){
	nStr = (p==null?this:this.toFixed(p))+'';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

