var openDiv = null;
var last = '';
var win = null;
var hiddenObjects = new Array();

function hidePanel (choice){
    if (choice){
        document.getElementById("_ctl0_body_contents_overlay").style.display = "none";
        choice.style.display = "none";
    }
}

function isEmailAddr(email){
    var str = email
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str)) {
        testresults = true;
    }
    else {
        testresults = false;
    }
    return (testresults);
}

function showDiv(object, width, height){
    window.scrollTo(0, 0);

    var objects = document.getElementsByTagName('object');
    	for (var i = 0; i != objects.length; i++) {
    		if (objects[i].style.visibility != 'hidden') {
    			objects[i].style.visibility = 'hidden';
    			hiddenObjects[hiddenObjects.length] = objects[i];
    		}
    	}

    //centrar o popup na horizontal
    if (window.innerWidth) {
        parent.document.getElementById(object).style.left = ((parent.window.innerWidth / 2) - (width / 2)) + 'px';
    }
    else {
    	parent.document.getElementById(object).style.left = ((parent.document.body.offsetWidth / 2) - (width / 2)) + 'px';
    }

    parent.document.getElementById(object).style.top = '150px';

    parent.document.getElementById('overlay_popup').style.display = 'block';
    parent.document.getElementById(object).style.display = 'block';

    openDiv = object;
}


function showDivNoOverlay(object, width, height){
	window.scrollTo(0, 0);

    var objects = document.getElementsByTagName('object');
    for (var i = 0; i != objects.length; i++) {
    	if (objects[i].style.visibility != 'hidden') {
    		objects[i].style.visibility = 'hidden';
            hiddenObjects[hiddenObjects.length] = objects[i];
        }
    }

    if (width != null) {

 		//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';
 		}
 	}

 	if (height != null) {

 		//centrar o popup na horizontal
 		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';
 		}
 	} else {

     	//document.getElementById(object).style.top = '150px';

 	}


     document.getElementById(object).style.display = 'block';

     openDiv = object;
}

function hideDiv(object){
	document.getElementById(object).style.display = 'none';

    if (document.getElementById('overlay_popup')) {
        document.getElementById('overlay_popup').style.display = 'none';
    }
    for (var i = 0; i != hiddenObjects.length; i++) {
        hiddenObjects[i].style.visibility = 'visible';
    }
    openDiv = null;
}

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)
}