var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject() 
{	
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
 
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

function change_sum(account_id, sum, pass_hash) {
	var url;
	var xmlDocumentElement;
	var account_span;
	var sum_input;
	
	account_span = document.getElementById('account'+account_id);
	sum_input = document.getElementById('sum'+account_id);
	
	url = "/account.php?account_id=" + account_id + "&sum=" + sum + "&pass_hash=" + pass_hash;
	xmlHttp.open("GET", url, false);
	xmlHttp.send(null);
	
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			xmlResponse = xmlHttp.responseText;
			account_span.innerHTML = xmlResponse;
			if (parseFloat(xmlResponse) > 0.00)
				account_span.style.color = 'green';
			else
				account_span.style.color = 'red';
			sum_input.value = '';
		}
	}
	
}

function opendesc(id, catalog, link_id)
{
	if (document.getElementById(link_id))
		document.getElementById(link_id).style.color = '#f3bbaf';
	/*f4ac9d*/
	win=window.open("/details.php?id="+id+"&catalog_id="+catalog, "kard", "width=620, height=550, toolbar=0, top=10, left=10, directories=0, status=0, resizable=1, scrollbars=1");
	win.focus();
}

function fn_resize(e, intWidth, intHeight) {
 /*var newW;
 newW = (intWidth == null || intWidth == '' || isNaN(parseInt(intWidth))) ? 800 : parseInt(intWidth);
 var newL = Math.round(screen.width/2 - newW);
 var newH;
 newH = (intHeight == null || intHeight == '' || isNaN(parseInt(intHeight))) ? 800 : parseInt(intHeight);
 var newT = Math.round(screen.height/2 - newH);*/
 newW = document.getElementById('table_detail').clientWidth + 30;
 newH = document.getElementById('table_detail').clientHeight + 60;
 if (e.sizeToContent) {
   e.sizeToContent(); // изменить размер по содержимому (для FireFox,Mozilla)
 } else {
   e.resizeTo(newW,newH); // изменить размер окна на предустановленные значения
 }
 //e.moveTo(newT,newL); // переместить окно в середину экрана
}
/*fn_resize(window,800,500); // вызов процедуры*/
