/*	Creat, modificat i/o adequat per Pablo Sanz
* http://www.xtec.es/~psanz
* psanz@pie.xtec.es
*	Śltima versió : 13-11-00
*/


function isnew(maxDays, addDate){

	var oldDate = new Date(addDate);
	var newDate = new Date();
	var maxDaysOld = maxDays*24*60*60*1000;
	var resta=0;

	if ((newDate.getTime()-oldDate.getTime()) <=  maxDaysOld)
   		document.write("<img src='new.gif' width=10 height=10 ALIGN=MIDDLE Alt='Nou!!!'> ");
	else document.write("<img src='FLECHA.gif' width=10 height=10 ALIGN=MIDDLE Alt='Ja publicat'> ");
	return "";
}

//Funció que determina si el navegador és diferent de Netscape 4.03 i avisa //consecuentement.
function checkBrowser(){
	if (navigator.appName!="Netscape") alert("Aquestes pągines es visualitzant millor amb Netscape 4 o superior.");
	else if (navigator.appVersion!="4.03 [es] (Win95; I)") alert("Aquestes pągines es visualitzant millor amb Netscape 4.03 o superior.");
}


function imgOn(nomImagen, img) {
	var activado=new Image();

	if(!document.images) return;

   	activado.src=img;
     document[nomImagen].src=activado.src;
}

function imgOff(nomImagen, img) {
	var desactivado= new Image();

	if(!document.images) return;

    desactivado.src=img;
    document[nomImagen].src=desactivado.src;
}

/*
-----------------------------------------
|      By Mattias Sjöberg 2/18-96       |
|You're welcome to use/edit this script.|
| Keep the comments and drop me a note. |
-----------------------------------------
|      mattias.sjoberg@swipnet.se       |
| www.geocities.com/SiliconValley/7116  |
|     Visit  The JavaScript Planet      |
-----------------------------------------
*/
//Modificat i adequat per Pablo Sanz

function imgisnew(maxDays, addDate){

	var oldDate = new Date(addDate);
	var newDate = new Date();
	var maxDaysOld = maxDays*24*60*60*1000;
	var resta=0;

	if ((newDate.getTime()-oldDate.getTime()) <=  maxDaysOld)
   		document.write("<img src='gifs/flecha.gif' width=20 height=20 ALIGN=MIDDLE Alt='Nou!!!'> ");
	return "";
}

//Modifica la data d'actualització automąticamentt.
//Idea de Stephen King i James Wright: 03/22/96
//Funciona per sobre del 2000!
//Adequat al catalą i comentat per en Pablo Sanz

//funció	 que serveix per inicialitzar qualsevol array.
function initArray() {  // Thanks JavaScript Mailing List for this function
  this.length = initArray.arguments.length
  for (var i = 0; i < this.length; i++)
  this[i+1] = initArray.arguments[i]
}

function DataUpdate() {

   //Conté el dia de la setmana
   var DOWArray = new initArray("diumenge", "dilluns", "dimarts", "dimecres",
                                "dijous", "divendres", "dissabte");
   //Conté el mes
   var MOYArray = new initArray("gener","febrer","marē","abril",
                                "maig","juny","juliol","agost","setembre",
                                "octubre","novembre","desembre");

   //Conté l'śltima actualiztació del document
   var LastModDate = new Date(document.lastModified);
   
   var de;

   if(LastModDate.getMonth() == 3 || LastModDate.getMonth() == 7 || LastModDate.getMonth() == 9) de = " d'";
   else de = " de ";
   
   document.write("<FONT SIZE=-2>&Uacute;ltima actualització: ");
   document.write(DOWArray[(LastModDate.getDay() + 1)], " ", LastModDate.getDate(), de);
   document.write(MOYArray[(LastModDate.getMonth() + 1)], " ", LastModDate.getFullYear());
   document.write("</FONT>");

}

function init() { 
	// Create the navigation bars. 
  myNavBar.resize(getWindowWidth());
  myNavBar.create();
  updatePosition();
 }

function updatePosition() {

  var viewTop, viewBottom;
  var dy;

  viewTop = getPageScrollY();
  viewBottom = viewTop + getWindowHeight();

  if (myNavBar.bottom < viewTop)
    myNavBar.moveTo(0, viewTop - myNavBar.height);
  if (myNavBar.top > viewBottom)
    myNavBar.moveTo(0, viewBottom);

  dy = Math.round(Math.abs(viewTop - myNavBar.y) / 2);
  if (viewTop < myNavBar.y)
    dy = -dy;

  myNavBar.moveBy(0, dy);
  setTimeout('updatePosition()', 25);
}


function newWindow(url) {
    win = window.open(url, "extra");
}

function isDomBrowser()	{
	var canWork = true;
	var ie4 = false, ie5_mac = false, ie55 = false;
	var nn4 = false, dom = false, opera = false, safari = false;
	var agent = navigator.userAgent.toLowerCase();
	
	if (agent.indexOf("opera") != -1)
		opera = true;
	else if (agent.indexOf("safari") != -1)
		safari = true;
	else if (document.all) {
		var version = parseFloat(agent.substr(agent.indexOf("msie")+5, 3));
		if (agent.indexOf("mac") != -1 && version >= 5)
			ie5_mac = true;
		else 	{
			if (version >= 5.5)
				ie55 = true;
			else if (version >= 4)	{
				ie4 = true;
				canWork = false;
			}
		}
	} else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4 && 
		parseInt(navigator.appVersion) < 5)	{
		nn4 = true;
		canWork = false;
		alert("este");
	} else if (document.getElementById)
		dom = true;
		
	return canWork;
}	

