var enviarContato = {	'tweencreate': 0,
	'aberto':0,
	'btOK': '',
	'show': function(id) {
		id = id || 0;
		$('enviarContato').style.display = "block";	
		if(this.tweencreate == 0){
			new tween('enviarContato');
			this.tweencreate = 1;		
		}
			var sl = new selectLoader();
			sl.onLoad = function() {
				for (var k = 0; k < $('enviarContato.Setor').options.length; k++) if ($('enviarContato.Setor').options[k].value == id) $('enviarContato.Setor').selectedIndex = k;
			};
			sl.load("enviarContato.Setor","setoresXML.php",id);
		this.aberto = 1;
		this.alinha();
		bgSite.show();	
		document.getElementById('enviarContato.Setor').style.display = "block";
	},
	'alinha': function(){
		if(this.aberto == 0)return;
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('enviarContato');
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;	
		$('enviarContato').tweenTo((newY+SC.y), (newX+SC.x), 'easeoutexpo', 0.3);		
	},
	'hide': function(){
		var SC = getScroll();
		var VS = getDocVisibleSize();
		var SZ = getSize('enviarContato');	
		
		newX = (VS.x-SZ.x)/2;
		newY = (VS.y-SZ.y)/2;
		this.aberto = 0;			
		$('enviarContato').tweenTo(-SZ.y+SC.y, -SZ.x+SC.x, 'easeoutexpo', 1,function(){
			$('enviarContato').style.top = "-1000px";
			$('enviarContato').style.lef = "-1000px";		
			$('enviarContato').style.display = "none";
		});	
		bgSite.hide();	
	},
	'onClick':function(){
		if($('enviarContato.Setor').value.length == 0){
			SA.onClick = function(){
				$('enviarContato.Setor').focus();
			}
			SA.open('Selecione um setor!');
			return false;
		}		
		if($('enviarContato.nome').value.length == 0){
			SA.onClick = function(){
				$('enviarContato.nome').focus();
			}
			SA.open('Digite um nome!');
			return false;
		}
		if($('enviarContato.email').value.length == 0){
			SA.onClick = function(){
				$('enviarContato.email').focus();
			}
			SA.open('Digite um e-mail!');
			return false;
		}
		if(!$('enviarContato.email').value.isMail()){
			SA.onClick = function(){
				$('enviarContato.email').select();
			}
			SA.open('Digite um e-mail v&aacute;lido!');
			return false;
		}
		if($('enviarContato.cidade').value.length == 0){
			SA.onClick = function(){
				$('enviarContato.cidade').focus();
			}
			SA.open('Digite uma cidade!');
			return false;
		}		
		if($('enviarContato.telefone').value.length == 0){
			SA.onClick = function(){
				$('enviarContato.telefone').focus();
			}
			SA.open('Digite um telefone!');
			return false;
		}		
		if($('enviarContato.texto').value.length == 0){
			SA.onClick = function(){
				$('enviarContato.texto').focus();
			}
			SA.open('Digite uma observa&ccedil;&atilde;o!');
			return false;
		}	
		var xml = new xmlConnection();
		if (xml.create()) {
			xml.setMethod('POST');
			xml.setURL('enviarContatoXML.php');
			xml.add('setor',$('enviarContato.Setor').value);			
			xml.add('nome',$('enviarContato.nome').value);
			xml.add('email',$('enviarContato.email').value);
			xml.add('cidade',$('enviarContato.cidade').value);
			xml.add('telefone',$('enviarContato.telefone').value);			
			xml.add('texto',$('enviarContato.texto').value);			
			xml.setChildName('r');
			xml.onComplete = function() {
				if(this.getAttByName('s',0) == 1){		
					SA.onClick  = function(){
						$('enviarContato.nome').value = "";
						$('enviarContato.email').value = "";
						$('enviarContato.cidade').value = "";
						$('enviarContato.telefone').value = "";						
						$('enviarContato.texto').value = "";
						var sl = new selectLoader();
						sl.load("enviarContato.Setor","setoresXML.php");
						enviarContato.hide();
					}
					SA.open('Contato enviado com sucesso!');					
				}else{						
					SA.open('Erro ao enviar o contato!');
				}
				$('enviarContato.loading').innerHTML = '';
			}
			$('enviarContato.loading').innerHTML = '<img src="imagens/loading.gif" width="16" height="16" style="vertical-align:middle;" />';
			xml.execute();
		}
	}
};