<!--//


var xmlhttp;
function pop_subs(id,tip)
{
//se scot optiunile curente/vechi
if(tip=='sub') 
{
	var obj = document.getElementById('id_subcategorie');
	var opt=obj.getElementsByTagName('option');
	for(var j=opt.length-1;j>=0;j--){
	if(j!=0) obj.removeChild(opt[j]);
	}
}
/*
if(tip=='tips')
{
	var obj = document.getElementById('id_tip');
	var opt=obj.getElementsByTagName('option');
	for(var j=opt.length-1;j>=0;j--){
	if(j!=0) obj.removeChild(opt[j]);
	}
}
*/
// Moz
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=function(){xmlhttpChange(tip)}
  xmlhttp.open("GET",'selecturi_link.php?tip='+tip+'&id='+id,true)
  xmlhttp.send(null)
  }
// IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=function(){xmlhttpChange(tip)}
    xmlhttp.open("GET",'selecturi_link.php?tip='+tip+'&id='+id,true)
    xmlhttp.send()
    }
  }
}

function xmlhttpChange(tip)
{
// daca xmlhttp arata "loaded"
if (xmlhttp.readyState==4)
  {
  // daca "OK"
  if (xmlhttp.status==200)
    {
    	if(xmlhttp.responseText!='')
    	{
			facere(xmlhttp.responseText,tip);
    	}
    }
  else
    {
    alert("Probleme de acces DB, mai incercati!")
    }
  }
}

function facere(s,tip){
	var s=s.split('#');
	var a=[];
	if(tip=='sub') var root=document.getElementById('id_subcategorie');
	if(tip=='tips') var root=document.getElementById('id_tip');
	for(var i=0;i<s.length-1;i+=2){
	var opt=document.createElement('option');
	root.appendChild(opt);
	opt.value=s[i];
	opt.appendChild(document.createTextNode(s[i+1]));
	}
	
	if((s.length-1)>0) root.disabled=false;
}



var xmlhttp;
function fill_prioritar()
{
	var f = document.forma;
	//verificari
	if (f.id_cat.selectedIndex == 0)
	{
		alert('Por favor, seleccione una categoria.');
		f.id_cat.focus();
		f.prioritar.checked=false;
		return false;
	}
	
	if (f.id_subcat.selectedIndex == 0)
	{
		alert('Por favor, seleccione una subcategoria.');
		f.id_subcat.focus();
		f.prioritar.checked=false;
		return false;
	}
	
	if (f.titlu.value == "")
	{
		alert('Por favor introduce el titulo del enlace!');
		f.titlu.focus();
		f.prioritar.checked=false;
		return false;
	}
	
	if(f.adauga_link.value=="")
	{
		alert('Por favor, introduce el link!');
		f.adauga_link.focus();
		f.prioritar.checked=false;
		return false;
	}
	
	if(!f.prioritar.checked)
	{
		document.getElementById('cod').value='';
		return false;
	}
	//end verificari
	
	var val_categorie=document.getElementById('id_categorie').value;
	var val_subcategorie=document.getElementById('id_subcategorie').value;
	var val_titlu=f.titlu.value;
	
	// Moz
	if (window.XMLHttpRequest)
	  {
	  xmlhttp=new XMLHttpRequest()
	  xmlhttp.onreadystatechange=function(){xmlhttpChange_fill()}
	  xmlhttp.open("GET",'prioritar_link.php?cat='+val_categorie+'&subcat='+val_subcategorie+'&titlu='+val_titlu,true)
	  xmlhttp.send(null)
	  }
	// IE
	else if (window.ActiveXObject)
	  {
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	    if (xmlhttp)
	    {
	    xmlhttp.onreadystatechange=function(){xmlhttpChange_fill()}
	    xmlhttp.open("GET",'prioritar_link.php?cat='+val_categorie+'&subcat='+val_subcategorie+'&titlu='+val_titlu,true)
	    xmlhttp.send()
	    }
	  }
}

function xmlhttpChange_fill()
{
// daca xmlhttp arata "loaded"
if (xmlhttp.readyState==4)
  {
  // daca "OK"
  if (xmlhttp.status==200)
    {
    	if(xmlhttp.responseText!='')
    	{
			facere_fill(xmlhttp.responseText);
    	}
    }
  else
    {
    alert("Probleme de acces DB, mai incercati!")
    }
  }
}

function facere_fill(s){
	var s=s.split('#');
	var cat_shortname=s[0];
	var subcat_shortname=s[1];
	var titlu_shortname=s[2];
	var codf=document.getElementById('codf').value;
	
	var text_pre="<!-- BEGIN enlacesespana.es code --><a href=\"";
	//var link="http://www.enlacesespana.es/"+cat_shortname+"/"+subcat_shortname+"/"+titlu_shortname+".html";
	var link="http://www.enlacesespana.es/el-comercio-en-linea/reservas-online/pidecita-sistema-de-reservas-online-y-agenda-online-para-pedir.html";
	//var text_after="\"><img src=\"http://www.enlacesespana.es/link_manager.php?cc="+codf+"\" alt=\""+titlu_shortname+"\" title=\""+titlu_shortname+"\" border=\"0\" /></a><noscript><a href=\"http://www.enlacesespana.es\"><img src=\"http://www.enlacesespana.es/link_manager.php?cc="+codf+"\" alt=\"enlacesespana.es\" /></a></noscript><!-- END enlacesespana.es code -->";
	var text_after="\" title=\"PideCita, sistema de reservas online\"><img src=\"http://www.enlacesespana.es/link_manager.php?cc="+codf+"\" alt=\"PideCita, sistema de reservas online\" title=\"PideCita, sistema de reservas online\" border=\"0\" /></a><noscript><a href=\"http://www.enlacesespana.es\"><img src=\"http://www.enlacesespana.es/link_manager.php?cc="+codf+"\" alt=\"PideCita, sistema de reservas online\" title=\"PideCita, sistema de reservas online\"  /></a></noscript><!-- END enlacesespana.es code -->";
	
	document.getElementById('cod').value=text_pre+link+text_after;
}

function fill_golire()
{
	document.getElementById('cod').value='';
	document.forma.prioritar.checked=false;
}

//-->
