// JavaScript Document

function TractarParametre(P1) {
	switch(P1) {
		case "0": 
			// Presentació				
			mostraTitol('Desarrollo de software');
			mostraTexte('linies','Diseñamos software para usted<br/>Los primeros en aplicaciones de Diseño Gráfico, GIS, Gestión...');									
			mostraTexte('titolbanner',' ');
			mostraFoto('home');
			mostraHTML('abaix','inici.html');
		break;
		case "1": 
			// Empresa							
            mostraTitol('Empresa');
			mostraTexte('linies',' ');									
			mostraTexte('titolbanner','Empresa');
			mostraFoto('empresa');
			mostraHTML('abaix','empresa.html');
		break;							
		case "2": 
			// Serveis			
            mostraTitol('Servicios');
			mostraTexte('linies','Nos gusta nuestro trabajo');			
			mostraTexte('titolbanner','Servicios');
			mostraFoto('servicios');
			mostraHTML('abaix','serveis.html');
		break;
		case "3": 
			// Referències			
            mostraTitol('Referencias');
			mostraTexte('linies','Gracias');			
			mostraTexte('titolbanner','Referencias');
			mostraFoto('gracias');
			mostraHTML('abaix','referencies.html');
		break;									
		case "4": 
			// Projectes			
            mostraTitol('Proyectos');
			mostraTexte('linies','Profesionales del software');			
			mostraTexte('titolbanner','Proyectos');			
			mostraFoto('proyectos');
			mostraHTML('abaix','projectes.html');
		break;							
		case "5": 
			// Contacte			
            mostraTitol('Contacto');
			mostraTexte('linies',' ');			
			mostraTexte('titolbanner','Contacto');			
			mostraFoto('contacte');
			mostraHTML('abaix','contacte.html');
		break;		
	};
};

function ObtenirP(nParametre) 
{ 
	//Capturem la URL 
	var callingURL = document.location.href; 

	//Separem els paràmetres 
	var cgiString = callingURL.substring(callingURL.indexOf('?')+1,callingURL.length); 

    // En realitat comencem per zero
	nParametre -=1; 

	// Dividim els paràmetres
	var col_array=cgiString.split("&"); 
	var part_num=0; 
	
	if (cgiString.length<callingURL.length) {

  		// Ara recorrem els paràmetres
		while (part_num < col_array.length) 
		{ 
			if ( part_num == nParametre ) 
				return col_array[part_num]; 
			else part_num+=1; 
		}
	} 

	// valor per defecte (no trobat)
	return "0"; 
};

function mostraTitol(texte){
  document.title="Index Consulting S.L. - ".concat(texte);  
};

function mostraTexte(element,texte){
  document.getElementById(element).innerHTML=texte;
};

function mostraFoto(foto){
  document.getElementById('banner').style.backgroundImage="url(./imatges/".concat(foto).concat(".jpg)");
};

function mostraHTML(IdDIV,filename){
  document.getElementById(IdDIV).innerHTML=getFile(filename);
};

function getFile(filename)
  { oxmlhttp = null;
    try
      { oxmlhttp = new XMLHttpRequest();
        oxmlhttp.overrideMimeType("text/xml");
      }
    catch(e)
      { try
          { oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
          }
        catch(e)
          { return null;
          }
      }
    if(!oxmlhttp) return null;
    try
      { oxmlhttp.open("GET",filename,false);
        oxmlhttp.send(null);
      }
    catch(e)
      { return null;
      }
    return oxmlhttp.responseText;
  }
