﻿function getPageScroll(){

	var xScroll, yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}

	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

var t;
var t2;
var video;
var texto;
var opacidade=100;

function anima(xx,yy,video1, texto1){
video=video1;
texto=texto1;
        var box1=document.getElementById("box");
		var block=document.getElementById("divblock");		
		
		s=getPageScroll();
		d=getPageSize();
		block.style.width=d[0]+'px';
		block.style.height=d[1]+'px';
		//block.style.top=s[1]+'px';
		//block.style.left=s[0]+'px';
		block.style.display='block';
		
        box1.style.top=(s[1]+yy)+'px';
        box1.style.left=(s[0]+xx - 70) +'px';		
		box1.style.width='320px';
        box1.style.height='240px';		
		box1.style.display='block';
		opacidade=100;
		//box1.innerHTML = img.innerHTML;
		box1.style.filter ="alpha(style=0,opacity=100)";
		//opacidade=60;      	
        t=setInterval("moveDiv()",100);			
    }
	
function fechar(){
	var box2=document.getElementById("exibevideo");
	var txt=document.getElementById("textovideo");
	
	box2.innerHTML ='';
	txt.innerHTML="";
	opacidade=100;
	t2=setInterval("fechadiv()",100);	
	
	
	
}

function fechadiv(){
 var box1=document.getElementById("box");
	opacidade-=20;
	box1.style.filter ="alpha(style=0,opacity=" + opacidade + ")";
	if(opacidade==0){	
	 var block=document.getElementById("divblock");
	box1.style.display='none';
	block.style.display='none';
	clearInterval(t2);
	}

}

    function moveDiv(){
		s=getPageScroll();
		d=getPageSize();
		
        var box1=document.getElementById("box");
		var block=document.getElementById("divblock");
        var topo =  parseFloat(box1.style.top.substr(0,box1.style.top.length-1));
        var esquerda =  parseFloat(box1.style.left.substr(0,box1.style.top.length-1));		
        box1.style.top=parseInt((((d[3]/2) - 300) + s[1]+ topo)/2)+'px';
        box1.style.left=parseInt((((d[2]/2) - 170) + esquerda)/2)+'px';
		
		var w =  parseFloat(box1.style.width.substr(0,box1.style.width.length-1));
        var h =  parseFloat(box1.style.height.substr(0,box1.style.height.length-1));		
        box1.style.width=parseInt((340+ w)/2)+'px';
        box1.style.height=parseInt((360+ h)/2)+'px';
	
	
		if(parseInt((320+ w)/2)>=319){			
            var box2=document.getElementById("exibevideo");
			var txt=document.getElementById("textovideo");
			var caption=document.getElementById("caption"+texto);
			//box2.innerHTML ='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="320" height="240"><param name="movie" value="player.swf" ><param name="quality" value="high" ><param name="menu" value="false" ><param name="FlashVars" value="&v=http://www.vivianeacontece.com.br/'+video+'" ><embed src="player.swf" FlashVars="&v=http://www.vivianeacontece.com.br/'+video+'" width="320" height="240" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false"></embed></object>';
			
				
		
	
	
		var s1 = new SWFObject("player.swf","ply","320","240","9","#FFFFFF");
		s1.addParam("allowfullscreen","true");
		s1.addParam("allowscriptaccess","always");
		s1.addParam("flashvars","file="+video+"&image=preview.jpg");
		s1.write("exibevideo");
		
		txt.innerHTML='&nbsp;&nbsp;<font color="#000000">'+caption.innerHTML+'</font>';
		clearInterval(t);
		clearInterval(this);
		}
    }
