function ShowImage(_id,_aid){
	document.location = "?album="+_aid+"&picture="+_id;
}

function ShowAlbum(_aid){
	document.location = "?album="+_aid
}
// comment operations	
function GetLastCommentCount(){
	var s = 0;
	$.each($("div.comCount"),function(i,v){
	    s = ($(v).text()*1>s?$(v).text()*1:s);
	});
	s++;
	return s;
}

function SaveComment(p){
	// txtName, txtEmail , txtMessagpe
	var name = $("#txtName").val();
	var email = $("#txtEmail").val();
	var message = $("#txtMessage").val();
	var msg = "";
	$("#divLoading").html("<img src='img/ajax-loader.gif'/>").show();
	$.post("operations/savecomment.php",{n:name,e:email,m:message,p:p},function(data){
		if(data.rcode=="00"){
			var _last = GetLastCommentCount();
			msg = "<div style='padding:4px;margin:5px;'>";
				msg += "<div style='padding:2px;margin:10px;clear:both'>";
				msg += "<div class='comCount'>";
					msg +=  _last;
				msg += "</div>";
				msg += "<div class='comDate'>";
					msg += data.rmdate;
				msg += "</div>";
				msg += "<span class='comMessage'>";
					msg += message;
				msg +=  "</span></div>";
			msg += "</div>";
			$("#divLoading").html(data.rmsg).show();
			$("div.cWrites").prepend(msg);
			ClearCommentFields();
			$(".commentCount").html(_last);
		} else {
			$("#divResult").html(data.rmsg).fadeIn();
			$("#divLoading").hide();
		}
	},"json");
}

function ClearCommentFields(){
	$("#txtName").val("");
	$("#txtEmail").val("");
	$("#txtMessage").val("");
}



