// JavaScript Document
loadSifr ('page'); // Tem que ser fora do onload

function loadSifr (what)
{
	var type = arguments[0];
 	if(getServer() != 'teste')
	{
 		var myriadPro = { src: '/site/pt/motion/fonts/myriadPro.swf' };
	}
	else
	{
		var myriadPro = { src: '/panarello/site/pt/motion/fonts/myriadPro.swf' };
	}
	
    sIFR.activate(myriadPro);
	sIFR.compatMode = true;
	sIFR.forceClear = true;

	if(what == 'page')
	{
		sIFR.replace(myriadPro, {
		  selector: '.srfTitle h1',
		  css: [
			'.sIFR-root { font-size: 56px; color: #052457; font-weight: normal;  }'
		  ],
		  wmode: 'transparent', forceSingleLine: true
		});
		sIFR.replace(myriadPro, {
		  selector: '.srfName h2',
		  css: [
			'.sIFR-root { font-size: 25px; color: #052457; font-weight: normal;  }'
		  ],
		  wmode: 'transparent', forceSingleLine: true
		});
		sIFR.replace(myriadPro, {
		  selector: '.srfNro h3',
		  css: [
			'.sIFR-root { font-size: 25px; color: #052457; font-weight: normal;  }'
		  ],
		  wmode: 'transparent', forceSingleLine: true
		});
		sIFR.replace(myriadPro, {
		  selector: '.srfPopupTitle',
		  css: [
			'.sIFR-root { font-size: 18px; color: #052457; font-weight: normal;  }'
		  ],
		  wmode: 'transparent', forceSingleLine: true
		});
	}
	if(what == 'modal')
	{
		sIFR.replace(myriadPro, {
		  selector: '.srfWindowAlertTitle',
		  css: [
			'.sIFR-root { font-size: 16px; color: #052457; font-weight: normal; }'
		  ],
		  wmode: 'transparent', forceSingleLine: true
		});
	}
}
function noCache()
{
	data = new Date();
	cache = (data.getDate() +''+ data.getMonth() +''+ data.getFullYear() +''+ data.getHours() +''+ data.getMinutes() +''+ data.getSeconds() +''+ data.getMilliseconds());
	return cache;
}
function getPath()
{
	path = '';
	start = unescape(document.location.toString()).indexOf('content');
	end = unescape(document.location.toString()).length;

	path_arr = unescape(document.location.toString());
	path_arr = path_arr.substring(start,end);
	path_arr = path_arr.split('/')
	for (i=0; i < (path_arr.length-1); i++)
	{
		path += '../';
	}
	return path;
}
function getServer()
{
	server = document.location.host.toString();
	if(server == 'teste.popweb.com.br:8080') 	{ return 'teste'; }
	if(server == 'teste.popweb.com.br') 		{ return 'teste'; }
	if(server == 'cuba') 						{ return 'teste'; }
	if(server == 'ira') 						{ return 'teste'; }
	if(server == 'india') 						{ return 'teste'; }
	if(server == '192.168.1.102') 				{ return 'teste'; }
	if(server == '192.168.1.103') 				{ return 'teste'; }
	if(server == '192.168.1.104') 				{ return 'teste'; }
		
	return 'producao';
}
function doTab(tabId)
{
	switch (tabId)
	{
		case 'supplier':
			$("#client").hide();
			$("#businessman").hide();
			$("#supplier").fadeIn("fast");
			urchinTracker('/abas/fornecedor/');
		break
		case 'client':
			$("#supplier").hide();
			$("#businessman").hide();
			$("#client").fadeIn("fast");
			urchinTracker('/abas/clientes/');
		break
		case 'businessman':
			$("#supplier").hide();
			$("#client").hide();
			$("#businessman").fadeIn("fast");
			urchinTracker('/abas/representantes/');
			break
		default:
			$("#client").hide();
			$("#businessman").hide();
			$("#supplier").fadeIn("fast");
			urchinTracker('/abas/fornecedor/');
	}
}
function goToCSP()
{
	document.location.href = '../contact/';
}
function acaoDownload(id, name)
{
	var pathToAnalytics = '/downloads/' + name;
	urchinTracker(pathToAnalytics);
	document.location.href = "../../includes/download.asp?id="+id;
}
function needLogin()
{
	document.location.href = '../login/needLogin.asp'
}
function clearInitialValue(obj)
{
	return obj.value='';
}
function writeInitialValue(obj, str)
{
	if(obj.value == '')
	{
		return obj.value=str;
	}
}
function validLogin()
{
	var str
		str = '';
	if(!stringCode.test(document.forms['loginApp'].username.value) || (document.forms['loginApp'].username.value == 'usuário') )
	{
		str += 'Digite o usuário.<br />';
	}
	if(!stringCode.test(document.forms['loginApp'].senha.value))
	{
		str += 'Digite a senha.<br />';
	}
	if(str != '')
	{
		windowResponseAlert('Atenção', str);
	}
	else
	{
		document.forms['loginApp'].submit();
	}
}
function showPass(o, n)
{
	document.getElementById(n).style.display = '';
	document.getElementById(o.id).style.display = 'none';
	document.getElementById(n).focus();
}
function hidePass(o, n, l)
{
	if(o.value == '')
	{
		document.getElementById(n).style.display = '';
		document.getElementById(o.id).style.display = 'none';
		document.getElementById(n).value = l;
	}
}
function openWin(url,janela,larg,alt,scroll)
{
	if (!scroll)
	{
		scroll='auto'
	}
	var posx = (screen.width - larg) / 2;
	var posy = (screen.height - alt) / 2;
	janelaNova = window.open(url,janela,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scroll+",resizable=0,copyhistory=0,width="+larg+",height="+alt+",left="+posx+",top="+posy+"");
	janelaNova.focus();
}
function windowPrint(autoClose)
{
	window.print();
	if(autoClose)
	{
		window.close();	
	}
}
function windowResponseAlert( _title, _content )
{
	_htmlDiv = '';
	_htmlDiv += '<div id="blockContentWindow">';
	_htmlDiv += '<div id="windowAlert"><div id="windowAlertTitle" class="srfWindowAlertTitle"></div><div class="floatRight buttomClose"><a href="javascript:windowAlertClose();"><img src="../../images/popups/btnClose.gif" alt="Fechar" border="0" /></a></div><div id="windowAlertContent"></div></div>';
	_htmlDiv += '<div id="blockContent"></div>';
	_htmlDiv += '</div>';

	$("#page").before( _htmlDiv ); // Escreve _div dentro do #page
	$("#windowAlertTitle").empty(); // Limpa o Titulo
	$("#windowAlertContent").empty(); // Limpa o Conteudo
	$("#windowAlertTitle").append( _title ); // Escreve o Titulo
	$("#windowAlertContent").append( _content ); // Escreve o Conteudo
	$("#blockContentWindow").show(); // Mostra a janela

	posDivCenter("#windowAlert"); // Posiciona no Centro

	if($.browser.version == 6.0 && $.browser.msie) // Corrige a altura no IE 6
	{
		$("select").css("display","none");
	}
	$("#blockContent").height( $("#page").height() ); // Corrige a altura do block preto
	loadSifr ('modal');
	window.scroll(0,0);
}
function windowAlertClose()
{
	 // Corrige a altura no IE 6
	if($.browser.version == 6.0 && $.browser.msie)
	{
		$("select").css("display","");
	}
	$("#blockContentWindow").hide();
}
function posDivCenter(div)
{
	var total_w = $(document.body).width();
	var window_w =$((div)).width();
	
	var total_h = $(document.body).height();
	var window_h = $((div)).height();
	
	var screenWidth = ((total_w - window_w ) / 2) + 'px';
	var screenHeight = ((total_h - window_h ) / 2) + 'px';

	$((div)).css("margin-left", screenWidth);
	$((div)).css("margin-top", 200);
}
function simulatePopup()
{
	_htmlPopup  = '';
	_htmlPopup += '<div id="blockContentWindow">';
	_htmlPopup += '		<div id="windowAlert">';
    _htmlPopup += '			<div id="headerPopup">';
	_htmlPopup += '				<div><img src="../../images/popups/logo.gif" alt="Panarello" /></div>';
	_htmlPopup += '				<div><div id="titulo" class="srfPopupTitle">| Lista de Documentos</div><img src="../../images/popups/bg.gif" alt="Panarello" /></div>';
	_htmlPopup += '			</div>';
	_htmlPopup += '			<div class="p15">';
	_htmlPopup += '				<div class="HDotted"></div>';
	_htmlPopup += '				<div class="mT20 mB10 mL20">';
	_htmlPopup += '					ij ij oij oij oij oij o joi j';
	_htmlPopup += '				</div>';
	_htmlPopup += '				<div class="buttomPrint floatRight"><a href="javascript:void(0);" onclick="windowPrint(false);">Imprimir</a></div>';
	_htmlPopup += '			</div>';
	_htmlPopup += '			<div id="blockContent"></div>';
	_htmlPopup += '		</div>';
	_htmlPopup += '</div>';

	$("#page").before( _htmlPopup ); // Escreve _div dentro do #page
	$("#windowPopupTitle").empty(); // Limpa o Titulo
	$("#windowAlertContent").empty(); // Limpa o Conteudo
	$("#windowAlertTitle").append( _title ); // Escreve o Titulo
	$("#windowAlertContent").append( _content ); // Escreve o Conteudo
	$("#blockContentWindow").show(); // Mostra a janela

	posDivCenter("#windowAlert"); // Posiciona no Centro

	if($.browser.version == 6.0 && $.browser.msie) // Corrige a altura no IE 6
	{
		$("select").css("display","none");
	}
	$("#blockContent").height( $("#page").height() ); // Corrige a altura do block preto
}