var acl = 0;
var tim = '';
$(document).ready(function(){
	/** Agencia **/
	/* Accordion */
        if (navigator.appVersion.indexOf("Mac")!=-1) $("#bite").css('padding-bottom','57px');
	$("#jquiacc").accordion({
		autoHeight:false,
		collapsible:true
	});
	$(".siguiente").click(function(){
		var n = parseInt($(this).parent().attr('id').split('acc')[1]);
		$('#jquiacc').accordion('activate',n);
	});

	//Background position of bite segons scroll
	minh = $("#content").offset()['top'];
	maxh = $("#downside").offset()['top'];
	var n = $(window).scrollTop();
	if(n>minh && n<maxh){$("#bite").css('background-position','0px -176px');$("#bite_static").css('background-position','0px -222px');}
	else{$("#bite").css('background-position','0px -1px');$("#bite_static").css('background-position','0px -49px');}
	$(window).scroll(function(){
		//$('html, body').stop();
		minh = $("#content").offset()['top'];
		maxh = $("#downside").offset()['top'];
		var n = $(window).scrollTop();
		if(n>minh && n<maxh){
			$("#bite").css('background-position','0px -176px');
                        $("#bite_static").css('background-position','0px -222px');
		}else{
			$("#bite").css('background-position','0px -1px');
                        $("#bite_static").css('background-position','0px -49px');
		}
	});
	// Bite pulse 2 times every 10s, if hover stop.
	//tim = window.setInterval(function(){$("#bite").effect("pulsate",{times:1},1000);},10000);
	//$("#bite").mouseenter(function(){window.clearInterval(tim);});
	//$("#bite").mouseleave(function(){tim = window.setInterval(function(){$("#bite").effect("pulsate",{times:1},1000);},10000);})
	
	//Lazy load of images
	$("img").each(function(i,e){
		$(this).addClass('lazy');
	});
	$("#slidec img").removeClass('lazy');
	$("#content img.lazy").show().lazyload();
	$("#modals img.lazy").lazyload({event: "inslide"});
	
	//Facybox setup (modal window)
	/*$(".pop").fancybox({
		'titleShow'		: false,
		'centerOnScroll': false,
		'autoDimensions': true,
		'padding'		: 0,
		'onStart'		: function(){$("html,body").css('overflow','hidden')},
		'onCleanup'		: function(){$("html,body").css('overflow','auto')}
		
	});
	$(".popi").fancybox({ //'popups' de click seguros (con acordeon)
		'titleShow'		: false,
		'centerOnScroll': false,
		'autoDimensions': true,
		'padding'		: 0,
		'onStart'		: function(){$("html,body").css('overflow','hidden');},
		'onCleanup'		: function(){$("html,body").css('overflow','auto')},
		'onComplete'	: function(){
			setTimeout(function() {$("#"+acl+" .inactive").click();}, 1000);
		}
	});
	$(".pop").click(function(e){
		e.preventDefault();
		var id = $(this).attr('href');
		$(id+" img.lazy").trigger("inslide");
	});
	$(".popi").click(function(e){
		e.preventDefault();
		var id = $(this).attr('href');
		$(id+" img.lazy").trigger("inslide");
	})*/
	
	/** Slideshow popup **/
	$('#pop2').anythingSlider({
		// Appearance
		  width               : 978,      // Override the default CSS width
		  height              : 600,      // Override the default CSS height
		  resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport

		// Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : false,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 5000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing"    // Anything other than "linear" or "swing" requires the easing plugin

		});
	$('#f1').click(function(){$('#pop2').data('AnythingSlider').goForward();});
	$('#b1').click(function(){$('#pop2').data('AnythingSlider').goBack();});
	$('#pop3').anythingSlider({
		// Appearance
		  width               : 978,      // Override the default CSS width
		  height              : 600,      // Override the default CSS height
		  resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport

		// Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : false,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 5000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing",    // Anything other than "linear" or "swing" requires the easing plugin
		  onSlideBegin		  : function(){
			 slide = $('#pop3').data('AnythingSlider');
			 if(slide.targetPage==3){
			  $.getScript("js/flowplayer-3.2.6.min.js", function() {
					flowplayer("player", "img/flowplayer-3.2.7.swf");
				});
			 }
		  },
		  onSlideComplete: function(){
			  slide = $('#pop3').data('AnythingSlider');
			  if(slide.targetPage==2){
				  $('#carn').animate({scrollTop:31163}, 2000);
			  }
		  }
		});
	$('#f2').click(function(){$('#pop3').data('AnythingSlider').goForward();});
	$('#b2').click(function(){$('#pop3').data('AnythingSlider').goBack();});
	$('#b3').click(function(){$('#pop3').anythingSlider(1);});
	$('#b4').click(function(){$('#pop3').data('AnythingSlider').goBack();});
	$('#f3').click(function(){$('#pop3').anythingSlider(3);});
	$('#f4').click(function(){$('#pop3').data('AnythingSlider').goForward();});
	$('#pop4').anythingSlider({
		// Appearance
		  width               : 978,      // Override the default CSS width
		  height              : 600,      // Override the default CSS height
		  resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport

		// Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : false,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 5000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing",    // Anything other than "linear" or "swing" requires the easing plugin
		  onSlideComplete: function(){
		  }
		});
	$('#f22').click(function(){$('#pop4').data('AnythingSlider').goForward();$('#carn2').animate({scrollTop:31163}, 2000)});
	$('#b22').click(function(){$('#pop4').data('AnythingSlider').goBack();});
	$('#b23').click(function(){$('#pop4').anythingSlider(1);});
	$('#b24').click(function(){$('#pop4').data('AnythingSlider').goBack();});
	$('#f23').click(function(){$('#pop4').anythingSlider(3);});
	$('#f24').click(function(){$('#pop4').data('AnythingSlider').goForward();});
	$('#pop5').anythingSlider({
		// Appearance
		  width               : 978,      // Override the default CSS width
		  height              : 600,      // Override the default CSS height
		  resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport

		// Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : false,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 5000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing",    // Anything other than "linear" or "swing" requires the easing plugin
		  onSlideComplete: function(){
			  
		  }
		});
	$(".pop[href=#newsletter]").click(function(){setTimeout(function() {$("#pop5 .imagestring img").css('display','none');$(".fcl").css('display','block');}, 1000);});
	$('#f32').click(function(){$('#pop5').data('AnythingSlider').goForward();});
	$('#b32').click(function(){$('#pop5').data('AnythingSlider').goBack();});
	$('#b33').click(function(){$('#pop5').anythingSlider(1);});
	$('#b34').click(function(){$('#pop5').data('AnythingSlider').goBack();});
	$('#f33').click(function(){$('#pop5').anythingSlider(3);});
	$('#f34').click(function(){$('#pop5').data('AnythingSlider').goForward();});
	$("#news .ts .it").click(function(){
		var nimg = $(this).attr('id').split('_')[1];
		$("#news img").css('display','none');
		$("#news img").eq(nimg).css('display','block');
		$("#news .ts .it").removeClass('curit');
		$(this).addClass('curit');
	});
	$("#newsfr .ts .it").click(function(){
		var nimg = $(this).attr('id').split('_')[1];
		$("#newsfr img").css('display','none');
		$("#newsfr img").eq(nimg).css('display','block');
		$("#newsfr .ts .it").removeClass('curit');
		$(this).addClass('curit');
	});
	$("#newspt .ts .it").click(function(){
		var nimg = $(this).attr('id').split('_')[1];
		$("#newspt img").css('display','none');
		$("#newspt img").eq(nimg).css('display','block');
		$("#newspt .ts .it").removeClass('curit');
		$(this).addClass('curit');
	});
	$('#pop6').anythingSlider({
		// Appearance
		  width               : 978,      // Override the default CSS width
		  height              : 600,      // Override the default CSS height
		  resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport

		// Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : false,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 5000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing"   // Anything other than "linear" or "swing" requires the easing plugin

		});
	$("#cels").click(function(){
		  $("#ytvids .vidtit iframe").remove();
		  var iframes = new Array();
		  iframes[0] = '<iframe width="600" height="340" src="http://www.youtube.com/embed/0OAvQVVV6Dk" frameborder="0" allowfullscreen></iframe>';
		  iframes[1] = '<iframe width="600" height="340" src="http://www.youtube.com/embed/-pGRaEEIXk8" frameborder="0" allowfullscreen></iframe>';
		  iframes[2] = '<iframe width="600" height="340" src="http://www.youtube.com/embed/F8J-CbzVSkY" frameborder="0" allowfullscreen></iframe>';
		  iframes[3] = '<iframe width="600" height="340" src="http://www.youtube.com/embed/G60xmsuhtaM" frameborder="0" allowfullscreen></iframe>';
		  iframes[4] = '<iframe width="600" height="340" src="http://www.youtube.com/embed/3CCb7LxZCb0" frameborder="0" allowfullscreen></iframe>';
		  iframes[5] = '<iframe width="600" height="340" src="http://www.youtube.com/embed/XmP5Juz8sdc" frameborder="0" allowfullscreen></iframe>';
		  $("#ytvids .vidtit").each(function(i){
			 $(iframes[i]).appendTo($(this)); 
		  });
		
	});
	$('#f42').click(function(){$('#pop6').data('AnythingSlider').goForward();});
	$('#b42').click(function(){$('#pop6').data('AnythingSlider').goBack();});
	$('#b43').click(function(){$('#pop6').anythingSlider(1);});
	$('#b44').click(function(){$('#pop6').data('AnythingSlider').goBack();});
	$('#f43').click(function(){$('#pop6').anythingSlider(3);});
	$('#f44').click(function(){$('#pop6').data('AnythingSlider').goForward();});
	
	/** Slideshow de Agencia **/
        $('#ag_wrap').anythingSlider({
		// Appearance
		  width               : null,      // Override the default CSS width
		  height              : 420,      // Override the default CSS height
		  resizeContents      : true,      // If true, solitary images/objects in the panel will expand to fit the viewport

		// Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : false,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 5000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing",    // Anything other than "linear" or "swing" requires the easing plugin
		  onSlideComplete: function(){
			  cli = $('#ag_wrap').data('AnythingSlider').$currentPage.attr('id');
			  n = $('#ag_wrap').data('AnythingSlider').currentPage;
			  setpage3(n);
			  
		  }
        });
        $('#backwhite, #forwhite').click(function(){
		cur = $('#ag_wrap').data('AnythingSlider').currentPage;
  		if($(this).is('#backwhite')){
  			$('#ag_wrap').data('AnythingSlider').goBack();
  			cur--;
  		}else{
  			$('#ag_wrap').data('AnythingSlider').goForward(); 
  			cur++;
  		}
  		setpage3(cur);	  		
	});
	$(".slideagency a").click(function(){
		var slide = $(this).attr('href').substring(1);
		$("#ag_wrap").anythingSlider(slide);
		setpage3(slide);
		return false;
	});
	function setpage3(n){
		$(".slideagency a").removeClass('current');
		$(".slideagency a").eq(n-1).addClass('current');
	}
	/** Slideshow de Citas **/
	$('#citas').anythingSlider({
		// Appearance
		  width               : null,      // Override the default CSS width
		  height              : null,      // Override the default CSS height
		  resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport

		// Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : false,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : true,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 10000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing",    // Anything other than "linear" or "swing" requires the easing plugin
		  onBeforeInitialize  : function(){
                      cli = $('#citas .cita').eq(0).attr('id');
                      id = cli.split('_')[1];
                      if($(window).width()>320){
                              $(".client").css('opacity',0.7);
                              $("#"+id).css('opacity',1);
                      }else{
                              $(".client").css('display','none');
                              $("#"+id).css({'opacity':1,'display':'block'});
                      }
                  },
                  onSlideComplete: function(){
			  cli = $('#citas').data('AnythingSlider').$currentPage.attr('id');
			  n = $('#citas').data('AnythingSlider').currentPage;
			  setpage2(n);
			  id = cli.split('_')[1];
			  if($(window).width()>320){
				  $(".client").css('opacity',0.7);
				  $("#"+id).css('opacity',1);
			  }else{
				  $(".client").css('display','none');
				  $("#"+id).css({'opacity':1,'display':'block'});
			  }
		  }
		});
	$('.back, .for').click(function(){
		cur = $('#citas').data('AnythingSlider').currentPage;
  		if($(this).is('.back')){
  			$('#citas').data('AnythingSlider').goBack();
  			cur--;
  		}else{
  			$('#citas').data('AnythingSlider').goForward(); 
  			cur++;
  		}
  		setpage2(cur);	  		
	});
	$(".slidetabs a").click(function(){
		var slide = $(this).attr('href').substring(1);
		$("#citas").anythingSlider(slide);
		setpage2(slide);
		return false;
	});
	function setpage2(n){
		$(".slidetabs a").removeClass('current');
		$(".slidetabs a").eq(n-1).addClass('current');
	}
	
	/** Accordion Click **/
	$(".accordeon .inactive").click(function(){
		act = $(".act").attr('id');
		act--;
		target = $(this).parent().attr('id');
		target--;
		if(act!=target){
			$("#promos .promo").fadeOut(1000);
			$(".act").next().animate({'margin-left':-622},1000);
			$(".act .inactive").fadeIn();
			$(".act").removeClass("act");
			$(this).parent().addClass("act");
			$(".act .inactive").fadeOut();
			$(".act").next().animate({'margin-left':0},1000);
			$("#promos .promo").eq(target).fadeIn(1000);
		}else{
                    $("#promos .promo").hide();
                    $("#promos .promo").eq(target).show();
                }
	});
	
		
		

	
	/** Slideshow de contenido **/
	$('#slider').anythingSlider({
		  // Appearance
		  width               : null,      // Override the default CSS width
		  height              : null,      // Override the default CSS height
		  resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport

		  // Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : true,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 3000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing",    // Anything other than "linear" or "swing" requires the easing plugin
		  onSlideComplete     : function(){
			  if($(window).width()>320) $('html, body').animate({scrollTop:100}, 2000);
			  else $('html, body').animate({scrollTop:100}, 0);
			  slide = $('#slider').data('AnythingSlider');
			  if(slide.targetPage==3 && $(window).width()>320){
					  $("#fisherprice .gearwrap").each(function(i){
						 if(!$(this).hasClass('absolute_gear')){
							 p = $(this).offset();
							 nd = $(this).clone();
							 $(this).css('visibility','hidden');
							 nd.addClass('absolute_gear');
							 nd.appendTo(document.body);
							 if(nd.hasClass('left')){
								 nd.css({
									 'position':'absolute',
									 'top': p.top,
									 'left':0,
									 'margin':0,
									 'visibility':'visible'
								 });	 
							 }else{
								 nd.css({
									 'position':'absolute',
									 'top': p.top,
									 'right':0,
									 'margin':0,
									 'visibility':'visible'
								 });
							 }
						 }
					  });
			  }else{
				  $(".absolute_gear").remove();
			  }
		  }
		});
	$('#slidec').anythingSlider({
		  // Appearance
		  width               : null,      // Override the default CSS width
		  height              : null,      // Override the default CSS height
		  resizeContents      : false,      // If true, solitary images/objects in the panel will expand to fit the viewport

		  // Navigation
		  startPanel          : 1,         // This sets the initial panel
		  hashTags            : true,      // Should links change the hashtag in the URL?
		  buildArrows         : false,      // If true, builds the forwards and backwards buttons
		  buildNavigation     : false,      // If true, buildsa list of anchor links to link to each panel
		  buildStartStop	  : false,
		  navigationFormatter : null,      // Details at the top of the file on this use (advanced use)
		  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
		  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)

		  // Slideshow options
		  autoPlay            : false,      // This turns off the entire slideshow FUNCTIONALY, not just if it starts running or not
		  startStopped        : false,     // If autoPlay is on, this can force it to start stopped
		  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
		  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a youtube video is playing, it will pause the autoplay until the video has completed
		  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page
		  playRtl             : false,     // If true, the slideshow will move right-to-left
		  startText           : "Start",   // Start button text
		  stopText            : "Stop",    // Stop button text
		  delay               : 3000,      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
		  animationTime       : 600,       // How long the slideshow transition takes (in milliseconds)
		  easing              : "swing"    // Anything other than "linear" or "swing" requires the easing plugin
		});
	$('.sbackward, .sforward').click(function(){
			cur = $('#slider').data('AnythingSlider').currentPage;
	  		if($(this).is('.sbackward')){
	  			$('#slider').data('AnythingSlider').goBack();
	  			$('#slidec').data('AnythingSlider').goBack();
	  			if(cur==0) cur=3; else cur--;
	  		}else{
	  			$('#slider').data('AnythingSlider').goForward(); 
	  			$('#slidec').data('AnythingSlider').goForward();
	  			if(cur==3) cur=1; else cur++;
	  		}
	  		setpage(cur);	  		
	  });
	$("#pag1 a").click(function(){
		var slide = $(this).attr('href').substring(1);
		$("#slider").anythingSlider(slide);
		$("#slidec").anythingSlider(slide);
		setpage(slide);
		return false;
	});
	$(".slidenums a").click(function(){
		var slide = $(this).attr('href').substring(1);
		$("#slider").anythingSlider(slide);
		$("#slidec").anythingSlider(slide);
		setpage(slide);
		return false;
	});
	$("#submenu a.cli").click(function(){
		var slide = $(this).attr('href').substring(1);
		$("#slider").anythingSlider(slide);
		$("#slidec").anythingSlider(slide);
		setpage(slide);
		return false;
	});
	$("#bite a").click(function(){
		var slide = $(this).attr('href').substring(1);
		$("#slider").anythingSlider(slide);
		$("#slidec").anythingSlider(slide);
		setpage(slide);
		return false;
	});
	function setpage(n){
		$("#pag1 a").removeClass('cur');
		$("#pag1 a").eq(n-1).addClass('cur');
		$(".slidenums a").removeClass('curr');
		$(".slidenums a").eq(n-1).addClass('curr');
		$("#submenu a").removeClass('cur');
		$("#submenu a").eq(n-1).addClass('cur');
		$("#bite a").removeClass('cur');
		$("#bite a").eq(n-1).addClass('cur');
	}
	
	
	/** Google Maps Stuff **/
	$("#madrid").click(function(){
		if($(window).width()>320){
			var madrid = new google.maps.LatLng(40.42709770,-3.68374130);
			var myOptions = {
				zoom: 15,
				center: madrid,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			};
	
			var map = new google.maps.Map(document.getElementById('madrid'),myOptions);
			var marker = new google.maps.Marker({
			      position:madrid, 
			      map: map, 
			      title:"Oficinas de Carrots en Madrid."
			 });
			
			$("#madrid").unbind('click');
			$("#madrid").css('background-image','none');
		}else{
			window.open('http://maps.google.com/maps?q=c%2FVel%C3%A1zquez+50+28001+Madrid&hl=es&ie=UTF8&sll=27.371767,-95.712891&sspn=56.321448,79.013672&vpsrc=0&hnear=Calle+de+Vel%C3%A1zquez,+50,+28001+Madrid,+Comunidad+de+Madrid,+Espa%C3%B1a&t=h&z=16','Google Maps');
		}
		
	});
	$("#barcelona").click(function(){
		if($(window).width()>320){
			var barcelona = new google.maps.LatLng(41.38800660,2.16746140);
			var myOptions = {
				zoom: 15,
				center: barcelona,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			};
	
			var map = new google.maps.Map(document.getElementById('barcelona'),myOptions);
			var marker = new google.maps.Marker({
			      position:barcelona, 
			      map: map, 
			      title:"Oficinas de Carrots en Barcelona."
			 });
			
			$("#barcelona").unbind('click');
			$("#barcelona").css('background-image','none');
		}else{
			window.open('http://maps.google.com/maps?q=Rambla+Catalunya+13+08007+Barcelona&hl=es&ie=UTF8&sll=40.427098,-3.683741&sspn=0.012169,0.01929&vpsrc=0&hnear=Rambla+de+Catalunya,+13,+08007+Barcelona,+Catalu%C3%B1a,+Espa%C3%B1a&t=h&z=16','Google Maps');
		}
	});
//}     
        if($.browser.webkit){
            $("#bite").css('padding-bottom','63px');
        }

 });
$(window).resize(function(){
	if($(window).width()>320){
		$(".client").css('display','block');
		$(".tab").css({'width':'980','height':'auto'});
		$("#slider").anythingSlider();
		$(".cita").css('width','780');
		$('#citas').anythingSlider();
	}else{
		$(".absolute_gear").remove();
		$(".tab").css('width','308');
		$("#slider").anythingSlider();
		$(".cita").css('width','308');
		$('#citas').anythingSlider();
	}
	
	
});

