function YcreateRequestObject() {
    var xmlHttp;
    try
    { 
        // Firefox, Opera 8.0+, Safari 
        xmlHttp=new XMLHttpRequest(); 
    }
    catch (e)
    { 
        // Internet Explorer 
        try
        {   
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
        }
        catch (e)
        {   
            try
            {     
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");     
            }
            catch (e)
              {     
                  alert("Your browser does not support AJAX!");     
                return false;     
            }   
        } 
    }
   
    return xmlHttp;
}

//call the above function to create the XMLHttpRequest object
var Yhttp = YcreateRequestObject();

function get_oras() {
    //make a connection to the server ... specifying that you intend to make a GET request
    //to the server. Specifiy the page name and the URL parameters to send
    
     
        Yhttp.open('get', 'http://www.bancibancomate.ro/ajax/get_localitate.php?judet='+document.getElementById('id_judet').value);   
   		
    //assign a handler for the response
    Yhttp.onreadystatechange = YprocessResponse;
   
    //actually send the request to the server
    Yhttp.send(null);
}

//urmeaza functia care scrie oras
function YprocessResponse() {
    //check if the response has been received from the server
    if(Yhttp.readyState == 4){
   
        //read and assign the response from the server
        var Yresponse = Yhttp.responseText;
       
        //do additional parsing of the response, if needed
       
        //in this case simply assign the response to the contents of the <div> on the page.
        document.getElementById('oras').innerHTML = Yresponse;
       
       
        //If the server returned an error message like a 404 error, that message would be shown within the div tag!!.
        //So it may be worth doing some basic error before setting the contents of the <div>
    }
}

function do_loc_u(judet,banca) {
    //make a connection to the server ... specifying that you intend to make a GET request
    //to the server. Specifiy the page name and the URL parameters to send
    	
		document.getElementById('doloc').value = judet;
		document.getElementById('banca').value = banca;
        
		Yhttp.open('get', 'http://www.bancibancomate.ro/ajax/do_loc_u.php?&judet='+judet+'&banca='+banca);   
   		
    //assign a handler for the response
    Yhttp.onreadystatechange = Yprocessdoloc;
   
    //actually send the request to the server
    Yhttp.send(null);
}

//urmeaza functia care scrie oras
function Yprocessdoloc() {
    //check if the response has been received from the server
    if(Yhttp.readyState == 4){
   
        //read and assign the response from the server
        var Yresponse = Yhttp.responseText;
       
        //do additional parsing of the response, if needed
       
        //in this case simply assign the response to the contents of the <div> on the page.
		var doloc = document.getElementById('doloc').value;
        var banca = document.getElementById('banca').value;
		
		document.getElementById('orasel'+doloc).innerHTML = Yresponse;
		
		
		document.getElementById('pm'+doloc).innerHTML = "<a href=\"javascript:;\" onclick=\"undo_loc_u("+doloc+","+banca+")\"><img src='http://www.bancibancomate.ro/images/minus.jpg' class='v_align' border='0' alt='minus' /></a>";
       
       
        //If the server returned an error message like a 404 error, that message would be shown within the div tag!!.
        //So it may be worth doing some basic error before setting the contents of the <div>
    }
}

function undo_loc_u(doloc,banca) {

	document.getElementById('pm'+doloc).innerHTML = "<a href=\"javascript:;\" onclick=\"do_loc_u("+doloc+","+banca+")\"><img src=\"http://www.bancibancomate.ro/images/plus.jpg\" class=\"v_align\" border=\"0\" alt=\"plus\" /></a>";
	document.getElementById('orasel'+doloc).innerHTML = "";
	
}

function do_loc_b(judet,banca) {
    //make a connection to the server ... specifying that you intend to make a GET request
    //to the server. Specifiy the page name and the URL parameters to send
    	
		document.getElementById('doloc').value = judet;
		document.getElementById('banca').value = banca;
        
		Yhttp.open('get', 'http://www.bancibancomate.ro/ajax/do_loc_b.php?&judet='+judet+'&banca='+banca);   
   		
    //assign a handler for the response
    Yhttp.onreadystatechange = Yprocessdolocb;
   
    //actually send the request to the server
    Yhttp.send(null);
}

function Yprocessdolocb() {
    //check if the response has been received from the server
    if(Yhttp.readyState == 4){
   
        //read and assign the response from the server
        var Yresponse = Yhttp.responseText;
       
        //do additional parsing of the response, if needed
       
        //in this case simply assign the response to the contents of the <div> on the page.
		var doloc = document.getElementById('doloc').value;
        var banca = document.getElementById('banca').value;
		
		document.getElementById('orasel'+doloc).innerHTML = Yresponse;
		
		
		document.getElementById('pm'+doloc).innerHTML = "<a href=\"javascript:;\" onclick=\"undo_loc_b("+doloc+","+banca+")\"><img src='http://www.bancibancomate.ro/images/minus.jpg' class='v_align' border='0' alt='minus' /></a>";
       
       
        //If the server returned an error message like a 404 error, that message would be shown within the div tag!!.
        //So it may be worth doing some basic error before setting the contents of the <div>
    }
}

function undo_loc_b(doloc,banca) {

	document.getElementById('pm'+doloc).innerHTML = "<a href=\"javascript:;\" onclick=\"do_loc_b("+doloc+","+banca+")\"><img src=\"http://www.bancibancomate.ro/images/plus.jpg\" class=\"v_align\" border=\"0\" alt=\"plus\" /></a>";
	document.getElementById('orasel'+doloc).innerHTML = "";
	
}

function show_reclamatii() {
	 
	Yhttp.open('get','http://www.bancibancomate.ro/ajax/show_reclamatii.php');   
   		
    //assign a handler for the response
    Yhttp.onreadystatechange = Yprocessreclamatii;
   
    //actually send the request to the server
    Yhttp.send(null);	
}

function Yprocessreclamatii() {
    //check if the response has been received from the server
    if(Yhttp.readyState == 4){
   
        //read and assign the response from the server
        var Yresponse = Yhttp.responseText;
       
        //do additional parsing of the response, if needed
       
        //in this case simply assign the response to the contents of the <div> on the page.
		
		
		document.getElementById('reclamatii').innerHTML = Yresponse;       
       	document.getElementById('linkr').innerHTML = '<a href="#linkr" onclick="hide_reclamatii();"><strong>M-am razgandit! Ascunde formularul de reclamatii!</strong></a>';
        //If the server returned an error message like a 404 error, that message would be shown within the div tag!!.
        //So it may be worth doing some basic error before setting the contents of the <div>
    }
}

function hide_reclamatii() {
	document.getElementById('reclamatii').innerHTML = '';
	document.getElementById('linkr').innerHTML = '<a href="#reclamatii" onclick="show_reclamatii();"><strong>Anunta-ne daca ai observat date gresite. Multumim!</strong></a>';

}

//filtrul cursului valutar
function check_key(e) {
	
	//aici captam codul tastei apasate
	if(window.event) {
	    KeyID = window.event.keyCode;
	} else if(e) {
		KeyID = e.which;
	} else {
		return null;
	}
	//transformam in string
	var Key = String.fromCharCode(KeyID);
	//tastele permise sa se apese
	AllowKeys = "0123456789./";
	//daca tasta apasata se afla intre cele permise
	if(AllowKeys.indexOf(Key) != -1) {
		return true;
	}
	//daca tasta apasata este de control (sus,jos,stanga,dreapta,delete)
	if( KeyID==0 || KeyID==8 || KeyID==9 || KeyID==13 || KeyID==27 ) {
		return true;
	}
	
	return false;
}

function get_curs(location) {
	var zi = document.getElementById('zi').value;
	var luna = document.getElementById('luna').value;
	var an = document.getElementById('an').value;
	window.location = "http://www.bancibancomate.ro/"+location+"/"+zi+"-"+luna+"-"+an;

}

function checkfeedback(document)
{
		if(document.nume.value==""){
		alert("Va rugam introduceti numele dorit!");
		document.nume.focus();
		return false;
		}
		
		if(document.mesaj.value==""){
		alert("Va rugam introduceti mesajul dorit!");
		document.mesaj.focus();
		return false;
		}
		
		if(document.security_code.value==""){
		alert("Va rugam introduceti codul de securitate!");
		document.security_code.focus();
		return false;
		}
}
