/**
 * @author Divonei
 */

var menu, inicio, startStop, Ajax=false;
var curHot=0, curRss=0, hotInterval, rssInterval, pauseHot;

var arr = new Array();

var arrx = new Array();
arrx[0] = "images/menu/menu.gif";
arrx[1] = "images/menu/menu2.gif";
arrx[2] = "images/menu/menu3.gif";
//arrx[3] = "images/menu4.png";
//arrx[4] = "images/menu5.png";

var images = new Array;

var rssarr = new Array();
rssarr[0] = "xml/ticker.php";
rssarr[1] = "xml/ajax.datasample.xml";
rssarr[2] = "./xml/ticker.php";
//rssarr[2] = "images/menu4.png";
//rssarr[3] = "images/menu5.png";

for(var k=0; k<arrx.length; k++){
	images[k] = new Image();
	images[k].src = arrx[k];
	images.onload = function(){}	
}

function teste(str){
	
	var p = document.getElementById('q');
	if(p){
		if(str=="show"){		
			p.style.display = "block";			
			//p.setAttribute("type", "search");			
			p.style.backgroundColor = "#000";
		}
		else
			p.style.display = "none";
	}
	
}
function data(){
	var data = new Date;
	document.write(data.getFullYear());
}

function web_kit(){	
	 var version = get_webkit_version();		
      if(version){
	  	var p = document.getElementById('q');
		//p.setAttribute("type", "search");
		}
}

function limpa(b){
	var kids = b.childNodes;
	var numkids = kids.length;		
	for(var i=numkids-1; i>=0; i--){
	b.removeChild(kids[i]);
	}		
}
//window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);

var d=document, imgs = new Array(), zInterval = null, pause=false, cOpacity=1.00, nOpacity=0.00;
var menu, nIndex, fadeInterval, backCourse=false;

function so_init() {
	var current=1;
	
	if(!d.getElementById || !d.createElement)return;	
	imgs = d.getElementById("inicio").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0.01;
	imgs[current].style.display = "block";
	imgs[current].xOpacity = 0.01;
	
	var images = new Array();

	//setTimeout(so_xfade,50);
	menu = document.getElementById("menu");
	nIndex = current;
	
	//alert(nIndex);

}

function so_xfade() {
		
	if(!backCourse)
		nIndex = imgs[current+1]?current+1:0;	
		
	cOpacity-=0.01; 
	nOpacity+=0.01;
	
	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;
	
	ImgOpacity(imgs[current]); 
	ImgOpacity(imgs[nIndex]);
	if(cOpacity<=0) {
		imgs[current].style.display = "none";		
		current = nIndex;
		cOpacity = 1.00;
		nOpacity = 0;
		backCourse = false;
		clearInterval(fadeInterval);
		//Loop continuo!! descomentar para activar pase diapos
		iniCross('Next');
	} else {
		fadeInterval = setTimeout(so_xfade,100);	
	}	
	
}

function ImgOpacity(IMGobj) {
		if(IMGobj.xOpacity>.99) {
			IMGobj.xOpacity = .99;
			return;
		}
		IMGobj.style.opacity = IMGobj.xOpacity;
		IMGobj.style.MozOpacity = IMGobj.xOpacity;
		IMGobj.style.filter = "alpha(opacity=" + (IMGobj.xOpacity*100) + ")";
}

function iniCross(prev_next){
	if(!pause){
		clearInterval(zInterval);
	 	//zInterval =setTimeout("so_xfade()", 50);
	}
	if(prev_next=='Next'){		
		so_xfade();
	}
	else if(prev_next=='Previous') {																			
		nIndex--;								
		if(nIndex<0){
			nIndex = (imgs.length)-1;
		}
		backCourse = true;
		//so_xfade();		
	}
}

function Start(){	
	pause = false;	
	iniCross('Next');
}

function Stop(){
	pause = true;
	clearTimeout(zInterval);
	//iniCross('Previous');
}

function boxLocate() {
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
	var mytop = (myHeight/16)/8;
	//alert("mytop = "+mytop);
	if (mytop <= 5) {
	document.getElementById('topbanner').style.height = "2.0em";
	} else {
	document.getElementById('topbanner').style.height = mytop + "em";
	}
}
