var http_request = false;
    
    function chartCurSwap(cur_id) {

        
        url="http://www.inwestycje.pl/includes/chart_cur_swap.php?waluta="+cur_id;
        http_request = false;

        if (window.XMLHttpRequest) { 
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            //alert('WAL: Poddaję się :( Nie mogę stworzyć instancji obiektu XMLHTTP');
            return false;
        }
        http_request.onreadystatechange = function() { putCurContents(http_request,cur_id); };
        http_request.open('GET', url, true);
        http_request.send(null);
        

    }
    
    function putCurContents(http_request,cur_id) {
        
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmldoc = http_request.responseXML;
                var root_node = xmldoc.getElementsByTagName('chart').item(0);
                //var date_node = root_node.getElementsByTagName('date').item(0);
                var image_node = root_node.getElementsByTagName('image').item(0);
                
                //document.getElementById('cur_date_box').innerHTML = 'Data notowania: <b>'+date_node.firstChild.data+'</b>';
                document.getElementById('curchart').src=image_node.firstChild.data;
                
                document.getElementById('wal_1_usd').style.backgroundColor = '';
                document.getElementById('wal_1_usd').style.color = '';
                document.getElementById('wal_1_eur').style.backgroundColor = '';
                document.getElementById('wal_1_eur').style.color = '';
                document.getElementById('wal_1_chf').style.backgroundColor = '';
                document.getElementById('wal_1_chf').style.color = '';
                document.getElementById('wal_1_gbp').style.backgroundColor = '';
                document.getElementById('wal_1_gbp').style.color = '';
                
                document.getElementById('wal_'+cur_id).style.color = 'white';
                document.getElementById('wal_'+cur_id).style.backgroundColor = '#15497B';
                
                document.getElementById('waluta').value=cur_id;
                
                //form.price.value=root_node.firstChild.data;
                //toggleLayer('add_to_cart_button');
            } else {
                //alert('Wystąpił problem z zapytaniem.');
            }
        }
  }

  


var ind_http_request = false;

    function chartIndSwap(ind_id) {

        url="/includes/chart_swap.php?ind="+ind_id;
        ind_http_request = false;

        if (window.XMLHttpRequest) { 
            ind_http_request = new XMLHttpRequest();
            if (ind_http_request.overrideMimeType) {
                ind_http_request.overrideMimeType('text/xml');
                
            }
        } else if (window.ActiveXObject) { // IE
            try {
                ind_http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    ind_http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!ind_http_request) {
            //alert('IND: Poddaję się :( Nie mogę stworzyć instancji obiektu XMLHTTP');
            return false;
        }
        ind_http_request.onreadystatechange = function() { putIndContents(ind_http_request,ind_id); };
        ind_http_request.open('GET', url, true);
        ind_http_request.send(null);

    }
    
    function putIndContents(ind_http_request,ind_id) {

                
        if (ind_http_request.readyState == 4) {
            if (ind_http_request.status == 200) {
                var xmldoc = ind_http_request.responseXML;
                var root_node = xmldoc.getElementsByTagName('chart').item(0);
                var date_node = root_node.getElementsByTagName('date').item(0);
                var image_node = root_node.getElementsByTagName('image').item(0);
                
                document.getElementById('date_box').innerHTML = 'Wykres z dnia: <b>'+date_node.firstChild.data+'</b>';
                document.getElementById('indchart').src=image_node.firstChild.data;
                
                document.getElementById('WIG').style.backgroundColor = '';
                document.getElementById('WIG').style.color = '';
                document.getElementById('WIG20').style.backgroundColor = '';
                document.getElementById('WIG20').style.color = '';
                document.getElementById('mWIG40').style.backgroundColor = '';
                document.getElementById('mWIG40').style.color = '';
                
                document.getElementById(ind_id).style.color = 'white';
                document.getElementById(ind_id).style.backgroundColor = '#15497B';
                
                document.getElementById('indchart_link').href="http://www.inwestycje.pl/gpw/indeksy?mode=view&name="+ind_id;
                
                //form.price.value=root_node.firstChild.data;
                //toggleLayer('add_to_cart_button');
            } else {
               // alert('Wystąpił problem z zapytaniem.');
            }
        }
  }

// ogolny uzytek
function DuzyWykres(adres) {
  window.open(adres,"waluty_large","height=470,width=620,resizable=no,scrolling=auto,menu=no,toolbar=no");
}
// koniec wykresowych
