function funAddComment(id) {
	var vComment = $("textarea[name=txtComment]").val();
	vComment = trim(vComment);	
	if (vComment.length == 0)	{
		$('#err').html('<span class="warning">Please enter your comment...</span>');
		return false;
	}
	$('#err').html('');
	$("textarea[name=txtComment]").val('');
	$.ajax({		
		type : "POST",
		url	 :g_site_path+"ajax/addcomments",
		data : 'type=3&id='+id+'&type=3&vComment='+vComment+'&rand='+Math.random(),
		dataType: "html",
		success: function(html){			
			$('#divComment').html(html);
			//$('#err').html('<span class="warning">Comment posted sucessfully...</span>');
		}
   });

}

function funGetComment(id) {	
	$("textarea[name=txtComment]").val('');
	$('#err').html('');
	$('#divComment').html('<span class="warning">Loading...</span>');
	$.ajax({
		type : "POST",
		url	 :g_site_path+"ajax/slideshow",
		data : 'id='+id+'&type=2&rand='+Math.random(),
		dataType: "html",
		success: function(html){
			//alert(html)
			$('#divComment').html(html);
		}
   });	
}

function prev(id){
	
	$.ajax({
		type : "POST",
		url	 :g_site_path+"ajax/comments",
		data : 'id='+id+'&rand='+Math.random(),
		dataType: "html",
		success: function(html){
			//alert(html)
			$('#a').html(html);
		}
   });	
}

function next(id){
	
	$.ajax({
		type : "POST",
		url	 :g_site_path+"ajax/comments",
		data : 'id='+id+'&rand='+Math.random(),
		dataType: "html",
		success: function(html){
			//alert(html)
			$('#a').html(html);
		}
   });	
}
function paging(page){
	
	var id=$('#id').val();
		vData = 'id='+id+'&p='+page+"&rand="+Math.random();
		$.ajax({
			type : "POST",
			url	 : g_site_path+"ajax/comments?vData",
			data : vData,
			dataType : 'html',
			success: function(html){				
				$('#a').html(html);
			}
		})
}
function flagUpdate(id) {	
	vData = 'pmid='+id;	
	$.ajax({
		type : "POST",
		url	 : g_site_path+"ajax/flag-user",
		data : vData,
		dataType : 'html',
		success: function(html){			
			//$('#'+id).html( 'Report abuse updated sucessfully...' );
			$('#'+id).fadeOut("slow");			
		}
	});
	 
}

function tipsPopUp(id) {

d = new dialog({'title':'Report a TIP', 'ismodel':true,'width':'505','height':'350', 'onclose':'d.close()'});
	d.show();
	d.sethtml('<span class="warning">Loading...</span>');
	vData = 'id='+id+'&rand='+Math.random();
	$.ajax({
		type : "POST",
		url	 : g_site_path+"ajax/tips-add",
		data : vData,
		dataType : 'html',
		success: function(html){
			d.sethtml( html );
		}
	});

}
function SaveTipsValues(id) {	
	var txtTips=$('#txtTips').val();
	clearHighlightFields( ['txtTips'], 'error_text_field' );
	if (txtTips == "") {
		$('#error').html('Please enter your tip');
		return false;
	}
	if ( checkRestrictedWord( txtTips ) ){
		$('#error').html('We\'ve found that some of the text is offensive. Please avoid offensive word(s)');
		makeHightlightField('txtTips', 'error_text_field');
		ge('txtTips').focus();
		d.resizeDialog();
		return 0;
	}
	
	vData = 'pmid='+id+'&txtTips='+txtTips+'&rand='+Math.random();;	
	$.ajax({
		type : "POST",
		url	 : g_site_path+"ajax/tips-insert",
		data : vData,
		dataType : 'html',
		success: function(html){
			$('#error').html('Your tips added sucessfully...');
			setTimeout('d.close();',1000);						
		}
	});
}
