// Brand spanking new Envatolized code

var j=jQuery.noConflict();
/*jQuery.noConflict();
(function($) {
    $(document).ready(function() {
        // Sponsored search, hoorah!
        var target = $("#sponsored-search");
        target.length && target.load("/sponsored-search/", {
            path: window.location.pathname + window.location.search
        });
    });
})(jQuery);
*/

// Legacy Code (TM) below - enter with caution!

function fav(id) {
	if($("star_" + id).src.indexOf("/img/icon_fav_on.jpg") > 0)
	{
		var aj = new Ajax.Request("/ajax.php?a=rf&id=" + id);
		$("star_" + id).src = "/img/icon_fav_off.jpg";
	}
	else
	{
		var aj = new Ajax.Request("/ajax.php?a=af&id=" + id);
		$("star_" + id).src = "/img/icon_fav_on.jpg";
	}
	return false;
}

function fav_comment(id){
	if ($("like_"+id).src.indexOf("/img/like_blue.png")>0){
		var aj=new Ajax.Request("/ajax.php?a=rl&id="+id);
		$("like_"+id).src="/img/like_gray.png";
	}
	else{
		var aj=new Ajax.Request("/ajax.php?a=al&id="+id);
		$("like_"+id).src="/img/like_blue.png";
	}
	return false;
}

function spam(id) {
	if (confirm("Are you sure you want to mark this snippet as spam?  You cannot undo this action."))
	{
		var aj = new Ajax.Request("/ajax.php?a=spam&id=" + id);
		$("spam").update("<em>Thank you for helping to keep Snipplr spam-free!  Your request has been noted and appropriate action will be taken.</em>");
	}
	return false;
}

function referral_feedback(source_id,target_id,score){
    $.get("/ajax.php",{a:(score==1?"gs":"bs"),source:source_id,target:target_id},function(data){
        $("#recommendation").html(data);
    });
    return false;
}

function versionjump(a,b) {window.location="/view/" + a + "." + b + "/";}
function wraplines() {
	if ($("innersource").className=="nowrap")
		$("innersource").className = "wrap";
	else
		$("innersource").className = "nowrap";
	//if(el.checked == true) $("innersource").className = "wrap";
	//else $("innersource").className = "nowrap";
}
function expand() {
	if ($("maincol").className=="expand") {
		$("sidecol").show();
		$("maincol").className = "";
		$("toggleexpand").update("Expand");
	}
	else {
		$("sidecol").hide();
		$("maincol").className = "expand";
		$("toggleexpand").update("Collapse");
	}
}
var searchCleared = 0;
function clearOnce() {
	if (searchCleared) {return;}
	searchCleared = 1;
	document.search.q.value="";
}
// For searching with the WordPress blog which uses an input value of 's' instead of 'q'.
function blogClearOnce() {
	if (searchCleared) {return;}
	searchCleared = 1;
	document.search.s.value="";
}

// --- [ Experimental jQuery code ] --- //
/*
jQuery(document).ready(function() {
	jQuery('.drag').draggable({helper: 'clone'});

	jQuery("#yourtabs, #langtabs").droppable({
		accept: ".drag",
		drop: function(ev, ui) {
			ui.draggable.fadeOut("fast",
			function() { jQuery(this).fadeIn("fast")}).appendTo(jQuery(this));
			//jQuery('#contents').append(ui.draggable);
			console.log(ui.draggable);
		}
	});
});
*/

