function focusSobre(){
	if(getE('sobre').value == 'Descreva aqui sua atividade') getE('sobre').value = '';
}

function blurSobre(){
	if(getE('sobre').value == '') getE('sobre').value = 'Descreva aqui sua atividade';
}

function getE(obj){
	return document.getElementById(obj);
}

function modalLogo(acao){
	var modal = getE('wmodal');
	var foto = getE('wfoto');
	var logo = getE('logo');
		
	if(acao){
		var tam = getPageSize();
		
		modal.style.width = tam[0]+'px';
		modal.style.height = tam[1]+'px';
		modal.style.visibility = 'visible';
		modal.style.zIndex = '10000';
		
		var w_half = Math.ceil((tam[0]-400)/2);
		var h_half = Math.ceil((tam[3]-300)/2);
		
		foto.style.top = h_half + 'px';
		foto.style.left = w_half + 'px';
		foto.style.visibility = 'visible';
		foto.style.zIndex = '11000';
	}else{
		var cook = readCookie('wizard_logo');
		if(cook!='') {
			logo.className = '';
			logo.innerHTML = '<img src="'+replaceAll('%2F', '/', cook)+'" />';
		}
		
		modal.style.visibility = 'hidden';
		modal.style.zIndex = '-1';
		foto.style.visibility = 'hidden';
		foto.style.zIndex = '-1';
	}
}

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	 
	var xScroll, yScroll;
	 
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	 
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	 
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	 
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	 
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	 
	return arrayPageSize;
}

//************************************************************************** FUNCOES DE COOKIES
function createCookie(name,value,days) { // GRAVA COOKIE
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) { // LE COOKIES
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) { // APAGA COOKIES
	createCookie(name,"",-1);
}

function replaceAll(de, para, em){
	eval('while(/'+de+'/.test(em)){ em = em.replace("'+de+'", "'+para+'"); }');
	return em;
}

function checkURL(key){ 
	if((key > 47 && key < 58)||(key == 8)||(key == 9)||(key == 39)||(key == 37)) {
		alert(key);
		return key;
	}
	else return false;
}

function validnumber(key){ // CHECA RETORNO DE TECLA VALIDO COMO NUMERO
	if((key > 95 && key < 106)||(key > 47 && key < 58)||(key == 8)||(key == 9)||(key == 39)||(key == 37)) return key;
	else return false;
}

function phoneformat(obj){ // FORMATA CAMPO DE TELEFONE (66)6666-6666
	var date = obj.value;
	while(date.search('\\(')>-1) date = date.replace('(','');
	while(date.search('\\)')>-1) date = date.replace(')','');
	while(date.search('-')>-1) date = date.replace('-','');
	
	if(date.length == 0) return false;
	
	if(date.length>=7) result = '('+date.substr(0,2)+')'+date.substr(2,4)+'-'+date.substr(6,4);
	else if(date.length>=3) result = '('+date.substr(0,2)+')'+date.substr(2,4);
	else if(date.length>=1) result = '('+date.substr(0,2);
	
	obj.value = result;
	obj.focus();
	return;
}

function checkTermos(){
	if(getE('cbTermos').checked) document.step_1.submit();
	else alert('Você precisa aceitar os termos de uso para utilizar o Imobox!');
}




