function SetCookie(cookieName,cookieValue,nHours,nDays) {
var today = new Date();
var expire = new Date();
if (nHours==null || nHours==0) nHours=24;
if (nDays==null || nDays==0)
expire.setTime(today.getTime() + 3600000*nHours);
else
expire.setTime(today.getTime() + 3600000*24*nDays);
if (nHours==-1)
expire.setTime(0);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString()+";path=/;domain=adsantos.com.br;";
}
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return document.cookie.substring(offset, endstr);
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function compra(lote,url,que,a)
{compras = GetCookie('Compras');
flag2 = '';
zero = "0000";
lote = '' + lote;
lote = zero.substring(0,4 - lote.length) + lote;
if (compras)
{for (counter = 0;counter < compras.length;counter += 8)
{if (compras.substring(counter + 4,counter + 8) == lote)
{if (!que)
flag = confirm('Este livro já consta de sua cesta de compras. Clique [Ok] para mantê-lo, ou [Cancelar] para retirá-lo.');
else
if(a)
flag = 1;
else
{
flag = !confirm('Eliminar este produto de sua lista de compras?');
if(flag)
return false;
}
flag2 = 1;
if (counter > 0)
{if (counter < compras.length - 7)
{compras = compras.substring(0,counter) + compras.substring(counter + 8,compras.length + 1)}
else
{compras = compras.substring(0,counter)}}
else
{compras = compras.substring(counter + 8,compras.length + 1)}}
else
{if (!flag2) {flag = 1}}}
if (flag) {quant = parseInt(prompt('Quantidade:','1'));
if (quant > 9999 || quant < 0)
{alert("Quantidade invalida!!")}
else if (!quant)
return false;
else
{quant = '' + quant;
quant = zero.substring(0,4 - quant.length) + quant;
if (quant > 0) {compras = compras + quant + lote}}}
SetCookie("Compras",compras,0,2)}
else
{quant = parseInt(prompt('Quantidade:','1'));
if (quant > 9999 || quant < 0)
{alert("Quantidade invalida!!")}
else if (!quant)
return false;
else
{quant = '' + quant;
quant = zero.substring(0,4 - quant.length) + quant;
if (quant > 0) {lote = quant + lote;
SetCookie("Compras",lote,0,2)}}}
compras = GetCookie('Compras');
if (!compras)
{SetCookie("Compras",'',-1);
thisPage=parent.janela.location;
parent.janela.location=thisPage;
return true;
}
else
{
if (!parent.cesta) {
window.location.reload();
return true;
}
else
{
top(compras.length,compras);
return true;
}
}}
function itens(abs)
{tudo = '0';
for (counter = 0;counter < abs.length;counter += 8)
{cod = Math.abs(abs.substring(counter,counter + 4));
tudo = eval(Math.abs(tudo) + " + " + cod)}
return tudo}
function top(tam,compras,flag)
{var teste = parent.frames.cesta.document;
teste.open();
var janela = parent.frames.janela.document.location.href;
total = tam / 8;
var quant = itens(compras);
if (quant > 1)
s = 'ns';
else
s = 'm';
if (total > 1)
ss = 's';
else
ss = '';
teste.write('
');
teste.close()}
function abjan(texto,imagem) {
alerta = window.open("","newwin","width=350,height=250,location=0,status=0,resizable=0,maximizable=0,scroll=1");
alerta.document.open();
alerta.document.write(' Cesta de compras' );
alerta.document.close();
}
function URLEncode(url)
{
var SAFECHARS = "0123456789" + // Numeric
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
"abcdefghijklmnopqrstuvwxyz" +
"-_.!~*'()"; // RFC2396 Mark characters
var HEX = "0123456789ABCDEF";
var plaintext = url;
var encoded = "";
for (var i = 0; i < plaintext.length; i++ ) {
var ch = plaintext.charAt(i);
if (ch == " ") {
encoded += "+"; // x-www-urlencoded, rather than %20
} else if (SAFECHARS.indexOf(ch) != -1) {
encoded += ch;
} else {
var charCode = ch.charCodeAt(0);
if (charCode > 255) {
alert( "Unicode Character '"
+ ch
+ "' cannot be encoded using standard URL encoding.\n" +
"(URL encoding only supports 8-bit characters.)\n" +
"A space (+) will be substituted." );
encoded += "+";
} else {
encoded += "%";
encoded += HEX.charAt((charCode >> 4) & 0xF);
encoded += HEX.charAt(charCode & 0xF);
}
}
} // for
return encoded;
}
function closeDiv() {
document.getElementById('floatLayer').style.left = "-1000";
document.getElementById('floatLayer').style.left = "-1000px";
document.cookie = 'escondebanner='+escape('1');
return false;
}
window.onerror = null;
//VALOR DE 75 ABAIXO É A POSIÇÃO ACIMA E ABAIXO DA JANELA//
var topMargin = 75;
var slideTime = 1000;
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);
function layerObject(id,left) {
if (ns6) {
this.obj = document.getElementById(id).style;
this.obj.left = left+'px';
poscima=parseInt((pageHeight-altura) / 2);
return this.obj;
}
else if(ie4) {
this.obj = document.all[id].style;
this.obj.left = left;
poscima=parseInt((pageHeight-altura) / 2);
return this.obj;
}
else if(ns4) {
this.obj = document.layers[id];
this.obj.left = left;
poscima=parseInt((pageHeight-altura) / 2);
return this.obj;
}
}
function layerSetup() {
floatLyr = new layerObject('floatLayer',parseInt((pageWidth - largura)/2));
window.setInterval("main()", 10)
}
function floatObject() {
if (ns4 || ns6) {
findHt = window.innerHeight;
} else if(ie4) {
findHt = document.documentElement.clientHeight;
}
}
function main() {
if (ns4) {
this.currentY = document.layers["floatLayer"].top;
this.scrollTop = window.pageYOffset;
mainTrigger();
}
else if(ns6) {
this.currentY = parseInt(document.getElementById('floatLayer').style.top);
this.scrollTop = scrollY;
mainTrigger();
} else if(ie4) {
this.currentY = floatLayer.style.pixelTop;
this.scrollTop = document.documentElement.scrollTop;
mainTrigger();
}
}
function mainTrigger() {
var newTargetY = this.scrollTop + this.poscima;
if ( this.currentY != newTargetY ) {
if ( newTargetY != this.targetY ) {
this.targetY = newTargetY;
floatStart();
}
animator();
}
}
function floatStart() {
var now = new Date();
this.A = this.targetY - this.currentY;
this.B = Math.PI / ( 1 * this.slideTime );
this.C = now.getTime();
if (Math.abs(this.A) > this.findHt) {
this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
this.A = this.A > 0 ? this.findHt : -this.findHt;
}
else {
this.D = this.currentY;
}
}
function animator() {
var now = new Date();
var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
newY = Math.round(newY);
if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
if ( ie4 )document.all.floatLayer.style.pixelTop = newY;
if ( ns4 )document.layers["floatLayer"].top = newY;
if ( ns6 )document.getElementById('floatLayer').style.top = newY + "px";
}
}
function start(dados_layer) {
pageWidth = document.documentElement.clientWidth;
pageHeight = document.documentElement.clientHeight;
largura=dados_layer[0];
altura=dados_layer[1];
layerSetup();
floatObject();
}