$(document).ready(function() {


	$('.home-normal,.home-active').mouseover(function() {
		document.body.style.cursor='pointer';
	});
	$('.home-normal,.home-active').mouseout(function() {
		document.body.style.cursor='default';
	});
	$('.home-normal,.home-active').click(function() {
		window.location.href='/';
	});

	$('.about-normal,.about-active').mouseover(function() {
		document.body.style.cursor='pointer';
	});
	$('.about-normal,.about-active').mouseout(function() {
		document.body.style.cursor='default';
	});
	$('.about-normal,.about-active').click(function() {
		window.location.href='/about/';
	});

	$('.blog-normal,.blog-active').mouseover(function() {
		document.body.style.cursor='pointer';
	});
	$('.blog-normal,.blog-active').mouseout(function() {
		document.body.style.cursor='default';
	});
	$('.blog-normal,.blog-active').click(function() {
		window.location.href='/category/blog-journal/';
	});

	$('.psp-normal,.psp-active').mouseover(function() {
		document.body.style.cursor='pointer';
	});
	$('.psp-normal,.psp-active').mouseout(function() {
		document.body.style.cursor='default';
	});
	$('.psp-normal,.psp-active').click(function() {
		window.location.href='/category/psp/';
	});

	$('.comps-normal,.comps-active').mouseover(function() {
		document.body.style.cursor='pointer';
	});
	$('.comps-normal,.comps-active').mouseout(function() {
		document.body.style.cursor='default';
	});
	$('.comps-normal,.comps-active').click(function() {
		window.location.href='/category/comps/';
	});
	
	$('#header h1').mouseover(function() {
		document.body.style.cursor='pointer';
	});
	$('#header h1').mouseout(function() {
		document.body.style.cursor='default';
	});
	$('#header h1').click(function() {
		window.location.href='http://shubhomeet.net';
	});
	
	var tip;
	$(".tip_trigger").hover(function(){

		//Caching the tooltip and removing it from container; then appending it to the body
		tip = $(this).find('.tip').remove();
		$('body').append(tip);

		tip.show(); //Show tooltip

	}, function() {

		tip.hide().remove(); //Hide and remove tooltip appended to the body
		$(this).append(tip); //Return the tooltip to its original position

	}).mousemove(function(e) {
	//console.log(e.pageX)
		  var mousex = e.pageX + 20; //Get X coodrinates
		  var mousey = e.pageY + 20; //Get Y coordinates
		  var tipWidth = tip.width(); //Find width of tooltip
		  var tipHeight = tip.height(); //Find height of tooltip

		 //Distance of element from the right edge of viewport
		  var tipVisX = $(window).width() - (mousex + tipWidth);
		  var tipVisY = $(window).height() - (mousey + tipHeight);

		if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - tipWidth - 20;
			$(this).find('.tip').css({  top: mousey, left: mousex });
		} if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - tipHeight - 20;
			tip.css({  top: mousey, left: mousex });
		} else {
			tip.css({  top: mousey, left: mousex });
		}
	});

})
