var openDiv = null;


function mudaform(step, back){
	
	document.frmMember.action = 'index.php?page=70&step='+ step+'&back='+back;
	document.frmMember.submit();	

}


function showDiv(object, width, height){
    
	
	scroll(0, 0);
    //centrar o popup na horizontal
    if (window.innerWidth) {
        document.getElementById(object).style.left = ((window.innerWidth / 2) - (width / 2)) + 'px';
    }
    else {
        document.getElementById(object).style.left = ((document.body.offsetWidth / 2) - (width / 2)) + 'px';
    }
    
    //centrar o popup na vertical
    if (window.innerHeight) {
        document.getElementById(object).style.top = ((window.innerHeight / 2) - (height / 2)) + 'px';
    }
    else {
        document.getElementById(object).style.top = ((document.body.offsetHeight / 2) - (height / 2)) + 'px';
    }
    
    document.getElementById('overlay_popup').style.display = 'block';
    document.getElementById(object).style.display = 'block';
    
    openDiv = object;
}

function hideDiv(object){
    document.getElementById(object).style.display = 'none';
    document.getElementById('overlay_popup').style.display = 'none';
    openDiv = null;
}

var page = new Array();
var lastpage = new Array();
function abre(div){
    var prefixDiv = div.substring(0, div.indexOf('_', 0));
    var sufixDiv = div.substring(div.indexOf('_', 0) + 1, div.length);
    
    if (document.getElementById(div) != null) {
        if (document.getElementById(div).style.display == 'block') {
            document.getElementById(div).style.display = 'none';
        }
        else {
            document.getElementById(div).style.display = 'block';
        }
    }
    
    //fechar todas as divs do mesmo nivel
    if (prefixDiv != 'lasterpage') {
        if (prefixDiv == 'page') {
            for (i in page) {
                if (sufixDiv != page[i]) {
                    element = prefixDiv + '_' + page[i];
                    if (document.getElementById(element) != null) {
                        document.getElementById(element).style.display = 'none';
                    }
                    
                }
            }
        }
        else 
            if (prefixDiv == 'lastpage') {
                for (i in lastpage) {
                    if (sufixDiv != lastpage[i]) {
                        element = prefixDiv + '_' + lastpage[i];
                        if (document.getElementById(element) != null) {
                            document.getElementById(element).style.display = 'none';
                        }
                    }
                }
            }
    }
}

function toggleQuestion(id){
    var image = document.getElementById(id + '_img');
    var question = document.getElementById(id + '_question');
    var answer = document.getElementById(id + '_answer');
    
    if (answer.style.display == null || answer.style.display == 'none') {
        answer.style.display = 'block';
        image.src = 'images/bt_close_question.gif';
        question.style.color = '#e0003b';
    }
    else {
        answer.style.display = 'none';
        image.src = 'images/bt_open_question.gif';
        question.style.color = '#6e6e6e';
    }
}

function Centrar(pagina, titulo, w, h, scrollu, resize){
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scrollu + ',resizable=' + resize + '';
    win = window.open(pagina, titulo, settings)
}

function recoverPass(){
    document.getElementById('loginBox').style.display = 'none';
	document.getElementById('recoverPassForm').style.display = 'block';
}

function closeRecover(){
    document.getElementById('recoverPassForm').style.display = 'none';
	document.getElementById('loginBox').style.display = 'block';
}

function listCategoryEditors(categoryID) {
	var httpRequest;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		try {
        	httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch(e)   {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2)   {
			}
		}
	}
	
	httpRequest.onreadystatechange = function() {
		processCategoryEditors(httpRequest);
	};

	httpRequest.open('GET', 'index.php?view=Entity:CategoryEditors&categoryID=' + categoryID, true);
	httpRequest.send(null);
}

function processCategoryEditors(httpRequest) {
	if (httpRequest.readyState == 4) {
		if (httpRequest.status == 200) {
			
			var categoryEditorsCombo = document.getElementById('frmEntity');
			categoryEditorsCombo.options.length = 0;
			
			if (httpRequest.responseText.length != 0) {
	   			categoryEditorsCombo.innerHTML = httpRequest.responseText;
			}
	    } else {
			alert(httpRequest.responseText);
		}
	}
}