$("div.authorPhoto a").colorbox({height:"95%", close : translations.close});
$("a.colorbox").colorbox();

$(".authorPhoto a").hover(
	function() { $(this).parent().addClass("authorPhotoHover") },
	function() { $(this).parent().removeClass("authorPhotoHover") }
);

// hover/select input.text
$("input.text, textarea").mouseenter(function(){
  $(this).addClass("textHover");
}).mouseleave(function(){
  $(this).removeClass("textHover");
}).focus(function() {
	$(this).addClass("textActive");
}).blur(function() {
	$(this).removeClass("textActive");
});

$(".selectonclick").click(function() {
	this.select();
});

/* delete maby 
$(".activate_quotes table").each(function() {
	var width = 0;
	$("td", this).each(function() {
		width += 230;
	});
	this.style.width = width+"px";
});
*/

function vote_for(that, q_id)
{
	$.ajax({
		type: "GET",
		url: "/?ajax=1&vote_for=1",
		data: "q_id="+q_id,
		success: function(msg){
			if (isNaN(msg)) {
				alert(msg);
			}
			else {
				$(".current_rank", $(that).parent()).html(msg);
			}
		}
	});
}

function vote_against(that, q_id)
{
	$.ajax({
		type: "GET",
		url: "/?ajax=1&vote_against=1",
		data: "q_id="+q_id,
		success: function(msg){
			if (isNaN(msg)) {
				alert(msg);
			}
			else {
				$(".current_rank", $(that).parent()).html(msg);
			}
		}
	});
}

function add_to_facebook(q_id, el)
{
	$(el).addClass("shareOnFacebookLoading");
	$.ajax({
		type: "GET",
		url: "/?ajax=1&get_quote_for_facebook=1",
		data: "q_id="+q_id,
		success: function(msg){
			eval(msg);
			FB_RequireFeatures(["Connect"], function() {
				//FB.FBDebug.isEnabled = true;
				//FB.FBDebug.logLevel = 4;
				FB.init(q_config.facebook.api_key, '/xd_receiver.htm');
				FB.ensureInit(function() {
					var message = '';
					FB.Connect.streamPublish(message, attachment, action_links);
					$(el).removeClass("shareOnFacebookLoading");
				});
			});
		}
	});
}

$("ul.mainNav > li").mouseenter(function() { 
	$("ul", this).css("display", "block");
}).mouseleave(function() { 
	$("ul", this).css("display", "none");
});


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

/*
function loadLikebuttons() {
  var iframeHtml = '<iframe src="http://www.facebook.com/plugins/like.php?href=__url__&amp;layout=button_count&amp;show_faces=false&amp;width=210&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:210px; height:21px;" allowTransparency="true"></iframe>';
  $(".fblike .url").each(function() {
    var url = this.innerHTML;
    $(this).replaceWith(iframeHtml.replace("__url__", url));
  });
}

addLoadEvent(loadLikebuttons);*/
