var $j = jQuery.noConflict();
$j(document).ready(function(){

$j("a.screenshot1").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

$j("a.postimg").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

$j("a.screenshot2").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
$j("a.screenshot3").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
$j("a.screenshot4").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});

$j("#promotion_link").click(function () {
      $j("#promotion_box").slideToggle();
	  return false;
    });

$j("h2.trigger").mouseenter(function () {
    $j(".toggle_sidebar_container").removeClass("active");
    $j(this).next().addClass("active");
  });  
 $j("h2.trigger").click(function(){
  return false;
  });
 $j(".toggle_sidebar_container").mouseleave(function() {
    $j(this).removeClass("active");
     });
 
 $j(".hover_target").mouseenter(function () {
    $j(this).next().addClass("hover");
 });
 $j(".hover_target").mouseleave(function() {
    $j(this).next().removeClass("hover");
    });

 
 $j("a.postimg").append('<img src="http://payperhead.com/payperhead2/wp-content/themes/pph-theme/images/fancy_plus.png" class="pagePlus" />');

 $j(".tip_trigger").hover(function(){
        tip = $j(this).find('.tip');
        tip.show(); //Show tooltip
    }, function() {
        tip.hide(); //Hide tooltip
    }).mousemove(function(e) {
        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 = $j(window).width() - (mousex + tipWidth);
        //Distance of element from the bottom of viewport
        var tipVisY = $j(window).height() - (mousey + tipHeight);
 
        if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
            mousex = e.pageX - tipWidth - 20;
        } if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
            mousey = e.pageY - tipHeight - 20;
        }
        //Absolute position the tooltip according to mouse position
        tip.css({  top: mousey, left: mousex });
    });
 
});

