// JavaScript Document

 $(document).ready(function() {

			

            $(".dropdown dt a").click(function() {

                $(".dropdown dd ul").slideToggle('medium');

            });

                        

            $(".dropdown dd ul li a").click(function() {

                var text = $(this).html();

                $(".dropdown dt a span").html(text);

                $(".dropdown dd ul").hide();

                $("#result").html("Selected value is: " + getSelectedValue("sample"));

            });

                        

            function getSelectedValue(id) {

                return $("#" + id).find("dt a span.value").html();

            }

 

            $(document).bind('click', function(e) {

                var $clicked = $(e.target);

                if (! $clicked.parents().hasClass("dropdown"))

                    $(".dropdown dd ul").hide();

            });

 

 

            $("#flagSwitcher").click(function() {

                $(".dropdown img.flag").toggleClass("flagvisibility");

            });

			

			$(window).scroll(function () {  

				if ($(this).scrollTop() != 0) {  

					$('#toTop').fadeIn();  

				} else {  

					$('#toTop').fadeOut();  

				}  

			});  

			$('#toTop').click(function () {  

				$('body,html').animate({  

					scrollTop: 0  

				},  

				800);  

			}); 
			
			
			$('.PLN').click(function () {  

				$('body,html').animate({ scrollTop: $('#plans').position().top}, 800);}); 

			$('#container').tabs();

			$('fieldset legend > a, .fieldset .legend > a').live('click',function(event)
{$(this).toggleFieldsetOpen();event.preventDefault();});
			

			$.fn.toggleFieldsetOpen=function()
				{this.each(function()
				{$(this).closest('fieldset, .fieldset').toggleClass('collapsed');});return this;};
				
			

});

 function buscarNuevoAjax()

	{

		var xmlhttp=false;

 		try 

		{

 			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

 		} catch (e) 

		{

 			try {

 				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

 			} catch (E) 

			{

 				xmlhttp = false;

 			}

  		}

		if (!xmlhttp && typeof XMLHttpRequest!='undefined') 

		{

 			xmlhttp = new XMLHttpRequest();

		}

		return xmlhttp;

	}

			

function setUpNavigationBehavior() {

	//process the main navigation
	// Content tabs:
	
	$('#mainNavigation ul li:first-child a').addClass('navCurrent'); // Add .current to the first class
		$('.content-box .tab_content').hide(); // Hide all .tab-content divs
		$('.content-box .tab_content:first-child').show(); // Show default tabs
	
		$('#mainNavigation ul li a').click(function() {
			$(this).parent().siblings().find("a").removeClass('navCurrent'); // Remove .current from all tabs
			$(this).addClass('navCurrent'); // Set tab to current
			var tabcontent = $(this).attr('href'); // Get link to requested tab
			$(tabcontent).siblings().hide(); // Hide all other .tab-content divs
			$(tabcontent).show(); // Show content div
			return false;
		});

}

function delNavActive() {

	$('#mainNavigation li a').each(function() {

		$(this).removeClass('navCurrent');

	});

}

/* *********************************************************************
 * Menus
 * *********************************************************************/
function InitMenuEffects () {
    $('.menu li').hover(function () {
        			$(this).find('ul:first').css({'visibility': 'visible', 'display': 'none'}).slideDown();
    }, function () {
        $(this).find('ul:first').css({visibility: "hidden"});

    });
    
    // Look for active element
    indexStart = 1;
    $('#iconbar li').each( function(index) { 
            if ($(this).hasClass('active')) 
                indexStart = index;
    });
    // Initialize carousel plugin
    $('#iconbar').jcarousel({
        start:          indexStart,
        scroll:         7,
        buttonPrevHTML: '<span>&lt;</span>',
        buttonNextHTML: '<span>&gt;</span>',
        initCallback:   function (instance, state) {}
    });    
    instance = $('#iconbar').data('jcarousel')
    // Roll on active element
    if (indexStart >= 7) {
        if (!$.browser.webkit) {
            list = $('#iconbar .jcarousel-list');  
            number = list.css('left');
            list.css({'left': 0});
            list.delay(500).animate({left: '+=' + number}, 750, function () {});
        }
    }

}
