imagem_lista = Array('media/btn1_hover.gif', 'media/btn2_hover.gif', 'media/btn3_hover.gif');
imagem_qtd = imagem_lista.length;
for (i = 0; i <imagem_qtd; i++) {
    var preload = new Image();
    preload.src = imagem_lista[i];
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function setFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById('content').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
			}
			else {
				footerElement.style.position = 'static';
			}
		}
	}
}
window.onload = function() {
	setFooter();
}
window.onresize = function() {
	setFooter();
}

/* ///////////////////////////////////////////// SUB MENU*/

tms=new Array()

function over(n){
	if(typeof(tms[n])!="undefined")clearTimeout(tms[n])
	document.getElementById("s"+n).style.visibility="visible"
}

function out(n){
	tms[n]=setTimeout('document.getElementById("s'+n+'").style.visibility="hidden"',350)
} 

/* ///////////////////////////////////////////// POPUP ZOOM*/

function popzoom(idImg, page) { //v2.0
var d = document.getElementById('principal');
windowWidth = 570;
windowHeight = 420;

winleft=(screen.width/2)-(windowWidth/2+10);
wintop=(screen.height/2)-(windowHeight/2+20);
window.open('OurCollectionIntPopUp.asp?id='+idImg+'&page='+page+'&adi='+d.src.replace('gde', 'pop') , 'popupzoom', 'left='+winleft+',top='+wintop+',width=570,height=420');
}

function swap(img, thumb){
thumb = thumb+'thumb';
var d = document.getElementById('principal');
var t = document.getElementById(thumb);
var aux;
aux = t.src;
aux = aux.replace('thu', 'gde');

t.src = d.src.replace('gde', 'thu');
d.src = aux;
d.style.margin='0';

}

//
function valida(){
	if ((document.form1.email.value != "")||(document.form1.password.value != "")){
		document.form1.email_new.value='';
		document.form1.email_new.disabled=true;
		document.form1.email_new_conf.value='';
		document.form1.email_new_conf.disabled=true;
		document.form1.password_new.value='';
		document.form1.password_new.disabled=true;
		document.form1.password_new_conf.value='';
		document.form1.password_new_conf.disabled=true;
		document.form1.acao.value='cadastrado';
	}else if ((document.form1.email_new.value != "")||(document.form1.password_new.value != "")||(document.form1.password_new_conf.value != "")||(document.form1.email_new_conf.value != "")){
		document.form1.email.value='';
		document.form1.email.disabled=true;	
		document.form1.password.value='';
		document.form1.password.disabled=true;
		document.form1.acao.value='novo';
	}else{
		document.form1.email.disabled=false;	
		document.form1.password.disabled=false;
		document.form1.email_new.disabled=false;
		document.form1.email_new_conf.disabled=false;
		document.form1.password_new.disabled=false;
		document.form1.password_new_conf.disabled=false;
		document.form1.acao.value='';		
	}
}

//
function validaLogin(){
	if(document.form1.acao.value==''){
		alert('You must fill one of the options below');
		return false;
	}else if(document.form1.acao.value=='cadastrado'){
		if(document.form1.email.value==''){
			alert('E-mail is required');
			document.form1.email.focus();
			return false;
		}else{
			if (ValidaEmail(document.form1.email.value) == false){
		  		alert("E-mail must contain an e-mail address");
				document.form1.email.focus();
				return (false);
			}
		}
		if(document.form1.password.value==''){
			alert('Password is required');
			document.form1.password.focus();
			return false;
		}		
	}else if(document.form1.acao.value=='novo'){
		if(document.form1.email_new.value==''){
			alert('E-mail is required');
			document.form1.email_new.focus();
			return false;
		}else{
			if (ValidaEmail(document.form1.email_new.value) == false){
		  		alert("E-mail must contain an e-mail address");
				document.form1.email_new.focus();
				return (false);
			}
		}
		if(document.form1.email_new_conf.value==''){
			alert('Confirm e-mail adress is required');
			document.form1.email_new_conf.focus();
			return false;
		}		
		if((document.form1.email_new.value!='')&&(document.form1.email_new_conf.value!='')){
			if(document.form1.email_new.value!=document.form1.email_new_conf.value){
				alert('Your confirm e-mail is different of e-mail');
				document.form1.email_new_conf.focus();
				return false;				
			}
		}		
		if(document.form1.password_new.value==''){
			alert('Password is required');
			document.form1.password_new.focus();
			return false;
		}	
		if(document.form1.password_new_conf.value==''){
			alert('Confirm password is required');
			document.form1.password_new_conf.focus();
			return false;
		}
		if((document.form1.password_new.value!='')&&(document.form1.password_new_conf.value!='')){
			if(document.form1.password_new.value!=document.form1.password_new_conf.value){
				alert('Your confirm password is different of password');
				document.form1.password_new_conf.focus();
				return false;				
			}
		}		
	}
}

//

function ValidaEmail(email) {
	var achou_ponto=false;
    var achou_arroba=false;
    var achou_caracter=false;

    for (var i=0; i<email.length; i++) {
		if (email.charAt(i)=="@")
        { 
			if (email.charAt(i+1)==".")
				achou_arroba=false;
            else
                achou_arroba=true;
            }
        else if (email.charAt(i)==".") achou_ponto=true;
			else if (email.charAt(i)!=" ") achou_caracter=true;
    }

    if((email.charAt(0)=="W" || email.charAt(0)=="w") &&
		(email.charAt(1)=="W" || email.charAt(1)=="w") &&
        (email.charAt(2)=="W" || email.charAt(2)=="w") &&
        (email.charAt(3)=="."))
	  {
		achou_ponto=false;
		achou_caracter=false;
      }
    if(email.charAt(email.length-1)==".")
    {
		achou_ponto=false;
    }	
    return (achou_ponto && achou_arroba && achou_caracter);
}

function validaCredit(){
	if(document.form1.credit_card.value == "0"){
		alert('Select credit card type');
		document.form1.credit_card.focus();
		return false;
	}
	if(document.form1.card_number.value == ""){
		alert('Card number is required');
		document.form1.card_number.focus();
		return false;
	}
	if(document.form1.expiration_month.value == "0"){
		alert('Select Expiration Month');
		document.form1.expiration_month.focus();
		return false;
	}	
	if(document.form1.expiration_year.value == "0"){
		alert('Select Expiration Year');
		document.form1.expiration_year.focus();
		return false;
	}		
	if(document.form1.cvv.value == ""){
		alert('CVV2 Code number is required');
		document.form1.cvv.focus();
		return false;
	}	
	if (document.form1.credit_card.value=="American Express"){
		if(document.form1.cvv.value.length != 4){
			alert('CVV2 Code Number for America Express must contain four digit');
			return false;
		}
	}else{
		if(document.form1.cvv.value.length != 3){
			alert('CVV2 Code Number for '+document.form1.credit_card.value+' must contain three digit');
			return false;
		}		
	}
}