/* JQuery Cookie */
jQuery.cookie=function(a,b,c){if(typeof b!="undefined"){c=c||{};if(b===null){b="";c.expires=-1}var d="";if(c.expires&&(typeof c.expires=="number"||c.expires.toUTCString)){var e;if(typeof c.expires=="number"){e=new Date;e.setTime(e.getTime()+c.expires*24*60*60*1e3)}else{e=c.expires}d="; expires="+e.toUTCString()}var f=c.path?"; path="+c.path:"";var g=c.domain?"; domain="+c.domain:"";var h=c.secure?"; secure":"";document.cookie=[a,"=",encodeURIComponent(b),d,f,g,h].join("")}else{var i=null;if(document.cookie&&document.cookie!=""){var j=document.cookie.split(";");for(var k=0;k<j.length;k++){var l=jQuery.trim(j[k]);if(l.substring(0,a.length+1)==a+"="){i=decodeURIComponent(l.substring(a.length+1));break}}}return i}}
;


/* 
 Scroll To
*/
(function(b){if(b.ScrollTo)window.console.warn("$.ScrollTo has already been defined...");else{b.ScrollTo={config:{duration:400,easing:"swing",callback:undefined,durationMode:"each"},configure:function(c){b.extend(b.ScrollTo.config,c||{});return this},scroll:function(c,d){var f=b.ScrollTo,a=c.pop(),e=a.$container,g=a.$target;a=b("<span/>").css({position:"absolute",top:"0px",left:"0px"});var h=e.css("position");e.css("position","relative");a.appendTo(e);var i=a.offset().top;g=g.offset().top-i;a.remove();
e.css("position",h);e.animate({scrollTop:g+"px"},d.duration,d.easing,function(j){if(c.length===0)typeof d.callback==="function"&&d.callback.apply(this,[j]);else f.scroll(c,d);return true});return true},fn:function(c){var d=b.ScrollTo,f=b(this);if(f.length===0)return this;var a=f.parent(),e=[];for(config=b.extend({},d.config,c);a.length===1&&!a.is("body")&&a.get(0)!==document;){c=a.get(0);if(a.css("overflow-y")!=="visible"&&c.scrollHeight!==c.clientHeight){e.push({$container:a,$target:f});f=a}a=a.parent()}e.push({$container:b(b.browser.msie?
"html":"body"),$target:f});if(config.durationMode==="all")config.duration/=e.length;d.scroll(e,config);return this},construct:function(c){var d=b.ScrollTo;b.fn.ScrollTo=d.fn;d.config=b.extend(d.config,c);return this}};b.ScrollTo.construct()}})(jQuery)
; 
	

/* JQuery History.Js Adapter */
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.jQuery;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){d(a).bind(b,c)},trigger:function(a,b,c){d(a).trigger(b,c)},extractEventData:function(a,c,d){var e=c&&c.originalEvent&&c.originalEvent[a]||d&&d[a]||b;return e},onDomLoad:function(a){d(a)}},typeof c.init!="undefined"&&c.init()})(window)
;

/*
 Opaque	
*/
function opaqalize() {
	// embed
	$('embed').each(function() {
		if (!$(this).attr('wmode')) {
			$(this).attr({'wmode':'transparent'});
		}
	});
	// object
	$('object').each(function() {
		var e = document.createElement('param');
		e.setAttribute('name','wmode');
		e.setAttribute('value','transparent');
		$(this).append(e);
	});
	
}

$('.block .fbLikeFake.fbLikeHolder').bind('mouseover', function(event) {
	fb_id = $(this).attr('id');
	article_id = fb_id.replace('fb_', '#article_');
	article_href = $(article_id).attr('data-url');
	$(this).html('<div class="fb-like" data-href="' + article_href + '" data-send="false" data-layout="button_count" data-width="40" data-show-faces="false" ref="fb_homepage_block"></div>');
	FB.XFBML.parse(document.getElementById(fb_id));
	$(this).removeClass('fbLikeFake');
	$(this).unbind(event);
});

$(document).ready(function() {

	//opaqalize();
	// Menu	
	$(".parent").hover(
	  function () {
	    $("ul", this).show();
	  }, 
	  function () {
	    $("ul", this).hide();
	  }
	);
	$(".child li:odd").css("background-color", "#333");  
	$(".child li:last").css("border-bottom", "0");  

	
		$('.aBlock').click(function() {
			window.location = $(this).attr('data-url');
		});
	
	
	if($('#tags').length > 0) {
		tagHeight = $('#tags ul').height();
		if(tagHeight > 45) { 
			$('#tags ul').height(45);
			$('#tags .more').show();
		}
		
		$('#tags .more').click(function() {
			if($('#tags .more span').hasClass('circleDown')) {
				$('#tags ul').animate({
					'height' : tagHeight + 'px'
				}, 'fast', function () {
					$('#tags .more strong').html('Fewer Tags');
					$('#tags .more span').removeClass('circleDown');
					$('#tags .more span').addClass('circleUp');
				});
			} else {
				$('#tags ul').animate({
					'height' : '45px'
				}, 'fast', function () {
					$('#tags .more strong').text('More Tags');
					$('#tags .more span').removeClass('circleUp');
					$('#tags .more span').addClass('circleDown');
				});
			}
		});
	}
  
  
});
