$(document).ready(function() {	
	/**** Eliminar outlines das checkboxes, radio buttons e botoes em geral ****/
	$("A,INPUT[@type='radio'],INPUT[@type='checkbox'],INPUT[@type='button'],INPUT[@type='image'],INPUT[@type='submit']").bind("focus",function(){this.blur();});

	/**** coloca fundo transparente em todos os input tipo radio e checkbox ****/
	$('INPUT[@type="radio"],INPUT[@type="checkbox"]').each(function(){$(this).css('background', 'transparent');});
	
	/**** altera os PNG qdo o browser e' IE ****/
	//if ($.browser.msie) _fixPNG();
	
});

function _fixPNG() {
	var images = $('img[@src*="png"]'), png;
	images.each(
		function() {
			png = this.src;
			this.src = '../images/icons/spacer.gif';
			this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + png + "')";
		}
	);
}

function submitForm(formName, actionPage, target, method, encoding){
	//validacoes
	if (formName.length==0)//
		formName = "form";
		
	if (actionPage.length==0)
		actionPage = document.URL;
	
	if (method.length==0) //
		method = "POST";
		
	if (target.length==0)//
		target = "";
	
	if (encoding.length==0)//
		encoding = "application/x-www-form-urlencoded";		
		
	//envio
	var myForm = document.getElementById(formName);
	myForm.method  = method;
	myForm.target  = target;
	myForm.encoding= encoding;
	myForm.action  = actionPage;
	myForm.submit();
}

function popwindow(url, windowName, width, height, resize){
	if (width.length==0)//
		width=200;
	if (height.length==0)//
		height=300;
	if (resize.length==0)//
		resize='yes';
		
	var screenWidth = self.screen.width/2 - width/2;
	var screenHeight = self.screen.height/2 - height/2;	

	window.open (url,windowName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable='+resize+',top='+screenHeight+',left='+screenWidth+',width='+width+',height='+height+'')
}

// fc to capitalize first words of a sentence
makeUpperSentence = function(fieldToSiglate, fieldToSave){
    var a = fieldToSiglate.value.split(/\s+/g); // split the sentence into an array of words

    for (i = 0 ; i < a.length ; i ++ ) {
        var firstLetter = a[i].substring(0, 1).toUpperCase();
        var restOfWord = a[i].substring(1, a.length).toLowerCase();

        a[i] = firstLetter + restOfWord; // re-assign it back to the array and move on
    }
    
    fieldToSave.value = a.join(' '); // join it back together
}


// fc q faz sigla a partir das iniciais de uma frase, ignorando palavras de <3 caracteres
makeSigla = function(fieldToSiglate, fieldToSave){
    var a = fieldToSiglate.value.split(/\s+/g); // split the sentence into an array of words
    var result = "";
	var firstLetter = "";
	
    for (i = 0 ; i < a.length ; i ++ ) {
    	if(a[i].length>3){
	        firstLetter = a[i].substring(0, 1).toUpperCase();
	        result += firstLetter; 
        }
    }    
    fieldToSave.value = result; 
}