// JavaScript Document

/**
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}};

// FadeToggle plugin
jQuery.fn.fadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

// jQuery Begin
jQuery(document).ready(function() {

// Bottom Panel Fade
jQuery("#spanel").css("opacity","0.5");
jQuery("#spanel").hover(function () {
jQuery(this).stop().animate({opacity: 1}, 'slow');
},
function () {
var tokens = jQuery('#s').val();
if(tokens.length > 0){
}
else {
jQuery(this).stop().animate({opacity: 0.5}, 'slow');}
});

// Bottom Panel
jQuery("#spanel_right").click(function(){
jQuery("#bottompanel_top").fadeOut(400);
jQuery("#bottompanel_main").delay(400).slideDown(500);
});
jQuery("#bottompanel_close").click(function(){
jQuery("#bottompanel_top").slideDown(500);
jQuery("#bottompanel_main").slideUp(500);
});

// Bottom Scrolltop Fade
jQuery("#jtop").css("opacity","0");
jQuery(window).scroll(function(){
var scrollTop = jQuery(window).scrollTop();
if(scrollTop != 0)
jQuery('#jtop').stop().animate({'opacity':'0.5'},'slow');
else
jQuery('#jtop').stop().animate({'opacity':'0'},'slow');
});
jQuery('#jtop').hover(
function (e) {
var scrollTop = $(window).scrollTop();
if(scrollTop != 0){
jQuery('#jtop').stop().animate({'opacity':'1'},'slow');
}
},
function (e) {
var scrollTop = $(window).scrollTop();
if(scrollTop != 0){
jQuery('#jtop').stop().animate({'opacity':'0.5'},'slow');
}
});

// Bottom Search Focus
jQuery("#searchsubmit").fadeOut(0);
jQuery('#s').focus(function(e){
jQuery(this).blur(function(){
jQuery(this).parents("#spanel").stop().animate({opacity: 0.5}, 'slow');
});
jQuery(this).keyup(function(e){
var swords = jQuery(this).val();
if(swords.length > -1){
jQuery(this).parents("#spanel").stop().animate({opacity: 1}, 'slow');
};
var tokens = jQuery(this).val();
if(tokens.length > 0){
jQuery(this).parent().children('#searchsubmit').fadeIn(500);
};
});
jQuery(this).keyup(function(e){
var tokens = jQuery(this).val();
if(tokens.length == 0){
jQuery(this).parent().children('#searchsubmit').fadeOut(500);
};
});
});

// Smoothscroll
jQuery('a[href*=#]').click(function() { 
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
&& location.hostname == this.hostname) {var $target = $(this.hash);
$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 1000);
return false;
}
}
});

// SideBar Tabs
jQuery('.inside ul li:last-child').css('border-bottom','0px') // remove last border-bottom from list in tab conten
jQuery('.tabs_js').each(function(){
jQuery(this).children('li:first').addClass('selected'); // Add .selected class to first tab on load
});
jQuery('.inside > *').hide();
jQuery('.inside > *:first-child').show();
jQuery('.tabs_js li').click(function(evt){ // Init Click funtion on Tabs
var clicked_tab_ref = jQuery(this).attr('title'); // Strore Href value
jQuery(this).parent().children('li').removeClass('selected'); //Remove selected from all tabs
jQuery(this).addClass('selected');
jQuery(this).parent().parent().children('.inside').children('*').hide()
jQuery('.inside ' + clicked_tab_ref).fadeIn(1000);
evt.preventDefault();
})

// Bottom Logo Fade
jQuery('#f_wsqlogo strong,#f_wordpresslogo strong').hide().animate({opacity: '0',left: '-15px',top: '-25px'},0);
jQuery('#f_wsqlogo,#f_wordpresslogo').hover(function() {jQuery(this).find('strong').show().animate({opacity: '0.9',left: '-15px',top: '-35px'},400);
}, function() {
jQuery(this).find('strong').animate({opacity: '0',left: '-15px',top: '-25px'},500,function() {
jQuery(this).hide();});
});

// Share Panel Hide
jQuery(".post").hover(function(){
jQuery(this).find(".sharepanel").animate({opacity: '0',left: '0'},0);
jQuery(this).find(".sharepanel").stop().show().animate({opacity: '0.5'},"slow");
},
function(){
jQuery(this).find(".sharepanel").stop().animate({opacity: '0'}, "slow");
jQuery(this).find(".sharesubdiv").stop().animate({opacity: '0'}, "slow");
});
jQuery(".sharepanel").hover(function(){
jQuery(this).stop().show().animate({opacity: '1'},"slow");
},
function(){
jQuery(this).stop().animate({opacity: '0.5'}, "slow");
});
jQuery(".panel_excon").click(function(){
jQuery(this).parents(".post").children(".postcontent").stop().fadeToggle("slow");
jQuery(this).stop().toggleClass("active");return false; 
});

// Share Div
jQuery(".panel_bird").click(function(){
jQuery(this).parents(".postpanel").children(".sharesubdiv").stop().animate({opacity: '0',left: '-10px',top: '-200px'},0);
jQuery(this).parents(".postpanel").children(".sharesubdiv").stop().show().animate({opacity: '1',left: '-10px',top: '-189px'},"slow");
jQuery(this).parents(".postpanel").hover(function() {}, function(){
jQuery(this).children(".sharesubdiv").stop().animate({opacity: '0',left: '-10px',top: '-200px'},1000);
});
});

// Comment Reply
jQuery(".comment-reply").css("opacity","0");
jQuery(".comment-main").hover(function(){
jQuery(this).find(".comment-reply").stop().animate({opacity: '1'},"fast");
},
function(){
jQuery(this).find(".comment-reply").stop().animate({opacity: '0'}, "slow");
});

// Fade BlogLink
jQuery(".g_01 li a em").hide().css("opacity","0");
jQuery(".g_01 li").hover(function () {
jQuery(this).find("a em").show().animate({opacity: 1}, 500);
},
function(){
jQuery(this).find("a em").stop().animate({opacity: '0'},500,function() {
jQuery(this).hide();});
});

});// END


// Target Blank
function externallinks() { 
if (!document.getElementsByTagName) return; 
var anchors = document.getElementsByTagName("a"); 
for (var i=0; i<anchors.length; i++) { 
var anchor = anchors[i]; 
if (anchor.getAttribute("href") && 
anchor.getAttribute("rel") == "external") 
anchor.target = "_blank"; 
} 
} 
window.onload = externallinks;
