/**
* comments.oneindia.in - Client-Side Scripts - Comments
*
* LICENSE: This file belongs to Greynium Information Technologies Pvt.Ltd
*
* @category   JavaScript
* @package    script.js
* @author     Vikram Reddy N (vikram.reddy@greynium.com)
* @copyright  2007-2008 Greynium Information Technologies
* @version    1.0
* @see        comments.js
* @since      File available since Release 1.0.x
* @deprecated File Not yet deprecated
*/
var img_captcha = new Image();
img_captcha.src = '/common/captcha.php';
var img_submit = new Image();
img_submit.src = '/images/btn_submit.gif';
var img_cancel = new Image();
img_cancel.src = '/images/btn_cancel.gif';


var d, dom, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op;

d = document;
n = navigator;
na = n.appVersion;
nua = n.userAgent;
win = ( na.indexOf( 'Win' ) != -1 );
mac = ( na.indexOf( 'Mac' ) != -1 );
lin = ( nua.indexOf( 'Linux' ) != -1 );

if ( !d.layers )
{
	dom = ( d.getElementById );
	op = ( nua.indexOf( 'Opera' ) != -1 );
	konq = ( nua.indexOf( 'Konqueror' ) != -1 );
	saf = ( nua.indexOf( 'Safari' ) != -1 );
	moz = ( nua.indexOf( 'Gecko' ) != -1 && !saf && !konq);
	ie = ( d.all && !op );
	ie4 = ( ie && !dom );

	/*
	ie5x tests only for functionality. ( dom||ie5x ) would be default settings. 
	Opera will register true in this test if set to identify as IE 5
	*/

	ie5x = ( d.all && dom );
	ie5mac = ( mac && ie5x );
	ie5xwin = ( win && ie5x );
}

window.size = function()
{
var w = 0;
var h = 0;
//IE
if(!window.innerWidth)
{
//strict mode
if(!(document.documentElement.clientWidth == 0))
{
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
}
//quirks mode
else
{
w = document.body.clientWidth;
h = document.body.clientHeight;
}
}
//w3c
else
{
w = window.innerWidth;
h = window.innerHeight;
}
return {width:w,height:h};
}
window.center = function()
{
var hWnd = (arguments[0] != null) ? arguments[0] : {width:0,height:0};
var _x = 0;
var _y = 0;
var offsetX = 0;
var offsetY = 0;
//IE
if(!window.pageYOffset)
{
//strict mode
if(!(document.documentElement.scrollTop == 0))
{
offsetY = document.documentElement.scrollTop;
offsetX = document.documentElement.scrollLeft;
}
//quirks mode
else
{
offsetY = document.body.scrollTop;
offsetX = document.body.scrollLeft;
}
}
//w3c
else
{
offsetX = window.pageXOffset;
offsetY = window.pageYOffset;
}
_x = ((this.size().width-hWnd.width)/2)+offsetX;
_y = ((this.size().height-hWnd.height)/2)+offsetY-115;
return{x:_x,y:_y};
}

function refreshCaptcha()
{
	var randomnumber = Math.floor(Math.random()*99999999);
	img_captcha.src = '/common/captcha.php?rand=' + randomnumber;
}

function Ltrim(val)
{
	return val.replace(/^\s+/,"");
}

function Rtrim(val)
{
	return val.replace(/\s+$/,"");
}

function trim(val)
{
	return Ltrim(Rtrim(val));
}

function chkSpecialChar(val)
{
	var iChars = "`~_!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	
	for (var i = 0; i < val.length; i++)
	{
		if (iChars.indexOf(val.charAt(i)) != -1)
		{
			return false;
		}
	}
	return true;
}

function IsNumeric(val)
{
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;	
	for (i = 0; i < val.length && IsNumber == true; i++) 
	{
		Char = val.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}

function createCookie(name,value,seconds)
{
    var date = new Date();
    date.setTime(date.getTime()+(seconds*1000));
    var expires = "; expires="+date.toGMTString();
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name)
{
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++)
    {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name)
{
    createCookie(name,"",-1);
}

function addComment(theForm)
{
	var iChars = "`~^"; 
	var err='', response;
	var author = trim(theForm.author.value);
	var comment = trim(theForm.cmnComment.value);
	var page_type = theForm.page_type.value;
	var submit_obj = theForm.getElementsByTagName('input')[theForm.getElementsByTagName('input').length - 3];
	var cancel_obj = theForm.getElementsByTagName('input')[theForm.getElementsByTagName('input').length - 1];
	var loader_obj = theForm.getElementsByTagName('span')[theForm.getElementsByTagName('span').length - 1];
	var month = theForm.month.value;
	var year = theForm.year.value;
	var article_id = theForm.article_id.value;
	var domain = theForm.cmnwebsite.value;
	
	if(author == ""){
		err +='Please enter your name.\n';
		//return false;
	}
	else if(author.length < 3){
		err +='Name should be atleast three characters.\n';
	}
	else if(!chkSpecialChar(author)){
		err +='Name should not have special characters.\n';
	} else if(IsNumeric(author)) {
		err +='Name should contain atleast one alphabet.\n';
	}
	if(comment==""){
		err +='Comment cannot be blank.\n';
	} else if(comment!="") {
		cerr = '';
		for (var i = 0; i < comment.length; i++) {
			if (iChars.indexOf(comment.charAt(i)) != -1) {
				cerr = "Comment can't have special characters.\n";
			}
		}
		err += cerr;
	}
	if(trim(theForm.scode.value)==''){
		err +='Please enter Security Code.';
	}
	if(err != '')
	{
		alert(err);
		return false;
	}	
	var theDiv = 'DisplayAllComments';
	var path = theForm.path.value;
	var aid = theForm.aid.value;
	var pid = theForm.pid.value;
	var container_id = theForm.container_id.value;
	var newpath = path.replace(/\//g, "_");
	showLoader(submit_obj, cancel_obj, loader_obj);
	var status = AjaxRequest.submit(
		theForm
		,{
			'onSuccess':function(req)
			{
			  response = trim(req.responseText);
			  responseData = response.split('~~||~~');
			  //alert(response); return false;
			  if(response == 'captcha_error')
			  {
			  	hideLoader(submit_obj, cancel_obj, loader_obj);
				//alert("Please enter valid security code.");
				alert('Error in processing security code.\nPlease enter new security code.');
				loadCaptcha('frmComments');
			  }
			  else if(response == 'ip_blocked')
			  {
			  	hideLoader(submit_obj, cancel_obj, loader_obj);
				closeDiv(container_id);
				createCookie('oneIndia-comments', '1', 300);
			  }
			  else if(responseData[0] == 'comment_inserted')
			  {
			  	hideLoader(submit_obj, cancel_obj, loader_obj);
					closeDiv(container_id);
					createCookie('oneIndia-comments', '1', 300);
					if (document.getElementById("no_comments_div"))
					{
						document.getElementById("no_comments_div").style.display = 'none';
					}
					//showComments(newpath, aid, pid);
					document.getElementById('actual-comments-div').innerHTML = responseData[2];
					//window.location.hash = 'cmntTop';
					if (page_type == 'article')
					{
						document.getElementById('read-all-comments').innerHTML = '&nbsp; &nbsp;[ <a id="read-all-link" href="/comment/' + year + '/' + month + '/' + getContentId() + '.html" target="_blank" class="smalllink">Read All Comments</a> ]';
					}
					if (page_type == 'article')
					{
						showCommentAlert('/comment/' + year + '/' + month + '/' + getContentId() + '.html');
					}
					else
					{
						alert('Your comment has been added.');
					}
					window.setTimeout("getLatestComments()",100);
			  }
			  else
			  {
			  	hideLoader(submit_obj, cancel_obj, loader_obj);
					alert('Your comment has been added.\nIt will appear in few minutes.');
					closeDiv(container_id);
					createCookie('oneIndia-comments', '1', 300);
			  }
			}
			,'onError':function(req)
			{
				hideLoader(submit_obj, cancel_obj, loader_obj);
				//alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
			}
		}
	);
	
	/*alert(ie);
	alert(comment_status);
	if (ie && comment_status)
	{
		iePopup();
	}*/
	return false;
}

function showLoader(submit_obj,cancel_obj,loader_obj)
{
	submit_obj.style.display = 'none';
	cancel_obj.style.display = 'none';
	loader_obj.style.display = '';
}
function hideLoader(submit_obj,cancel_obj,loader_obj)
{
	loader_obj.style.display = 'none';
	submit_obj.style.display = '';
	cancel_obj.style.display = '';	
}

function loadCaptcha(theForm)
{
	img_captcha = '/common/captcha.php?rand=' + Math.floor(Math.random()*99999999);
	document.getElementById("" + theForm + "").getElementsByTagName('img')[document.getElementById("" + theForm + "").getElementsByTagName('img').length - 4].src = img_captcha;
	document.getElementById("" + theForm + "").getElementsByTagName('input')[document.getElementById("" + theForm + "").getElementsByTagName('input').length - 4].value = '';
}

function reportAbuse(theForm)
{
	var err='', response, checked = false;
	if((theForm.abusecheck1.checked == true) || (theForm.abusecheck2.checked == true) || (theForm.abusecheck3.checked == true) || (theForm.abusecheck4.checked == true) || (theForm.abusecheck5.checked == true) || (theForm.abusecheck6.checked == true))
	{
		checked= true;
	}
	if(!checked)
	{
		err += 'Please select the reason(s) that best describe your complaint\n';
	}
	if(trim(theForm.scode.value)==''){
		err +='Please enter Security Code.';
	}
	if(err != '')
	{
		alert(err);
		return false;
	}

	var aid = theForm.aid.value;
	var container_id = theForm.container_id.value;
	var submit_obj = theForm.getElementsByTagName('input')[theForm.getElementsByTagName('input').length - 3];
	var cancel_obj = theForm.getElementsByTagName('input')[theForm.getElementsByTagName('input').length - 1];
	var loader_obj = theForm.getElementsByTagName('span')[theForm.getElementsByTagName('span').length - 1];
	showLoader(submit_obj, cancel_obj, loader_obj);
	var status = AjaxRequest.submit(
		theForm
		,{
			'onSuccess':function(req)
			{ 
			  response = req.responseText;
			  //alert(response);
			  if(response == 'error')
			  {
			  	hideLoader(submit_obj, cancel_obj, loader_obj);
					alert('Please enter valid security code.');
			  }
			  else if(response == 'success')
			  {
			  	hideLoader(submit_obj, cancel_obj, loader_obj);
				closeDiv(container_id);
				alert('Your abuse report has been sent.');
			  }
			  else if(response == 'failed1')
			  {
			  	hideLoader(submit_obj, cancel_obj, loader_obj);
				alert('Failed to send your abuse report.');
			  }
			  else
			  {
			  	hideLoader(submit_obj, cancel_obj, loader_obj);
				alert('Failed to send your abuse report.');
			  }
			  
			}
			,'onError':function(req)
			{ 
				hideLoader(submit_obj, cancel_obj, loader_obj);
				//alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
			}
		}
	);
	return false;
}

function getLatestComments()
{
	var pageURL = "/scripts/comments/publish_recent_comments.php?domain=living.oneindia.in";
	var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req){
					//alert(req.responseText);
				}
			,'onError':function(req)
				{ 
					//alert(req.statusText+'\nContents='+req.responseText); 
				}
		}
	);
	return false;
}

function showComments(path, aid, pid)
{
	document.getElementById('preDiv').value = '';
	var pageURL = "/new_comments/comments_"+path+aid;
	var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req){
					//alert(pid);
					//alert(req.responseText);
					var objDiv = document.getElementById('DisplayAllComments');
					if(objDiv.style.display=='none')
						objDiv.style.display='block';
					document.getElementById('DisplayAllComments').innerHTML = req.responseText;
					if(pid > 1)
					{
						var page = 'Comment'+pid;
						//switchPage(page);
					}
					else
					{
						var page = 'Comment1';
					}
					readComments(page);
					document.location.href='#cmntTop';
				}
			,'onError':function(req)
				{ 
					//alert(req.statusText+'\nContents='+req.responseText); 
				}
		}
	);
	return false;
}

function showCommentsForm(path, aid, parent_id, theDiv, level_id, pid, wid)
{
	if(pid == 1 && document.getElementById('prePage'))
	{
		var prepage = document.getElementById('prePage').value;
		readComments(prepage);
	}
	var preDiv = document.getElementById('preDiv').value;
	if(preDiv == '')
	{
		document.getElementById('preDiv').value = theDiv;
	}
	else
	{
		closeDiv(preDiv);
		document.getElementById('preDiv').value = theDiv;
	}

	var cmnwebsite = window.location.hostname;
	var cmntitle = getmetaContents('title');

	var pageURL = "/post_comments.php?path="+path+"&aid="+aid+"&parent_id="+parent_id+"&theDiv="+theDiv+"&level_id="+level_id+"&pid="+pid+"&wid="+wid+"&cmnwebsite="+cmnwebsite+"&cmntitle="+cmntitle;
//alert(pageURL); return false;
	var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req){
					theFormTxt = req.responseText;
					//alert(theFormTxt);
					document.getElementById(theDiv).style.display = 'block';
					document.getElementById(theDiv).innerHTML = theFormTxt;
				}
			,'onError':function(req){ alert(req.statusText+'\nContents='+req.responseText); }
		}
	);
	return false;
}

function showCommentsFormNew(path, aid, parent_id, theDiv, level_id, pid, wid)
{
	if(pid == 1 && document.getElementById('prePage'))
	{
		var prepage = document.getElementById('prePage').value;
		readComments(prepage);
	}
	var preDiv = document.getElementById('preDiv').value;
	if(preDiv == '')
	{
		document.getElementById('preDiv').value = theDiv;
	}
	else
	{
		closeDiv(preDiv);
		document.getElementById('preDiv').value = theDiv;
	}

	var cmnwebsite = window.location.hostname;
	var cmntitle = getmetaContents('title');

	var pageURL = "/post_comments.php?path="+path+"&aid="+aid+"&parent_id="+parent_id+"&theDiv="+theDiv+"&level_id="+level_id+"&pid="+pid+"&wid="+wid+"&cmnwebsite="+cmnwebsite+"&cmntitle="+cmntitle;
	//alert(pageURL); return false;
	var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req){
					theFormTxt = req.responseText;
					//alert(theFormTxt);
					document.getElementById(theDiv).style.display = 'block';
					document.getElementById(theDiv).innerHTML = theFormTxt; 
				}
			,'onError':function(req){ alert(req.statusText+'\nContents='+req.responseText); }
		}
	);
	return false;
}

var current_comment_box = '';

function showCommentsFormNew1(path, aid, parent_id, theDiv, level_id, pid, wid, article_id, month, year, page_type)
{
	var cmnwebsite = window.location.hostname;
	var cmntitle = getmetaContents('title');

	var pageURL = "/scripts/comments/post_comments.php?path="+ cmnwebsite+path+"&aid="+aid+"&parent_id="+parent_id+"&theDiv="+theDiv+"&level_id="+level_id+"&pid="+pid+"&wid="+wid+"&cmnwebsite="+cmnwebsite+"&cmntitle="+cmntitle+"&art_id="+article_id+"&month="+month+"&year="+year+"&page_type="+page_type;
	//alert(pageURL); return false;
	var status = AjaxRequest.get(
		{
			'url':pageURL
			,'onSuccess':function(req){
					theFormTxt = req.responseText;
					//alert(theFormTxt);
					//alert(current_comment_box);
					if (current_comment_box != '' && document.getElementById(current_comment_box))
					{
						document.getElementById(current_comment_box).innerHTML = '';
						document.getElementById(current_comment_box).style.display = 'none';
					}
					if (current_comment_box != '')
					{
						//alert(document.getElementById(current_comment_box).innerHTML);
					}
					document.getElementById(theDiv).style.display = 'block';
					document.getElementById(theDiv).innerHTML = theFormTxt;
					current_comment_box = theDiv;
				}
			,'onError':function(req){ alert(req.statusText+'\nContents='+req.responseText); }
		}
	);
	document.getElementById('newCommentFormDiv').style.display = 'none';
	return false;
}

function readComments(id)
{
	if(document.getElementById('readComments'))
	{
		document.getElementById('readComments').style.display = 'none';
		document.getElementById('CommentsInitial').style.display = 'none';
	}
	document.getElementById(id).style.display = 'block';
}

function makeOriginalFormBlank()
{
	var orig_div = document.getElementById('cmntsForm');

	orig_div.getElementsByTagName("form")[0].name = '';
	orig_div.getElementsByTagName("form")[0].id = '';
	orig_div.getElementsByTagName("input")[1].value = '';
	orig_div.getElementsByTagName("input")[2].value = '';
	orig_div.getElementsByTagName("input")[3].value = '';
	orig_div.getElementsByTagName("input")[4].value = '';
	orig_div.getElementsByTagName("input")[5].value = '';
	orig_div.getElementsByTagName("input")[6].value = '';
	orig_div.getElementsByTagName("input")[7].value = '';
	orig_div.getElementsByTagName("input")[8].value = '';
	orig_div.getElementsByTagName("input")[9].value = '';
	orig_div.getElementsByTagName("input")[10].value = '';
	orig_div.getElementsByTagName('img')[orig_div.getElementsByTagName('img').length - 4].src = '';
}

function checkSleep()
{
	return true;
}

function getmetaContents(mn)
{
	var m = document.getElementsByTagName('meta');
	var metaTitle = '';
	for(var i in m)
	{
		if(m[i].name == mn)
		{
			metaTitle = m[i].content;
		}
	}
	if((metaTitle == '') || (metaTitle == 'undefined'))
	{
		metaTitle = document.title;
	}
	return metaTitle;
}
var current_abuse_box = '';
function showReportAbuse(aid, comment_id, theDiv, wid)
{
	var randomnumber = Math.floor(Math.random()*999999)
	document.getElementById('abuspace').width = wid;
	document.getElementById('abuaid').value = aid;
	document.getElementById('abucontainer_id').value = theDiv;
	document.getElementById('abucomment_id').value = comment_id;
	//refreshCaptcha();
	//captcha_pre_load = new Image('/common/captcha.php?rand=' + randomnumber);
	document.getElementById('abucaptcha').src = '/common/captcha.php?rand=' + randomnumber;

	//theFormTxt = document.getElementById('abuseForm').innerHTML;
	if (current_abuse_box != '' && document.getElementById(current_abuse_box))
	{
		document.getElementById(current_abuse_box).style.display = 'none';
	}
	
	window.setTimeout("document.getElementById('"+theDiv+"').innerHTML = document.getElementById('abuseForm').innerHTML; document.getElementById('"+theDiv+"').style.display = 'block';",100);
	current_abuse_box = theDiv;
	//alert('ji');
	//return false;
}

function hideComments(theDiv)
{
	var objDiv = document.getElementById(theDiv);
	
	if(objDiv.style.display=='block')
		objDiv.style.display='none';
}

function switchPage(id)
{
	//safe function to show an element with a specified id
	var prepage = document.getElementById('prePage').value;
	var preDiv = document.getElementById('preDiv').value;
	if(preDiv != '')
	{
		closeDiv(preDiv);
	}
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
		document.getElementById(prepage).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
			document.prepage.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
			document.all.prepage.style.display = 'none';
		}
	}
	document.getElementById('prePage').value = id;
	document.location.href='#cmntTop';
}

function closeDiv(id)
{
document.getElementById(id).innerHTML='';
}

function textCounter(field, countfield, maxlimit)
{
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);// otherwise, update 'characters left' counter
	else 
		countfield.innerHTML = maxlimit - field.value.length;
}

function showFullComments()
{
	if ((location.hash != '') && (location.hash != '#cmntTop'))
	{
		readComments('Comment1');
	}
}

/*function newPopup(url)
{
	popupWindow = window.open(url,'CommentsWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes').blur();
	//popupWindow.focus();
	window.focus();
}
*/
function newPopup(url)
{
	var form = document.createElement("form");
	form.method = "GET";
	form.action = url;
	form.target = "_blank";
	document.body.appendChild(form);
	form.submit();
	window.focus();
}

function iePopup()
{
	//alert("inside");
	if (document.getElementById('read-all-link') && (document.getElementById('read-all-link').href != ''))
	{
		document.getElementById('read-all-link').click();
		window.focus();
	}
	else
	{
		setTimeout("iePoupup()", 100);
	}	
	
}

/*function showCommentAlert(url)
{
	var point = window.center({width:270,height:80});
	alert(point.y);
	alert(point.x);
	var div = document.createElement("div");
	div.setAttribute('id',"alertDiv");
	div.style.background = "#dedede";
	div.style.border="solid 1px navy";
	div.style.position = "absolute";
	div.style.top = point.y + "px";
	div.style.left = point.x + "px";
	div.style.width = "280px";
	div.style.height = "80px";
	div.style.padding = "10px";
	div.style.font = "normal 12px arial,verdana";
	div.innerHTML = '<br />Your comment has been added.<br /><br /><form><input type="button" name="alert_ok" value="OK" onclick="callPopup(' + "'" + url + "'" + ');" /></form>';
	document.body.appendChild(div);
	document.body.setAttribute('onClick', "callPopup(" + "'" + url + "'" + ");");
}*/

var comment_alert_tab = new Image();
comment_alert_tab.src = '/img/comments/alert.jpg';
var comment_alert_icon = new Image();
comment_alert_icon.src = '/img/comments/alert-icon.jpg';
function showCommentAlert(url)
{
	var point = window.center({width:270,height:115});
	var div = document.createElement("div");
	div.setAttribute('id',"alertDiv");
	div.style.verticalAlign="middle";
	div.style.textAlign="center";
	div.style.background ="#ece9d8";
	div.style.position = "absolute";
	div.style.top = point.y + "px";
	div.style.left = point.x + "px";
	div.style.width = "270px";
	div.style.display = "none";
	div.style.height = "115px";
	div.style.padding="0px";
	div.style.font = "normal 12px arial,verdana";
	div.innerHTML = '<img id="alert-tab-img" src="/img/comments/alert.jpg" border="0" /><div id="info-box" style="margin-top: -5px;height: 86px;padding: 0px;border: solid 2px #0047df;width: 266px;"><div id="alert-icon-div" style="float: left;"><img id="alert-icon-img" src="/img/comments/alert-icon.jpg" border="0" style="float: left;padding-top: 10px;padding-bottom: 5px;padding-right:10px;padding-left: 10px;"  /></div><div id="comment-alert-msg-div" style="float: left;padding-top:20px;font: normal 12px arial;">Your comment has been added.</div><div id="alert-form-div" style="padding-top: 50px;*padding-top: 25px;"><form><input type="button" style="width: 73px;height: 23px;font: normal 11px arial;" name="alert_ok" value="OK" onclick="callPopup(' + "'" + url + "'" + ');" /></form></div></div>';
	document.body.appendChild(div);
	document.getElementById('alert-tab-img').src = comment_alert_tab.src;
	document.getElementById('alert-icon-img').src = comment_alert_icon.src;
	document.body.setAttribute('onClick', "callPopup(" + "'" + url + "'" + ");");
	document.getElementById("alertDiv").style.display="block";
}


function callPopup(url)
{
	if (ie)
	{
		iePopup();
	}
	else
	{
		newPopup(url);
	}
	//alert(document.getElementById("alertDiv"));
	var divobj = document.getElementById("alertDiv");
	//alert(divobj);
	document.body.removeChild(divobj);
	document.body.setAttribute('onClick', "");
	return false;
}
function setReadAllLink()
{
	if (document.getElementById('article_info_form'))
	{
		var obj = document.getElementById('article_info_form');
		var article_id = obj.content_id.value;
		//alert(article_id);
		var d_obj = document.getElementById('read-all-comments');
		var a_obj = document.getElementById('read-all-link');
		a_obj.href = (a_obj.href).replace('.html', article_id + '.html');
		d_obj.style.display = 'block';
		/*if (read_all_link)
		{
			d_obj.style.display = 'block';
		}*/
		//alert(a_obj.href);
	}
}

function setTopReadAllLink()
{
	var str = document.getElementById('read-all-comments').innerHTML;
	str = str.replace("[ ","");
	str = str.replace(" ]","");
	str = str.replace("Read All Comments","<b>Post/Read All Comments</b>");
	document.getElementById('top_read_all_comments').innerHTML = str;
}

function getContentId()
{
	if (document.getElementById('article_info_form'))
	{
		return document.getElementById('article_info_form').content_id.value;
	}
}

function hookEvent(el, event, fn)
{
	if ( el.attachEvent )
		el.attachEvent("on"+event, fn);
	else
		el.addEventListener(event, fn, false);
}
