/*este es del menu principal*/

jQuery(document).ready(function()
{	
		jQuery(" #botones_arriba_principal ul ").css({display: "none"}); // Opera Fix
		jQuery(" #botones_arriba_principal li").hover(function(){
		jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(400);
		},function(){
		jQuery(this).find('ul:first').css({visibility: "hidden"});
		});
/*esto es para llamarla funcion del movieminto suave del desplazamineto*/
		jQuery.smoothAnchors(1000, "swing", false);
});
/*
 * 
 * Center Plugin 1.0 - Easy cross-browser centering a div!
 * Version 1.0.1
 * @requires jQuery v1.3.0
 * 
 * Copyright (c) 2010 Matthias Isler
 * Licensed under the GPL licenses:
 * http://www.gnu.org/licenses/gpl.html
 * 
 */
jQuery.fn.center = function(init) {
		
	var object = this;
		
	if(!init) {
			
		
		object.css('margin-left', $(window).width() / 2 - this.width() / 2);
			
		$(window).resize(function() {
			object.center(!init);
		});
		
	} else {
			
		var marginTop = $(window).height() / 2 - this.height() / 2;
		var marginLeft = $(window).width() / 2 - this.width() / 2;
			
		marginTop = (marginTop < 0) ? 0 : marginTop;
		marginLeft = (marginLeft < 0) ? 0 : marginLeft;

		object.stop();
		object.animate(
			{
				
				marginLeft: marginLeft
			}, 
			150, 
			'linear'
		);
		
	}
}
/*este es el slinding del panel de opciones superior */
jQuery(document).ready(function() {
	jQuery("div.panel_button").click(function(){
		jQuery("div#panel").animate({
			height: "120px"
		})
		.animate({
			height: "99px"
		}, "fast");
		jQuery("div.panel_button").toggle();
	
	});	
	
   jQuery("div#hide_button").click(function(){
		jQuery("div#panel").animate({
			height: "0px"
		}, "fast");
   });	
});
/*este es el smooth anchor pa el desplzamiento suave*/
(function($){
	$.extend({
		smoothAnchors : function(speed, easing, redirect){
			speed = speed || "fast";
			easing = easing || null;
			redirect = (redirect === true || redirect == null) ? true : false;
			$("a").each(function(i){
				var url = $(this).attr("href");
				if(url){
					if(url.indexOf("#") != -1 && url.indexOf("#") == 0){
						var aParts = url.split("#",2);
						var anchor = $("a[name='"+aParts[1]+"']");
						if(anchor){
							$(this).click(function(){
								if($(document).height()-anchor.offset().top >= $(window).height()
								 || anchor.offset().top > $(window).height()
								 || $(document).width()-anchor.offset().left >= $(window).width()
								 || anchor.offset().left > $(window).width()){
									$('html, body').animate({
										scrollTop: anchor.offset().top,
										scrollLeft: anchor.offset().left
									}, speed, easing, function(){
										if(redirect){ 
											window.location = url 
										}
									});
								}
								return false;
							});
						}
					}
				}
			});
		}
	});
})(jQuery);
/*este es de la las opciones de coufon pa mis h no se cuantos*/
 jQuery(function() {
 
            jQuery('a.click').click(function() {              
				jQuery("").attr("id");
				Cufon.replace('h1, h2, h3, h5, h6');
         });
    });
	
  jQuery(function() {
  Cufon.replace('h1, h2, h3, h5, h6');
  });
  /**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de / klaus.hartl@stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function(name, value, options) {
	if (typeof value != 'undefined') { // name and value given, set cookie
		options = options || {};
		if (value === null) {
			value = '';
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
		}
		// CAUTION: Needed to parenthesize options.path and options.domain
		// in the following expressions, otherwise they evaluate to undefined
		// in the packed version for some reason...
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
		document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
	} else { // only name given, get cookie
		var cookieValue = null;
		if (document.cookie && document.cookie != '') {
			var cookies = document.cookie.split(';');
			for (var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '=')) {
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};
/*esta es la el movientos chachi del menu y el submenu de los servicio*/
jQuery(document).ready(function() {
	jQuery('a.nudge').hover(function() { //mouse in
		jQuery(this).animate({ paddingTop: '6px' }, 400);
	}, function() { //mouse out
		jQuery(this).animate({ paddingTop: '0px' }, 400);
	});
	jQuery('#centercolumn').center(); // esta es la linea q pongo para el easing de la web al centro
});
jQuery(document).ready(function() {
	jQuery('#contenedor_menu_superior ul li ul li a').hover(function() { //mouse in
		jQuery(this).animate({ paddingRight: '40px' }, 400);
	}, function() { //mouse out
		jQuery(this).animate({ paddingRight: '21px' }, 400);
	});
});
 /**
 * zudolab jqStyleswitcher
 *
 * @version    1
 * @copyright    (c)2008 Takeshi Takatsudo (http://zudolab.net/)
 * @license    MIT (http://www.opensource.org/licenses/mit-license.php)
 * original idea of this script is "styleswitcher.js" by Paul Sowden (http://www.alistapart.com/articles/alternate/)
 */
(function($){

	Styleswitcher = function()
	{
		this.linkElemSets = [];
		this.prepareElems();
		this.enableLastCSSFromCookie();
		this.setUnloadEvents();
	}
	Styleswitcher.prototype.prepareElems = function()
	{
		var links = $("link[rel*=style][title]");
		var sets = [];
		for(var i=0,link; link=links[i]; i++){
			sets.push({
				elem: link,
				title: link.title
			});
		}
		this.linkElemSets = sets;
	}
	Styleswitcher.prototype.enableLastCSSFromCookie = function()
	{
		var lastCSSTitle = $.cookie("siteStyle");
		if(!lastCSSTitle) return;
		this.setActiveCSS(lastCSSTitle);
	}
	Styleswitcher.prototype.setActiveCSS = function(requestedTitle)
	{
		var activeLinkElem;
		for(var i=0,link; link=this.linkElemSets[i]; i++){
			link.elem.disabled = true;
			if(requestedTitle==link.elem.title) activeLinkElem = link.elem;
		}
		activeLinkElem.disabled = false;
		$.cookie("siteStyle", activeLinkElem.title, { expires:365,path:"/" });
	}
	Styleswitcher.prototype.getActiveCSSTitle = function()
	{
		for(var i=0,link; link=this.linkElemSets[i]; i++){
			if(!link.elem.disabled) return link.title;
		}
		return null;
	}
	Styleswitcher.prototype.setUnloadEvents = function()
	{
		var self = this;
		$(document).unload(function(){
			var activeCSSTitle = self.getActiveCSSTitle();
			$.cookie("siteStyle", activeCSSTitle, { expires:365,path:"/" });
		});
	}
	
})(jQuery);
var styleswitcher = new Styleswitcher;
/*aqui lo que permite que una capa sea clicable*/
  jQuery(document).ready(function(){
   var block = jQuery("#caja, #caja1, #caja2, #caja3, #caja4");
   block.click(function(){
      window.location = jQuery(this).find("a:first").attr("href")
   });
   block.addClass("clickable");
   block.hover(function(){
      window.status = jQuery(this).find("a:first").attr("href")
   }, function(){
      window.status = ""
   })
});
/*aqui el la orden que activa el web_lado_derecho move*/
        jQuery(function() {
            var offset = jQuery("#web_lado_derecho").offset();
            var topPadding = 15;
            jQuery(window).scroll(function() {
                if (jQuery(window).scrollTop() > offset.top) {
                    jQuery("#web_lado_derecho").stop().animate({
                        marginTop: jQuery(window).scrollTop() - offset.top + topPadding
                    });
                } else {
                    jQuery("#web_lado_derecho").stop().animate({
                        marginTop: 0
                    });
                };
            });
        });


/* ---------------------------------------------
expandAll v.1.3.8
http://www.adipalaz.com/experiments/jquery/expand.html
Requires: jQuery v1.3+
Copyright (c) 2009 Adriana Palazova
Dual licensed under the MIT (http://www.adipalaz.com/docs/mit-license.txt) and GPL (http://www.adipalaz.com/docs/gpl-license.txt) licenses
------------------------------------------------ */
(function($) {
$.fn.expandAll = function(options) {
    var o = $.extend({}, $.fn.expandAll.defaults, options);   
    
    return this.each(function(index) {
        var $$ = $(this), $referent, $sw, $cllps, $tr, container, toggleTxt, toggleClass;
               
        // --- functions:
       (o.switchPosition == 'before') ? ($.fn.findSibling = $.fn.prev, $.fn.insrt = $.fn.before) : ($.fn.findSibling = $.fn.next, $.fn.insrt = $.fn.after);
                    
        // --- var container 
        if (this.id.length) { container = '#' + this.id;
        } else if (this.className.length) { container = this.tagName.toLowerCase() + '.' + this.className.split(' ').join('.');
        } else { container = this.tagName.toLowerCase();}
        
        // --- var $referent
        if (o.ref && $$.find(o.ref).length) {
          (o.switchPosition == 'before') ? $referent = $$.find("'" + o.ref + ":first'") : $referent = $$.find("'" + o.ref + ":last'");
        } else { return; }
        
        // end the script if the length of the collapsible element isn't long enough.  
        if (o.cllpsLength && $$.closest(container).find(o.cllpsEl).text().length < o.cllpsLength) {$$.closest(container).find(o.cllpsEl).addClass('dont_touch'); return;}
    
        // --- if expandAll() claims initial state = hidden:
        (o.initTxt == 'show') ? (toggleTxt = o.expTxt, toggleClass='') : (toggleTxt = o.cllpsTxt, toggleClass='open');
        if (o.state == 'hidden') { 
          $$.find(o.cllpsEl + ':not(.shown, .dont_touch)').hide().findSibling().find('> a.open').removeClass('open'); 
        } else {
          $$.find(o.cllpsEl).show().findSibling().find('> a').addClass('open'); 
        }
        
        (o.oneSwitch) ? ($referent.insrt('<p class="switch"><a href="#" class="' + toggleClass + '">' + toggleTxt + '</a></p>')) :
          ($referent.insrt('<p class="switch"><a href="#" class="">' + o.expTxt + '</a>&nbsp;|&nbsp;<a href="#" class="open">' + o.cllpsTxt + '</a></p>'));

        // --- var $sw, $cllps, $tr :
        $sw = $referent.findSibling('p').find('a');
        $cllps = $$.closest(container).find(o.cllpsEl).not('.dont_touch');
        $tr = (o.trigger) ? $$.closest(container).find(o.trigger + ' > a') : $$.closest(container).find('.expand > a');
                
        if (o.child) {
          $$.find(o.cllpsEl + '.shown').show().findSibling().find('> a').addClass('open').text(o.cllpsTxt);
          window.$vrbls = { kt1 : o.expTxt, kt2 : o.cllpsTxt };
        }

        var scrollElem;
        (typeof scrollableElement == 'function') ? (scrollElem = scrollableElement('html', 'body')) : (scrollElem = 'html, body');
        
        $sw.click(function() {
            var $switch = $(this),
                $c = $switch.closest(container).find(o.cllpsEl +':first'),
                cOffset = $c.offset().top;
            if (o.parent) {
              var $swChildren = $switch.parent().nextAll().children('p.switch').find('a');
                  kidTxt1 = $vrbls.kt1, kidTxt2 = $vrbls.kt2,
                  kidTxt = ($switch.text() == o.expTxt) ? kidTxt2 : kidTxt1;
              $swChildren.text(kidTxt);
              if ($switch.text() == o.expTxt) {$swChildren.addClass('open');} else {$swChildren.removeClass('open');}
            }
            if ($switch.text() == o.expTxt) {
              if (o.oneSwitch) {$switch.text(o.cllpsTxt).attr('class', 'open');}
              $tr.addClass('open');
              $cllps[o.showMethod](o.speed);
            } else {
              if (o.oneSwitch) {$switch.text(o.expTxt).attr('class', '');}
              $tr.removeClass('open');
              if (o.speed == 0 || o.instantHide) {$cllps.hide();} else {$cllps[o.hideMethod](o.speed);}
              if (o.scroll && cOffset < $(window).scrollTop()) {$(scrollElem).animate({scrollTop: cOffset},600);}
          }
          return false;
        });
        /* -----------------------------------------------
        To save file size, feel free to remove the following code if you don't use the option: 'localLinks: true'
        -------------------------------------------------- */
        if (o.localLinks) { 
          var localLink = $(container).find(o.localLinks);
          if (localLink.length) {
            // based on http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links:
            $(localLink).click(function() {
              var $target = $(this.hash);
              $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
              if ($target.length) {
                var tOffset = $target.offset().top;
                $(scrollElem).animate({scrollTop: tOffset},600);
                return false;
              }
            });
          }
        }
        /* -----------------------------------------------
        Feel free to remove the following function if you don't use the options: 'localLinks: true' or 'scroll: true'
        -------------------------------------------------- */
        //http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links:
        function scrollableElement(els) {
          for (var i = 0, argLength = arguments.length; i < argLength; i++) {
            var el = arguments[i],
                $scrollElement = $(el);
            if ($scrollElement.scrollTop() > 0) {
              return el;
            } else {
              $scrollElement.scrollTop(1);
              var isScrollable = $scrollElement.scrollTop() > 0;
              $scrollElement.scrollTop(0);
              if (isScrollable) {
                return el;
              }
            }
          };
          return [];
        }; 
      /* --- end of the optional code --- */
});};
$.fn.expandAll.defaults = {
        state : 'hidden', // If 'hidden', the collapsible elements are hidden by default, else they are expanded by default 
        initTxt : 'show', // 'show' - if the initial text of the switch is for expanding, 'hide' - if the initial text of the switch is for collapsing
        expTxt : '[Expand All]', // the text of the switch for expanding
        cllpsTxt : '[Collapse All]', // the text of the switch for collapsing
        oneSwitch : true, // true or false - whether both [Expand All] and [Collapse All] are shown, or they swap
        ref : '.expand', // the switch 'Expand All/Collapse All' is inserted in regards to the element specified by 'ref'
        switchPosition: 'before', //'before' or 'after' - specifies the position of the switch 'Expand All/Collapse All' - before or after the collapsible element
        scroll : false, // false or true. If true, the switch 'Expand All/Collapse All' will be dinamically repositioned to remain in view when the collapsible element closes
        showMethod : 'slideDown', // 'show', 'slideDown', 'fadeIn', or custom
        hideMethod : 'slideUp', // 'hide', 'slideUp', 'fadeOut', or custom
        speed : 600, // the speed of the animation in m.s. or 'slow', 'normal', 'fast'
        cllpsEl : '.collapse', // the collapsible element
        trigger : '.expand', // if expandAll() is used in conjunction with toggle() - the elements that contain the trigger of the toggle effect on the individual collapsible sections
        localLinks : null, // null or the selector of the same-page links to which we will apply a smooth-scroll function, e.g. 'a.to_top'
        parent : false, // true, false
        child : false, // true, false
        cllpsLength : null, //null, {Number}. If {Number} (e.g. cllpsLength: 200) - if the number of characters inside the "collapsible element" is less than the given {Number}, the element will be visible all the time
        instantHide : false // {true} fixes hiding content inside hidden elements
};

/* ---------------------------------------------
Toggler - http://www.adipalaz.com/experiments/jquery/expand.html
When using this script, please keep the above url intact.
*** Feel free to remove the Toggler script if you need only the plugin expandAll().
------------------------------------------------ */
$.fn.toggler = function(options) {
    var o = $.extend({}, $.fn.toggler.defaults, options);
    
    var $this = $(this);
    $this.wrapInner('<a style="display:block" href="#" title="Expand/Collapse" />');
    if (o.initShow) {$(o.initShow).addClass('shown');}
    $this.next(o.cllpsEl + ':not(.shown)').hide();
    return this.each(function() {
      var container;
      (o.container) ? container = o.container : container = 'html';
      if ($this.next('div.shown').length) { $this.closest(container).find('.shown').show().prev().find('a').addClass('open'); }
      $(this).click(function() {
        $(this).find('a').toggleClass('open').end().next(o.cllpsEl)[o.method](o.speed);
        return false;
    });
});};
$.fn.toggler.defaults = {
     cllpsEl : 'div.collapse',
     method : 'slideToggle',
     speed : 'slow',
     container : '', //the common container of all groups with collapsible content (optional)
     initShow : '.shown' //the initially expanded sections (optional)
};
/* ---------------------------------------------
Feel free to remove any of the following functions if you don't need it.
------------------------------------------------ */
$.fn.toggleHeight = function(speed, easing, callback) {
    return this.animate({height: 'toggle'}, speed, easing, callback);
};
//http://www.learningjquery.com/2008/02/simple-effects-plugins:
$.fn.fadeToggle = function(speed, easing, callback) {
    return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
$.fn.slideFadeToggle = function(speed, easing, callback) {
    return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};
/* --- end of the optional code --- */
})(jQuery);
