
//////////////// for rating ///////////////////////////////////
function updateRating(action,item_id,rate,total_rating,total_votes)
{
	var args=action+"###"+item_id+"###"+rate+"###"+total_rating+"###"+total_votes;
	/*alert(args);
	return false;*/
	x_update_rating(args,ReturnRating);
}
//////////////// for rating ///////////////////////////////////

function ReturnRating(theCode)
{
	//alert(theCode);
	//return false;
	if(theCode=="notlogin")
	{
		alert("Loggin is required for rating");
		return false;
	}
	else if(theCode=="rated")
	{
		alert("You have already rated this product");
		return false;
	}
	else
	{
		alert("Thanks for rating");
		var tmp_arr=new Array();
		tmp_arr=theCode.split("~~~");
		action=tmp_arr[0];
		item_id=tmp_arr[1];
		CodeToShow=tmp_arr[2];
		if(action=="product_rating")
		{
			var div_id_name="product_rate_"+item_id;
		}
		document.getElementById(div_id_name).innerHTML=CodeToShow;
	}
}


function update_product_content(action,pid,params)
{
	var go=0;
	if(params=="undefined")
	{
		params="";
	}
	var args="";
	
	if(action=="add_new_comment")
	{
		go=1;
		var content_div=document.getElementById("add_new_comment");
		var params=content_div.value;
		params=trim(params);
		if(params=="")
		{
			return false;
		}
		
		content_div.value="";
		args=action+"###"+pid+"###"+params;
		x_update_product_content(args,ReturnCode);
		
	}
	
	
}


function ReturnCode(theCode)
{
	var tmp_arr=new Array();
	tmp_arr=theCode.split("~~~");
	var action=tmp_arr[0];
	var CodeToShow=tmp_arr[1];
	
	/*if(action=="article_list")
	var div_name=document.getElementById("store_articles");
	else
	{*/
		if(action=="add_new_comment")
		{
			if(CodeToShow=="notloggedin")
			{
				alert("You need to login to post comment.");
				return false;
			}
			ShowLayer('add_comment');
			
			var div_name=document.getElementById("product_comments");
			
		}
		else
		{
			
			if(action=="comment_list")
			{
				var div_name=document.getElementById("product_comments");
			}
		}
	/*}*/
	div_name.innerHTML=CodeToShow;
}


