function cambia_sector(industria,sector)
{
	if (sector != null)
	{
		sector = '&sector=' + sector;
	} else
	 {
		 sector = '';
	 }
	  $.ajax({
           async:true,
           type: "GET",
           dataType: "html",
           contentType: "application/x-www-form-urlencoded",
           url:"index.php",
           data:'action=sectores&flw=y&industria=' + industria + sector,
           //beforeSend:inicioEnvio,
           success:llegadaDatosSectores,
           timeout:4000
         }); 
         return false;
	 
}
function drawPercentBar(percent, v_color,size,ancho)
  {

    var width = ancho;

    var color = v_color;
    var background = "#FFFFFF";
    var border = "#4C0039";

    if (!color) { color = "#B0B0B0"; }
    if (!background) { background = "none"; }
    if (!border) { border = "#000000"; }

    var pixels = width * (percent / 100);

    document.write("<div style=\"position: relative; line-height: 1em; background-color: "
                   + background + ";font-size:"+ size +"px; border: 1px dotted " + border + "; width: "
                   + width + "px;\">");
    document.write("<div style=\"height: 1em; width: " + pixels + "px; background-color: "
                   + color + "; margin: 0.1em 0.1em 0.1em 0.1em\"><\/div>");
    
    document.write("<\/div>");
  }
function cambia_canton(provincia,canton)
{
	if (canton != null)
	{
		canton = '&canton=' + canton;
	} else
	 {
		 canton = '';
	 }
	  $.ajax({
           async:true,
           type: "GET",
           dataType: "html",
           contentType: "application/x-www-form-urlencoded",
           url:"index.php",
           data:'action=cantones&flw=y&provincia=' + provincia + canton,
           //beforeSend:inicioEnvio,
           success:llegadaDatosCantones,
           timeout:4000
         }); 
         return false;
	 
}
function ChequearTodos(chkbox)
{
	for (var i=0;i < document.inv_contactos.elements.length;i++)
	{
		var elemento = document.inv_contactos.elements[i];
		if (elemento.type == "checkbox")
		{
		  elemento.checked = chkbox.checked
		}
	}
}



function llegadaDatosCantones(datos)
	{
	  var x;
	  x = $("#cantones");
	  x.html(datos);
	} 

function llegadaDatosSectores(datos)
	{
	  var x;
	  x = $("#sectores");
	  x.html(datos);
	} 
	
	
function guarda_sector(industria,sector,estado)
{
	  if (estado == true)
	   {
		   estado = 'ins';
	   } else
	     {
		   estado = 'del';	  
		 }
		 	

	  $.ajax({
           async:true,
           type: "GET",
           dataType: "html",
           contentType: "application/x-www-form-urlencoded",
           url:"index.php",
           data:'action=u_guarda_sector&flw=y&industria=' + industria + '&sector=' + sector + '&ope=' + estado,
           //beforeSend:inicioEnvio,
           success:llegada_sector,
           timeout:4000
         }); 
         return false;
	 
}
function muestra_habilidad(industria,sector)
{
	  $.ajax({
           async:true,
           type: "GET",
           dataType: "html",
           contentType: "application/x-www-form-urlencoded",
           url:"index.php",
           data:'action=u_muestra_habilidad&flw=y&industria=' + industria + '&sector=' + sector,
           //beforeSend:inicioEnvio,
           success:llegada_habilidad,
           timeout:4000
         }); 
         return false;
}
function llegada_habilidad(datos)
	{
		 var x;
	     x = $("#habilidad");
	     x.html(datos); 
	} 
function llegada_sector(datos)
	{
		
	} 

function actualiza_barra_principal()
{
	  $.ajax({
           async:true,
           type: "GET",
           dataType: "html",
           contentType: "application/x-www-form-urlencoded",
           url:"index.php",
           data:'action=u_grafico&flw=y&tip=P',
           //beforeSend:inicioEnvio,
           success:llegadaDatosbarra_principal,
           timeout:4000
         }); 
         return false;
	 
}
function llegadaDatosbarra_principal(datos)
	{
		 var x;
	     x = $("#barra_principal");
	     x.html(datos); 
	} 

function actualiza_barra_secundaria()
{
	  $.ajax({
           async:true,
           type: "GET",
           dataType: "html",
           contentType: "application/x-www-form-urlencoded",
           url:"index.php",
           data:'action=u_grafico&flw=y&tip=S',
           //beforeSend:inicioEnvio,
           success:llegadaDatosbarra_secundaria,
           timeout:4000
         }); 
         return false;
	 
}
function llegadaDatosbarra_secundaria(datos)
	{
		 var x;
	     x = $("#barra_secundaria");
	     x.html(datos); 
	} 


	
	
/*function inicioEnvio()
	{
	  var x=$("#resultados");
	  x.css("text-align","center");
	  x.html('<img src="images/loading.gif">');
	}*/
