function colorFade(id,element,start,end) {
  var startrgb,endrgb,er,eg,eb,step,rint,gint,bint,step;
  var target = document.getElementById(id);
  steps = 15;
  speed = 15;
  clearInterval(target.timer);
  endrgb = colorConv(end);
  er = endrgb[0];
  eg = endrgb[1];
  eb = endrgb[2];
  if(!target.r) {
    startrgb = colorConv(start);
    r = startrgb[0];
    g = startrgb[1];
    b = startrgb[2];
    target.r = r;
    target.g = g;
    target.b = b;
  }
 
  rint = Math.round(Math.abs(target.r-er)/steps);
  gint = Math.round(Math.abs(target.g-eg)/steps);
  bint = Math.round(Math.abs(target.b-eb)/steps);
  if(rint == 0) { rint = 1 }
  if(gint == 0) { gint = 1 }
  if(bint == 0) { bint = 1 }
  target.step = 1;
  target.timer = setInterval( function() { animateColor(id,element,steps,er,eg,eb,rint,gint,bint) }, speed);
}
function animateColor(id,element,steps,er,eg,eb,rint,gint,bint) {
  var target = document.getElementById(id);
  var color;
  if(target.step <= steps) {
    var r = target.r;
    var g = target.g;
    var b = target.b;
    if(r >= er) {
      r = r - rint;
    } else {
      r = parseInt(r) + parseInt(rint);
    }
    if(g >= eg) {
      g = g - gint;
    } else {
      g = parseInt(g) + parseInt(gint);
    }
    if(b >= eb) {
      b = b - bint;
    } else {
      b = parseInt(b) + parseInt(bint);
    }
    color = 'rgb(' + r + ',' + g + ',' + b + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
    target.r = r;
    target.g = g;
    target.b = b;
    target.step = target.step + 1;
  } else {
    clearInterval(target.timer);
    color = 'rgb(' + er + ',' + eg + ',' + eb + ')';
    if(element == 'background') {
      target.style.backgroundColor = color;
    } else if(element == 'border') {
      target.style.borderColor = color;
    } else {
      target.style.color = color;
    }
  }
}
function colorConv(color) {
  var rgb = [parseInt(color.substring(0,2),16), 
    parseInt(color.substring(2,4),16), 
    parseInt(color.substring(4,6),16)];
  return rgb;
}
////////////////////////////////////////////////////
function negro(i){
	for(x=1;x<10;x++){
			if(x!=i){
			document.getElementById('e'+x).style.color="#000000";
			document.getElementById('e'+x).style.filter = "alpha(opacity=25)";
			document.getElementById('e'+x).style.opacity = ".25";
			}else{
			document.getElementById('e'+x).style.color="#FFFFFF";
			document.getElementById('e'+x).style.filter = "alpha(opacity=100)";
			document.getElementById('e'+x).style.opacity = "1";
			}
	}
}

function aparecer(){
	var color = new Array();
	
	color[1] = "#cc3300";
	color[2] = "#006699";
	color[3] = "#719601";
	color[4] = "#e7b900";
	color[5] = "#c10030";
	color[6] = "#006699";
	color[7] = "#996600";
	color[8] = "#990000";
	color[9] = "#727272";
	
	for(x=1;x<10;x++){
	document.getElementById('e'+x).style.color=color[x];
	document.getElementById('e'+x).style.filter = "alpha(opacity=100)";
	document.getElementById('e'+x).style.opacity = "1";
	}
}

//************************slide de contacto*/
	var aa = 5;	
	var zz = 225;
	
function mostrar_contacto(){
	if(zz >= 0 ){
	document.getElementById('contacto_head').style.marginTop = '-'+zz+'px';
	setTimeout('mostrar_contacto()',10);
	zz = zz-5;
	aa=5;
	}
}	
function ocultar_contacto(){
	if(aa <= 225){
	document.getElementById('contacto_head').style.marginTop = '-'+aa+'px';
	setTimeout('ocultar_contacto()',10);
	aa = aa+5;
	zz=225;
	}
}


//**********************cambio de imagenes en menu derecho
function cambiar_img (obj,img) {
    document.images[obj].src = img;
}
function regre_img (obj,img) {
    document.images[obj].src = img;
} 

//*******************slide promociones
var m = -350;
var obj; 
var v = 0; 
op=9;

function ver(div){
	document.getElementById('imagen'+div).style.display ='block';
	document.getElementById('imagen'+div).style.marginLeft = m+'px';
	document.getElementById('imagen'+div).style.opacity = 1.0;
	document.getElementById('imagen'+div).style.filter = 'alpha(opacity=100)';
	obj = div;
	entrar(div);
}

function entrar(obj){
	if(m < 0){
		m += 5;
		document.getElementById('imagen'+obj).style.marginLeft = m+'px';
		setTimeout('entrar(obj)',25);
	}else{
		m = -350; 
		pau = 1; 
			if(obj <=4){
				if(obj <=2)	obj = obj + 1; 
					else obj = 1;
				if(v==4)v=2;	
					else v = v+1;
				pausa();	
			}else{
				obj = 1;
				pausa();
			}
	}
}

function pausa(){
	if(pau <= 10){
		setTimeout('pausa()',1000);
		pau = pau + 1;
	}else{
		obj = obj+1;
			if(obj <= 4)fade(obj);
			else{
				obj = 1;
				fade(obj);
			}
	}
}

function fade(obj){
	if(obj != 1)obj = obj-1;
	else obj = 4;
	
	if(op<10 && op > 0){
	document.getElementById('imagen'+obj).style.filter = 'alpha(opacity='+op+'0)';
	document.getElementById('imagen'+obj).style.opacity = '0.'+op;
	document.getElementById('imagen'+obj).style.khtmlOpacity = op;
	document.getElementById('imagen'+obj).style.opacity = '.'+op;
	op = op - 1;
	setTimeout('fade(obj)',50);
	}else{
	document.getElementById('imagen'+obj).style.display ='none';
	if(obj == 4) obj = 1;
	else obj = obj+1;
	op=9;
	ver(obj);
	}	
}

//***************************************tool tip
var tooltip=function(){
	var id = 'tt';
	var top = 10;
	var left = 10;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 90;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

function vent(ve){
document.getElementById('oculta').style.display = 'block';
document.getElementById('pop'+ve).style.display = 'block';
}
function c_vent(ve){
document.getElementById('oculta').style.display = 'none';
for(i=1;i<5;i++) document.getElementById('pop'+i).style.display = 'none';
}
//abre otra web
function web(url){
window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
}
//abre pag promociones
function promo(web){
	document.location.href = web;
}