// tabs - jQuery plugin for accessible, unobtrusive tabs by Klaus Hartl
// v 1.2
// http://stilbuero.de/tabs/
// Free beer and free speech. Enjoy!
$.fn.tabs = function(options) {
    // basic stuff
    var ON_CLASS = 'on';
    var OFF_CLASS = 'tabs-hide';
    // options
    var on = options && options.on && (typeof options.on == 'number' && options.on > 0) ? options.on - 1 : 0;
    return this.each(function() {
        var re = /([_\-\w]+$)/i;
        // retrieve active tab from hash in url
        if (location.hash) {
            var hashId = location.hash.replace('#', '');
            $(this).find('>ul>li>a').each(function(i) {
                if (re.exec(this.href)[1] == hashId) {
                    on = i;
                    var unFocus = function() { // required to not scroll to fragment
                        scrollTo(0, 0);
                    }
                    // be nice to IE via Conditional Compilation
                    // this needs to preceed call to unFocus for other browsers
                    /*@cc_on
                    //location.replace('#'); // required to not scroll to fragment
                    setTimeout(unFocus, 150); // IE needs a little timeout here
                    @*/
                    unFocus();
                    setTimeout(unFocus, 100); // be nice to Opera
                }
            });
        }
        $(this).find('>div').not(':eq(' + on + ')').addClass(OFF_CLASS);
        $(this).find('>ul>li:eq(' + on + ')').addClass(ON_CLASS);
        var container = this;
        var undefined;
        $(this).find('>ul>li>a').click(function() {
            if (!$(this.parentNode).is('.' + ON_CLASS)) {
                var target = $('#' + re.exec(this.href)[1]);
                if (target.size() > 0) {
                    var self = this;
                    var visible = $(container).find('>div:visible');
                    if (options && options.slide && options.fade) {
                        visible.animate({height: 'hide', opacity: 'hide'}, options.slide, function() {
                            // TODO check accessibility for fade
                            //$(this).addClass(OFF_CLASS).css({display: '', height: 'auto'}); // retain acccessibility for print and other media types
                            $(container).find('>ul>li').removeClass(ON_CLASS);
                            $(self.parentNode).addClass(ON_CLASS);
                            //target.css('display', 'none').removeClass(OFF_CLASS).animate({height: 'show', opacity: 'show'}, options.slide);
                            target.animate({height: 'show', opacity: 'show'}, options.slide);
                        });
                    } else if (options && options.slide) {
                        visible.slideUp(options.slide, function() {
                            //$(this).addClass(OFF_CLASS).css({display: '', height: 'auto'}); // retain acccessibility for print and other media types
                            $(container).find('>ul>li').removeClass(ON_CLASS);
                            $(self.parentNode).addClass(ON_CLASS);
                            //target.css('display', 'none').removeClass(OFF_CLASS).slideDown(options.slide);
                            target.slideDown(options.slide);
                        });
                    } else if (options && options.fade) {
                        visible.fadeOut(options.fade, function() {
                            // TODO check accessibility for fade
                            //$(this).addClass(OFF_CLASS).css({display: '', opacity: '1'}); // retain acccessibility for print and other media types
                            $(container).find('>ul>li').removeClass(ON_CLASS);
                            $(self.parentNode).addClass(ON_CLASS);
                            //target.css('display', 'none').removeClass(OFF_CLASS).fadeIn(options.fade);
                            target.fadeIn(options.fade);
                        });
                    } else {
                        visible.addClass(OFF_CLASS);
                        $(container).find('>ul>li').removeClass(ON_CLASS);
                        $(this.parentNode).addClass(ON_CLASS);
                        target.removeClass(OFF_CLASS);
                    }
                } else {
                    alert('There is no such container.');
                }
            }
            return false;
        });
    });
};

// start the activetab function

function activateTab(i) {
    $('#container-1>ul>li:eq(' + (i - 1) + ')').find('a').trigger('click');
}

$(document).ready(function() {
    $('#container-1').tabs();
    $('#container-2').tabs({on: 2});
    $('#container-3').tabs({slide: 'normal'});
    $('#container-4').tabs({fade: 'normal'});
    $('#container-5').tabs({slide: 'normal', fade: 'normal'});
    $('#trigger-tab').before('<p><a href="#" onclick="activateTab(3); return false;">Activate third tab</a></p>');
});


// code-lindley show-hide
/*
$(document).ready(function() {
	$("a").toggle(function() {
		$(".stuff").hide('fast');
	}, function() {
		$(".stuff").show('fast');
	});
});	$('#age-limit').click( function() { $('.age-update').toggle('fast'); }); $('#promotion').click( function() { $('.promotion-update').toggle('fast'); });*/

$(document).ready(function() {	
	$("a.cover1").toggle(function() {	$(".cover-1").show('fast'); }, function() {  $(".cover-1").hide('fast'); }); 
	$("a.cover2").toggle(function() {	$(".cover-2").show('fast'); }, function() {  $(".cover-2").hide('fast'); });
	$("a.cover3").toggle(function() {	$(".cover-3").show('fast'); }, function() { $(".cover-3").hide('fast');	});
	$("a.cover4").toggle(function() {	$(".cover-4").show('fast'); }, function() { $(".cover-4").hide('fast');	});
	$("a.cover5").toggle(function() {	$(".cover-5").show('fast'); }, function() { $(".cover-5").hide('fast');	});
	$("a.cover6").toggle(function() {	$(".cover-6").show('fast'); }, function() { $(".cover-6").hide('fast');	});
	$("a.cover7").toggle(function() {	$(".cover-7").show('fast'); }, function() { $(".cover-7").hide('fast');	});
	$("a.cover8").toggle(function() {	$(".cover-8").show('fast'); }, function() { $(".cover-8").hide('fast');	});
	$("a.cover9").toggle(function() {	$(".cover-9").show('fast'); }, function() { $(".cover-9").hide('fast');	});
	$("a.cover10").toggle(function() {	$(".cover-10").show('fast'); }, function() { $(".cover-10").hide('fast');	});
	$("a.cover11").toggle(function() {	$(".cover-11").show('fast'); }, function() { $(".cover-11").hide('fast');	});
	$("a.cover12").toggle(function() {	$(".cover-12").show('fast'); }, function() { $(".cover-12").hide('fast');	});
	$("a.cover13").toggle(function() {	$(".cover-13").show('fast'); }, function() { $(".cover-13").hide('fast');	});
	$("a.cover14").toggle(function() {	$(".cover-14").show('fast'); }, function() { $(".cover-14").hide('fast');	});
	$("a.cover15").toggle(function() {	$(".cover-15").show('fast'); }, function() { $(".cover-15").hide('fast');	});
	$("a.cover16").toggle(function() {	$(".cover-16").show('fast'); }, function() { $(".cover-16").hide('fast');	});
	$("a.cover17").toggle(function() {	$(".cover-17").show('fast'); }, function() { $(".cover-17").hide('fast');	});
	$("a.cover18").toggle(function() {	$(".cover-18").show('fast'); }, function() { $(".cover-18").hide('fast');	});
	$("a.cover19").toggle(function() {	$(".cover-19").show('fast'); }, function() { $(".cover-19").hide('fast');	});
	$("a.cover20").toggle(function() {	$(".cover-20").show('fast'); }, function() { $(".cover-20").hide('fast');	});
	$("a.cover21").toggle(function() {	$(".cover-21").show('fast'); }, function() { $(".cover-21").hide('fast');	});
	$("a.cover22").toggle(function() {	$(".cover-22").show('fast'); }, function() { $(".cover-22").hide('fast');	});
	$("a.cover23").toggle(function() {	$(".cover-23").show('fast'); }, function() { $(".cover-23").hide('fast');	});
	$(".cover24").toggle(function() {	$(".cover-24").show('fast'); }, function() { $(".cover-24").hide('fast');	});
	$(".cover25").toggle(function() {	$(".cover-25").show('fast'); }, function() { $(".cover-25").hide('fast');	});
	$(".cover26").toggle(function() {	$(".cover-26").show('fast'); }, function() { $(".cover-26").hide('fast');	});
	$(".cover27").toggle(function() {	$(".cover-27").show('fast'); }, function() { $(".cover-27").hide('fast');	});
	$(".cover28").toggle(function() {	$(".cover-28").show('fast'); }, function() { $(".cover-28").hide('fast');	});
	$(".cover29").toggle(function() {	$(".cover-29").show('fast'); }, function() { $(".cover-29").hide('fast');	});
	$(".cover30").toggle(function() {	$(".cover-30").show('fast'); }, function() { $(".cover-30").hide('fast');	});
	$(".cover31").toggle(function() {	$(".cover-31").show('fast'); }, function() { $(".cover-31").hide('fast');	});
	$(".cover32").toggle(function() {	$(".cover-32").show('fast'); }, function() { $(".cover-32").hide('fast');	});
	$(".cover33").toggle(function() {	$(".cover-33").show('fast'); }, function() { $(".cover-33").hide('fast');	});
	$(".cover34").toggle(function() {	$(".cover-34").show('fast'); }, function() { $(".cover-34").hide('fast');	});
	$(".cover35").toggle(function() {	$(".cover-35").show('fast'); }, function() { $(".cover-35").hide('fast');	});
	$(".cover36").toggle(function() {	$(".cover-36").show('fast'); }, function() { $(".cover-36").hide('fast');	});
	$(".cover37").toggle(function() {	$(".cover-37").show('fast'); }, function() { $(".cover-37").hide('fast');	});
	$(".cover38").toggle(function() {	$(".cover-38").show('fast'); }, function() { $(".cover-38").hide('fast');	});
	$(".cover39").toggle(function() {	$(".cover-39").show('fast'); }, function() { $(".cover-39").hide('fast');	});	
	
	$('#age-limit').click( function() { $('.age-update').toggle(); });
	$('#promotion').click( function() { $('.promotion-update').toggle(); });
	$('#destkey0').click( function() { $('.quote-worldwide').toggle('fast'); });
	$('#destkey1').click( function() { $('.quote-europe').toggle('fast'); });
	$('#destkey2').click( function() { $('.quote-uk').toggle('fast'); });
	$('#destkey3').click( function() { $('.quote-pacific').toggle('fast'); });
	$('#destkey4').click( function() { $('.quote-spacific').toggle('fast'); });
	$('#destkey5').click( function() { $('.quote-aus').toggle('fast'); });
	$('#destkey6').click( function() { $('.quote-southeastasia').toggle('fast'); });
	
	$('#typekey0').click( function() { $('.quote-single').toggle('fast'); });
	$('#typekey1').click( function() { $('.quote-family').toggle('fast'); });
	
	$('#destkey-pacific').click( function() { $('.quote-pacific').toggle('fast'); });
	$('#destkey-europe').click( function() { $('.quote-europe').toggle('fast'); });
	$('#destkey-world').click( function() { $('.quote-world').toggle('fast'); });
	$('#destkey-ukasia').click( function() { $('.quote-ukasia').toggle('fast'); });
	$('#destkey-southpac').click( function() { $('.quote-southpac').toggle('fast'); });
	$('#destkey-australia').click( function() { $('.quote-australia').toggle('fast'); });
	$('#destkey-newzealand').click( function() { $('.quote-newzealand').toggle('fast'); });
	$('#destkey-southeastasia').click( function() { $('.quote-southeastasia').toggle('fast'); });
	
	$('#typekey-single').click( function() { $('.quote-single').toggle('fast'); });
	$('#typekey-family').click( function() { $('.quote-family').toggle('fast'); });	
});


