def_path = "http://lycan.slbloodlines.com";
var soul_on = new Image(); soul_on.src = def_path+"/images/icon_soul_on.gif";
var abyss_on = new Image(); abyss_on.src = def_path+"/images/icon_abyss_on.gif";

function soul_over(){
  var imgsrc = $(this).children('img').attr('src');
	imgsrcNew = imgsrc.replace(/.gif$/ig,"_on.gif");
	$(this).children('img').attr('src',imgsrcNew);
}

function soul_out(){
  var imgsrc = $(this).children('img').attr('src');
	imgsrcNew = imgsrc.replace(/_on.gif$/ig,".gif");
	$(this).children('img').attr('src',imgsrcNew);
}


function loadVials(overlayId,memberId,vialType)
{
	var mid = $("#profile_col1").attr('class');
	$("#"+overlayId+" .overlay_content").html('<img src="/images/icon_ajax_black.gif" class="loading" alt="" />');
	$.ajax({
    type: "POST",
		data: "k=932&vt="+vialType,
		dataType:"html",
		url: "/members/vials/"+memberId,
    success: function(result) {
			$("#"+overlayId+" .overlay_content").html(result);
			$("#"+overlayId+" .overlay_loadstatus").html("1");
    },
		error: function(result,errorType){
		  $("#"+overlayId+" .overlay_content").html("<span class='red'>There was an error!</span>");
		}
  });
}

$(document).ready(function(){
   //rollovers 
	 $('.soul > a').bind('mouseover',soul_over);
	 $('.soul > a').bind('mouseout',soul_out);
	 $("img[title]").tooltip({position:'top center',effect:'fade'});
	
	$("img.vialicon[rel]").overlay({
	 		closeOnClick:true,
			onLoad:function(event){
				var overlayId = this.getOverlay().attr("id");
				//get overlay data
				var dataString = $("#"+overlayId+" .data").html();
				var data = JSON.parse(dataString);
				
				//get overlay load status
				var loadStatus = $("#"+overlayId+" .overlay_loadstatus").html();
				if(loadStatus == "0")
					loadVials(overlayId,data.mid,data.vial_type);
			}
	});
	 
});
