﻿$(document).ready(function() {

//grab all the anchor tag with rel set to shareit
$('a[rel=shareit], #shareit-box').mouseenter(function() {

//get the height, top and calculate the left value for the sharebox
var height = $(this).height();
var top = $(this).offset().top;

//get the left and find the center value
var left = $(this).offset().left + ($(this).width() /1) - ($('#shareit-box').width() / 2);

//grab the href value and explode the bar symbol to grab the url and title
//the content should be in this format url|title
var value = $(this).attr('href').split('|');

//assign the value to variables and encode it to url friendly
var field = value[0];
var url = encodeURIComponent(value[0]);
var title = encodeURIComponent(value[1]);

//assign the height for the header, so that the link is cover
$('#shareit-header').height(height);

//display the box
$('#shareit-box').show();

//set the position, the box should appear under the link and centered
$('#shareit-box').css({'top':top, 'left':left});

//assign the url to the textfield
$('#shareit-field').val(field);

//make the bookmark media open in new tab/window
$('a.shareit-sm').attr('target','_blank');

});

//onmouse out hide the shareit box
$('#shareit-box').mouseleave(function () {
$('#shareit-field').val('');
$(this).hide();
});

//hightlight the textfield on click event
$('#shareit-field').click(function () {
$(this).select();
});
});








/* Tabл */ 
$(document).ready(function() {	
  //Get all the LI from the #tabMenu UL
  $('#tabMenu > li').click(function(){
    //remove the selected class from all LI    
    $('#tabMenu > li').removeClass('selected');
    //Reassign the LI
    $(this).addClass('selected');
    //Hide all the DIV in .boxBody
    $('.boxBody div').slideUp('1500');
    //Look for the right DIV in boxBody according to the Navigation UL index, therefore, the arrangement is very important.
    $('.boxBody div:eq(' + $('#tabMenu > li').index(this) + ')').slideDown('1500');
  }).mouseover(function() {
    //Add and remove class, Personally I dont think this is the right way to do it, anyone please suggest    
    $(this).addClass('mouseover');
    $(this).removeClass('mouseout');   
  }).mouseout(function() {
    //Add and remove class
    $(this).addClass('mouseout');
    $(this).removeClass('mouseover');    
  });
  //Mouseover with animate Effect for Category menu list
  $('.boxBody #category li').mouseover(function() {
    //Change background color and animate the padding
    $(this).css('backgroundColor','#555555');
    $(this).children().animate({paddingLeft:"20px"}, {queue:false, duration:300});
  }).mouseout(function() {
    //Change background color and animate the padding
    $(this).css('backgroundColor','');
    $(this).children().animate({paddingLeft:"0"}, {queue:false, duration:300});
  });  
  //Mouseover effect for Posts, Comments, Famous Posts and Random Posts menu list.
  $('.boxBody li').click(function(){
    window.location = $(this).find("a").attr("href");
  }).mouseover(function() {
    $(this).css('backgroundColor','#555555');
  }).mouseout(function() {
    $(this).css('backgroundColor','');
  });  	
});

/* ʾرղ */ 
jQuery(document).ready(function($){
	$('#close-sidebar a').toggle(function(){
	$(this).css('backgroundImage','url(/THEMES/EasyBule/STYLE/EasyBule/eb_tips_close.gif)');
	$('#sidebar').hide();
	$('#shop').animate(1000);
	$('#column').animate({width: "945px"}, 1000);
	},function(){
	$(this).css('backgroundImage','url(/THEMES/EasyBule/STYLE/EasyBule/eb_tips_open.gif)');
	$('#shop').animate(1000);
	$('#column').animate({width: "675px"}, 800, function(){$('#sidebar').show();});
});
/* » */ 
	var s= $('#shop').offset().top; 
	$(window).scroll(function (){ 
	$("#shop").animate({top : $(window).scrollTop() + s + "px" },{queue:false,duration:500});	
});
	$('#goheader').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);}); 
	$('#gocolumn').click(function(){$('html,body').animate({scrollTop:$('#gocolumn').offset().top}, 800);});
	$('#gofooter').click(function(){$('html,body').animate({scrollTop:$('#footer').offset().top}, 800);});
	});
/*  */
	$(function() {
		//run the currently selected effect
		function runEffect(){
			//get effect type from 
			var selectedEffect = $('#effectTypes').val();
			
			//most effect types need no options passed by default
			var options = {};
			//check if it's scale or size - they need options explicitly set
			if(selectedEffect == 'scale'){  options = {percent: 0}; }
			else if(selectedEffect == 'size'){ options = { to: {width: 200,height: 60} }; }
			
			//run the effect
			$("#effect").toggle(selectedEffect,options,500);
		};
		
		//set effect from select menu value
		$("#button").click(function() {
			runEffect();
			return false;
		});

	});
