// CAMBALACHE

function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

function changeImage(layer,imgName,imgObj) {
	if (document.images) {
		if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')
		else document.images[imgName].src = eval(imgObj+".src")
	}
}


//------------------------FUNCIONES MOUSEOVER--------------------------------


//alert (n)
//alert (ie)
var esperando = null
mo=0;
ao=315;
var grifo=0;

function andando()
  { 
    if(grifo == 2){return false};
    if(grifo == 0)
	{
		mo = mo + 1;
    	eval("esperando=setTimeout('andando2(" + (mo) + ")',10)");
    }
    else 
	{
		eval("esperando=setTimeout('andandoatras2(" + (ao) + ")',10)");
    	ao = ao - 1;
	};
	return(true);
  }

function andando2(mo)
  { 
    if (mo >0 && mo < 44)    {mp(16,13,mo,'traba11')};
    if (mo >44 && mo < 60)   {mp(16,13,mo,'forma11')};
    if (mo >60 && mo < 77)   {mp(16,13,mo,'nego11')};
    if (mo >77 && mo < 95)   {mp(16,13,mo,'indus11')};
    if (mo >95 && mo < 113)  {mp(16,13,mo,'agri11')};
    if (mo >113 && mo < 130) {mp(16,13,mo,'hogar11')};
    if (mo >130 && mo < 148) {mp(16,13,mo,'mueble11')};
    if (mo >148 && mo < 165) {mp(16,13,mo,'inmue11')};
    if (mo >165 && mo < 183) {mp(16,13,mo,'motor11')};
    if (mo >183 && mo < 199) {mp(16,13,mo,'ima11')};
    if (mo >198 && mo < 216) {mp(16,13,mo,'infor11')};
    if (mo >216 && mo < 234) {mp(16,13,mo,'viajes11')};
    if (mo >234 && mo < 250) {mp(16,13,mo,'tiempo11')};
    if (mo >250 && mo < 265) {mp(16,13,mo,'deportes11')};
    if (mo >265 && mo < 280) {mp(16,13,mo,'rela11')};
    if (mo >280 && mo < 295) {mp(16,13,mo,'varios11')};
    if (mo >295 && mo < 310) {mp(16,13,mo,'inter11')};
    if (mo >310 && mo < 315) {mp(16,13,mo,'prof11')};
    if (mo >315) {ao=315;grifo=1};
	andando();
  } 

 
function andandoatras2(ao)
  {
    if (ao >0 && ao < 40)    {mp(16,13,ao,'traba11')};
    if (ao >40 && ao < 58)   {mp(16,13,ao,'forma11')};
    if (ao >58 && ao < 75)   {mp(16,13,ao,'nego11')};
    if (ao >75 && ao < 90)   {mp(16,13,ao,'indus11')};
    if (ao >90 && ao < 110)  {mp(16,13,ao,'agri11')};
    if (ao >110 && ao < 130) {mp(16,13,ao,'hogar11')};
    if (ao >130 && ao < 145) {mp(16,13,ao,'mueble11')};
    if (ao >145 && ao < 160) {mp(16,13,ao,'inmue11')};
    if (ao >160 && ao < 180) {mp(16,13,ao,'motor11')};
    if (ao >180 && ao < 195) {mp(16,13,ao,'ima11')};
    if (ao >195 && ao < 211) {mp(16,13,ao,'infor11')};
    if (ao >211 && ao < 230) {mp(16,13,ao,'viajes11')};
    if (ao >230 && ao < 245) {mp(16,13,ao,'tiempo11')};
    if (ao >245 && ao < 260) {mp(16,13,ao,'deportes11')};
    if (ao >260 && ao < 275) {mp(16,13,ao,'rela11')};
    if (ao >275 && ao < 293) {mp(16,13,ao,'varios11')};
    if (ao >293 && ao < 305) {mp(16,13,ao,'inter11')};
    if (ao >305 && ao < 320) {mp(16,13,ao,'prof11')};
    if (ao < 1) {mo=0;grifo=0};
	andando();
  } 

function mouseMove(e) {
 if (n) {var x=e.pageX; var y=e.pageY};
 if (ie) {var x=event.x; var y=event.y};
 if (x > 120 && x < 220 && y > 0 && y < 315)
	{ 
	grifo = 2;
    speed = Math.round((y-183)/5);
    if (y >21 && y < 40) {mp(15,12,y,'traba11')};
    if (y >40 && y < 60) {mp(15,12,y,'forma11')};
	} 
}


function mp(va,vb,vc,vd)
{
changeImage('it1','sb0',vd)
	if (ie)
	{
		eval("it1.style.top = vc -va");
		eval("cuadrito.style.top = vc -vb");
	}
	if (n)
	{
		eval("document.layers.it1.top = vc -va");
		eval("document.layers.cuadrito.top = vc -vb");
	}
}


function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()

numItems=6

circleXstart=50
circleYstart=380
circleXoffset=-18
circleYoffset=-3 

circlePXspeed=10 
circleTspeed=1 

circleStay=1 


function makeObj(obj,nest,x,y){nest=(!nest) ? '':'document.'+nest+'.'		
this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
this.evnt=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?this.css:0;			
this.showIt=b_showIt; this.moveIt=b_moveIt; this.slide=b_slide; this.slideIt=b_slideIt;			
this.obj = obj + "Object"; 	eval(this.obj + "=this"); return this}
function b_showIt(){this.css.visibility="visible"}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x;this.css.top=this.y}
function b_slideIt(endx,endy,inc,speed,fn,wh) {
if (!this.slideactive) {var distx = endx - this.x;var disty = endy - this.y
var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc
var dx = distx/num;var dy = disty/num; this.slideactive = 1; this.slide(dx,dy,endx,endy,speed,fn,wh)}}
function b_slide(dx,dy,endx,endy,speed,fn,wh) { if (!fn) fn = null; if(!wh) wh=null
if (this.slideactive && (Math.floor(Math.abs(dx))<Math.floor(Math.abs(endx-this.x)) || 
Math.floor(Math.abs(dy))<Math.floor(Math.abs(endy-this.y)))) { this.moveIt(this.x+dx,this.y+dy); eval(wh)
slidTim=setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+speed+",'"+fn+"','"+wh+"')",speed)
}else{this.slideactive = 0;this.moveIt(endx,endy);eval(fn)}}


function slideball_init(){
	oBut=new Array();
	for(i=0;i<=numItems;i++){
		oBut[i]=new makeObj('divButton'+i)
	}
	oCircle=new makeObj('divCircle');
	oBut[0].moveIt(120,350) 
	oBut[1].moveIt(120,367)
	oBut[2].moveIt(120,384)
	oBut[3].moveIt(120,401)
	oBut[4].moveIt(120,418)
	oBut[5].moveIt(120,435)
	oBut[6].moveIt(120,452)
//	oBut[7].moveIt(120,469)
//	oBut[8].moveIt(120,485)
	oCircle.moveIt(circleXstart,circleYstart)
	//Showing the buttons
	for(i=0;i<=numItems;i++){
		oBut[i].showIt()
	}
}
var slidTim=100;
var active=-1;

function sbmover(num){
	clearTimeout(slidTim)
	oCircle.slideactive=false
	oCircle.slideIt(oBut[num].x+circleXoffset,oBut[num].y+circleYoffset,circlePXspeed,circleTspeed)
}

function sbmout(num){
	clearTimeout(slidTim)
	oCircle.slideactive=false
	if(active>-1 && circleStay)oCircle.slideIt(oBut[active].x+circleXoffset,oBut[active].y+circleYoffset,circlePXspeed,circleTspeed)
	else oCircle.slideIt(circleXstart,circleYstart,circlePXspeed,circleTspeed)
}

function changeListing(num){
	active=num
}


// Funciones titulos verticales de categorias
function Ver(cual){
	Ocultartodos();
	if (document.layers){
		eval('document.layers.'+cual+'.visibility = "show"' )  ; }
	else {
		eval( cual+'.style.visibility = "visible"');
	}
}

function Ocultartodos(){
	for (x=1; x<=18; x++)
	{
		if (document.layers){
			eval( 'document.layers.ind'+x+'.visibility = "hide"' ); }
			else {
			eval( 'ind'+x+'.style.visibility = "hidden"' );}
	}
}


function init()
{
	if (document.layers) {n=1;ie=0};
	if (document.all) {n=0;ie=1};
    speed = 0;
	statdyn = "dynamic";
	started = 0;
	mo = 0;
	document.onmousemove = mouseMove;
	if (n) document.captureEvents(Event.MOUSEMOVE);
}


