// JavaScript Document

// Popup home
function somepop() {
	$("#popmsg").slideUp("slow");
}
function surgepop() {
	$("#popmsg").slideDown("normal");
}
function createpopup(adiv,arquivo,w,h) {
	   var tempo = 30000; // milisegundos
	   var oiframe ='<div class="barracmd"><a href="javascript:somepop()">[X] Fechar</a></div>\n'
				+'<iframe frameborder="0" width="100%" height="90%" id="fr_msg" src="'+arquivo+'"></iframe>\n';
	   var pai = document.getElementById(adiv);
	   var elem = document.createElement("div");
	   elem.setAttribute("id", "popmsg");
	   elem.setAttribute("class", "popmsg");
	   if(w!='')elem.style.width=w+'px';
	   if(h!='')elem.style.height=h+'px';
	   var txt = document.createTextNode(oiframe);
	   elem.innerHTML = oiframe;
	   pai.appendChild(elem);
	   var tempo1 = setTimeout('surgepop()', 2000);
	   var tempo2 = setTimeout('somepop()', tempo);
	   
}

jQuery.preloadImages = function() {
  for(var i=0; i<arguments.length; i++)   {
    jQuery("<img>").attr("src", arguments[i]);
  }
}


// jQuery

$(document).ready(function() {
	
	
	$.preloadImages("img/pop-peq.jpg","img/pop-peq.jpg","img/pop-grd-2.jpg");
	
	
	// links para imagens em popup
	$("a[href$=jpg]").click(function() { 
		var tmpImg = new Image();
		tmpImg.src=$(this).attr("href");
		var wImg = $(tmpImg).attr("width");
		var hImg = $(tmpImg).attr("height");
		if (wImg<10) wImg=500;
		if (hImg<10) hImg=400;

		var hImg = $(tmpImg).attr("height");
		var atrJan = 'scrollbars=yes,resizable=yes,width='+(wImg+50)+',height='+(hImg+50);

		window.open($(this).attr("href"), 'popup',atrJan);
		return false;
	});
	
	
});


