
// JavaScript Document
var xmlhttp_left_content_title;
var xmlhttp_left_content;
var xmlhttp_right_content;
var xmlhttp_projects_content;
var xmlhttp_image_content;


function showClientData(id_cliente)
{
	resizeBrowser(-1);
	
	fade_out_image("recuadro_imagenes");

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	xmlhttp_image_content=GetXmlHttpObject();
	if (xmlhttp_image_content==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	}
	
	var url_image_content = "ajax/getClientImage.php";
	url_image_content=url_image_content + "?id_cliente=" + id_cliente;
	url_image_content=url_image_content + "&sid=" + Math.random();
	xmlhttp_image_content.onreadystatechange = stateChanged_image_content;
	xmlhttp_image_content.open("GET", url_image_content, true);
	xmlhttp_image_content.send(null);
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	xmlhttp_left_content_title=GetXmlHttpObject();
	//alert(xmlhttp_left_content_title);
	
	if (xmlhttp_left_content_title==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	}
	
	var url_left_content_title = "ajax/getQueryResult.php";
	url_left_content_title=url_left_content_title + "?statement=SELECT nombre_empresa FROM clientes WHERE id_cliente = " + id_cliente;
	url_left_content_title=url_left_content_title + "&sid=" + Math.random();
	xmlhttp_left_content_title.onreadystatechange = stateChanged_left_content_title;
	xmlhttp_left_content_title.open("GET", url_left_content_title, true);
	xmlhttp_left_content_title.send(null);	

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	xmlhttp_left_content=GetXmlHttpObject();
	if (xmlhttp_left_content==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	}
	
	var url_left_content = "ajax/getQueryResult.php";
	url_left_content=url_left_content + "?statement=SELECT necesidad FROM clientes WHERE id_cliente = " + id_cliente;
	url_left_content=url_left_content + "&sid=" + Math.random();
	xmlhttp_left_content.onreadystatechange = stateChanged_left_content;
	xmlhttp_left_content.open("GET", url_left_content, true);
	xmlhttp_left_content.send(null);	

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	xmlhttp_right_content=GetXmlHttpObject();
	if (xmlhttp_right_content==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	}
	
	var url_right_content = "ajax/getQueryResult.php";
	url_right_content=url_right_content + "?statement=SELECT objetivo FROM clientes WHERE id_cliente = " + id_cliente;
	url_left_content=url_right_content + "&sid=" + Math.random();
	xmlhttp_right_content.onreadystatechange = stateChanged_right_content;
	xmlhttp_right_content.open("GET", url_right_content, true);
	xmlhttp_right_content.send(null);

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	xmlhttp_projects_content=GetXmlHttpObject();
	if (xmlhttp_projects_content==null)
	{
	  alert ("Browser does not support HTTP Request");
	  return;
	}
	
	var url_projects_content = "ajax/getClientProjects.php";
	url_projects_content=url_projects_content + "?id_cliente=" + id_cliente;
	url_projects_content=url_projects_content + "&sid=" + Math.random();
	xmlhttp_projects_content.onreadystatechange = stateChanged_projects_content;
	xmlhttp_projects_content.open("GET", url_projects_content, true);
	xmlhttp_projects_content.send(null);

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

}

function stateChanged_left_content_title()
{
	if (xmlhttp_left_content_title.readyState==4)
	{
		document.getElementById("client_name").innerHTML=xmlhttp_left_content_title.responseText;
	}
}

function stateChanged_left_content()
{
	if (xmlhttp_left_content.readyState==4)
	{
		document.getElementById("left_content").innerHTML=xmlhttp_left_content.responseText;
	}
}

function stateChanged_right_content()
{
	if (xmlhttp_right_content.readyState==4)
	{
		document.getElementById("right_content_title").innerHTML="Objetivos";
		document.getElementById("right_content").innerHTML=xmlhttp_right_content.responseText;
	}
}

function stateChanged_projects_content()
{
	if (xmlhttp_projects_content.readyState==4)
	{
		document.getElementById("projects_content").innerHTML=xmlhttp_projects_content.responseText;
	}
}

function stateChanged_image_content()
{
	if (xmlhttp_image_content.readyState==4)
	{
		document.getElementById("recuadro_imagenes").innerHTML=xmlhttp_image_content.responseText;
		
		fade_in_image("recuadro_imagenes");
		
		resizeBrowser(1);
	}
}

/*
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
	  // code for IE6, IE5
	  return new ActiveXObject("Microsoft.XMLHTTP");
	  //return new ActiveXObject("MSXML2.XMLHTTP.3.0");
	}
	  
	return null;
}*/


function GetXmlHttpObject()
{
	var req = null;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = null;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = null;
        	}
		}
    }
	  
	return req;
}

// We use this function to force browser to repaint the styled scroll.
function resizeBrowser(value){
	
	window.resizeBy(value,0);

}


