function getInternetExplorerVersion() {
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}

function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

$(document).ready(function() {
	var ver = getInternetExplorerVersion();
	if(ver<=8.0) {
		$("ul.jobs.home li:nth-child(-n+5)").css("border-top","2px solid #d1c9c1");
		$("ul.jobs.home li:nth-child(5n)").css("margin-right", 0);
		$("#colunas_jobs>div:nth-child(3n)").css("margin-right", 0);
		$("#colunas_jobs>div.col2 ul.jobs li:nth-child(2n)").css("margin-right", 0);
		$("body.page-template-pagesobrelatte-php #conteudo ul.como_fazemos li:nth-child(5n)").css("margin-right", 0);
	}
	
	function showLI(li, idx) {
		$(li).eq(idx).css({opacity: 0, visibility: "visible"});
		$(li).eq(idx).animate({opacity: 1}, {duration: 500, queue:false });
		$(li).eq(idx).children("a").children("div.img").animate({marginBottom: 0}, {duration: 500, queue:0});
		idx = idx+1;
		
		if($(li).eq(idx).length>0) {
			setTimeout(function() { showLI(li, idx); }, 50);
		}
	}
	
	function hideLI(li, idx, limite, vaiPara) {
		var fc = function() { };
		if ((idx+1)>limite || $(li).eq((idx+1)).length==0) {
			fc = function() {
				//alert("done");
				//$(li).css({opacity: 0});
				setTimeout(function() { window.location = vaiPara; }, 50);
				
				//$("h2").html("done " + idx);
			}
		}
		
		
		$(li).eq(idx).animate({opacity: 0}, {duration: 500, complete: fc() });
		idx = idx+1;
		
		if($(li).eq(idx).length>0 && idx<limite) {
			setTimeout(function() { hideLI(li, idx, limite, vaiPara); }, 20);
		} else if (idx>limite || $(li).eq(idx).length==0) {

		}
	}
	
	if($("ul.jobs").length>0) {
		showLI("ul.jobs li", 0);
	}
	
	
	// Esconde ou mostra textholder do login
	$("div.h2floater.form form>input").each(function() {
		if($(this).val()!="") {
			$(this).addClass("no_holder");
		}
	});
	
	$("div.h2floater.form form>input").focus(function() {
		$(this).addClass("no_holder");
	});
	
	$("div.h2floater.form form>input").blur(function() {
		if($(this).val()=="") {
			$(this).removeClass("no_holder");
		}
	});	
	
});
