// JavaScript Document

// ***********************************************  FUNCIONS PER DESCARTAR ************************************
function CanviColorM1(B,BQ){
	if (BQ==1){
		  B.style.color='#d23227'; // vermell
	}
	 
	if (BQ==0){
		  B.style.color='#000000'; // negre
	}
}
function CanviColorM2(B,BQ){
	if (BQ==1){
		  B.style.color='#d23227'; // vermell
	}
	 
	if (BQ==0){
		  B.style.color='#999999'; // gris
	}
}
function CanviColorVersion(B,BQ){
	if (BQ==1){
		  B.style.color='#d23227'; // vermell
	}
	 
	if (BQ==0){
		  B.style.color='#AAAAAA'; // gris
	}
}
function CanviColorI2(B,BQ){
	if (BQ==1){
		  B.style.border='2px solid #d23227'; // vermell
	}
	 
	if (BQ==0){
		  B.style.border='2px solid #FFFFFF'; // blanc
	}
}
function CanviColorM(B,BQ){
	if (BQ==1){
		  B.style.border='1px solid #d23227'; // vermell
	}
	 
	if (BQ==0){
		  B.style.border='1px solid #FFFFFF'; // blanc
	}
}

//********************************* SLIDE **********************************
// Browser Slide-Show script.
// With image cross fade effect for those browsers that support it.
var slideCache = new Array();
function RunSlideShow(pictureName,imageFiles,displaySecs){
	var imageSeparator = imageFiles.indexOf(";");
	var nextImage = imageFiles.substring(0,imageSeparator);
	
	if (document.all){
		document.getElementById(pictureName).style.filter="blendTrans(duration=2)";
		document.getElementById(pictureName).filters.blendTrans.Apply();
	}
	
	document.getElementById(pictureName).src = nextImage;
	
	if (document.all){
		document.getElementById(pictureName).filters.blendTrans.Play();
	}
	
	var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)+ ';' + nextImage;
	setTimeout("RunSlideShow('"+pictureName+"','"+futureImages+"',"+displaySecs+")",displaySecs*1000);
	
	// Cache the next image to improve performance.
	imageSeparator = futureImages.indexOf(";");
	nextImage = futureImages.substring(0,imageSeparator);
	
	if (slideCache[nextImage] == null) {
		slideCache[nextImage] = new Image;
		slideCache[nextImage].src = nextImage;
	}
}

/*****************************************************************************************************/

function mostrar(foto,obra,tope,posicio) {
	
	contingutREAL="<div id='imatgeGRAN"+obra+"' class='imatgeGRAN'><img src='imgs/fotos/prods/"+foto+"' height='500px' border='0' /></div>";
	contingutREAL+="<div id='divprint'><a href='download.php?file="+foto+"' target='_blank' onClick='window.open(this.href, this.target, \"height=10, width=10\"); return false;'>";
	contingutREAL+="<img src='imgs/baixarbn.jpg' height='33' width='34' border='0' alt='"+missatgeDOWNLOAD+"' />";
	contingutREAL+="</a>&nbsp;&nbsp;&nbsp;";
	contingutREAL+="<a href='javascript:imprSelec(\"imatgeGRAN"+obra+"\")'>";
	contingutREAL+="<img src='imgs/imprimirbn.jpg' height='33' width='34' border='0' alt='"+missatgeIMPRIMIR+"' />";
	contingutREAL+="</a>";
	contingutREAL+="</div>";
	document.getElementById('foto'+obra).innerHTML = contingutREAL;
	anterior=posicio-1;
	posterior=posicio+1;
	var miArray=this['miArray'+obra];
	if (posicio==0){
		document.getElementById('enrera'+obra).innerHTML = "";
	}else{
		document.getElementById('enrera'+obra).innerHTML = "<a href='#'><img src='img/mootools/prevlabel.jpg' onClick='mostrar(\""+miArray[posicio-1]+"\","+obra+", "+tope+", "+anterior+");' border='0'/></a>";
	}
	if (posicio==tope-1){
		document.getElementById('endavant'+obra).innerHTML = "";
	}else{
		document.getElementById('endavant'+obra).innerHTML = "<a href='#'><img src='img/mootools/nextlabel.jpg' onClick='mostrar(\""+miArray[posicio+1]+"\","+obra+", "+tope+", "+posterior+");' border='0'/></a>";
	}
	
	// requadre vermell
	for (r=0;r<tope;r++){
		if (r==posicio) {
			document.getElementById(obra+'foto'+r).style.border = "2px solid #d23227";	
		}else{
			document.getElementById(obra+'foto'+r).style.border = "2px solid #ffffff";		
		}
	}
}

/*******************************************************************************************************************/

function imprSelec(nombre){
  var ficha0 = "<center>";
  var ficha = document.getElementById(nombre);
  var ficha2 = "<div style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;color:#666666;padding-top:5px;'>";
  ficha2+="<span style='color:#000000'><strong>&copy; Arquitectura Textil S.L. </strong></span><br> C/ Progrés, s/n Nave 7 - Pol. Ind. El Pedregar - 08160 Montmeló (Barcelona)<br>";
  ficha2+="T 93 568 44 66 - F 93 568 28 00 - info@arquitecturatextil.com</div></center>";
  var ventimp = window.open(' ', 'popimpr');
  ventimp.document.write(ficha0+ficha.innerHTML+ficha2);
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
} 

/*******************************************************************************************************************/

function eliminar(id,obra,proyecto,espai){
	
	if(!confirm("¿Seguro que quieres eliminar el proyecto: "+obra+" ?")) { 

     // no fem res

	} else {

		window.open("admin.php?seccio=proyectos&nom=obras&proyecto="+proyecto+"&espai="+espai+"&eliminar="+id,"_self");

	}   
}

function eliminar_link(id,titol){
	
	if(!confirm("¿Seguro que quieres eliminar: "+titol+" ?")) { 

     // no fem res

	} else {

		window.open("admin.php?nom=informacion_tecnica&eliminar="+id,"_self");

	}   
}


// *****************************************************************************************************
