function MM_swapImgRestore() { //v3.0

	var i,x,a=document.MM_sr; for(i=0;a&&i < a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}

function MM_preloadImages() { //v3.0

	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i < a.length; i++)

	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

function MM_openBrWindow(theURL,winName,features) { //v2.0

	window.open(theURL,winName,features);

}

function MM_findObj(n, d) { //v4.0

	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i < d.forms.length;i++) x=d.forms[i][n];

	for(i=0;!x&&d.layers&&i < d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

	if(!x && document.getElementById) x=document.getElementById(n); return x;

}

function MM_swapImage() { //v3.0

	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i < (a.length-2);i+=3)

	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}	



function openPopup(winurl,winname,winfeatures) {
	window.open(winurl,winname,winfeatures);
}
function pop(winurl,winname,winfeatures) {
	window.open(winurl,winname,winfeatures);
}


var defaultEmptyOK = false



function isEmpty(s) {

   return ((s == null) || (s.length == 0))

}

function isString (s) {  

	if (isEmpty(s)) 

       if (isString.arguments.length == 1) return defaultEmptyOK;

       else return (isString.arguments[1] == true);

	// All characters are considered valid for now.

    return true;

}



function LoginForm_check_all_fields() {

    var invalid_fields = '';

    var valid_form = true;

    if(!isString(document.forms.LoginForm.loginuser.value)) {

    	invalid_fields += ('\n    ' + 'Valor inválido em Username: ' + document.forms.LoginForm.login_user.value);

    	valid_form = false;

    }

    if(!isString(document.forms.LoginForm.loginpassword.value)) {

    	invalid_fields += ('\n    ' + 'Valor inválido em Password: ' + document.forms.LoginForm.login_password.value);

    	valid_form = false;

    }

    if (! valid_form) {

    	alert('Foram encontrados alguns campos inválidos: ' + invalid_fields);

    }

    return valid_form;

} 



function LoginForm_submit() {

    if(LoginForm_check_all_fields()) {

    	document.forms.LoginForm.login_user.value = document.forms.LoginForm.loginuser.value;

    	document.forms.LoginForm.login_password.value = document.forms.LoginForm.loginpassword.value;

    	document.forms.LoginForm.hasSubmitted.value = "1";		

    	document.forms.LoginForm.submit();

    	return true;

    } else {

        return false;   

    }

}



/* Esta funcao foi criada para se usar no href */

function LoginFormSubmit() {

    if(LoginForm_check_all_fields()) {

    	document.forms.LoginForm.login_user.value = document.forms.LoginForm.loginuser.value;

    	document.forms.LoginForm.login_password.value = document.forms.LoginForm.loginpassword.value;

    	document.forms.LoginForm.hasSubmitted.value = "1";		

    	document.forms.LoginForm.submit();

    }

}



function criarjanela(href, target, width, height, haveTool, haveLocation, haveStatus, haveMenu, haveScroll, resizable) {

    mywindow = window.open(href,target,"width=" + width + ",height=" + height + ",toolbar=" + haveTool + ",location=" + haveLocation + "status=" + haveStatus + ",menubar=" + haveMenu + ",scrollbars=" + haveScroll + ",resizable=" + resizable);

    return mywindow;

}



function openChild (parentName, href, target, width, height, haveTool, haveLocation, haveStatus, haveMenu, haveScroll, resizable) {

	if (parentName != '') {

		window.name = parentName;   

	}

	mywindow = criarjanela(href, target, width, height, haveTool, haveLocation, haveStatus, haveMenu, haveScroll, resizable);

	mywindow.opener = parent;

}



function closeChild (parentURL, reload) {

	if (parentURL != '') {

		opener.location = parentURL;

	} else {

		if ( reload ) {

			top.opener.window.location.reload();

		}

	}

	top.window.close(); 

}



function AddVar(form, nome, valor) { 

	var objHTML = document.createElement("INPUT"); 

	objHTML.setAttribute("type", "hidden"); 

	objHTML.setAttribute("name", nome); 

	objHTML.setAttribute("id", nome); 

	objHTML.setAttribute("value", valor); 

	form.appendChild(objHTML);

}



function RemoveVar(form, nome) { 

	var objHTML = document.getElementById(nome);

	if ( objHTML != null ) {

		form.removeChild(objHTML);

	}

}



function openWindow (url,name) {

    window.open(url,name,'height=600, width=600, status=no, toolbar=no, menubar=no, resizable=no, scrollbars=no');    

}
