jQuery(document).ready(function(){
	carregar_Pagina2("home/home.php");

	marqueeInit({
		uniqueid: 'mycrawler2',
		style: {
			'padding': '2px',
			'width': '260px',
			'height': '60px'
		},
		inc: 7, //speed - pixel increment for each iteration of this marquee's movement
		mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false)
		moveatleast: 1,
		neutral: 150,
		savedirection: true
	});
});
function Passar_dados(acao){
	alert(acao);
	abrir_Pagina(url, campo)
	return false;
}

function Passar_dados(url, acao){
	alert(acao);
	
	carregar_Pagina(url);
	
	alert(url);
}

function carregar_Pagina2(url){
	
	$("#conteudo").ajaxStart(function(){
		$(this).html("");
		$(this).hide();
		//carregando(true);
	});
	$("#conteudo").ajaxComplete(function(){
		$(this).show();
		//carregando(false);
		//alert("passou aki no carregar_Pagina");
		//resp_alert(true, 'Operaçao foi cancelada com sucesso!');
	});
	
	$("#conteudo").load(url);
	return false;
//	if(url == "http://www.suldamerica.edu.br/biblioteca/"){
//		//$("#conteudo").html('<iframe src="' + url + '"></iframe>');
//		$("#conteudo").html('<iframe src="' + url + '" frameborder="0" style="width:100%" height="auto"></iframe>');
//		//$("#conteudo").load(url);
//		return false;
//	}	
}

function carregar_Pagina3(url){
	$("#conteudo").ajaxStart(function(){
		$(this).html("");
		$(this).hide();
		carregando(true);
	});
	$("#conteudo").ajaxComplete(function(){
		$(this).show();
		carregando(false);
		//alert("passou aki no carregar_Pagina");
		//resp_alert(true, 'Operaçao foi cancelada com sucesso!');
	});
	$("#conteudo").load('<iframe scr="'+ url +'" height="100px" width="100px" frameborder="0"></iframe>');
	return false;
}

function carregar_Pagina(url){
	
	//alert("passou aki no carregar_Pagina");
	
	jQuery("#conteudo").empty();
	//jQuery("#geral_conteudo").remove();
	//jQuery("#conteudo").html('');
	//jQuery('titulo").wrap('<div class='tituloPrincipal'></div>');
	//jQuery('body').wrap("<div id='conteudo'></div>");
	
	carregando(true);

	jQuery.ajax({
		type: "POST",
		url: url,
		//dataType: "html",
		dataType: "html",
		// enviado com sucesso
		success: function(response){
			carregando(false);
			//$.create("iframe",{src: "editor/index.php"}).appendTo("#conteudo");
			//jQuery("#conteudo").append(response);
			jQuery("#conteudo").html(response);
			//$('<iframe id="myFrame" name="myFrame" src="editor/index.php">').appendTo('body');
		},
		// quando houver erro
		error: function(){
			carregando(false);
			alert("Ocorreu um erro durante a requisição");
		}
	});
	return false;
}
// limpando a div antes de um novo envio
function enviar_dados(url, acao, valor){
	
	//alert("passou aki no enviar_dados" + "\n" + url + "\n" + campo);
	jQuery("#conteudo").empty();	
	
	//alert(url + "\n" + acao + "\n" + valor);
	
	carregando(true);

	jQuery.ajax({
		type: "POST",
		url: url,
		dataType: "html",
		data: "acao=" + acao + "&txt_cod=" + valor,
		// enviado com sucesso
		success: function(response){
			
			//alert(response);
			
			carregando(false);
			jQuery("#conteudo").append(response);
		},
		// quando houver erro
		error: function(){
			carregando(false);
			alert("Ocorreu um erro durante a requisição");
		}
	});
	return false;
		
}

//alert(pad("150", "11", "0"));
function pad (n, len, padding){
   var sign = '', s = n;

   if (typeof n === 'number'){
      sign = n < 0 ? '-' : '';
      s = Math.abs (n).toString ();
   }

   if ((len -= s.length) > 0){
      s = Array (len + 1).join (padding || '0') + s;
   }
   return sign + s;
}

function carregando(valor){
	if (valor == true){	
		//$('iframe#frame_geral').hide();
		var divContainer = document.createElement('div');
		divContainer.style.visibility = 'hidden';
		divContainer.id = 'carregar_2';
		divContainer.className = 'carregando';
		document.body.appendChild(divContainer);
		divContainer.style.visibility = 'visible';
		//$('iframe#frame_geral').hide();
	} else {
		if (document.getElementById('carregar_2')){
			document.body.removeChild(document.getElementById('carregar_2'));
		}
		
		//$('iframe#frame_geral').show();
	}
}

function resp_alert(valor,msg){
	
	if (document.getElementById('resposta')){
		remover_resp_alert();
	}

	var divContainer = document.createElement('div');
	divContainer.style.visibility = 'hidden';
	divContainer.id = 'resposta';
	divContainer.className = 'cx_resposta';
	document.body.appendChild(divContainer);
	divContainer.style.visibility = 'visible';
	var html = "";

	if (valor == true){
		html += "<img src='img/sucesso.png' width='64' alt='sucesso!' />";
		html += "<p class='txt_sucesso'>sucesso!<br />"+msg+"</p>";
	} else {
		html += "<img src='img/alerta.png' width='64' alt='alerta!' />";
		html += "<p class='txt_alerta'>alerta!<br />"+msg+"</p>";
	}
	document.getElementById('resposta').innerHTML = html;
	setTimeout('remover_resp_alert()',3000);
}

function remover_resp_alert(){
	if (document.getElementById('resposta')){
		document.body.removeChild(document.getElementById('resposta'));
	}
}


function carregar_Pagina5(url){

//	jQuery('script[src="editor/ckeditor.js"]').remove();
//	jQuery('script[src="editorckeditor.js"]').remove();
//	jQuery('script[src="editor/config.js"]').remove();
//	jQuery('script[src="editor/skins/office2003/skin.js"]').remove();
//	jQuery('script[src="editor/lang/pt-br.js"]').remove();
	
	
	carregando(true);
	$("#conteudo").ajaxStart(function(){
		$(this).html("");
		$(this).hide();
		carregando(true);
	});
	$("#conteudo").ajaxComplete(function(){
		$(this).show();
		carregando(false);
	});
	//$("#conteudo").html('<iframe id="agenda" src="' + url + '" frameborder="1" scrolling="no"></iframe>');
	$("#conteudo").html('<iframe src="' + url + '" scrolling="no" frameborder="0" style="width: 100%; height:560px"></iframe>');
	carregando(false);
	return false;
}

function carregar_Pagina6(url){	
	jQuery("#conteudo").empty();
	carregando(true);
	jQuery.ajax({
		type: "POST",
		url: url,
		dataType: "html",
		success: function(response){
			carregando(false);
			jQuery("#conteudo").html(response);
		},
		error: function(){
			carregando(false);
			alert("Ocorreu um erro durante a requisição");
		}
	});
	return false;
}
