
//(function ($) {
//   var cache = [];
//   // Arguments are image paths relative to the current page.
//   $.preLoadImages = function () {
//      var args_len = arguments.length;
//      for (var i = args_len; i--; ) {
//         var cacheImage = document.createElement('img');
//         console.log(arguments[i]);
//         cacheImage.src = arguments[i];
//         cache.push(cacheImage);
//      }
//   }
//})(jQuery)

   //jQuery.preLoadImages('../Images/bg_body.jpg', '../Images/bg_body_home.jpg', '../Images/bg_body1.jpg', '../Images/bg_body2.jpg', '../Images/bg_body3.jpg', '../Images/bg_body4.jpg', '../Images/bg_body5.jpg', '../Images/bg_body6.jpg', '../Images/bg_body7.jpg', '../Images/bg_body8.jpg', '../Images/bg_body9.jpg', '../Images/bg_body10.jpg', '../Images/bg_body11.jpg', '../Images/bg_body12.jpg', '../Images/bg_body13.jpg', '../Images/bg_body14.jpg', '../Images/bg_body15.jpg');

   //Extend
	$.fn.defTxt=function(){this.focus(function(){clTxt(this)});this.blur(function(){clTxt(this)});function clTxt(thefield){if(thefield.defaultValue==thefield.value){thefield.value=""}else if(thefield.value==""){thefield.value=thefield.defaultValue}}};

	$(function () {

	   //links
	   $('.off').click(function () { return false; });
	   $('a[rel="external"]').click(function () { window.open($(this).attr('href')); return false; });
	   $('.lnkSubmit').click(function () {
	      $("form:first").submit();
	      return false;
	   });
	   //limpa campo
	   $('.defTxt').defTxt();
	   //hover navbar
	   $('#navbar > li').hover(function () {
	      $(this).addClass('hover');
	   }, function () {
	      $(this).removeClass('hover');
	   });
	   //zebrado
	   $('.zebra > li:even,.zebra tr:even').addClass('even');
	   // lista expansível
	   var $lstExpCont,
		$lstExpAtv;
	   $('.lstExpand dt').live('click', function () {
	      $lstExpAtv = $('.lstExpand dt.on');
	      $lstExp_Cont = $(this).next('dd');

	      if ($(this).is('.on')) {
	         $(this).removeClass('on');
	         $lstExp_Cont.slideUp();
	      } else {
	         $lstExpAtv.removeClass('on');

	         $(this).addClass('on');

	         $lstExpAtv.next('dd').slideUp();
	         $lstExp_Cont.slideDown();
	      }
	      return false;
	   });

	   // acesso rapido
	   var $contAR = $('#lstAcessoRapido');
	   $('#btnARClose,#lnkAcessoRapido').click(function () {
	      $contAR.toggle();
	      return false;
	   });
	   $('*:not(#lnkAcessoRapido)').click(function () {
	      if ($contAR.is(':visible')) {
	         $contAR.hide();
	      }
	   });

	   // webmail
	   $('#lnkwebmailtop').click(function () {
	      $('#boxWebmailTop').slideToggle();
	   }).blur(function () {
	      $('#boxWebmailTop').slideUp();
	   });

	   $('#lnkwebmailbot').click(function () {
	      $('#boxWebmailBot').slideToggle();
	   }).blur(function () {
	      $('#boxWebmailBot').slideUp();
	   });

	   $('#boxWebmailTop a,#boxWebmailBot a').click(function () { $('#boxWebmailTop, #boxWebmailBot').hide(); });

	   // abas
	   var $abasCurr,
		abaTarget, abaInner;
	   $('.abaIndex a').click(function () {
	      $(this).closest('.abaIndex').find('li.on').removeClass('on');
	      $(this).closest('li').addClass('on'); //Marca o menu

	      $abasCurr = $(this).closest('.abaTp1,.abaTp2');
	      abaTarget = $(this).attr('href');
	      $abasCurr.find('.abaCont:visible').removeClass('abaOn');
	      $(abaTarget).addClass('abaOn');

	      $(abaTarget).find('.lstExpand > dt:first:not(".on")').click();

	      if (abaInner != "" && abaInner != undefined) {
	         link = $("<a href='#" + abaInner + "'>ssss</a>").appendTo("body");
	         window.location.hash = abaInner;
	      }
         
	      return false;
	   });

	   //lstSelos
	   $('.lnkTarget').click(function () {
	      abaTarget = $(this).attr("href");
	      abaInner = $(this).attr("rel");
	      $(abaTarget).click();
	      return false;
	   });

	   //hover login
	   $('a.btnCadFunc').click(function () {
	      $('#boxFrmLogin').toggleClass('boxFrmLoginAtv');
	      return false;
	   });

	   //btnimpressao
	   //	$('.btnImprimirPortaRetratoBB').click(function(){
	   //		imprimir($(this).closest('.contIn').html());
	   //	});

	   //modais
	   $('a.btnEnviarAmigoBB').nyroModal({ minHeight: 420, width: 400, blocker: '#aspnetForm' });
	   $('a.btnEnviarMsgPais').nyroModal({ minHeight: 310, width: 400, blocker: '#aspnetForm' });
	   //tooltip
	   $(".tooltip").tooltip({
	      track: true,
	      delay: 0,
	      showURL: false,
	      opacity: 1,
	      top: -85,
	      left: -22
	     });

	   //****************//
	   $(document).ready(function () {
	      if (document.URL.indexOf('#', 0) > 1) {
	         var aba = document.URL.split('#');
	         $("a[href='#" + aba[1] + "']").click();
	      }
	   });
	});

//impressao de porta retrato
function imprimir(printElement) {
   var boSexo = "";

   if (printElement.indexOf('Menina', 0) > 0)
      boSexo = "F";
   else if (printElement.indexOf('Menino', 0) > 0)
      boSexo = "M";

   //popimpressao = window.open('', '', 'width=650,height=330,left=0,top=0,scrollbars=yes,resizable=yes,menubar=no,toolbar=no');
   popimpressao = window.open('', '', 'width=650,height=630,left=0,top=0,scrollbars=yes,resizable=yes,menubar=no,toolbar=no');

	with(popimpressao.document){
		write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
		write('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Hospital Mãe de Deus</title>');
		write('<link rel="stylesheet" href="../CSS/print.css" type="text/css">');
		write('</head>');
		write('<body>');
		if (boSexo == "F") {
		   write('<div id="bgTop"><img id="bgImgTop" height="256" width="595" src="../Images/Institucional/MolduraF_Top.jpg" /></div>');
		   write('<div id="printContent" class="tpF">');
		   write('<div id="bgMid"><img id="bgImgMid" height="281" width="595" src="../Images/Institucional/MolduraF_Middle.jpg" /></div>');
		   write(printElement);
		   write('</div>');
		   write('<div id="bgBot"><img id="bgImgBot" height="305" width="595" src="../Images/Institucional/MolduraF_Bottom.jpg" /></div>');
		} else if (boSexo == "M") {
         
		}
		write('</body></html>');
		close();
   }
   popimpressao.scrollTo(0, 256);
	popimpressao.print();
	//popimpressao.close();
}


//sIFR
fonteSwf();
function fonteSwf(){
	var futuraMdBt = {
		src: '../SWF/futuraMdBt.swf'
	};
	sIFR.debugMode = true;
	sIFR.delayCSS  = true;
	sIFR.activate(futuraMdBt);
	sIFR.replace(futuraMdBt, {
		selector: 'h1.sifr'
		,css: [
			'.sIFR-root{font-size:35px;color:#006A6C;}'
		]
		,wmode:'transparent'
		,offsetLeft:20
		,offsetTop:19
		,tuneHeight:19
		,filters: {
			DropShadow: {
				knockout: false
				,distance: 1
				,color: '#000000'
				,strength: 1
			}
		}

	});
}

//Modal Bebê
function RetratoBebe(ident) {
   if (ident != "") {
      window.setTimeout("$('html, body').animate({ scrollTop: 675 }, 700);", 300);
      $.nyroModalManual({
         title: 'Consulta de Exames',
         closeButton: '<a href="#" class="nyroModalClose" id="closeModal" title="Fechar">Fechar</a>',
         modal: false,
         height: 365,
         width: 650,
         type: 'iframe',
         forceType: 'iframe',
         url: '../Institucional/Album-Bebe-Retrato.aspx?bebe=' + ident
      });
   }
   return false;
}

function ConsultarExames(protocolo, senha) {
   if ((protocolo != "") && (senha != "")) {
      /*window.setTimeout("$('html, body').animate({ scrollTop: 130 }, 700);", 300);
      window.setTimeout("$('#nyroModalFull').css('zIndex', 9999);", 500);
      $.nyroModalManual({
         title: 'Consulta de Exames',
         closeButton: '<a href="#" class="nyroModalClose" id="closeModal" title="Fechar">Fechar</a>',
         modal: false,
         height: 380,
         width: 650,
         type: 'iframe',
         forceType: 'iframe',
         cssOpt: { bg: { zIndex: 9999 } },
         url: 'http://internet.diagnosticosdaamerica.com.br/sislu/public/laudoComPesquisa.jsp?marca=R&rg=' + protocolo + '&senha=' + senha
      });*/
   	window.open('http://internet.diagnosticosdaamerica.com.br/sislu/public/laudoComPesquisa.jsp?marca=R&rg=' + protocolo + '&senha=' + senha);
   }
   return false;
}
