//MANARA
function Abre(page){
	nw = window.open("pops/"+page+".php","POPMANARA", "width=450,height=500,top=100,left=40,resizable=no,scrollbars=no, status=yes");
	nw.focus();
}
function Fecha(){
	window.close();	
}
function AbreFlyer(flyer){
	nw = window.open("pops/flyer.php?flyer="+flyer+"&","FLYERMANARA", "width=680,height=350,top=100,left=50,resizable=no,scrollbars=no, status=yes");
	nw.focus();
}
//VALIDAÇÂO DE E-MAIL
function checkEmail(email) {	
	if (email.value == ""){
		alert("Por favor, digite seu e-mail.");
		email.focus();
		return (false);
	}		
	var checkStr = email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailAtN = 0;
	var EmailPeriod = false;
	
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);		
		if ( ch == "@" )	
			if ( i > 0 ){	// O @ não pode ser o primeiro caracter digitado
				EmailAt  = true;
				EmailAtN = i;
			}
		if ( ch == "." )	
			if ( EmailAt )	// Deve existir um "." após o "@"
				if ( i > (EmailAtN + 1) )	// Deve haver algum caracter entre o "@" e o "."
					if ( i < (checkStr.length - 2) ) 	// Devem haver pelo menos 2 caracteres após o "."
						EmailPeriod = true;
						
		if (EmailAt && EmailPeriod){
			EmailValid = true
			break;
		}
	}	
	if (!EmailValid){
		alert("O e-mail digitado não é válido.");
		email.focus();
		return false;
	}	
	return true;
}
// Scrollayer
function ScrollStruct(objName, layerID, xPos, yPos, orientation, visibleSize, lenght){
	var layer_obj = document.getElementById(layerID);
	this.name          = objName;
	this.layerID       = layerID;
	this.xPos = layer_obj.offsetLeft;//         = xPos;
	this.yPos = layer_obj.offsetTop;//          = yPos;
	if (orientation == 'Horiz') this.orientation = 1;
	else if (orientation == 'Vert') this.orientation = 0;
	else alert("Não foi definida a orientação do scroller '"+objName+"'.");
	this.visibleSize   = visibleSize;
	this.clipOffsetPos = 0; // Relative from LEFT if "Horiz", TOP if "Vert" 
	this.dist          = 0;
	this.speed         = 0;
	this.stopPoint     = 0;
	this.intervalID    = 0; // For setInterval and clearInterval
	this.scrolling     = false; 
	this.lenght		   = lenght;
}
function ScrollLayer(scrollStruct){
	var width, height, elem;
	elem = document.getElementById(scrollStruct.layerID);
	if(scrollStruct.orientation){
		width = scrollStruct.lenght;
		if(width<scrollStruct.visibleSize)
			width = scrollStruct.visibleSize;
		height  = parseInt(elem.style.height);
	}
	else{
		width = parseInt(elem.style.width);
		height  = scrollStruct.lenght;
		if(height<scrollStruct.visibleSize)
			height = scrollStruct.visibleSize;
	}	
	if(scrollStruct.clipOffsetPos + scrollStruct.speed >= 0 && scrollStruct.clipOffsetPos + scrollStruct.speed + scrollStruct.visibleSize
		<= (scrollStruct.orientation ? width : height)){
	scrollStruct.clipOffsetPos += scrollStruct.speed;
	
		// Check for stop points
		if(scrollStruct.speed > 0 && scrollStruct.dist*(scrollStruct.stopPoint+1) >= scrollStruct.clipOffsetPos - scrollStruct.speed
		&& scrollStruct.dist*(scrollStruct.stopPoint+1) <= scrollStruct.clipOffsetPos){
			scrollStruct.stopPoint += 1;
			clearInterval(scrollStruct.intervalID);
			scrollStruct.scrolling = false;
		}
		else if (scrollStruct.speed < 0 && scrollStruct.dist*(scrollStruct.stopPoint-1) >= scrollStruct.clipOffsetPos
		&& scrollStruct.dist*(scrollStruct.stopPoint-1) <= scrollStruct.clipOffsetPos - scrollStruct.speed){
			scrollStruct.stopPoint -= 1;
			clearInterval(scrollStruct.intervalID);
			scrollStruct.scrolling = false; 
		} 
	
		// Create and display the clip in the approppriate location
		// if the position of the clip remains inside the layer.
		// clip: rect(top right bottom left)
		if(scrollStruct.orientation){
			elem.style.left = scrollStruct.xPos - scrollStruct.clipOffsetPos;
			elem.style.top  = scrollStruct.yPos; 
			elem.style.clip = "rect(auto " + (scrollStruct.clipOffsetPos + scrollStruct.visibleSize) + "px auto " + scrollStruct.clipOffsetPos + "px)";
		}
		else{
			elem.style.left = scrollStruct.xPos;
			elem.style.top  = scrollStruct.yPos - scrollStruct.clipOffsetPos;
			elem.style.clip = "rect(" + scrollStruct.clipOffsetPos + "px auto " + (scrollStruct.clipOffsetPos + scrollStruct.visibleSize) + "px auto)"; 
		}
		elem.style.visibility = "visible"; 
	}
	else{
		clearInterval(scrollStruct.intervalID);
		scrollStruct.scrolling = false;
	}
}
// Methods to perform on a Scroll Layer
function ScrollForward(scrollStruct, dist, speed){
    if (!scrollStruct.scrolling){
		scrollStruct.dist       = dist;
		scrollStruct.speed      = speed;
		scrollStruct.scrolling  = true;
		scrollStruct.intervalID = setInterval("ScrollLayer(" + scrollStruct.name + ")", 1);
	}
}
function ScrollBackward(scrollStruct, dist, speed){
    if (!scrollStruct.scrolling){
		scrollStruct.dist       = dist;
		scrollStruct.speed      = -speed;
		scrollStruct.scrolling  = true; 
		scrollStruct.intervalID = setInterval("ScrollLayer(" + scrollStruct.name + ")", 1);
	}
}
function PauseScroll(scrollStruct){
	clearInterval(scrollStruct.intervalID);
	scrollStruct.scrolling = false;
}
