 // Definicao do separador das datas
var EW_dateSep; 
EW_dateSep = "-";




//Esconder as mensagens dos links na barras de estado
function hidestatus(){
window.status='RotadasViagens.com'
return true
}
if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
document.onmouseover=hidestatus
document.onmouseout=hidestatus

//Submeter Formulário
var EW_HTMLArea = [];
function EW_submitForm(EW_this) {	
	if (EW_HTMLArea) {			
		for (var i=0; i<EW_HTMLArea.length; i++) {
			var html = EW_HTMLArea[i].getHTML();
			if (html == "<p />" || html == "<br />\n") html = "";
			EW_HTMLArea[i]._textArea.value = html;
		}
	}	
	if (EW_checkMyForm(EW_this))
		EW_this.submit();
}

function EW_isHTMLArea(input_object, object_type) {
	return (object_type == "TEXTAREA" && EW_HTMLArea && input_object.style && input_object.style.display && input_object.style.display == "none");
}


//Criar pop-up com mensagem de erro 
function EW_onError(form_object, input_object, object_type, error_message) {
	alert(error_message);									
	if (object_type == "RADIO" || object_type == "CHECKBOX") {
		if (input_object[0])
			input_object[0].focus();
		else
			input_object.focus();
	}	else if (!EW_isHTMLArea(input_object, object_type)) { 
		input_object.focus();  
	}  
	if (object_type == "TEXT" || object_type == "PASSWORD" || object_type == "TEXTAREA" || object_type == "FILE") {
		if (!EW_isHTMLArea(input_object, object_type))
			input_object.select();
	}
	return false;	
}


//Verificar se o campo foi preenchido
function EW_hasValue(obj, obj_type) {
	if (obj_type == "TEXT" || obj_type == "PASSWORD" || obj_type == "TEXTAREA" || obj_type == "FILE")	{
		if (obj.value.length == 0) 
			return false;		
		else 
			return true;
	}	else if (obj_type == "SELECT") {
		if (obj.type != "select-multiple" && obj.selectedIndex == 0)
			return false;
		else if (obj.type == "select-multiple" && obj.selectedIndex == -1)
			return false;
		else
			return true;
	}	else if (obj_type == "RADIO" || obj_type == "CHECKBOX")	{
		if (obj[0]) {
			for (i=0; i < obj.length; i++) {
				if (obj[i].checked)
					return true;
			}
		} else {
			return (obj.checked);
		}
		return false;	
	}
}

// Verificação de quais os caracteres que são considerados numéricos
function EW_checknumber(object_value) {
	if (object_value.length == 0)
		return true;
	
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;
	
	check_char = start_format.indexOf(object_value.charAt(0));
	if (check_char == 1)
		decimal = true;
	else if (check_char < 1)
		return false;
	 
	for (var i = 1; i < object_value.length; i++)	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0) {
			return false;
		} else if (check_char == 1)	{
			if (decimal)
				return false;
			else
				decimal = true;
		} else if (check_char == 0) {
			if (decimal || digits)	
			trailing_blank = true;
		}	else if (trailing_blank) { 
			return false;
		} else {
			digits = true;
		}
	}	
	return true;
}

//Verificação de que o valor inserido é numérico
function EW_checkinteger(object_value) {
	if (object_value.length == 0)
		return true;
	
	var decimal_format = ".";
	var check_char;
	
	check_char = object_value.indexOf(decimal_format);
	if (check_char < 1)
		return EW_checknumber(object_value);
	else
		return false;
}

//Verificação de que o valor inserido é um e-mai
function EW_checkemail(object_value) {
	if (object_value.length == 0)
		return true;
	
	if (!(object_value.indexOf("@") > -1 && object_value.indexOf(".") > -1))
		return false;    
	
	return true;
}

//Funcao para mudar as classes dos elementos
function MudarClasse(id, newClass) {
Identity=document.getElementById(id);
Identity.className=newClass;
}


function EW_Login(EW_this) {
	if (!EW_hasValue(EW_this.userid, "TEXT" )) {
		if  (!EW_onError(EW_this, EW_this.userid, "TEXT", "Por favor insira o seu Username"))
			return false; 
	}
	if (!EW_hasValue(EW_this.passwd, "PASSWORD" )) {
		if (!EW_onError(EW_this, EW_this.passwd, "PASSWORD", "Por favor insira a sua Password"))
			return false; 
	}
	return true;
}


function EW_LoginCliente(EW_this) {
	if (!EW_hasValue(EW_this.contr, "TEXT" )) {
		if  (!EW_onError(EW_this, EW_this.contr, "TEXT", "Por favor insira o número de contribuinte"))
			return false; 
	}
	return true;
}


function Redimensionar() {
	obj = document.getElementById('imagem');
	w = obj.offsetWidth;
	h = obj.offsetHeight;
	if(navigator.appName == "Microsoft Internet Explorer"){
		h = parseInt(obj.offsetHeight+70);
	}else{
		h = parseInt(obj.offsetHeight+120);
	}
	//window.resizeTo(w,h);
	l = parseInt((screen.width - w)/2);
	t = parseInt((screen.height - h - 150)/2);
	window.moveTo(l,t);
}
function Fechar() {
	window.close();
	//alert("teste");
}


function imprimirFlash(arquivo,w,h,transparente) {	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" width="'+w+'" height="'+h+'">');	document.write('<param name="movie" value="'+arquivo+'">');	document.write('<param name="bgcolor" value="#999999">');	document.write('<param name=quality value=high>');	document.write('<param name="menu" value="false">');	if (transparente) {		document.write('<param name="wmode" value="transparent">');	}	document.write('<embed src="'+arquivo+'" quality="high" allowscriptaccess="samedomain" swliveconnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" bgcolor="#FFFFFF"');	if (transparente) {		document.write('wmode="transparent" ');	}	document.write('menu="false"></embed>');	document.write('</object>');}
