
function getPathByUrl(path)
{
	if(path.length == 0) return;
	re = new RegExp("/html/([0-9]{4}/[0-9]{2}/[0-9]{2})/([0-9]{1,})/index\.htm*", "gi");
	re.compile("/html/([0-9]{4}/[0-9]{1,2}/[0-9]{2})/([0-9]{1,})/index\.shtml*", "gi");
	arr = re.exec(path);
	re = null;
	if (arr == null || arr == "") return;
	
	return arr;
}
var commentUrl = document.getElementById("commentparam").value;
var pathArr = getPathByUrl(commentUrl);
var comment_path = pathArr[1]+"/";
var comment_id   = pathArr[2];
var comment_page = 20;
var comment_template = 1;


function $() { 
	var elements = new Array(); 
	for (var i = 0; i < arguments.length; i++) { 
		var element = arguments[i]; 
		if (typeof element == 'string') 
			element = document.getElementById(element); 
		if (arguments.length == 1) 
			return element; 
		elements.push(element); 
	} 
	return elements; 
}


function DoDigg(id)
{
	var url = "http://comment.mmosite.com/ajax/getajaxinfo.php";
	var pars = "UseScript=1&Work=digg&id="+id+"&rid="+comment_id+"&path="+comment_path+"&template="+comment_template+"&page="+comment_page;
	
	if(document.getElementById('ScriptDoDigg')) return;
	var srcObj = document.createElement('script');
	srcObj.id = 'ScriptDoDigg';
	
	try{
		srcObj.setAttribute('src', url + "?" + pars + "&time="+new Date().getTime());
		document.body.appendChild(srcObj);
	}catch(e){
		try{
			srcObj.src = url + "?" + pars + "&time="+new Date().getTime();
			document.body.appendChild(srcObj);
		}
		catch(e){
		}
	}
}


function responseDiggInfo(responseText)
{
	var srcObj = document.getElementById('ScriptDoDigg');
	if(srcObj) srcObj.parentNode.removeChild(srcObj);
	
	var arr = responseText.split("*");
	
	switch(arr[0])
	{
		case "-1":
			alert("Sorry, this comment doesn't support digg operation!");
		  break;
		case "0":
			window.location.reload();
		  break;
		case "2":
			alert("Sorry, you have digged this comment.");
		  break;
		case "3":
			alert("Parameter error, please try again.");
		  break;
		case "1":
			alert("OK, thank you for your participation.");
			if (arr[1].indexOf(",") == -1)
			{
				$('diggnum_'+arr[1]).innerHTML = parseInt($('diggnum_'+arr[1]).innerHTML)+1;
			}
		  break;
		default:
			alert("Sorry, an error occurred, please contact the administrators!");
		  break;
	}
	arr = null;
}


function DoBury(id)
{
	var url = "http://comment.mmosite.com/ajax/getajaxinfo.php";
	var pars = "UseScript=1&Work=bury&id="+id+"&rid="+comment_id+"&path="+comment_path+"&template="+comment_template+"&page="+comment_page;
	
	if(document.getElementById('ScriptDoDigg')) return;
	var srcObj = document.createElement('script');
	srcObj.id = 'ScriptDoDigg';
	
	try{
		srcObj.setAttribute('src', url + "?" + pars + "&time="+new Date().getTime());
		document.body.appendChild(srcObj);
	}catch(e){
		try{
			srcObj.src = url + "?" + pars + "&time="+new Date().getTime();
			document.body.appendChild(srcObj);
		}
		catch(e){
		}
	}
}


function responseBuryInfo(responseText)
{
	var srcObj = document.getElementById('ScriptDoDigg');
	if(srcObj) srcObj.parentNode.removeChild(srcObj);
	
	var arr = responseText.split("*");
		
	switch(arr[0])
	{
		case "-1":
			alert("Sorry, this comment doesn't support digg operation!");
		  break;
		case "0":
			window.location.reload();
		  break;
		case "2":
			alert("Sorry, you have digged this comment.");
		  break;
		case "3":
			alert("Parameter error, please try again.");
		  break;
		case "1":
			alert("OK, thank you for your participation.");
			if (arr[1].indexOf(",") == -1)
			{
				$('burynum_'+arr[1]).innerHTML = parseInt($('burynum_'+arr[1]).innerHTML)+1;
			}
			arr1 = null;
		  break;
		default:
			alert("Sorry, an error occurred, please contact the administrators!");
		  break;
	}
	arr = null;
}
