var NS3=((navigator.appName=='Netscape')&&parseInt(navigator.appVersion)>=3&&parseInt(navigator.appVersion)<4);
var NS4=((navigator.appName=="Netscape") && (navigator.appVersion.substr(0,1)<5));
var IE=(document.all)?1:0;
var NS4=((navigator.appName=="Netscape") && (navigator.appVersion.substr(0,1)<5));
var IE4=(document.all&&!document.getElementById)?1:0;
var IE5=(document.all&&document.getElementById)?1:0;
var NS6=(document.getElementById&&!document.all)?1:0;
var DHTML=(IE||NS4||NS6)?1:0;
var DOM=(IE5||NS6)?1:0;
var MAC=(navigator.userAgent.indexOf('Mac')!=-1)?1:0;
var IEMAC=(MAC&&IE)?1:0;
var IE4MAC=(IEMAC&&(navigator.appVersion.indexOf('4.',4)!=-1))?1:0;
var IE5MAC=(IEMAC&&(navigator.appVersion.indexOf('5.')!=-1))?1:0;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 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];}}

}

function mover(dir) {
	if (readyFlag)	{
		if (dir=="izq") {
			if (fotoActual > 0) {
				moveFromTo(arrPos[fotoActual],arrPos[--fotoActual])
				window.parent.medioaba.der.src='images/der.gif';
			}
		}
		else {
			if (fotoActual < arrPos.length-1) {
				moveFromTo(arrPos[fotoActual],arrPos[++fotoActual])
				window.parent.medioaba.izq.src='images/izq.gif';
			}
		}
	}
	//modificacion 22/12 (fin de fotos)
	if (fotoActual >= arrPos.length-1)
		window.parent.medioaba.der.src='images/der_die.gif';

	if (fotoActual<=0)
		window.parent.medioaba.izq.src='images/izq_die.gif';

}
function actbtn(direc,ev) {
	if(direc=='der')
	{
		if (fotoActual < arrPos.length-1)
		{
			if(ev=='over')
			{
				window.parent.medioaba.der.src='images/der_over.gif';
			}
			else
			{
				window.parent.medioaba.der.src='images/der.gif';
			}
		}
	}
	else
	{
		if (fotoActual>0)
		{
			if(ev=='over')
			{
				window.parent.medioaba.izq.src='images/izq_over.gif';
			}
			else
			{
				window.parent.medioaba.izq.src='images/izq.gif';
			}
		}
	}
}
var percentageArray;
var sinArray;
var pii;
var steps;
var counter;
var increment; 
var sinTotal;
var testText;
var totalDistance;
var expCounter;
var bName;
var readyFlag=false;

function init(){
   readyFlag = false;

  // *****************
  // EDIT THESE VALUES
  // *****************
  
  var verStr=navigator.appVersion;

  // pc 
  
  steps = 2000; // more steps=smoother movement and more cpu -> slower, smoother scroll

  // mac 
  if ( verStr.indexOf("Mac")!=-1){
  steps	= 1500;   
  }

  exponential = 11; // increase this to make acceleration and deceleration
                         // more pronounced
  // define as many positions as you like. 
  // they are absolute positions measured from the far left
  // use code like:
  // <a href="javascript:void(0);" onclick="moveFromTo(pos1,pos2);">right</a>	
  // to call a move from one position to another
  // e.g if a link is at pos1, the above code moves from there to pos2.
   
  counter;
  pii = 3.1415927;
  increment = pii/steps;

  
  //********************************
  //initialise the percentage table
  //********************************
  
  percentageArray = new Array(steps+1);
  sinArray = new Array(steps+1);
  sinTotal = 0;

  // x goes from 0 to PI. sinx is caluculated<stepSize> times.
  for(counter=0;counter<=steps;counter++){

    sinArray[counter] = Math.sin(increment*counter);
    for(expCounter=0; expCounter<exponential; expCounter++){
    sinArray[counter]*=sinArray[counter];
    }
    sinArray[counter]*=0.25;
    sinTotal+= sinArray[counter];   

  }

  // now calulate each sinValue as a percentage of the sinTotal
  // put these values in the percentageArray
  
  for (counter=0; counter<=steps;counter++){
    percentageArray[counter] = sinArray[counter]/sinTotal;
          
  }

  readyFlag = true;
}// end init

function sinScroll(current, x, y){ 
  totalDistance = x;
  
  //alert("totalDisatnce");
  for(counter=0; counter<steps;counter++){
    //scrollBy(percentageArray[counter]*totalDistance, 0);
    move = percentageArray[counter]*totalDistance;
    scrollTo(current+move, 0);
    current+=move;
  }

}// end sinSCroll

function moveFromTo(current, target){
// move from the current position
// to then target position
var x, count=" ";

// this is done in two stages. 
// first scroll straight to 
 if(document.images){
  scrollTo(current, 0);
  sinScroll(current, target-current, 0);
 }
}// end moveFromTo

