var slideShowTimer;
var slideShowSlides;
var slideShowSettings;
var slideShowCurrent;
var slideShowLast;

//Add-Favoritos
function addFavoritos(url, title) {
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
    } else if( window.external ) { // IE Favorite
        window.external.AddFavorite( url, title); 
    } else if(window.opera && window.print) { // Opera Hotlist
        return true; }
}

function showVideoFlash(tipo) {	
	if (tipo == "cidadelacustre") {		
		$('#caixaLacustreHome').css("display","none");
		clearTimeout(slideShowTimer);		
		var html = $.ajax({
		 url: "/videos/ajaxXMLPlaylistGenerator.php?idVideo=1",
		 async: false
		}).responseText;
		eval(html);			
		
		_mwd = (730 - _width*1) / 2;
		_mhd = (350 - _height*1) / 2;		
		$("#flashContainerCL").css("margin-left",(_mwd) + "px");
		$("#flashContainerCL").css("margin-top",(_mhd) + "px");
		
		
		$("#videoCidadeLacustre").css("display","block");
		$("#flashContainerCL").css("display","block");
		$("#flashContainerCL").css("width",_width+"px");		
		$("#linkFecharCidadeLacustre").css("display","block");
		loadFlash("/videos/player.swf?rand=" + Math.random(),"flashContainerCL",1,_width,_height, _lingua);		
	}	
	else if (tipo == "empreendimentos") {		
		var html = $.ajax({
		 url: "/videos/ajaxXMLPlaylistGenerator.php?idVideo=2",
		 async: false
		}).responseText;
		eval(html);		
		
		_m_width = $("#videoEmpreendimentos").css("width");
		_m_height = $("#videoEmpreendimentos").css("height"); 
		
		_mwd = (_m_width.replace("px","")*1 - _width*1) / 2;
		_mhd = (_m_height.replace("px","")*1 - _height*1) / 2;
		$("#flashContainerE").css("margin-left",_mwd + "px");
		$("#flashContainerE").css("margin-top",_mhd + "px");			
		$("#videoEmpreendimentos").css("display","block");
		$("#flashContainerE").css("display","block");		
		$("#linkFecharEmpreendimentos").css("display","block");		
		loadFlash("/videos/player.swf?rand=" + Math.random(),"flashContainerE",2,_width,_height, _lingua);							
	}
}

function hideFlashVideo(tipo) {
	if (tipo == "cidadelacustre") {
		slideShowTimer = setTimeout((function(){$.slideshow.next(slideShowSlides, slideShowSettings, slideShowCurrent, slideShowLast);}), slideShowSettings.timeout);
		$("#videoCidadeLacustre").css("display","none");
		$("#flashContainerCL").css("display","none");
		$("#linkFecharCidadeLacustre").css("display","none");
		$("#flashContainerCL").html("");
				
	} else if (tipo == "empreendimentos") {
		$("#videoEmpreendimentos").css("display","none");
		$("#flashContainerE").css("display","none");
		$("#linkFecharEmpreendimentos").css("display","none");				
		$("#flashContainerE").html("");		
	}
}

function loadFlash(swfFile,container,videoType,_width,_height, lingua) {	
	var fo = new FlashObject(swfFile, "", _width, _height, "8", "#FFFFFF");
	fo.addParam("allowScriptAccess", "sameDomain");
	fo.addParam("quality", "high");
	fo.addParam("scale", "scale");
	fo.addVariable("fichxml", "/videos/playlist_" + videoType + "_" + lingua + ".xmlx");
	fo.addParam("wmode", "transparent");
	fo.write(container);
}

$(document).ready(function() { 

	$('div.telefone a').qtip({
		content: {
			url: '/gca/index.php?id=88'
		},
		position: { 
			target: 'mouse', 
			adjust: { 
				screen: true 
			}
		},
	   style: { 
		  width: 350,
		  padding: 5,
		  background: '#423A37',
		  color: 'white',
		  border: {
			 width: 1,
			 radius: 0,
			 color: '#F3F2ED'
		  }
		 }

	});
});