$(document).ready(function(){
	$('.nav li, #sidebar .sidebar-item').hoverIntent({
		sensitivity: 2,
		interval: 300,
		over: navon,
		timeout: 600,
		out: navoff
	});
	
	$('.producto_detalle a').click(function(){
		var route = $(this).attr('href');
		$(this).parent().parent().find('img').remove();
		$(this).parent().parent().prepend('<img src="'+route+'" />');
		return false;
		});

	$("#buscador").append('<div id="results"></div>')
	
	$('#testinput').keyup(function(){
		var R = $("#results");	

		if ($("#testinput").val().length != '0'){
			$.get("/virutex/resultados/index_temporal.php", {
			query: $("#testinput").val(),
			type: "count" }, function(data){
					$('#content').css({'z-index':'1'});
					R.css({'z-index':'6'});
					R.html(data);
					R.find("ul").append('<li class="top">&nbsp</li><li class="bottom">&nbsp</li>');
					R.css({'display':'block'});					
			});		
		} else {
			$("#results").empty();
			$('#content').css({'z-index':'5'});
		};
	});
	
	$("#results li a").each(function(){
		
		});
		
	$("#carrusel-mask").scrollable({
		size: 3, 
		loop: true,
		items: '#carrusel-wrapper',
		next: '.next', 
		prev: '.prev'
		});
	
}); //document.ready

function navon(){
	if (jQuery.support.opacity){
		$(this).css({'z-index':'8'});
		$(this).find('.second').fadeIn(300, function(){
			});
		}
	else {
		$(this).css({'z-index':'8'});
		$(this).parent().css({'z-index':'8'});
		$(this).find('.second').css({'display':'block'});
		};
	}
		  
function navoff(){ 
	if (jQuery.support.opacity){
		$(this).css({'z-index':'1'});	
		$(this).find('.second').fadeOut(50, function(){
			}); 
		}
	else {
		$(this).css({'z-index':'1'});		
		$(this).parent().css({'z-index':'1'});		
		$(this).find('.second').css({'display':'none'});
		}
	}

// Home Principal
var route = 'http://www.virutexilko.cl';
var flashvars = {};
var params = {
   wmode: "transparent",
   menu: "false"
};
var attributes = {};

swfobject.embedSWF(route+"/_media/movies/selector-marca.swf", "flash-selector", "910", "395", "7.0.0", "#ffffff", flashvars, params, attributes);

// Noticias
var route = 'http://virutex.multinetlabs.com';
var flashvars = {};
var params = {
   wmode: "transparent",
   menu: "false"
};
var attributes = {};

swfobject.embedSWF(route+"/_media/movies/virutex/home-noticias.swf", "contenido-noticias", "380", "140", "7.0.0", "#ffffff", flashvars, params, attributes);

// Tips destacado
var flashvars = {};
var params = {
   wmode: "transparent",
   menu: "false"
};
var attributes = {};


swfobject.embedSWF(route+"/_media/movies/virutex/home-destacado.swf", "header-tips-home", "470", "470", "10.0.0", "#ffffff", flashvars, params, attributes);

/*var options = {
			script: route+"buscador/test.php?json=true&id_marca=<?=$id_marca?>&limit=20&",
			varname:"input",
			json:true,
			shownoresults:false,
			maxresults:20,
			callback: function (obj) { document.getElementById('testid').value = obj.id; }
		};
		var as_json = new bsn.AutoSuggest('testinput', options);
		
		
		var options_xml = {
			script: function (input) { return route+"buscador/test.php?input="+input+"&testid="+document.getElementById('testid').value; },
			varname:"input"
		};
		var as_xml = new bsn.AutoSuggest('testinput_xml', options_xml);

		function validar_buscador(){
			 errores=0;
			 consulta	=document.form_buscador.elements['consulta'].value; 
			 if (consulta==""){
				window.alert("Por favor, ingresa correctamente su consulta");
			}else{
				document.form_buscador.submit();	
			}
		}

*/
