
$(function(){$('#menupie a').click(function(e){$('#menupie a').removeClass('selected')
$(this).addClass('selected')
x=$(this).attr('rel')
x=Math.round(x)
if(x>0){$('#prevart, #nextart, #listado, #blanco').hide()
Cufon.replace('div.pantalla h2');}
else{$('#prevart, #nextart, #listado').show()
if($('#blanco').css('opacity')==0.7){$('#blanco').show()}}
$('#marco').cycle(x,'scrollHorz');return false;});$('#pestalist, #blanco').click(function(e){x=$('#listado').position().top
if(x==250){$('#blanco').animate({'opacity':0})
$('#listado').stop().animate({'top':'450px'},500,'easeOutCirc')
$('#listado').queue(function(){$('#blanco').hide()});}
else{$('#blanco').animate({'opacity':0.7}).show()
$('#listado').stop().animate({'top':'250px'},1000,'easeOutCirc')}
return false;});})
$(window).resize(function(){if($(window).width()>=$('.caja').outerWidth()){izq=($(window).width()-$('.caja').outerWidth())/2}
if($(window).width()<$('.caja').outerWidth()){izq=0}
if($(window).height()>=$('.caja').outerHeight()){arr=($(window).height()-$('.caja').outerHeight())/2}
if($(window).height()<$('.caja').outerHeight()){arr=0}
$('.caja').css({position:'absolute',left:izq,top:arr});var pos=$("#marco1").offset().left
posr=800+pos
posl=190+pos});$(window).resize();$.getScript('json/productos.js',function(){var z=""
$.each(productos,function(i,item){midiv=item.grupo-1
ndiv=$("div.bloque").eq(midiv).length
if(ndiv>0){}
else{$("#marco11").append('<div id=mob'+item.grupo+' class=bloque></div>')}
$("div.bloque").eq(midiv).append('<a src="'+item.image+'" title="'+item.nombre+'" datos="<h2>'+item.nombre+'</h2>'+item.datos+'" ><img src="'+item.thumb+'" /></a>')});generar()});var top=0
function slide(where,topi){top=topi
if(where=='right'){top=top+70
if($('#marco11 img:visible:last').offset().left<=1150){top=top-70;}}
else{if(top<0){top=0}
top=top-70}
$("#marco1").stop().animate({scrollLeft:top},2000,'easeOutCirc');}
function generar(){arr=$('#marco11 div')
$.each(arr,function(i,val){div=$(val).width()
$(val).css('width',div/1)});var div=$('#marco')
var auto_slide_seconds=75;var maxt=$('#marco11 div:visible:last').position().left
if(maxt<1000){maxt=0}
var timer=0
var tt=0
$('#marco1').mousemove(function(e){if(e.pageX>posr&&tt==0){$("#marco1").clearQueue().stop();timer=setInterval('slide("right",top)',auto_slide_seconds);tt=1}
if(e.pageX<posl&&tt==0){$("#marco1").clearQueue().stop();timer=setInterval('slide("left",top)',auto_slide_seconds);tt=1}
if(e.pageX<posr-1&&e.pageX>posl-1){$("#marco1").clearQueue().stop();clearInterval(timer)
tt=0}
$('#marco1').bind('mouseleave',function(){clearInterval(timer)
tt=0});});function mover(){var div=$('#imagenficha')
$('#imagenficha img').mousemove(function(e){var maxScroll=$(div).attr("scrollWidth")-$(div).width();var maxScrollt=$(div).attr("scrollHeight")-$(div).height();var left=((e.pageX-div.offset().left)/$(div).attr("offsetWidth"))*(maxScroll);var top=((e.pageY-div.offset().top)/$(div).attr("offsetHeight"))*(maxScrollt);$(div).stop().animate({scrollLeft:left,scrollTop:top},1000,'easeOutCirc')});$('#imagenficha img').mouseout(function(e){$(div).stop().animate({scrollLeft:0,scrollTop:0},1000,'easeOutCirc')});}
$('#marco1d').cycle({fx:'scrollHorz',timeout:0,pager:'#foo2_pagx'});$('#marco').cycle({fx:'scrollVert',timeout:0,prev:'.prev',next:'.next'});$('#marco1 img, #zoom').css("opacity",0.7);$('#marco1 img').hover(function(){x=$(this).height()
jQuery(this).css("opacity",1);},function(){if($(this).hasClass("selected")==false){jQuery(this).css("opacity",0.7);}});$('#marco1 a').click(function(e){$('#marco1 img').removeClass('selected');$('#marco1 img').css('opacity',0.7)
$(this).children('img').css('opacity',1)
$(this).children('img').addClass('selected');numprod=$('div.familia a').index($(this))
$("#controlproductos span:first").html(numprod+1)
$('#ficha').stop().animate({'left':'-1000px'},5)
$('#imagenficha').html('<img src='+$(this).attr('src')+' />')
mover()
$('#textoficha').html($(this).attr('datos'))
Cufon.replace('#textoficha h2');$('#ficha').animate({'left':'0px'},200)
coord=$(this).attr('coord')
if(coord==null){coord='-100,-100'}
var arr=coord.split(';');$.each(arr,function(i,val){coord=val.split(',')
$('#contenidofondo').append('<div class=puntero title="'+coord[2]+'" style="top:'+coord[1]+'px;left:'+coord[0]+'px"></div>')});$('#contenidofondo img').tooltip({track:true,delay:0,showURL:false,showBody:" - ",fade:250});$('#marco').cycle(0);return false;});$('#marco1 a, .control').tooltip({track:true,delay:0,showURL:false,showBody:" - ",fade:0});$('#marco11 div.bloque').addClass('familia')
$('#familias a').click(function(e){$('#familias a').removeClass('selected')
$(this).addClass('selected')
x=$(this).attr('rel')
$('#marco11 div.bloque, #marco11 div.bloque img').hide().removeClass('familia')
if(x==''){var totalprod=$("#marco1 img").length
$("#controlproductos span:last").html(totalprod)
$('#marco11 div.bloque, #marco11 div.bloque img').fadeIn()
$('#marco11 div.bloque').addClass('familia')
x='mob1'}
else{var totalprod=$('#'+x+' img').length
$("#controlproductos span:last").html(totalprod)
$('#'+x).show()
$('#'+x).addClass('familia')
$('#'+x+' img').fadeIn()}
yy=$('#marco11').offset().left
y=$('#'+x).offset().left
$("#marco1").stop().animate({scrollLeft:y-yy},2000,'easeOutCirc');top=0
$('#marco1 a:visible').eq(0).trigger('click')
return false;});var totalprod=$('div.familia a').length
$("#controlproductos span:last").html(totalprod)
function iraproducto(e){yy=$('#marco11').offset().left
ir=$('#marco1 img.selected:visible').offset().left
var posx=$("#marco1").offset().left
$("#marco1").stop().animate({scrollLeft:ir-yy-300},2000,'easeOutCirc');top=ir-yy-300
return false}
$('#nextart').click(function(e){x=$("#controlproductos span:first").text()
x=Math.round(x)
var totalprod=$('div.familia a').length
if(x==totalprod){x=0}
$('div.familia a').eq(x).trigger('click')
iraproducto()});$('#prevart').click(function(e){x=$("#controlproductos span:first").text()
x=Math.round(x-2)
$('div.familia a').eq(x).trigger('click')
iraproducto()});$(".close").click(function(){$('#marco1 img:not(.selected)').css("opacity",0.7);$('#marco').cycle(0);iraproducto()
return false;});$('#marco1 a').eq(0).trigger('click')}
