//<-----------------vars ------------------>


//<-----------------Menu Functions------------------>
var Flipmenu=function(container){
	this.initialize=function(){
		this.container=$("#"+container);
	this.container.addClass("flipmenu");
	this.readLinks();
	};
	this.readLinks=function(){
		var self=this;
		this.container.find("a").each(function(i,el){
			self.render(i,el);
				});
	};
	this.render=function(inx,link){
		$(link).wrap('<div class=\"flipmenu_box\"></div>');
		$(link).addClass(($(link).hasClass('active'))?'flipmenu_link_active':'flipmenu_link');
		var parent=$(link).parent();
		parent.css({
				   width:(link.offsetWidth)+"px",height:link.offsetHeight+"px"
				   });
		var clone=$(link).clone();
		clone.removeClass("flipmenu_link");
		clone.addClass("flipmenu_link_over").css({
												 top:link.offsetHeight+"px",left:"0px"
												 });
		parent.append(clone);
		$(parent).bind("mouseenter",this,this.onMouseEnter);
		$(parent).bind("mouseleave",this,this.onMouseLeave);
	};
	this.onMouseEnter=function(event){
		var first=$(this.firstChild);
		if(first.hasClass("active")) return;
		var second=first.next();
		first.animate({top:"-"+first.outerHeight()},150);
		second.animate({top:"0"},150);}
	this.onMouseLeave=function(event){
		var first=$(this.firstChild);
		if(first.hasClass("active")) return;
		var second=first.next();first.stop().animate({top:"0"},150);second.stop().animate({top:$(this).outerHeight()},150);}
	this.initialize();}
//<--------------- End Menu Functionn -------------->
//<-----------------Move Arrow Function------------------>
	function move_my_arrow (affected,xposition){
		$(affected).animate({"left": xposition},'slow', function() {
  		});
	}
//<-------------  End Move Arrow Function  --------------->
 $(document).ready(function(){
				
				
			
				$('HTML').addClass('JS');  
                new Flipmenu('flip_menu');
				location.href='#home.html';
	
				
			/*	var url_param = window.location.href;
				var aQueryString = url_param.split("#");
				if((aQueryString[1] == undefined) || (aQueryString[1] == "")){
				location.href='#home.html';
				}*/
            });
	 function detectar_ie (){
		 if ($.browser.msie){
			return true;
			 }else {
			return false;
				 };
		 };
//<-------------  Funcion Que carga el contenido   --------------->
jQuery(document).ready(function($) {
        function load(num) {
			$('#content').load(num,function(response, status, xhr) {
		 // alert(status);
		 $("#content").hide();
		 switch (status)
				{
				case 'success':
 					$("#content").fadeIn('normal');
 				break;
				case 'error':
  				 var msg = "Ups, parace que hubo un error: ";
  		 		 $("#content").html(msg + xhr.status + " " + xhr.statusText);
				 $("#content").fadeIn('normal');
  				break;
				default:
 				var msg = "Cargando...";
  		 		$("#content").html(msg);
				$("#content").fadeIn('normal');
}
		});
        }
        $.history.init(function(url) {
                load(url == "" ? "1" : url);
				switch (url)
				{
				case 'home.html':
 				move_my_arrow('#arrow','345');
 				break;
				case 'instrucciones.html':
  				move_my_arrow('#arrow','415');
  				break;
				case 'tipos.html':
  				move_my_arrow('#arrow','515');
  				break;
				case 'faq.html':
  				move_my_arrow('#arrow','595');
  				break;
				default:
  				move_my_arrow('#arrow','345');
				}
            });
        $('#ajax-links a').live('click', function(e) {
                var url = $(this).attr('href');
                url = url.replace(/^.*#/, '');
                $.history.load(url);
                return false;
            });
    });

jQuery.fn.center = function () {
	
	
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;

}

