﻿var ajax;
var ajaxTimer;
function Convert_GetConvertion()
{
    var amount = document.getElementById("convert_amount").value;
    var from = document.getElementById("fromCurrency").value;
    var to = document.getElementById("toCurrency").value;
    ajax = "convertCurrencies|"+amount+"|"+from+"|"+to;
    clearTimeout
    SendAjaxDelay();
}
function MainConvert_GetConvertion()
{
    var amount = document.getElementById("main_convert_amount").value;
    var from = document.getElementById("main_fromCurrency").value;
    var to = document.getElementById("main_toCurrency").value;
    ajax = "convertCurrenciesMainPanel|"+amount+"|"+from+"|"+to;
    clearTimeout
    SendAjaxDelay();
}


function Convert_ChangePicture(origin)
{
    if (origin.id == "fromCurrency")
    {
        document.getElementById("from_currency").src= "../Ar-Img/currencies/"+origin.value+".gif";
    }
    else if (origin.id == "toCurrency")
    {
        document.getElementById("to_currency").src= "../Ar-Img/currencies/"+origin.value+".gif";
    }
}
function Main_Convert_ChangePicture(origin)
{
    if (origin.id == "main_fromCurrency")
    {
        document.getElementById("main_from_currency").src= "../Ar-Img/currencies/"+origin.value+".gif";
    }
    else if (origin.id == "main_toCurrency")
    {
        document.getElementById("main_to_currency").src= "../Ar-Img/currencies/"+origin.value+".gif";
    }
}


function Convert_ChangePictureHome(origin)
{
    if (origin.id == "fromCurrency")
    {
        document.getElementById("from_currency").src= "Ar-Img/currencies/"+origin.value+".gif";
    }
    else if (origin.id == "toCurrency")
    {
        document.getElementById("to_currency").src= "Ar-Img/currencies/"+origin.value+".gif";
    }
}





function ClientCallback(str)
{
    try
    {
        eval(str);
    }
    catch(e){}
}

function SendAjaxDelay()
{
    clearTimeout(ajaxTimer);
    ajaxTimer = setTimeout('SendAjax("' + ajax + '","NoContextToRefresh")',400);
}

function SendAjax(str,context)
{ 
         var httpRequest = false;
       if (window.XMLHttpRequest) { // Mozilla, Safari,...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
                // Voir la note ci-dessous à propos de cette ligne
            }
        }
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e) {}
            }
        }

    httpRequest.onreadystatechange  = function()
    { 
         if(httpRequest.readyState  == 4)
         {
              if(httpRequest.status  == 200) eval(httpRequest.responseText);
         }
    }
   httpRequest.open( "GET", "http://ar.ac-markets.com/Ajax.aspx?convert="+str,  true); 
   httpRequest.send(null); 
} 

