// ---------------------------------------------- ** Fun��o para inserir meio mask
(function($){
	// call setMask function on the document.ready event
	$(function(){
		$("input[alt='telefone']").setMask();
		$("input[alt='celular']").setMask();
		$("input[alt='date']").setMask();
		$("input[alt='cpf']").setMask();
		$("input[alt='rg']").setMask();
		$("input[alt='cep']").setMask();
	});
})(jQuery);
//------------------------------------------------------------------------------------------------>

// ---------------------------------------------- ** Fun��o para transformar array em JSON
function array2json(arr) {
    var parts = [];
    var is_list = (Object.prototype.toString.apply(arr) === '[object Array]');

    for(var key in arr) {
    	var value = arr[key];
        if(typeof value == "object") { //Custom handling for arrays
            if(is_list) parts.push(array2json(value)); /* :RECURSION: */
            else parts[key] = array2json(value); /* :RECURSION: */
        } else {
            var str = "";
            if(!is_list) str = '"' + key + '":';

            //Custom handling for multiple data types
            if(typeof value == "number") str += value; //Numbers
            else if(value === false) str += 'false'; //The booleans
            else if(value === true) str += 'true';
            else str += '"' + value + '"'; //All other things
            // :TODO: Is there any more datatype we should be in the lookout for? (Functions?)

            parts.push(str);
        }
    }
    var json = parts.join(",");
    
    if(is_list) return '[' + json + ']';//Return numerical JSON
    return '{' + json + '}';//Return associative JSON
}
//------------------------------------------------------------------------------------------------>

//---------------------------------------------- ** Fun��o para abrir popup
function bgs_void() {
	return '#';
}
//------------------------------------------------------------------------------------------------>


//---------------------------------------------- ** Fun��o para abrir popup
function popup(URL, properties) {
	if(properties == undefined || properties == '') {
		properties= "width=400, height=500, top=200, left=200, scrollbars=yes, status=no, toolbar=no, location=0,directories=0, menubar=0, resizable=0, fullscreen=0";
	}
	window.open(URL,'_blank', properties, true);
}
//------------------------------------------------------------------------------------------------>

