//Variables carrusel
var slideshow_width='480px'
var slideshow_height='260px'
var pause=3000

//var fadeimages=new Array()

var max_fotos_carrusel = 41 //Fotos disponibles + 1

/*
for (i=0;i<4;i++) {
	fadeimages[i]="imagenes/carrusel/carrusel" + (Math.floor(Math.random()*100)%max_fotos_carrusel) + ".jpg"
}*/

//Variables marquesina
var marqueetituloheight="15px"
var marqueetitulowidth="250px"
var marqueetituloleft="228px"
var marqueetitulotop="150px"

var marqueewidth="250px"
var marqueeheight="90px"
var marqueeleft="228px"
var marqueetop="167px"

var marqueespeed=1
var pauseit=1

//var marqueecontent='<table width="230" border="0" cellpadding="1" cellspacing="0"><tr><td valign="top"><table width="223" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td><a href="#" class="demandas">20/10/04 Buy penthouse 3 bed 2 bath</a></td></tr><tr><td><a href="#" class="demandas">20/10/04 Buy apartment 2 bed</a></td></tr><tr><td><a href="#" class="demandas">22/10/04 Buy villas 3 bed 2 bath</a></td></tr><tr><td><a href="#" class="demandas">01/11/04 Buy plot</a></td></tr><tr><td><a href="#" class="demandas">01/11/04 Buy apartment 3 bed 1 bath</a></td></tr><tr><td><a href="#" class="demandas">20/10/04 Buy penthouse 3 bed 2 bath</a></td></tr><tr><td><a href="#" class="demandas">20/10/04 Buy apartment 2 bed</a></td></tr><tr><td><a href="#" class="demandas">22/10/04 Buy villas 3 bed 2 bath</a></td></tr><tr><td><a href="#" class="demandas">01/11/04 Buy plot</a></td></tr><tr><td><a href="#" class="demandas">01/11/04 Buy apartment 3 bed 1 bath</a></td></tr></table></td></tr></table>'

marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
var actualheight=''
var cross_marquee, ns_marquee

var preloadedimages=new Array()
for (p=0;p<fadeimages.length;p++){
preloadedimages[p]=new Image()
preloadedimages[p].src=fadeimages[p]
}

var ie4=document.all
var dom=document.getElementById
var curpos=10
var degree=10
var curcanvas="canvas0"
var curimageindex=0
var nextimageindex=1

function scrollmarquee() {
	if (iedom) {
		if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
			cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
		else
			cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
	} else if (document.layers) {
		if (ns_marquee.top>(actualheight*(-1)+8))
			ns_marquee.top-=copyspeed
		else
			ns_marquee.top=parseInt(marqueeheight)+8
	}
}

function populate() {
	if (iedom)	{
		cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
		cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
		cross_marquee.innerHTML=marqueecontent
		actualheight=cross_marquee.offsetHeight
	} else if (document.layers) {
		ns_marquee=document.ns_marquee.document.ns_marquee2
		ns_marquee.top=parseInt(marqueeheight)+8
		ns_marquee.document.write(marqueecontent)
		ns_marquee.document.close()
		actualheight=ns_marquee.document.height
	}
	lefttime=setInterval("scrollmarquee()",70)
}

function fadepic(){
if (curpos<100){
curpos+=10
if (tempobj.filters)
tempobj.filters.alpha.opacity=curpos
else if (tempobj.style.MozOpacity)
tempobj.style.MozOpacity=curpos/100
}
else{
clearInterval(dropslide)
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML='<img src="'+fadeimages[nextimageindex]+'" width="480" height="260">'
nextimageindex=(nextimageindex<fadeimages.length-1)? nextimageindex+1 : 0
setTimeout("rotateimage()",pause)
}
}

function rotateimage() {
	if (ie4||dom) {
		resetit(curcanvas)
		var crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
		crossobj.style.zIndex++
		var temp='setInterval("fadepic()",50)'
		dropslide=eval(temp)
		curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
	} else {
		document.images.defaultslide.src=fadeimages[curimageindex]
	}
	
	curimageindex=(curimageindex<fadeimages.length-1)? curimageindex+1 : 0
}

function resetit(what){
	curpos=10
	var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
	
	if (crossobj.filters) {
		crossobj.filters.alpha.opacity=curpos
	} else if (crossobj.style.MozOpacity) {
		crossobj.style.MozOpacity=curpos/100
	}
}

function startit() {
	var crossobj = ie4 ? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
	crossobj.innerHTML='<img src="'+fadeimages[curimageindex]+'" width="480" height="260">'
	
	rotateimage()
	populate()
}

if (ie4||dom) {
	window.onload = startit
} else {
	setInterval("rotateimage()",pause)
}

if (ie4||dom) {
//CAPA TITULO
document.write('<div style="position:relative;width:'+slideshow_width+';height:'+slideshow_height+';overflow:hidden">')
//Capa carrusel
document.write('<div id="canvas0" style="position:absolute;z-index:0;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10"></div><div id="canvas1" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10"></div>')

//Capa Marquesina Titulo
document.write('<div style="position:absolute;z-index:302;top:'+marqueetitulotop+';left:'+marqueetituloleft+';width:'+marqueetitulowidth+';height:'+marqueetituloheight+';visibility:visible;">')
document.write('<table width="250" height="15" border="0" cellpadding="1" cellspacing="0"><tr><td valign="top" width="250" class="cabecera"><a class="cabecera" style="text-decoration:none; color:#fad040" href="javascript:do_accion_cod_w(\'demandas_tablon\',\'{$demandas[demandas_idx].codigo}\',\'width=600,height=400,status=yes,resizable=yes,scrollbars=yes\')">DEMANDAS</a></td></tr></table>')
document.write('</div>')

//Capa marquesina
if (iedom||document.layers) {
	with (document) {
		if (iedom) {
			write('<div style="position:absolute;z-index:301;background-color:#CCCCCC;filter:alpha(opacity=60);width:'+marqueewidth+';height:'+marqueeheight+';left:'+marqueeleft+';top:'+marqueetop+';overflow:hidden" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
			write('<div id="iemarquee" style="position:absolute;z-index:300;left:0px;top:0px;width:100%">')
			write('</div></div></div>')
		} else if (document.layers) {
			write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" left='+marqueeleft+' top='+marqueetop+' >')
			write('<layer name="ns_marquee2" width='+marqueewidth+' height='+marqueeheight+' left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
			write('</ilayer>')
		}
	}
}
document.write('</div>')
} else {
	document.write('<img name="defaultslide" src="'+fadeimages[0]+'" width="480" height="260">')
}

