//=======================================================
//==	generic.js
//==	Alexandre Busquets Triola - 3V2.NET
//==	07082004
//=======================================================

function winpopup(url, ample, alt, x, y)
{
	var win_x;
	var win_y;

	if (x == ""){
	
	win_x = (screen.width-ample)/2;
	}else{
	win_x = x;
	}

	if (y == "")
	{
	win_y = (screen.width-alt)/2;
	}else{
	win_y = y;
	}

	var wint = (screen.height-alt)/2;
	var opcions=('top='+win_x+',left='+win_y+',width='+ample+',height='+alt+',toolbar='+0+',menubar='+0+',scrollbars='+0+',status='+0+', resizable='+0);
	var finestra = Math.floor(Math.random()*1000000);
	window.open(url, finestra.toString(), opcions);
}

function in_array(mArray, mValor){

	for(q=0; q<mArray.length; q++){
		if (mArray[q] == mValor){
		return true;
		}
	}
return false;
}


function vigila_formulari(f){

	var vigila = f.vigila.value;
	var vigilatxt = f.vigilatxt.value;
	var el_array = vigila.split("|"); 
	var el_array_txt = vigilatxt.split("|");
	falle_txt = "";
	a=0;
	for(i=0; i < el_array.length; i++){
		if (f.elements[ el_array[i] ].value == ""){
			falle_txt += el_array_txt[i] + "\n";
			a++;
		}
	}


	if (a > 0){
	alert(f.missatge0.value+"\n"+falle_txt);
	}else{
	f.submit();
	}
}

function sobre(src,color)
{
	src.style.background = color; 
}


function popup_img(img,sx,sy) {


	//sx=(sx-20);
	//sy=(sy-20); 
	var winl = (screen.width-sx)/2; 
	var wint = (screen.height-sy)/2; 
	imatge ="<a href=\"javascript:self.close()\">\n";
	imatge +="<img src=\"" + img + "\" border=\"0\" alt=\" \" width=\""+sx+"\" height=\""+sy+"\">\n";
	imatge +="</a>\n";
	txt = "<html>\n";
	txt += "<head>\n";
	txt += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
	txt += "<title>"+get_title()+"</title>\n";
	txt += "</head>\n";
	txt += "<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n";
	txt += imatge+"\n";
	txt += "</body>\n";
	txt += "</html>\n";
	
	var opcions='top='+wint+',left='+winl+',width='+sx+',height='+sy+',toolbar='+0+',menubar='+0+',status='+0+',scrollbars='+0+',resizable='+0;

	popupwin=window.open("","CMS_foto",opcions);
	//toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sx+"");
	popupwin.document.write(txt);
	popupwin.document.close(); 
}

function popup_img2(img,sx,sy) {


	//sx=(sx-20);
	//sy=(sy-20); 
	var winl = (screen.width-sx)/2; 
	var wint = (screen.height-sy)/2; 
	imatge ="<a href=\"javascript:self.close()\">\n";
	imatge +="<img src=\"" + img + "\" border=\"0\" alt=\" \" width=\""+sx+"\" height=\""+sy+"\">\n";
	imatge +="</a>\n";
	txt = "<html>\n";
	txt += "<head>\n";
	txt += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
	txt += "<title>"+get_title()+"</title>\n";
	txt += "</head>\n";
	txt += "<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n";
	txt += imatge+"\n";
	txt += "</body>\n";
	txt += "</html>\n";
	
	var opcions='top='+wint+',left='+winl+',width='+sx+',height='+sy+',toolbar='+0+',menubar='+0+',status='+0+',scrollbars='+1+',resizable='+0;

	popupwin=window.open("","CMS_foto",opcions);
	//toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sx+"");
	popupwin.document.write(txt);
	popupwin.document.close(); 
}


function get_title(){
return document.title;
}


function popup(url, sx, sy)
{
	var winl = (screen.width-sx)/2;
	var wint = (screen.height-sy)/2;
	var finestra = 'Tibet';
	popupwin=window.open(url,finestra,"scrollbars=no, resizable=no, toolbar=no, location=no, directories=no, status=no, menubar=no, top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
}

function popupprint(url, ample, alt)
{
	var sx = ample;
	var sy = alt;
	var winl = (screen.width-sx)/2;
	var wint = (screen.height-sy)/2;
	var finestra = 'prindoc';
	popupwin=window.open(url,finestra,"scrollbars=yes, resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=yes, top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
}

function vigilaemail(str)
{ 
	if(!str.match(/^[\w]{1}[\w\.\-_]*@[\w]{1}[\w\-_\.]*\.[\w]{2,6}$/i)) { 
		return false; 
	} else { 
		return true; 
	} 
} 