Event.observe(window, 'load', function() {
	flickrF();
});

function flickrF() {
	jQuery.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=30511561@N05&lang=en-us&format=json&jsoncallback=?", function(data){
		jQuery.each(data.items, function(i,item){
			jQuery("<img/>").attr("src", item.media.m).appendTo("#images").wrap("<a href='" + item.link + "'></a>");
			if (i==8) return false;
		});
		jQuery("#title").html(data.title);
		jQuery("#description").html(data.description);
	});
}

function addBookmark () {
  if (document.all) window.external.AddFavorite(location.href, document.title);
  else if (window.sidebar) window.sidebar.addPanel(document.title, location.href, "")
 }
 
function setHomepage () {
 document.body.style.behavior='url(#default#homepage)';
 document.body.setHomePage(location.href);	 
}

function openPopup (id, popoptions) {
	url    = document.getElementById(id).getAttribute('href');
	target = id+'_popup';
	var nw = window.open(url, target, popoptions+',scrollbars=yes,resizable=yes,status=yes');
	if (nw) { return false; }
	return false;
}

function printVersion () {
	url    = document.getElementById("versaoimpressora").getAttribute('href');
	target = 'versaoimpressora_popup';
	var nw = window.open(url, target, 'width=600,height=480,scrollbars=yes,resizable=yes,status=yes');
	if (nw) { return false; } 
}

function sendFriend () {
 url    = document.getElementById("recomendaramigo").getAttribute('href');
 target = 'recomendaramigo_popup';
 var nw = window.open(url, target, 'width=500,height=400,scrollbars=yes,resizable=yes,status=yes');
 if (nw) { return false; } 
}

function doPopUp(e) {
	//set defaults - if nothing in rel attrib, these will be used
	var t = "standard";
	var w = "600";
	var h = "480";
	//look for parameters
	attribs = this.rel.split(" ");
	if (attribs[1]!=null) {t = attribs[1];}
	if (attribs[2]!=null) {w = attribs[2];}
	if (attribs[3]!=null) {h = attribs[3];}
	//call the popup script
	popUpWin(this.href,t,w,h);

	return false;
}
function popUpWin(url, type, strWidth, strHeight){
	closeWin();
		
	type = type.toLowerCase();
	
	if (type == "fullscreen"){
		strWidth = screen.availWidth;
		strHeight = screen.availHeight;
	}
	var tools="";
	if (type == "standard") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console" || type == "fullscreen") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}
var newWindow = null;
function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

/* Dinamiza popups: associar class=popup a cada link para gerar popup automaticamente
Event.observe(window, 'load', findPopUps, false);
function findPopUps() {
	
	popupx = $$('a.popup')

	popupx.each(
		function(s) {
			s.onclick = doPopUp;
			s.title = s.title + " [Abre em nova janela]";
		}
	)
}
*/
/* para dinamizar inputs pre-preenchidos
Event.observe(window, "load", function(){
	
	inputx= $$('input.ctrlVal')

	inputx.each(
		function(s){

			s.setAttribute('valueIni', s.value)
			Event.observe(s, "click", function(){if(s.value==s.getAttribute("valueIni")) s.value= ""})
			Event.observe(s, "blur", function(){if(s.value=="") s.value= s.getAttribute("valueIni")})
		}
	);
	inputxF= $$('form.ctrlValF')
	inputxF.each(
		function(s){
			Event.observe(s, "submit", ctrlValEsvazia)
		}
	);
});
function ctrlValEsvazia() {
	$$('form.ctrlVal').each(
		function(s, index) {if(s.value==s.getAttribute("valueIni")){s.value= "";}}
	);
	return true
}
*/