/* attempt to find a text selection */
function getSelected() {
	if(window.getSelection) { return window.getSelection(); }
	else if(document.getSelection) { return document.getSelection(); }
	else {
		var selection = document.selection && document.selection.createRange();
		if(selection.text) { return selection.text; }
		return false;
	}
	return false;
}
$(document).ready(function() {
  //BlockLoaded
  var url = 'http://foo.iskandar.web.id/result.html?cx=partner-pub-5869772765119979%3A68fn8iq1wl8&cof=FORID%3A10&ie=UTF-8&q={term}&search.x=0&search.y=0', selectionImage;
	$('#left').mouseup(function(e) {
		var selection = getSelected();
		if(selection && (selection = new String(selection).replace(/^\s+|\s+$/g,''))) {
			//ajax here { http://davidwalsh.name/text-selection-ajax }
			if(!selectionImage) {
				selectionImage = $('<a>').attr({
					href: url,
					title: 'Click here to know more related this keyword',
					target: '',
					id: 'selection-image'
				}).hide();
				$(document.body).append(selectionImage);
			}
			selectionImage.attr('href',url.replace('{term}',encodeURI(selection))).css({
				top: e.pageY - 30,	//offsets
				left: e.pageX - 13 //offsets
			}).fadeIn();
		}
	});
	$(document.body).mousedown(function() {
		if(selectionImage) { selectionImage.fadeOut(); }
	});
  // Accordion
  $("#accordion").accordion({
            autoHeight: true,
            fillSpace: false,
            collapsible: true,
            clearStyle: true,
            active: false,
            animated: 'bounceslide',
			icons: {
    			header: "ui-icon-circle-arrow-e",
   				headerSelected: "ui-icon-circle-arrow-s"
			}

		});
  // Tabs
  $('#tabs').tabs({fx: {opacity: "toggle",duration: "medium",collapsible: true}})/*.find(".ui-tabs-nav").sortable({axis:'x'});*/
  $.prettySociable();

  //slider Top
  $("#slider").easySlider({
  auto: true,
  continuous: true,
  numeric: true,
  controlsShow:false,
  /*controlsBefore: 'Previous Slide',
  controlsAfter: 'Next Slide'*/
  });

    /*$("ul#topnav li").hover(function() { //Hover over event on list item
	$(this).css({ 'background' : 'background: #b70808 url(images/active-menu.png) repeat-x left top'}); //Add background color + image on hovered list item
	$(this).find("span").show(); //Show the subnav
    } , function() { //on hover out...
	$(this).css({ 'background' : 'background: #b70808 url(images/active-menu.png) repeat-x left top'}); //Ditch the background
	$(this).find("span").hide(); //Hide the subnav
    });*/

  meerkat({
		close: '.close',
		dontShow: '.dont-show',
		animation: 'slide',
		animationSpeed: 500,
		dontShowExpire: 0,
		removeCookie: '.remove-cookie',
		meerkatPosition: 'bottom',
		background: '#2e2a22',
		height: '110px'
  });

//Slidder Buttom
    $('img.menu_class').click(function () {
	$('ul.the_menu').slideToggle('medium');
    });
/*    $("ul.the_menu").parent(); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav

	$("img.menu_class").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.the_menu").slideDown('slow').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.the_menu").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("linkhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("linkhover"); //On hover out, remove class "subhover"
	});*/
    var doFadeIn = function() {
		$('.fadein').css({ opacity:0, visibility:'visible'}).fadeTo(250,1);
	};
	$('body').one('mousemove',doFadeIn);
	$('#s').one('blur',doFadeIn);

});
<!--
function popup(mylink, retweet)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, retweet, 'width=980,height=400,left=5,top=100,scrollbars=yes');
return false;
}
//-->

//<![CDATA[
$(function(){
$('a[href*=#top]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 1000);
return false;
}
}
});
});
//]]>

this.tooltip = function(){
	/* CONFIG */
		xOffset = 10;
		yOffset = 20;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
	/* END CONFIG */
	$("a.tooltip").hover(function(e){
		this.t = this.title;
		this.title = "";
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$("#tooltip").remove();
    });
	$("a.tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
};

// starting the script on page load
$(document).ready(function(){
	tooltip();
});

/* jquery */
$.fn.nudge = function(params) {
	//set default parameters
	params = $.extend({
		amount: 20,
		duration: 300,
		property: 'padding',
		direction: 'left',
		toCallback: function() {},
		fromCallback: function() {}
	}, params);
	//For every element meant to nudge...
	this.each(function() {
		//variables
		var $t = $(this);
		var $p = params;
		var dir = $p.direction;
		var prop = $p.property + dir.substring(0,1).toUpperCase() + dir.substring(1,dir.length);
		var initialValue = $t.css(prop);
		/* fx */
		var go = {}; go[prop] = parseInt($p.amount) + parseInt(initialValue);
		var bk = {}; bk[prop] = initialValue;

		//Proceed to nudge on hover
		$t.hover(function() {
					$t.stop().animate(go, $p.duration, '', $p.toCallback);
				}, function() {
					$t.stop().animate(bk, $p.duration, '', $p.fromCallback);
				});
	});
	return this;
};

/* jquery usages */
$(document).ready(function() {
	/* usage 1 */
	$('#nudgeUs li a').nudge();
	/* usage 2 */
	$('#nudgeUs2 li a').nudge({
		property: 'margin',
		direction: 'left',
		amount: 30,
		duration: 400,
		toCallback: function() { $(this).css('color','#f00'); },
		fromCallback: function() { $(this).css('color','#000'); }
	});
});