
// MUDALINK
function MudaLink(objLink)
	{
	objLink.style.textDecorationUnderline = true;
	objLink.style.cursor = 'hand';
	};

// VOLTALINK
function VoltaLink(objLink)
	{  
	objLink.style.textDecorationUnderline = false;
	objLink.style.cursor = 'default';
	};
	
function check_date(field)
	 {
	 var checkstr = "0123456789";
	 var DateField = field;
	 var Datevalue = "";
	 var DateTemp = "";
	 var seperator = "/";
	 var day;
	 var month;
	 var year;
	 var leap = 0;
	 var err = 0;
	 var i;
	err = 0;
	DateValue = DateField.value;
	for (i = 0; i < DateValue.length; i++)
		{
		if (checkstr.indexOf(DateValue.substr(i,1)) >= 0)
			{
			DateTemp = DateTemp + DateValue.substr(i,1);
			}
		};
	DateValue = DateTemp;
	if (DateValue.length == 6)
		{
		DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2);
		};
	if (DateValue.length != 8)
		{
		err = 19;
		};
	year = DateValue.substr(4,4);
	if (year == 0)
		{
		err = 20;
		};
	month = DateValue.substr(2,2);
	if ((month < 1) || (month > 12))
		{
		err = 21;
		};
	day = DateValue.substr(0,2);
	if (day < 1)
		{
		err = 22;
		};
	if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0))
		{
		leap = 1;
		};
	if ((month == 2) && (leap == 1) && (day > 29))
		{
		err = 23;
		};
	if ((month == 2) && (leap != 1) && (day > 28))
		{
		err = 24;
		};
	if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12")))
		{
		err = 25;
		};
	if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11")))
		{
		err = 26;
		};
	if ((day == 0) && (month == 0) && (year == 00))
		{
		err = 0; day = ""; month = ""; year = ""; seperator = "";
		};
	if (err == 0)
		{
		DateField.value = day + seperator + month + seperator + year;
		}
	else
		{
		alert("Data inválida!");
		DateField.select();
		DateField.focus();
		};
	};

function isValidEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}
function abrirPopup(pagina, apelido, status, toolbar, location, menubar, directories, resizable, scrollbars, height, width) {	
	/*	status		The status bar at the bottom of the window. 
	toolbar		The standard browser toolbar, with buttons such as Back and Forward. 
	location	The Location entry field where you enter the URL. 
	menubar		The menu bar of the window 
	directories	The standard browser directory buttons, such as What's New and What's Cool 
	resizable	Allow/Disallow the user to resize the window. 
	scrollbars  Enable the scrollbars if the document is bigger than the window 
	height		Specifies the height of the window in pixels. (example: height='350') 
	width		Specifies the width of the window in pixels. 
	*/
	window.open(pagina,apelido,'status='+status+',toolbar='+toolbar+',location='+location+',menubar='+menubar+',directories='+directories+',resizable='+resizable+',scrollbars='+scrollbars+',height='+height+',width='+width);
}
function abrirPopup2(pagina, apelido, status, toolbar, location, menubar, directories, resizable, scrollbars, height, width, left, top) {	
	/*	status		The status bar at the bottom of the window. 
	toolbar		The standard browser toolbar, with buttons such as Back and Forward. 
	location	The Location entry field where you enter the URL. 
	menubar		The menu bar of the window 
	directories	The standard browser directory buttons, such as What's New and What's Cool 
	resizable	Allow/Disallow the user to resize the window. 
	scrollbars  Enable the scrollbars if the document is bigger than the window 
	height		Specifies the height of the window in pixels. (example: height='350') 
	width		Specifies the width of the window in pixels. 
	left		Posição esquerda
	top			posição superior
	*/
	mywindow = window.open(pagina,apelido,'status='+status+',toolbar='+toolbar+',location='+location+',menubar='+menubar+',directories='+directories+',resizable='+resizable+',scrollbars='+scrollbars+',height='+height+',width='+width);	mywindow.moveTo(left,top);
}