/**
 * @author Rubia Gardini
 */

function open_popup() 
{
    window.open('http://www.maxhaus.com.br/manual/index.html', '_blank', 'toolbar=no, location=yes, directories=no, status=yes, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes, width=1024, height=620');
}

$(document).ready( function ()
 {
 	var count = $('.main .top ul.menu li').length;
	
	for (i=0; i < count; i++)
	{
		var img = $('.main .top ul.menu li a:eq(' + i + ') img').attr('src');
		$('.main .top ul.menu li:eq(' + i + ')').css({'background-image' : 'url(' + img +')', 'background-position' : '0 -23px'});
	}
	
 	$('.main .top ul.menu li a img').mouseover(function () {
	    $(this).animate( { opacity:0 }, { queue:false, duration:500 } )
	});
	
	$('.main .top ul.menu li a img').mouseout(function () {
	    $(this).animate( { opacity:1 }, { queue:false, duration:500 } )
	});
 });
 
 
function allow_chars(e, type)
{
    var key = window.event ? e.keyCode : e.which;
    var keychar = String.fromCharCode(key);
    if ( navigator.appName == "Microsoft Internet Explorer" )
    {
        if( type == 'int' ) reg = /[\d]/;
        if( type == 'decimal' ) reg = /[,\d]/;
        if( type == 'currency' ) reg = /[,.\d]/;
        if( type == 'phone' ) reg = /[-\d]/;
        return reg.test(keychar);
    } 
    else
    {
        if(key != 0 && key != 9 && key != 8 && key != 35 && key != 36 && key != 37 && key != 39)
        {
            if( type == 'int' ) reg = /[\d]/;            
            if( type == 'decimal' ) reg = /[,\d]/;
            if( type == 'currency' ) reg = /[,.\d]/;
            if( type == 'phone' ) reg = /[-\d]/;
            return reg.test(keychar);
        }
        else return true;
    }
}

function hoverListPlants(obj){

	$.each(obj, function(i, n){
		$(n).append("<span>"+$(n).text()+"</span>");
		$(n).find("span").css("opacity","0");
	});
	
	$(obj).find("span").mouseover(function(){
		$(this).animate({
			opacity: 1
		}, {duration: 500, queue: false } );
	}).mouseout(function(){
		$(this).animate({
			opacity: 0
		}, {duration: 500, queue: false } );
	});

}

function openWindow(url, width, height) {
    window.open(url, '_blank', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=' + width + ',height=' + height);
}