function switchDiv(id1,id2) {
	id = 1;
	do {
		id = getDiv(id);
		hideDiv(id);
		id = explodeDiv(id);
		// alert(id);
		id++;
	} while (id <= 4);
	
	if(id2 == 2) {
		document.getElementById('preview').onclick=function () { switchDiv('3','4'); }
		document.getElementById('next').onclick=function () { switchDiv('3','4'); }
	}
	if(id2 == 4) {
		document.getElementById('preview').onclick=function () { switchDiv('1','2'); }
		document.getElementById('next').onclick=function () { switchDiv('1','2'); }
	}
	
	id1 = getDiv(id1);
	showDiv(id1);
	
	id2 = getDiv(id2);
	showDiv(id2);
}

function getDiv(id) {
	return 'product_' + id;
}

function explodeDiv(id) {
	return id.replace(/product_/g, "")
}

/*
function switchDiv(id) {
	
	hideDiv('all');
	
	if(id == 3) {
		nextId = 1;
		previewId = 2;
	} else if(id == 2) {
		nextId = 3;
		previewId = 1;
	} else {
		nextId = 2;
		previewId = 3;
	}
	
	divId = getDiv(id);
	document.getElementById('next').onclick=function () { switchDiv(nextId); }
	document.getElementById('preview').onclick=function () { switchDiv(previewId); }
	showDiv(divId);
	// alert('previewId: '+previewId+' / id: '+id+' / nextId:'+nextId);
}

function getDiv(id) {
	return 'product_' + id;
}

*/

function showDiv(id) {
	document.getElementById(id).style.display='block';
}

function hideDiv(id) {
	document.getElementById(id).style.display='none';
}


/* Validacao de campos */
function onlyNumber(event) {
    if(document.all) key = event.keyCode;
    else key = event.which;
    if ( key>=48 && key<=57 ) return 1;
    else if ( key==8 || key==0) return 2;
    else return false;
}

function autoChange(frm,source,target) {
    if (source.maxLength>0) {
        if ( source.value.length >= source.maxLength) {
            if (document.getElementById("postal_code") == source) {
                var formObj = document.getElementById( frm );
                formObj[target].focus();
                xajax_execModule("jpf_address","","check_postal_code","","postal_code="+document.getElementById("postal_code").value);
            } else {
                var formObj = document.getElementById( frm );
                formObj[target].focus();
            }
        }
    }
}
/*FIM Validacao de campos */

function tabProducts(btOn) {
    //$(".tabmenu").toggle();

    if(btOn == "bt1") {
        $("#bt-aba1").attr("class","menu-cat-products-on");
        $("#bt-aba2").attr("class","menu-cat-products-off");
    } else {
        $("#bt-aba1").attr("class","menu-cat-products-off");
        $("#bt-aba2").attr("class","menu-cat-products-on");
    }
    
}


var tabberOptions = {   'manualStartup':true };



function backButton() {
    $("#back-button").toggle();
}


