var iSub = false;
var iSub2 = false;
var iRun = false;
var iRun2 = false;
var xCoord = 0;
var yCoord = 0;
window.onload = init;
function init() {
	if (window.Event) {
	document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = getCursorXY;
}

function getCursorXY(e) {
	xCoord = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
	yCoord = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
}


function addrating(strID,strNum)
{
	if (iRun ==false)
	{
		iRun = true;
		document.getElementById("subform").src = "";
		document.getElementById("subform").src = "subform.asp?type=blog&ID="+strID+"&rating="+strNum;	
	}
	if (iSub ==false)
	{
		var sTime = setTimeout("addrating("+strID+","+strNum+")",500);
	}
	else
	{		
		for(i=1;i<strNum+1;i++)
		{
			strImg = document.getElementById('rating'+strID+'_'+i);
			strImg.src = "images/siteimages/red_star.gif";
		}
		for (i=5;i>strNum;i--)
		{
			strImg = document.getElementById('rating'+strID+'_'+i);
			strImg.src = "images/siteimages/grey_star.gif";
		}
		iSub = false
		sTime = "";
		iRun = false;
	}
}
function flaginap(strID,strComment)
{
	if (iRun ==false)
	{
		iRun = true;
		document.getElementById("subform").src = "subform.asp?type=flag&ID="+strID+"&comment="+strComment;	
	}
	if (iSub ==false)
	{
		var sTime = setTimeout("flaginap("+strID+","+strComment+")",500);
	}
	else
	{
		strLink = document.getElementById("flag"+strID+"_"+strComment);
		href = strLink.getAttribute("href");
    		if (href && href != "" && href != null)
		{
       			strLink.setAttribute('href_bak', href);
    		}
    		strLink.removeAttribute('href');
		strParent = strLink.parentNode;
		strParent.innerHTML = "Comment Flagged";
		strParent.style.fontSize="1.2em";
		iSub = false
		sTime = "";
		iRun = false;
	}		
}
function showComments(strID,strCount)
{
	strDiv = document.getElementById("comments_"+strID);
	strDiv2 = document.getElementById("commentlink"+strID);
	if (strDiv.style.display == "block")
	{
		strDiv.style.display = "none";	
		strDiv2.innerHTML = "View comments("+strCount+")";
	}
	else
	{
		strDiv.style.display = "block";	
		strDiv2.innerHTML = "Hide comments";
	}
}
function addComments(strID)
{
	sFrame = document.getElementById("subform");
	//alert (yCoord);
	sFrame.style.position = "absolute";
	sFrame.style.top = (yCoord-300)+"px";
	sFrame.style.left = xCoord+"px";
	sFrame.style.display = "block";	
	if (iRun ==false)
	{
		iRun = true; 

		//sFrame.src = "";
		sFrame.src = "replyform.asp?type=comment&bid="+strID;


	}
	if (iSub ==false)
	{
		//var sTime = setTimeout("addrating("+strID+","+strNum+")",500);
	}
	else
	{		
		//for(i=1;i<strNum+1;i++)
		{
		//	strImg = document.getElementById('rating'+strID+'_'+i);
		//	strImg.src = "images/siteimages/red_star.gif";
		}
		//for (i=5;i>strNum;i--)
		{
		//	strImg = document.getElementById('rating'+strID+'_'+i);
		//	strImg.src = "images/siteimages/grey_star.gif";
		}
		//iSub = false
		//sTime = "";
		//iRun = false;
	}
}
function postreply(strID,strCID)
{
	sFrame = document.getElementById("subform");
	//alert (yCoord);
	sFrame.style.position = "absolute";
	sFrame.style.top = (yCoord-250)+"px";
	sFrame.style.left = (xCoord+100)+"px";
	sFrame.style.display = "block";	
	if (iRun ==false)
	{
		iRun = true; 

		//sFrame.src = "";
		sFrame.src = "replyform.asp?type=reply&bid="+strID+"&cid="+strCID;


	}
	if (iSub ==false)
	{
		//var sTime = setTimeout("addrating("+strID+","+strNum+")",500);
	}
	else
	{		
		//for(i=1;i<strNum+1;i++)
		{
		//	strImg = document.getElementById('rating'+strID+'_'+i);
		//	strImg.src = "images/siteimages/red_star.gif";
		}
		//for (i=5;i>strNum;i--)
		{
		//	strImg = document.getElementById('rating'+strID+'_'+i);
		//	strImg.src = "images/siteimages/grey_star.gif";
		}
		//iSub = false
		//sTime = "";
		//iRun = false;
	}
}