var GUserCommentsIE;	
var GUserCommentsAjaxReq      		= null;
var GUserCommentsAjaxDoc     		  = null;
var GUserCommentsWhat  				 		= null;
var GUserCommentsUrl 							= null;
var GUserCommentsAjaxDiv         	= null;
var GUserCommentsForm       			= null;
var GUserCommentsSubmitParams 		= null;
  
if ((document.all) && (navigator.userAgent.indexOf('Opera')== -1)) {
	GUserCommentsIE = true;
} else {
	GUserCommentsIE = false;
}
  
  
function UserCommentsNewRequest() {
	if (GUserCommentsIE == true)  {
		return new ActiveXObject("Microsoft.XMLHTTP");    
	} else {
		return new XMLHttpRequest();
	}
}

function UserCommentsProcessAjax() {
	if ((GUserCommentsAjaxReq.readyState == 4) && ((GUserCommentsAjaxReq.status == 200) || (GUserCommentsAjaxReq.status == 404))) {
		GUserCommentsAjaxDoc = GUserCommentsAjaxReq.responseText;
		GUserCommentsAjaxDiv.innerHTML = GUserCommentsAjaxDoc;
	}
	
}

function UserCommentsSubmit() {
	try {
		GUserCommentsAjaxReq = UserCommentsNewRequest();
		GUserCommentsAjaxReq.onreadystatechange = UserCommentsProcessAjax;
		
		GUserCommentsAjaxReq.open("POST", GUserCommentsUrl, true);
		GUserCommentsAjaxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=ISO-8859-1;");
		GUserCommentsAjaxReq.setRequestHeader("Content-length", GUserCommentsSubmitParams.length);
		GUserCommentsAjaxReq.setRequestHeader("Connection", "close");
		GUserCommentsAjaxReq.send(GUserCommentsSubmitParams);
	} catch(e) {
		alert(e);  
	}  
}
  
function UserCommentsProcessCommmentForm() {	
	LFormErrors      = true;
	LForm           = document.getElementById(GUserCommentsForm);
	var LGetStr = '';
	
	for (i=0; i<LForm.childNodes.length; i++) {
		 if (LForm.childNodes[i].tagName == "INPUT"){
				if (LForm.childNodes[i].type == "text") {
					 LGetStr += LForm.childNodes[i].name + "=" + escape(LForm.childNodes[i].value) + "&";
				}
				if (LForm.childNodes[i].type == "checkbox") {
					 if (LForm.childNodes[i].checked) {
							LGetStr += LForm.childNodes[i].name + "=" + LForm.childNodes[i].value + "&";
					 } else {
							LGetStr += LForm.childNodes[i].name + "=&";
					 }
				}
				if (LForm.childNodes[i].type == "radio") {
					 if (LForm.childNodes[i].checked) {
							LGetStr += LForm.childNodes[i].name + "=" + LForm.childNodes[i].value + "&";
					 }
				}
		 }
		 
		 if (LForm.childNodes[i].tagName == "TEXTAREA"){
			 LGetStr += LForm.childNodes[i].name + "=" + escape(LForm.childNodes[i].value) + "&";       
		 }
		 
		 if (LForm.childNodes[i].tagName == "SELECT") {
				var LSel = LForm.childNodes[i];
				LGetStr += LSel.name + "=" + LSel.options[sel.selectedIndex].value + "&";
		 }
		 
		 if (LForm.childNodes[i].type == "hidden") {
			 LGetStr += LForm.childNodes[i].name + "=" + LForm.childNodes[i].value + "&";       
		 }
	}
	
	LGetStr = LGetStr + "Title=" + document.location.href + "&";
	GUserCommentsSubmitParams = LGetStr;
	GUserCommentsAjaxReq = null;
	UserCommentsSubmit();
}

function UserCommentsProcessRequest(ADivTag) {
	try {    
		GUserCommentsAjaxDiv = document.getElementById(ADivTag);     
		GUserCommentsAjaxDiv.innerHTML  = '<center> <img align="center" src="/graphics/progress.gif" border="0" alt="Loading, please wait..." /></center> ';
		GUserCommentsAjaxReq                    = UserCommentsNewRequest();
		GUserCommentsAjaxReq.onreadystatechange = UserCommentsProcessAjax;
		GUserCommentsAjaxReq.open("GET", GUserCommentsUrl, true);
		GUserCommentsAjaxReq.send(null);
	} catch(e) {
		alert(e);  
	}  
}


// Used to submit content 
function UserCommentsSubmitComment(AFormId,AUrl,ANew){
  GUserCommentsForm = AFormId;
  GUserCommentsUrl = AUrl + "&omniture=0";
  
  document.getElementById(AFormId + 'progress').style.visibility = "visible" 
  GUserCommentsWhat = 1;
  UserCommentsProcessCommmentForm();
}

// Used to get content
function UserCommentsGetIt(ADivTag,AAction){
  GUserCommentsUrl        = AAction;
  UserCommentsProcessRequest(ADivTag);
}

function UserCommentsDoDelay(AAmount) { 
   LD = new Date(); //today's date 
   while (1) { 
     LMill = new Date(); // Date Now 
     LDiff = LMill-LD; //difference in milliseconds 
     if( LDiff > AAmount ) { 
       break; 
     } 
   } 
 }
 
// Used to refresh site
function UserCommentsRefresh(){
  	
	UserCommentsDoDelay(2000);
  LStr = window.location.href;
  LStr = LStr.replace(/.Nocache../i, "");
  
  if (LStr.indexOf("FromPost=1") == -1)
  {
  	LStr = window.location.href + '&FromPost=1#commentbox';
  	window.location = LStr;
  }
  else
  	window.location.reload();
}


  
