/**
 * @author gsandrigo
 */
// JScript File
function displayReplyBox(e, commentId){
    var x;
    var y;
	var isIE = false;
	
	if(BrowserDetect.browser == "Explorer"){
		e = window.event;
		isIE = true;
	}
	
	if(isIE){
		if (document.body.scrollTop){
			x = e.clientX + document.body.scrollLeft;
		    y = e.clientY + document.body.scrollTop;
		}
		else{
		    x = e.clientX + document.documentElement.scrollLeft;
		    y = e.clientY + document.documentElement.scrollTop;
		}
	}
	else{
	    	x = e.pageX;
    		y = e.pageY;
	}
	
	xpos = x;
	ypos = y;
    	
			
	if(document.layers)	   //NN4+
	{
		
		document.layers["popup_box"].visibility = "show";
		if (postReply)
			document.layers['submitReplyLink'].href='javascript:submitReplyComment(' +commentId+ ');';
		else
			document.layers['submitReplyLink'].href='javascript:submitComment();';
	}
	else if(document.getElementById)	  //gecko + IE 5+
	{	
		var obj = document.getElementById("popup_box");
		if (postReply)
			document.getElementById('submitReplyLink').href='javascript:submitReplyComment(' +commentId+ ');';
		else
		{
			document.getElementById('submitReplyLink').href='javascript:submitComment();';
			alert(document.getElementById('submitReplyLink'));
		}
		document.getElementById('popup_box').style.left= (x - 300) + "px";
		if(isIE){
			document.getElementById('popup_box').style.top= (y + 5) + "px" ;
		}
		else{
			document.getElementById('popup_box').style.top= (y + 5) + "px";
		}
		obj.style.display = "block";
	}
	else if(document.all)	// IE 4
	{
		document.all["popup_box"].style.visibility = "visible";
		if (postReply)
			document.all['submitReplyLink'].href='javascript:submitReplyComment(' +commentId+ ');';
		else
			document.all['submitReplyLink'].href='javascript:submitComment();';
	}
	
}

function hideReplyBox()
{
	if(document.layers)	   //NN4+
		document.layers["popup_box"].visibility = "hide";
	else if(document.getElementById)	  //gecko + IE 5+
	{
		var obj = document.getElementById("popup_box");
		obj.style.display = "none";
	}
	else if(document.all)	// IE 4
		document.all["popup_box"].style.visibility = "hidden";
		
	document.getElementById("iReplySubject").value = "";
    document.getElementById("taReplyComments").value = "";
}	

//////////////////////////////////////////////////////////
function setupReplyBox(commentId)
{
	toggleBox('newPopup_post_comment_wrap', 1);
	//toggleBox('newPopup_post_reply', 0);
	
	
	if(document.layers)	   //NN4+
	{
		if (postReply)
			document.layers['submitReplyLink'].href='javascript:submitReplyComment(' +commentId+ ');';
		else
			document.getElementById("btnPostComment").style.display = "";
	}
	else if(document.getElementById)	  //gecko + IE 5+
	{	
		if (postReply)
			document.getElementById('submitReplyLink').href='javascript:submitReplyComment(' +commentId+ ');';
		else
		{
			document.getElementById("btnPostComment").style.display = "";
		}
	}
	else if(document.all)	// IE 4
	{
		if (postReply)
			document.all['submitReplyLink'].href='javascript:submitReplyComment(' +commentId+ ');';
		else
			document.getElementById("btnPostComment").style.display = "";
	}
	
}

function resizePic()
{
	if(document.getElementById("ContentImageCode"))
	{
		imageSizeInitInterval = setInterval(checkImageSize,100);
	}	
}

function checkImageSize()
{
	var theImage = document.getElementById("ContentImageCode");
	if(theImage.width > 0 )
	{
		if(theImage.width > 440) 
		{
			//alert(theImage.width);
			theImage.width = 440;
			clearInterval(parseInt(imageSizeInitInterval));
		}
	}
}
