// JavaScript Document

var direction = 1;
var delaytime = 50;

	isNS4 = (document.layers) ? true : false;
	isIE4 = (document.all && !document.getElementById) ? true : false;
	isIE5 = (document.all && document.getElementById) ? true : false;
	isNS6 = (!document.all && document.getElementById) ? true : false;

function findDOM(objectID,withStyle) {

	if (withStyle == 1) {
		if (isIE5 || isNS6) { return (document.getElementById(objectID).style); }
		else { 
			if (isIE4) { return (document.all[objectID].style); }
			else {
				if (isNS4) { return (document.layers[objectID]); }
			}
		}
	}
	else {
		if (isIE5||isNS6) { return (document.getElementById(objectID)) ; }
		else { 
			if (isIE4) { return (document.all[objectID]); }
			else {
				if (isNS4) { return (document.layers[objectID]); }
			}
		}
	}
}

function ExpandirMenu(objectID) {
	if (isIE5||isNS6||isIE4||isNS4) {
		domStyle = findDOM(objectID,1);
		if (domStyle.display =='block')  domStyle.display='none';
		else domStyle.display='block';
	}
	else {
		destination = objectID + '.html';
		self.location = destination;
	}
	return;
}

function AnimateLayers(tipus) {
  var x_pos;  
  var y_pos;

	if (tipus==0) {  
        x_pos = parseInt(shake.left);
		if (direction==1 && x_pos<125) {
			shake.left=x_pos+2;
		}
		else {
			direction=0;
			document.images['auto'].src='../images/cotxeP2.gif'
		}
		if (direction==0 && x_pos>0 ) {
		    shake.left = x_pos-2;
		}
		else {
			direction=1;
			document.images['auto'].src='../images/cotxeP3.gif'
		}
	    setTimeout("AnimateLayers('0')", delaytime);
    }
	if (tipus==1) {
      x_pos = parseInt(shake.left);
	  y_pos = parseInt(shake.top);

		if (direction==1 && x_pos<125) {
			shake.left=x_pos+1;
			if ((x_pos%2)==0) {
				shake.top = y_pos+1;
			}
			else{
				shake.top = y_pos-1;
			}
		}
		else {
			direction=0;
		}

		if (direction==0 && x_pos>1 ) {
		    shake.left = x_pos-1;
			if ((x_pos%2)==0) {
				shake.top = y_pos+1;
			}
			else{
				shake.top = y_pos-1;
			}
		}
		else {
			direction=1;
		}
		
	    setTimeout("AnimateLayers('1')", delaytime);	  
	}	
}

function Shake(which,tipus){	
	shake=findDOM(which,1);
	AnimateLayers(tipus);	
}


/*

function PreloadImages() {
  var d=document; 
  var i,j=d.MM_p.length,a=PreloadImages.arguments; 

   if(d.images) { 
       if(!d.MM_p) d.MM_p=new Array();
			for(i=0; i<a.length; i++) {
                if (a[i].indexOf("#")!=0) d.MM_p[j]=new Image(); 
				d.MM_p[j++].src=a[i];			   
	        }	   
   }
}
//PreloadImages('cotxeP2.gif cotxeP3.gif','')
*/
