
function getHTTPObject(url,c) { 
	  var http_request;
	
	  if (window.XMLHttpRequest) { // Mozilla, Safari,... alte browsere normale
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                   
            }
        } else if (window.ActiveXObject) { // IE
            try {
		    //ie 6 sp
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
			// ie 5,6
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e2) {
			// daca e un browser de consola n-ar trebui sa fie deranjat de alert
		alert('Your browser doesnt understand Ajax. Use Firefox');
		}
            }
        }

        if (!http_request) {
		// daca e un browser de consola n-ar trebui sa fie deranjat de alert
            alert('Your browser doesnt understand Ajax. Use Firefox');
            return false;
        }
	
	http_request.onreadystatechange = function() { handleHttpResponse(http_request,c); };
        http_request.open('GET', url, true);
	// nefolosit
        http_request.send(null);
  }
  

  
function handleHttpResponse(http_request,c) {

	if (http_request.readyState == 4) {
		// ca sa ii afisam un div cu Loading... sa stie omul ca dureaza - acum nefolosit
		//document.getElementById('loading').style.display = 'none';
        
		 
		if (http_request.status == 200) {
			
			switch (c)	{
				// start introducere
				case 'film_play':
								
				document.getElementById('playlist_ajax').innerHTML = http_request.responseText;
				  
				break;
				
				case 'masina_playlist':
								
				document.getElementById('masina_playlist').innerHTML = http_request.responseText;
				  
				break;
			
					
			//end introducere start search
			/*
			case 'oferte_search':
			var xmlDocument = http_request.responseXML;
			var title = xmlDocument.getElementsByTagName('content').item(0).firstChild.data;
			
			document.getElementById('tari').innerHTML = title;
			break;*/
			
				}
            } 
		else 
                alert('There was a problem with the request.');
            
			
		
        }
	else
	{
		// ca sa ii afisam un div cu Loading... sa stie omul ca dureaza -nefolosit acum
		//document.getElementById('loading').style.display = 'inline';
	}
		
}

// Start introducere oferte


function add_playlist(link_trimis) {

 
  getHTTPObject('include/play_ajax.php?'+link_trimis,'film_play');
  document.getElementById('playlist_ajax').innerHTML = '';
		
	
}

function remove_play(key) {
  getHTTPObject('include/play_ajax.php?remk='+key,'film_play');
  document.getElementById('playlist_ajax').innerHTML = '';
}

function nr_pag(nr) {
  getHTTPObject('include/play_ajax.php?nr='+nr,'film_play');
  document.getElementById('playlist_ajax').innerHTML = '';
}


function move_right(tip,tip2) {
  var index_pl=document.getElementById('id_playlist').selectedIndex;
  var value_pl=document.getElementById('id_playlist').options[index_pl].value;	

  var index=document.getElementById('listLeft').selectedIndex;
  var value=document.getElementById('listLeft').options[index].value;
  var index_r=document.getElementById('listRight').selectedIndex;
  if(index_r!=-1) { 
  	var value_r=document.getElementById('listRight').options[index_r].value;
  	var right_pos='&right_pos='+index_r;
  	}
  
  
  var j=0;
  var more="";
	
	for(i=0;i<document.getElementById('listLeft').length;i++) {
		if(document.getElementById('listLeft')[i].selected){
			j++;
			//alert(document.getElementById('listLeft')[i].value)
				more=more+'&id_left'+j+'='+document.getElementById('listLeft')[i].value;
			}
		}
	more=more+'&nr_selected='+j;
  
 

 getHTTPObject('../include/do_playlist.php?tip_pl='+tip2+'&tip1='+tip+'&id_playlist='+value_pl+'&id_left='+value+'&poz_left='+index+right_pos+more,'masina_playlist');
 document.getElementById('masina_playlist').innerHTML = '';
}


function move_up(tip) {
  var index_pl=document.getElementById('id_playlist').selectedIndex;
  var value_pl=document.getElementById('id_playlist').options[index_pl].value;	

  var index_r=document.getElementById('listRight').selectedIndex;
  if(index_r!=-1) { 
  	var value_r=document.getElementById('listRight').options[index_r].value;
  	var right_pos='&right_pos='+index_r;
	//alert(right_pos);
  	}
  var j=0;
  var more="";
	
	for(i=0;i<document.getElementById('listRight').length;i++) {
		if(document.getElementById('listRight')[i].selected){
			j++;
			
			//alert(document.getElementById('listLeft')[i].value)
			//	more=more+'&id_left'+j+'='+document.getElementById('listLeft')[i].value;
			}
		}
	more=more+'&nr_selected='+j;
  
 getHTTPObject('../include/do_playlist.php?tip1='+tip+'&id_playlist='+value_pl+right_pos+'&dinamic=up'+more,'masina_playlist');
 document.getElementById('masina_playlist').innerHTML = '';
}


function move_down(tip) {
  var index_pl=document.getElementById('id_playlist').selectedIndex;
  var value_pl=document.getElementById('id_playlist').options[index_pl].value;	

  var index_r=document.getElementById('listRight').selectedIndex;
  if(index_r!=-1) { 
  	var value_r=document.getElementById('listRight').options[index_r].value;
  	var right_pos='&right_pos='+index_r;
	//alert(right_pos);
  	}
  var j=0;
  var more="";
	
	for(i=0;i<document.getElementById('listRight').length;i++) {
		if(document.getElementById('listRight')[i].selected){
			j++;
			
			//alert(document.getElementById('listLeft')[i].value)
			//	more=more+'&id_left'+j+'='+document.getElementById('listLeft')[i].value;
			}
		}
	more=more+'&nr_selected='+j+'&lungime='+document.getElementById('listRight').length;
  
 getHTTPObject('../include/do_playlist.php?tip1='+tip+'&id_playlist='+value_pl+right_pos+'&dinamic=down'+more,'masina_playlist');
 document.getElementById('masina_playlist').innerHTML = '';
}



function move_up_js(tip) {
// 
// var index_r=document.getElementById('listRight').selectedIndex;
//  if(index_r!=-1) { 
//  	var value_r=document.getElementById('listRight').options[index_r].value;
//  	var right_pos='&right_pos='+index_r;
//  	}
  
  
  //var j=0;
//  var more="";
//	
	for(i=0;i<document.getElementById('listRight').length;i++) {
		if(document.getElementById('listRight')[i].selected){
			if(i>0){
				
				//daca i mai mare ca 1 fac interschimbare
				aux=document.getElementById('listRight')[i].value;
				document.getElementById('listRight')[i-1].value=document.getElementById('listRight')[i].value;
				document.getElementById('listRight')[i].value=aux;
					
				}
			
			//alert(document.getElementById('listLeft')[i].value)
			//	more=more+'&id_left'+j+'='+document.getElementById('listLeft')[i].value;
			}
		}
//	more=more+'&nr_selected='+j;
  
 
		
// getHTTPObject('../include/do_playlist.php?tip1='+tip+'&id_playlist='+value_pl+'&id_left='+value+'&poz_left='+index+right_pos+more,'masina_playlist');
// document.getElementById('masina_playlist').innerHTML = '';
}

function move_left(tip,tip2) {
  var index_pl=document.getElementById('id_playlist').selectedIndex;
  var value_pl=document.getElementById('id_playlist').options[index_pl].value;	

  var index=document.getElementById('listRight').selectedIndex;
  var value=document.getElementById('listRight').options[index].value;

  var j=0;
  var more="";
	
	for(i=0;i<document.getElementById('listRight').length;i++) {
		if(document.getElementById('listRight')[i].selected){
			j++;
			//alert(document.getElementById('listLeft')[i].value)
				more=more+'&poz_right'+j+'='+(i+1);
			}
		}
	more=more+'&nr_selected='+j;
 
 
		
 getHTTPObject('../include/do_playlist.php?tip_pl='+tip2+'&tip1='+tip+'&id_playlist='+value_pl+more+'&id_right=1','masina_playlist');
 document.getElementById('masina_playlist').innerHTML = '';
}


 
function atentionare(ID1,ID2)
    {
      if(confirm(ID1))
        document.location=ID2
        }

function arata_comentarii() {
		document.getElementById('comments2').style.display='block';
		document.getElementById('comment_bg2').style.display='block';
}

// end cautare oferte
	

