$(document).ready(function() {  
	var plag = $("#ajax_cf_ispost").attr("value");
	var id =$("#ajax_cf_id").attr("value");
	var singerid =$("#ajax_singerid").attr("value");
	var songid =$("#ajax_songid").attr("value");
	var photoid =$("#ajax_photoid").attr("value");
	var videoid =$("#ajax_videoid").attr("value");
	if (singerid){$("#commentform").attr("action","/commentformsinger/"+singerid+"/");}
	else if(songid){$("#commentform").attr("action","/commentformsong/"+songid+"/");}
	else if(photoid){$("#commentform").attr("action","/commentformphoto/"+photoid+"/");}
	else if(videoid){$("#commentform").attr("action","/commentformvideo/"+videoid+"/");}
	else {$("#commentform").attr("action","/commentform/");}
    var options = { 
        target:        '#SubmitOutput'   // target element(s) to be updated with server response 
    }; 
    $('#commentform').ajaxForm(options); 
	if (plag == 'true' && id){
		$("#id_comment").attr("value","");
		$.post('/addcommentlist/?id='+id,{},
			function(data){
				$('#ajax_addcomment').after(data);
				$('ul.comment').each(function(){
					if ( $(this).is(":hidden")){
						$(this).slideDown("normal");
					}
					if ( $('#no_comment').is(":visible")){
						$('#no_comment').slideUp("normal");
					}
				})
		})
	}
 	$("#form_state_message").hide();
})	
$(function(){  
	$("div.reply" ).live("click",function() {
		var re_id = $(this).children("input[name$='ajax_re_id']").attr("value");
		var re_owner = $(this).children("input[name$='ajax_re_owner']").attr("value");
		$("#id_comment").focus();
		if(re_id){$("#reply_id").attr("value",""+re_id);}
		if(re_owner){$("#id_comment").attr("value","@"+re_owner+" ");}
	})
});
 $(function(){  
	$("#id_submit" ).live("click",function() {
		$("#form_state_message").show();
	})
});