// AJAX Functions

var jq = jQuery;
var bp_ajax_request = null;


jq(document).ready( function() {
	//external anchors
	jQuery(".post a").not('.highslide, .pss-thumbnail, .pss-hyperlink').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).addClass('external');
	

	//classes and followers					 
	jQuery("#classes img").stop().delay(500).animate({"opacity": "0"},  "medium");

	jQuery("#classes img").stop().delay(1500).animate({"opacity": "1"},  "slow");
			
	jQuery("#classes img").hover(
	function() {
		jQuery(this).stop().animate({"opacity": "0"},  "medium");		
	},
	function() {
		jQuery(this).stop().animate({"opacity": "1"},  "slow");		
	});
	
	jQuery("#classes .fadeAreaTemp").hover(
	function() {
		jQuery(".textAreaTemp").stop().animate({"opacity": "1"},  "medium");		
	},
	function() {
		jQuery(".textAreaTemp").stop().animate({"opacity": "0"},  "slow");		
	});	
	jQuery("#classes .fadeAreaScoun").hover(
	function() {
		jQuery(".textAreaScoun").stop().animate({"opacity": "1"},  "medium");		
	},
	function() {
		jQuery(".textAreaScoun").stop().animate({"opacity": "0"},  "slow");		
	});
	
		jQuery("#classes .fadeAreaChant").hover(
	function() {
		jQuery(".textAreaChant").stop().animate({"opacity": "1"},  "medium");		
	},
	function() {
		jQuery(".textAreaChant").stop().animate({"opacity": "0"},  "slow");		
	});

	jQuery("#classes .fadeAreaBlack").hover(
	function() {
		jQuery(".textAreaBlack").stop().animate({"opacity": "1"},  "medium");		
	},
	function() {
		jQuery(".textAreaBlack").stop().animate({"opacity": "0"},  "slow");		
	});	
	jQuery("#classes .fadeAreaJew").hover(
	function() {
		jQuery(".textAreaJew").stop().animate({"opacity": "1"},  "medium");		
	},
	function() {
		jQuery(".textAreaJew").stop().animate({"opacity": "0"},  "slow");		
	});
	
		jQuery("#classes .fadeAreaMyst").hover(
	function() {
		jQuery(".textAreaMyst").stop().animate({"opacity": "1"},  "medium");		
	},
	function() {
		jQuery(".textAreaMyst").stop().animate({"opacity": "0"},  "slow");		
	});

	//Qtips
	jq('.blue-post').qtip({
	   content: {
			 text: function(api) {
				// Retrieve content from ALT attribute of the $('.selector') element
				return jq(this).children('.blue-tooltip').clone();
			 }
	   },
	   style: {
         tip: false, // Give it a speech bubble tip,	   
		 classes: 'blizzard qtip-tooltip ui-tooltip-shadow'
	   },
	   position: {
     	 target: 'mouse',
		  my: 'top left',  // Position my top left...
		  at: 'bottom left', // at the bottom right of...
	   }
	});

	jq('a').qtip({
	   style: {
         tip: false, // Give it a speech bubble tip,	   
		 classes: 'doa-tooltip qtip-tooltip ui-tooltip-shadow'
	   },
	   position: {
     	 target: 'mouse',
		  my: 'top left',  // Position my top left...
		  at: 'bottom left', // at the bottom right of...
	   },
	   show: {
		  delay: 750
	   }	   
	});	
	jq('#menu-item-3053 a,.blue-region a').qtip({
	   style: {
         tip: false, // Give it a speech bubble tip,	   
		 classes: 'doa-tooltip-blue qtip-tooltip ui-tooltip-shadow'
	   },
	   position: {
     	 target: 'mouse',
		  my: 'top left',  // Position my top left...
		  at: 'bottom left', // at the bottom right of...
	   },
	   show: {
		  delay: 750
	   }
	});	
	// Collapse all runes
	jQuery('.skill-list-runed').slideUp("fast");							 				 

	 // Add video thumbnail
	jQuery(document).ready(function(){

		jQuery(".pss-video .pss-thumbnail").each(function() {

		jQuery(this).before("<span class=\"video-icon\"></span>");	

		});

	});   



	// Skill toggle
	jQuery(function(){
		jQuery('.skill-list-template').click(function(){	
			if (jQuery(this).find('.skill-list-runed').hasClass("skill-list-active") ) {
				jQuery('.skill-list-runed').removeClass('skill-list-active');			
				jQuery(this).find('.skill-list-runed').slideUp("slow");
			} else {		
				jQuery('.skill-list-runed').slideUp("slow");
				jQuery(this).find('.skill-list-runed').addClass('skill-list-active').slideToggle("slow");
			}
	
		});
	});

	// Initiate Tabs

	jQuery(function() {

		jQuery( "#tabs" ).tabs({

			cookie: {

				// store cookie for a day, without, it would be a session cookie

				expires: 1

			}

		});

		jQuery( "#innertabs" ).tabs({

			cookie: {
				// store cookie for a day, without, it would be a session cookie
				expires: 1
			}
		});		

	});

});




hs.Expander.prototype.onAfterExpand = function (sender) {

	jQuery('.pss-ratings').not('.init').ratings({
		'path' : pss_ratings_settings.path,
		'root' : pss_ratings_settings.root,
		'nonce' : pss_ratings_settings.nonce,
		'position' : pss_ratings_settings.pos
	});

}




/*

jQuery(document).ready( function() {

	function getDocHeight() {

		var D = document;

		return Math.max(

			Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),

			Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),

			Math.max(D.body.clientHeight, D.documentElement.clientHeight)

		);

	}

	var documentEnd = getDocHeight() - jQuery(window).height();

	var offset = 5;

	var inAction = false;

	var reachedEnd = false;

	

	jQuery(document).scroll(function(){

	   if(jQuery(window).scrollTop() >= documentEnd && inAction == false){

		   inAction = true;

	

			var html = jQuery.ajax({

			  url: "http://localhost/darkestofangels/wp-content/themes/diablo/get-posts.php?offset='+offset",

			  async: false,

			  type: "get",

			  data: {offset : offset}

			 }).responseText;

			offset = offset + 5;

		  	inAction = false;	   

		   	documentEnd = getDocHeight() - jQuery(window).height();			

			jQuery(".article-list").append(html);

	   }

	});

});

*/

function showImage(image){ 
	document.getElementById('class-image').setAttribute('src', image) 
}

		/*					 

	 jQuery("img.pss-thumbnail").each(function() {

		jQuery(this).wrap(function(){

		  return '<span class="' + jQuery(this).attr('class') + '" style="background:url(' + jQuery(this).attr('src') + ') no-repeat center center; width: ' + jQuery(this).width() + 'px; height: ' + jQuery(this).height() + 'px;" />';

		});

		jQuery(this).css("opacity","0");

	  });
	   */
