function myXMLHttpRequest () {
  	var xmlhttplocal;

  	try {
  		xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")
  	}
  	
  	catch (e) {
		try {
			xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")
		}
		catch (E) {
	  		xmlhttplocal = false;
		}
  	}

  	if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
		try {
	  		var xmlhttplocal = new XMLHttpRequest ();
		}
		catch (e) {
	  		var xmlhttplocal = false;
		}
  	}
  	return (xmlhttplocal);
}

function comment(obj,url) {
	var hdnLinkId;
	hdnLinkId = document.getElementById('hdnLinkId').value;
	
	var newUrl = url+'/getComments.php?obj='+obj+"&amp;linkid="+hdnLinkId;
	
	checkitxmlhttp = new myXMLHttpRequest ();
	
	checkitxmlhttp.open ("GET", newUrl, true);
	checkitxmlhttp.send ("null");
	
	checkitxmlhttp.onreadystatechange = function(){
		if (checkitxmlhttp.readyState == 4) {
			responsestring = checkitxmlhttp.responseText;
			document.getElementById("commentAll").style.display = 'none';
			document.getElementById("commentCombo").innerHTML = responsestring;
		}
	}
}

function profaneFilteration(id) {
	if(id == 1) {
		document.getElementById('commentAll').style.display = 'none';
		document.getElementById('commentAll1').style.display = '';
		document.getElementById('filter').style.display = 'none';
		document.getElementById('unfilter').style.display = '';		
	}
	else {
		document.getElementById('commentAll').style.display = '';
		document.getElementById('commentAll1').style.display = 'none';	
		document.getElementById('filter').style.display = '';
		document.getElementById('unfilter').style.display = 'none';	
	}
}

function hideComment(id) {
	document.getElementById('hideComment-'+id).innerHTML = 'Show Comment';
	document.getElementById('hideComment-'+id).href = "javascript:showComment("+id+")";
	document.getElementById("hideShowReply-"+id).style.display = 'none';
	
	//document.getElementById('cvote-'+id).style.display = 'none';
	//document.getElementById('comment_content-'+id).style.display = 'none';
	/*document.getElementById('hideComment').style.display = 'none';
	document.getElementById('showComment').style.display = 'block';
	*/
}

function showComment(id) {
	document.getElementById('hideComment-'+id).innerHTML = 'Hide Comment';
	document.getElementById('hideComment-'+id).href = "javascript:hideComment("+id+")";
	document.getElementById("hideShowReply-"+id).style.display = 'block';
	
	/*document.getElementById('showComment').style.display = 'none';
	document.getElementById('hideComment').style.display = 'block';
	document.getElementById("hideShowReply-"+id).style.display = 'block';*/
}

var timerlen = 80;
var slideAniLen = 250;

var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();

function slidedown(objname, anchorId) {
    if(moving[objname])
            return;

    if(document.getElementById(objname).style.display != "none")
            return; // cannot slide down something that is already visible

    moving[objname] = true;
    dir[objname] = "down";
    
    document.getElementById('hideComment-'+anchorId).innerHTML = 'Hide Comment';
	document.getElementById('hideComment-'+anchorId).href = "javascript:slideup('" + objname + "' , '" + anchorId +"')";
    
	startslide(objname);
}

function slideup(objname, anchorId) {
    if(moving[objname])
            return;

    if(document.getElementById(objname).style.display == "none")
            return; // cannot slide up something that is already hidden

    moving[objname] = true;
    dir[objname] = "up";
    
    document.getElementById('hideComment-'+anchorId).innerHTML = 'Show Comment';
	document.getElementById('hideComment-'+anchorId).href = "javascript:slidedown('" + objname + "' , '" + anchorId +"')";
    
    startslide(objname);
}

function startslide(objname) {
    obj[objname] = document.getElementById(objname);
    endHeight[objname] = parseInt(obj[objname].style.height);
    startTime[objname] = (new Date()).getTime();
    
    if(dir[objname] == "down"){
	        //commented on 3rd oct, to avoid problem of extra vertical spaces when click on show comment and to display full text of comment
           // obj[objname].style.height = "1px";
	obj[objname].style.height = null;
    }

    obj[objname].style.display = "block";

    timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}

function slidetick(objname) {
    var elapsed = (new Date()).getTime() - startTime[objname];

    if (elapsed > slideAniLen)
            endSlide(objname)
    else {
            var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
            if(dir[objname] == "up")
                    d = endHeight[objname] - d;

	//commented for to avoid functionality problem of hide and show comment
       // obj[objname].style.height = d + "px";
    }

    return;
}

function endSlide(objname) {
    clearInterval(timerID[objname]);

    if(dir[objname] == "up")
            obj[objname].style.display = "none";

	  //commented for to avoid functionality problem of hide and show comment 
	// obj[objname].style.height = endHeight[objname] + "px";

    delete(moving[objname]);
    delete(timerID[objname]);
    delete(startTime[objname]);
    delete(endHeight[objname]);
    delete(obj[objname]);
    delete(dir[objname]);

    return;
}

