/**
*/
var req;

function Calc(exchtype, id_out)
{
loadXMLDoc('exchanger.php?exchtype=' +exchtype+ '&summa_na_obmen=' + document.sendform.summa.value + '&inoutcomiss='+document.sendform.inoutcomiss.checked, id_out );
}



function loadXMLDoc(url, id_out)
{
ID_out = id_out;
req = null;
if (window.XMLHttpRequest) {
try {
            req = new XMLHttpRequest();
        } catch (e){}
    } else if (window.ActiveXObject) {
        try {
            req = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){
            try {
                req = new ActiveXObject('Microsoft.XMLHTTP');
            } catch (e){}
        }
    }

    if (req) {
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    }

     else {alert ("Браузер не поддерживает AJAX технологии");}
}



function processReqChange ()
	{
    document.getElementById(ID_out).innerHTML = stat(req.readyState);
    ab = window.setTimeout("req.abort();", 100000);
    if (req.readyState == 4) {
        clearTimeout(ab);
        // only if "OK"
if (req.status == 200) {document.getElementById(ID_out).innerHTML = req.responseText;}
		else {document.getElementById(ID_out).innerHTML = "Ошибка - Не удалось получить данные: " + req.statusText;}
    	}


function stat(n)
{
  switch (n) {
    case 0: return "<img src=\"../images/page/ajax-loader.gif\" width=\"32\" height=\"32\" border=\"0\">"; break;
    case 1: return "<img src=\"../images/page/ajax-loader.gif\" width=\"32\" height=\"32\" border=\"0\">"; break;
    case 2: return "<img src=\"../images/page/ajax-loader.gif\" width=\"32\" height=\"32\" border=\"0\">"; break;
    case 3: return "<img src=\"../images/page/ajax-loader.gif\" width=\"32\" height=\"32\" border=\"0\">"; break;
    case 4: return "<img src=\"../images/page/ajax-loader.gif\" width=\"32\" height=\"32\" border=\"0\">"; break;
    default: return "Неопределенное состояние запроса";
  }
}

}



/*////////////////*/
function  OnBuy(){
document.form_curr.count.style.width="1px";
document.form_curr.count.style.visibility="hidden";
document.form_curr.inoutcomiss.style.visibility="hidden";
document.form_curr._inoutcomiss.style.visibility="hidden";
document.form_curr.need_count.value=document.form_curr.count.value;
document.form_curr.need_count.style.width="70px";
document.form_curr.need_count.style.visibility="visible";

}
function  OnSell(){
document.form_curr.need_count.style.width="1px";
document.form_curr.need_count.style.visibility="hidden";
document.form_curr.count.value=document.form_curr.need_count.value;
document.form_curr.count.style.width="70px";
document.form_curr.count.style.visibility="visible";
document.form_curr.inoutcomiss.style.visibility="visible";
document.form_curr._inoutcomiss.style.visibility="visible";
}

/* ////////////////////////////
 узнать значение группы input radio
 Использовать так:
var v = getRadioGroupValue(document.formName.radioName);
Если не отмечен ни один элемент, функция вернет null.
////////////////////////////////*/
function getRadioGroupValue(radioGroupObj)
{
for (var i=0; i < radioGroupObj.length; i++)
if (radioGroupObj[i].checked) return radioGroupObj[i].value;
return null;
}





