function resetCommFrm()
{
	//reset the form 
	document.getElementById("commFrm").reset();
	
	//remove message if any
	var msg = document.getElementById("commMsg");
	msg.style.display='none';
}

function toggleComment()
{	
	var commSign =document.getElementById("commSign"); 	
	var commDIV = document.getElementById("commDIV");
	
	//var signVal = commSign.firstChild.nodeValue;
	var signVal = commSign.innerHTML;
	
	
	
	if(signVal == '+')
	{		
		commDIV.style.display = 'block';	
		//commSign.firstChild.nodeValue = '-';
		commSign.innerHTML='-';
		
	}
	else if(signVal == '-')
	{		
		commDIV.style.display = 'none';	
		//commSign.firstChild.nodeValue = '+'; 
		commSign.innerHTML='+';
		
	}
	
}

function commentAjaxFunction(section){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		
		if(ajaxRequest.readyState == 4){
			
			//hide loading div
			var loader = document.getElementById("detailCommLoadingDIV");
			loader.innerHTML = '';
			
			if(ajaxRequest.responseText)
			{
				var ajaxDisplay = document.getElementById("comments");
				//ajaxDisplay.firstChild.nodeValue = ajaxRequest.responseText;
				
				var msg = document.getElementById("commMsg");				
				if(ajaxRequest.responseText == '1')
				{					
					msg.firstChild.nodeValue = 'Enter Your Comment Title. ';
					
				}
				else if(ajaxRequest.responseText == '2')
				{
					msg.firstChild.nodeValue = 'Enter Your Name. ';
				}
				else if(ajaxRequest.responseText == '3')
				{
					msg.firstChild.nodeValue = 'Your Email Adress is not valid. ';
				}
				else if(ajaxRequest.responseText == '5')
				{
					msg.firstChild.nodeValue = 'Enter Your Message. ';
				}
				else if(ajaxRequest.responseText == '6')
				{
					msg.firstChild.nodeValue = 'Your Comment Could Not be Saved. Please Retry';
				}
				else
				{					
					ajaxDisplay.innerHTML = ajaxRequest.responseText;
					
					//set msg property to table-cell
					if(isIE())
					{
						msg.style.display = 'block';
					}
					else
					{
						msg.style.display = 'table-cell';
					}
					
					msg.innerHTML = 'Your Opinion has been saved.';
										
					//alert(ajaxRequest.responseText);
					//document.commFrm.comm_title.value= '';
					//window.alert(comm_title);
					document.commFrm.comm_name.value = '';
					//window.alert(comm_name);
					document.commFrm.comm_email.value = '';
					//window.alert(comm_email);
					document.commFrm.comm_details.value = '';
				}
				
				
			}
			else
			{
				
				var msg = document.getElementById("msg");
				msg.firstChild.nodeValue = 'Error saving comment. Please retry.';
			}
		}
		else {
			
				var loader = document.getElementById("detailCommLoadingDIV");
				loader.innerHTML = '<img src="'+normal_path+'image/templateImg/detailCommLoading.gif">';
			}
	}
	
	if(ValidateForm())
	{	
	var comm_name = document.commFrm.comm_name.value;
	
	var comm_email = document.commFrm.comm_email.value;
	
	var comm_details = document.commFrm.comm_details.value;
	//window.alert(comm_details);
	var comm_type = document.commFrm.comm_type.value;
	//window.alert(comm_type);
	var comm_link = document.commFrm.comm_link.value;
	//window.alert(comm_link);
	
	
	var queryString = "section=" + section + "&comm_name=" + comm_name + "&comm_email=" + comm_email + "&comm_details=" + comm_details + "&comm_type=" + comm_type + "&comm_link=" + comm_link;
	ajaxRequest.open("POST", "php/comment.php", true);
	
	//Send the proper header information along with the request
	ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequest.setRequestHeader("Content-length", queryString.length);
	ajaxRequest.setRequestHeader("Connection", "close");
	
	ajaxRequest.send(queryString); 
	}
}

function reportComment(phn_id,comm_id,comm_type)
{ 
	var ajaxRequest;  // The variable that makes Ajax possible!
			
			try{
				
				// Opera 8.0+, Firefox, Safari
				ajaxRequest = new XMLHttpRequest();
			} catch (e){
				// Internet Explorer Browsers
				try{
					
					ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try{
						
						ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e){
						// Something went wrong
						alert("Your browser broke!");
						return false;
					}
				}
			}
			
			// Create a function that will receive data sent from the server
			ajaxRequest.onreadystatechange = function()
			{
				if(ajaxRequest.readyState == 4)
				{
					var ajaxDisplay = ajaxRequest.responseText;
					if(ajaxDisplay == 1)
					{
						//document.getElementById('putMsg').innerHTML = '<div  style="color:#1D5396;margin-top:30px; border:solid 1px #A4E1FF;background-color:#E7F9FE;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;font-weight:bold;text-align:center;opacity:100;">Your report has been submitted.</div>';
						//showAnimDiv('reportMsg');
						reportMsgBox('Your report has been submitted.');
						//window.alert("Your report has been submitted.");
					}
					else if(ajaxDisplay == 0)
					{
						//document.getElementById('putMsg').innerHTML = '<div  style="color:#1D5396;margin-top:30px; border:solid 1px #A4E1FF;background-color:#E7F9FE;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;font-weight:bold;text-align:center;opacity:100;">Your report has been consider as a spam.</div>';
						//showAnimDiv('reportMsg');
						reportMsgBox('Your report has been consider as a spam.');
						//window.alert("Your report has been consider as a spam.");
					}
					else if(ajaxDisplay == 2)
					{
						//document.getElementById('putMsg').innerHTML = '<div  style="color:#1D5396;margin-top:30px;border:solid 1px #A4E1FF;background-color:#E7F9FE;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;font-weight:bold;text-align:center;opacity:100;">This comment has already been reported.</div>';
						//showAnimDiv('reportMsg');
						
						//window.alert("This comment has already been reported.");
						
						reportMsgBox('This comment has already been reported.');
					}
					else
					{
						//document.getElementById('putMsg').innerHTML = '<div  style="color:#1D5396;margin-top:30px; border:solid 1px #A4E1FF;background-color:#E7F9FE;font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px;font-weight:bold;text-align:center;opacity:100;">Some Error occured to send this report.'+ajaxDisplay+'<div>';
						//showAnimDiv('reportMsg');
						reportMsgBox('Some Error occured to send this report.'+ajaxDisplay);
						//window.alert("Some Error occured to send this report."+ajaxDisplay);
					}
										
				}
				
			}
			
			var queryString = "phn_id=" + phn_id + "&comm_id=" + comm_id + "&comm_type=" + comm_type;
			//alert(queryString);
			ajaxRequest.open("POST", host + "php/reportAjax.php", true);
			
			//Send the proper header information along with the request
			ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			ajaxRequest.setRequestHeader("Content-length", queryString.length);
			ajaxRequest.setRequestHeader("Connection", "close");
			
			ajaxRequest.send(queryString);
}