bannerStatus = 0;
bannerTimer = null;
bannerWidth = 0;
bannerHeight = 0;
bannerTimeout = 15000;
bannerTimerStep = 50;
bannerStep = 10;
function getBannerStatus()
{
	var o = null;
	if(document.all)
		o = document.all['chamadacomercial'];
	else if(document.getElementById)
		o = document.getElementById('chamadacomercial');
	else return -1;
	if(o.style.display == 'block') {
		bannerStatus = 0;
		bannerWidth = parseInt(o.style.width);
		bannerHeight = parseInt(o.style.height);
		startTimer();
	}
}
function startTimer()
{
	bannerTimer = window.setTimeout('stepCurtain()', bannerTimeout);
}
function stepCurtain()
{
	if(typeof(bannerStatus)=='undefined') bannerStatus = 0;
	if(document.all)
		o = document.all['chamadacomercial'];
	else if(document.getElementById)
		o = document.getElementById('chamadacomercial');
	if(o.style.display == 'none') return;
	rect = o.style.clip;
	rect = rect.substring(rect.indexOf('(') + 1)
	rect = rect.substring(0, rect.length - 1);
	coords = rect.split(' ');
	w = parseInt(coords[1]);
	h = parseInt(coords[2]);
	if(bannerStatus == 0) 
		h -= bannerStep;
	else
		h += bannerStep;
	if(h < 0) h = 0;
	if(h > bannerHeight) h = bannerHeight;
	bannerWidth = w;
	o.style.clip = 'rect(0 '+w+' '+h+' 0)';
	o.style.height = h;
	if(h > 0) {
		t = h < bannerHeight / 2 ? bannerTimerStep / 3 : bannerTimerStep;
		if(bannerStatus == 0)
			bannerTimer = window.setTimeout('stepCurtain()', t);
		else if(h < bannerHeight)
			bannerTimer = window.setTimeout('stepCurtain()', t);
	}
	else {
		toggleChamada();
	}
}
function bannerOver()
{
	bannerStatus = 1;
}
function bannerOut()
{
	if(document.all)
		o = document.all['chamadacomercial'];
	else if(document.getElementById) 
		o = document.getElementById('chamadacomercial');
	else return;
	if(o.style.display == 'block')
		bannerTimer = window.setTimeout('stepCurtain()', bannerTimeout);
	bannerStatus = 0;
}
function toggleChamada()
{
	if(document.all) {
		o = document.all['chamadacomercial'];
		i = document.all['toggler'];
	}
	else if(document.getElementById) {
		o = document.getElementById('chamadacomercial');
		i = document.getElementById('toggler');
	}
	else return;
	if(o.style.display == 'block') {
		o.style.display = 'none';
		i.src = '/imagens/togglechamada_off.gif';
	}
	else {
		rect = 'rect(0 '+bannerWidth+' '+bannerHeight+' 0)';
		o.style.clip = rect;
		o.style.display = 'block';
		o.style.height = bannerHeight;
		i.src = '/imagens/togglechamada.gif';
		if(bannerTimer != null) window.clearTimeout(bannerTimer);
	}
}
function faq(topico)
{
	var url = '/FAQ.aspx?topico=' + escape(topico);
	wnd = window.open(url, 'faq','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=640,height=400,left=35,top=35');
	if(wnd) {
		wnd.focus();
	}
}
function institucional(u)
{
	wnd = window.open(u, 'institucional','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=640,height=400,left=35,top=35');
	if(wnd) {
		wnd.focus();
	}
}
function buscaitem(q, d, h, f)
{
	if(typeof(h) == 'undefined') h = '';
	if(typeof(f) == 'undefined') f = 0;
	q = q.replace(/\s{2}/g, '');
	if(q.length < 3) {
		alert('Palavra muito pequena');
		return false;
	}
	document.location = chamabusca(1, q, d, h, f);
	return false;
}
function buscafornecedor(q)
{
	document.location = chamabusca(2, q, 0, '', 0);
	return false;
}
function buscapreco(q)
{
	document.location = chamabusca(3, q, 0, '', 0);
	return false;
}
function chamabusca(t, q, d, h, f)
{
	return 'http://www.lojadolar.com/Busca.aspx?tipo='+t+'&q='+myEncode(q)+'&d='+escape(d)+'&h='+escape(h)+'&f='+escape(f);
}
function myEncode(s)
{
	if(typeof(encodeURI) == 'function') 
		return encodeURI(s);
	return escape(s);
}
function abreAjuda(x) {
	window.name = 'lojadolar';
	var popupajuda = null;
	var url = 'http://www.lojadolar.com/ajuda/';
	if (x > 0)
		url = url + 'default.asp?CodigoFaq=' + x;
	popupajuda = window.open(url, 'popupajuda','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=640,height=500,left=35,top=35');
	if (popupajuda != null) {
		popupajuda.location.href = url;
		popupajuda.focus();
	}
}
function ajuda(url, topic)
{
	if(typeof(topic) == 'undefined')
	{
		url = '';
		topic = url;
	}
	window.name = 'ajuda';
	var popupajuda = null;
	url = url + '/Ajuda.aspx?topic=' + escape(topic);
	popupajuda = window.open(url, 'popupajuda','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=640,height=500,left=50,top=50');
	if (popupajuda != null) {
		popupajuda.location.href = url;
		popupajuda.focus();
	}
}
function receberMkt()
{
	var w = window.open('/Hotsites/ReceberMkt.aspx', 'mkt', 'width=400,height=200,menubar=no,toolbar=no,statusbar=no,scrollbars=no,resizable=no,files=no');
	if(w != null && typeof(w) != 'undefined')
	{
		w.focus();
	}
}
function showPopup()
{
	var d = new Date();
	var biscoito = lsGetCookie('lojapopup');
	var hora = -1;
	if(biscoito != null) hora = parseInt(biscoito);
	if(d.getHours() != hora) {
		hora = d.getHours();
		var w = window.open('/Hotsites/Popup.aspx?r='+escape(document.location.href), 'lojapopup', 'width=500,height=220,toolbar=no,scrollbars=no,statusbar=no,resizable=no');
		if(typeof(w) != 'undefined' && w != null) w.blur();
		lsSetCookie('lojapopup', hora);
	}
}
function lsGetCookie(name) 
{
	var result = null;
	var myCookie = ' ' + document.cookie + ';';
	var searchName = ' ' + name + '=';
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	if (startOfCookie != -1) 
	{
		startOfCookie += searchName.length; 
		endOfCookie = myCookie.indexOf(';', startOfCookie);
		result = unescape(myCookie.substring(startOfCookie, endOfCookie));
	}
	return result;
}
function lsSetCookie(name, value) 
{
	if (name)
	{	
		var never = new Date();
		if (value)
		{
			never.setDate (31); 
			never.setMonth (12); 
			never.setYear (2037);
		}
		else 
			never.setTime(never.getTime() - 1);
		var expString = '; expires=' + never.toGMTString();
		_domain = document.location.href;
		if(_domain.substr(0, 7) == 'http://') {
			_pos = 7;
		}
		else if(_domain.substr(0, 8) == 'https://') {
			_pos = 8;
		}
		else _pos = -1;
		if(_pos != -1) {
			_domain = _domain.substring(_pos);
			_pos = _domain.indexOf('/');
			if(_pos != -1) {
				_domain = _domain.substring(0, _pos);
			}
		}
		if(_pos == -1) _domain = '';
		document.cookie = name + '=' + escape(value) + expString + '; path=/; domain=' + _domain;
	}
}
function lsIsCookieEnabled() 
{
	lsSetCookie('lsKey', '1');
	if (lsGetCookie('lsKey') == '1')
		return 1;
	return 0;
}
//window.onload = showPopup;