(function($) {

    $.fn.autoMouseOver = function(settings) {
        settings = $.extend({
            outStr: "-out.",    // default string to replace for the "out" images (eg. home-out.png)
            overStr: "-over."   // default string to replace for the "over" images (eg. home-over.png)
        }, settings || {});

        // Preload the images
        var preloadImageArray = new Array();
        $(this).filter("img").each(function() {
            var overImg = $(this).attr("src").replace(settings.outStr, settings.overStr);
            var img = new Image();
            img.src = overImg;
            preloadImageArray.push(img); 
        });

        // Set the hover handler
        $(this).filter("img").hover(function() {
            $(this).attr("src", $(this).attr("src").replace(settings.outStr, settings.overStr));
        }, function() {
            $(this).attr("src", $(this).attr("src").replace(settings.overStr, settings.outStr));
        });

	    return $;
    };

})(jQuery);

$(function() {
	$(".gb-audio").autoMouseOver();
});

$(document).ready(function() {
	$("#nav").css({height: function(index, value) {
		return parseFloat($("#section").height());
		}
	});
	$("#section").css({width: function(index, value) {
		return (parseFloat($("#container").width()) - 260);
		}
	});
});

$(window).resize(function() {
	$("#nav").css({height: function(index, value) {
		return parseFloat($("#section").height());
		}
	});
	$("#section").css({width: function(index, value) {
		return (parseFloat($("#container").width()) - 260);
		}
	});
});

$(document).ready(function() {
	$(".thumbnailsH, .thumbnailsV, .thumbnailsComparacion").mouseover(function() {
		$(this).fadeTo(0,0.7);
	});
});

$(document).ready(function() {
	$(".thumbnailsH, .thumbnailsV, .thumbnailsComparacion").mouseout(function() {
		$(this).fadeTo(0,1);
	});
});

$(document).ready(function() {
	$('#generalHeader').toggle(function() {
		$('.generalData').css('display','none');
		}, function() {
			$('.generalData').css('display','');
	});
});

$(document).ready(function() {
	$('#electricosHeader').toggle(function() {
		$('.electricosData').css('display','none');
		}, function() {
			$('.electricosData').css('display','');
	});
});

$(document).ready(function() {
	$('#thieleSmallHeader').toggle(function() {
		$('.thieleSmallData').css('display','none');
		}, function() {
			$('.thieleSmallData').css('display','');
	});
});

$(document).ready(function() {
	$('#materialesHeader').toggle(function() {
		$('.materialesData').css('display','none');
		}, function() {
			$('.materialesData').css('display','');
	});
});

$(document).ready(function() {
	$('#dimencionesHeader').toggle(function() {
		$('.dimencionesData').css('display','none');
		}, function() {
			$('.dimencionesData').css('display','');
	});
});

$(function() {
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
	});
});

$(document).ready(function() {
	$('#map').toggle(function() {
		if ($('object').length) {
			$('object').css('display','inline');
		}
		else {
			$('<object data="http://maps.google.com.ar/maps?f=q&amp;source=s_q&amp;hl=es&amp;geocode=&amp;q=Caracas+2176+Ciudad+Aut%C3%B3noma+de+Buenos+Aires&amp;sll=-38.341656,-63.28125&amp;sspn=37.179482,86.572266&amp;ie=UTF8&amp;hq=&amp;hnear=Caracas+2176,+Villa+Gral.mitre,+Ciudad+Aut%C3%B3noma+de+Buenos+Aires&amp;ll=-34.60672,-58.47456&amp;spn=0.008477,0.013733&amp;z=16&amp;iwloc=A&amp;output=embed"></object>').insertAfter('table');
		}
		$('#map').text('ocultar mapa');
		}, function() {
			$('object').css('display','none');
			$('#map').text('mostrar mapa');
	});
});

$(document).ready(function() {
	$('#nombre').focus(function() {
		$('#nombre').css('border','1px solid #09C');
	});
});

$(document).ready(function() {
	$('#correo').focus(function() {
		$('#correo').css('border','1px solid #09C');
	});
});

$(document).ready(function() {
	$('#asunto').focus(function() {
		$('#asunto').css('border','1px solid #09C');
	});
});

$(document).ready(function() {
	$('#mensaje').focus(function() {
		$('#mensaje').css('border','1px solid #09C');
	});
});

$(document).ready(function() {
	$('#nombre').blur(function() {
		$('#nombre').css('border','1px solid #CCC');
	});
});

$(document).ready(function() {
	$('#correo').blur(function() {
		$('#correo').css('border','1px solid #CCC');
	});
});

$(document).ready(function() {
	$('#asunto').blur(function() {
		$('#asunto').css('border','1px solid #CCC');
	});
});

$(document).ready(function() {
	$('#mensaje').blur(function() {
		$('#mensaje').css('border','1px solid #CCC');
	});
});

$(document).ready(function() {
	$('#comparar').click(function() {
		$('.parlantes').wrap('<form action="parlantes.php" method="get" />');
		$.each($('.parlantes li a'),function(index,value) {
			if ($(value).attr('id')) {
				var id = $(value).attr('id');
				$('<input type="checkbox" name="modelo[]" value="'+id+'">').insertBefore(value);
				$(value).unwrap();
			}
		});
		$('#comparar').replaceWith('<button type="submit">Comparar</button>');
	});
});

$(':checkbox').live('click',function() {
	if (($('input:checked').length)>3) {
		$(this).removeAttr('checked');
	}
});

