//JQuery Same Page Scrolling via http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links

$(document).ready(function() {

  function filterPath(string) {
  return string
    .replace(/^\//,'')
    .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
    .replace(/\/$/,'');
  }
 
  var locationPath = filterPath(location.pathname);
  $('a[href*=#]').each(function() {
    var thisPath = filterPath(this.pathname) || locationPath;
    if (  locationPath == thisPath
    && (location.hostname == this.hostname || !this.hostname)
    && this.hash.replace(/#/,'') ) {
      var $target = $(this.hash), target = this.hash;
      if (target) {
        var targetOffset = $target.offset().top;
        $(this).click(function(event) {
          event.preventDefault();
          $('html, body').animate({scrollTop: targetOffset}, 800, function() {
            location.hash = target;
          });
        });
      }
    }
  });
});

//Blank Target

$(function ($) {
$("a").filter(function() {
    return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');
});

//Link Fade

jQuery(document).ready(function(){
			$(".social img, .photos img, .cf-ol input, .cf-ol textarea, .singlepost input,.singlepost textarea").fadeTo(0, 0.5);
			$(".social img, .photos img,.cf-ol input, .cf-ol textarea, .singlepost input,.singlepost textarea").hover(function(){
			$(this).fadeTo(100, 1);
			},function(){
   			$(this).fadeTo(0, 0.5);
			});
//The News(ies)
		$(".news-tog").click(function(){
			$("#news").fadeIn(200)
			return false;
		});	
// Close that News
		$(".close-news").click(function(){ 
			$("#news").fadeOut(200)
			return false;			
		});
//The Story Expander		
		$(".btn-slide").click(function(){
			$("#panel").slideDown(200); // Expand Full Story
			$("p.slide").fadeOut(); // Fade Out Link
		});
//The Contact Toggle
		$("#contact").hide();
		$("#contact-btn").click(function(){
			$("#contact").slideToggle(300)
			return false; // Expand Contact
		});
	});
	
/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


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



//Mazel Sammy!
