/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/
/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 




function discuss(issue,name1){

//alert(issue)
document.comment.issue.value=issue;
if(name1!=undefined){
document.getElementById('issueName').innerHTML=name1;}
var dTime = new Date();
ti=dTime.setHours(dTime.getHours(),dTime.getMinutes(),dTime.getSeconds());//document.getElementById('user1').innerHTML="";
http.open('get','discussion.php?issue='+issue+'&ti='+ti);
//alert("check");
http.onreadystatechange = handleSC1;  
http.send(null);

var selID=document.moreHid.selID.value;

	var dum=document.comment.previousId.value;
	//alert(dum);
	

	if(dum!=issue){
				
		if(dum!=""){
			document.comment.previousId.value=issue;
			document.getElementById('td'+issue).className="discSel";
			document.getElementById('td'+dum).className="disc";
			
			//alert('ss');
		}else{
			document.comment.previousId.value=issue;
			document.getElementById('td'+selID).className="disc";
			document.getElementById('td'+issue).className="discSel";
			//document.getElementById('td'+dum).className="disc";
		}

	}

}


/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleSC1(){
	
	if(http.readyState == 1){			};//alert(http.readyState+"ikik"+response);
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;



			if (response=="")
			{
			}else{
				
					document.getElementById('user1').innerHTML="";
				document.getElementById('user1').innerHTML=unescape(response);
				//document.getElementById('user1').innerHTML=unescape(response);
				
				//alert(response)
			}
	}
}

function submitComments(){
	if(document.comment.issue.value!=""){
isssue=document.comment.issue.value;
	}else{isssue=document.moreHid.selID.value;}
//alert(isssue);
//name=document.comment.name.value;
//city=document.comment.city.value;
comments=document.comment.comments.value;
//alert(comments);
var dTime = new Date();
	ti=dTime.setHours(dTime.getHours(),dTime.getMinutes(),dTime.getSeconds());
http.open('get','discussionAction.php?issue='+isssue+'&comments='+comments+'&t='+ti);

http.onreadystatechange = handleSC2; 
http.send(null);



}
function handleSC2(){

	
	if(http.readyState == 1){};
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;

			//alert(response+"before"); 
			if (response=="")
			{		//	alert(response+"empty"); 
			}else{				
				
				isssue=document.comment.issue.value;				
				discuss(isssue);
				//alert(isssue); 
				//document.comment.city.value="";
				document.comment.comments.value="";
				
			}
	}
}

function more(nextrow,id, name13){
	//alert("check");
	//alert(nextrow);
	//alert(id);
    document.getElementById('issueName').innerHTML=name13;
	
/*document.comment.issue.value=issue;*/
var dTime = new Date();
	ti=dTime.setHours(dTime.getHours(),dTime.getMinutes(),dTime.getSeconds());
http.open('get','more.php?nextrow='+nextrow+'&id='+id+'&ti='+ti);

http.onreadystatechange = handleSC3; 
http.send(null);
			document.comment.previousId.value="";

}

function handleSC3(){
	
	if(http.readyState == 1){};
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;

			//alert(response);

			if (response=="")
			{
			}else{
				alert(response);
				document.getElementById('abc').innerHTML=response;
				var selID=document.moreHid.selID.value;
				//alert(selID);
				discuss(selID);
				
			}
	}
}

function what(id){
	
	//alert(id);  
	

http.open('get','changeWhatsNew.php?id='+id);

http.onreadystatechange = handleSC4; 
http.send(null);
			//document.comment.previousId.value="";

}

function handleSC4(){
	//alert('arun');
	if(http.readyState == 1){};
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;

			//alert(response);

			if (response=="")
			{
			}else{
				//alert(response);

				document.getElementById('whatsNew').innerHTML=response;
				
				
			}
	}
}

function subcat(id){
	
	//alert(id);  
	

http.open('get','subCate.php?id='+id);

http.onreadystatechange = handleSC5; 
http.send(null);
			//document.comment.previousId.value="";

}

function handleSC5(){
	
	if(http.readyState == 1){};
	if(http.readyState == 4){ //Finished loading the response
		var response = http.responseText;

			//alert(response);

			if (response=="")
			{
			}else{
				//alert(response);

				document.getElementById('subCat').innerHTML=response;
				
				
			}
	}
}
