$(document).ready(function() { var screenSize = $('body').width(); $('.panel .cap').click(function(){ var content = $(this).parent().find('.content'); var tabs = $(this).parent().find('.tabs'); var accordionWrapper = $(this).parent().find('.accordion-wrapper'); var isOpen = content.is(":visible"); if (!isOpen) { var isOpen = tabs.is(":visible"); } if (!isOpen) { var isOpen = accordionWrapper.is(":visible"); } if (isOpen){ if (screenSize <= 1024){ content.hide(); tabs.hide(); accordionWrapper.hide(); } else { content.slideUp(); tabs.slideUp(); accordionWrapper.slideUp(); } } else { if (screenSize <= 1024){ content.show(); tabs.show(); accordionWrapper.show(); } else { content.slideDown(); tabs.slideDown(); accordionWrapper.slideDown(); } } }); $('.alert-text .close').live('click',function(){ $(this).parents('.alert-wrapper').slideUp(300); return false; }); try { $(".pagesize").chosen(); } catch(e){} //When page loads... $(".tab_content").hide(); //Hide all content //Determine if first tab or passed tab should be active when page loads if (location.hash == "") { $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content } else { var activeTab = location.hash; //Grab hash to determine which tab to make active $('ul.tabs li a[href|="'+activeTab+'"]').parent().addClass("active"); $(activeTab).show(); //Show tab content } //On Click Event $("ul.tabs li a").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).parent().addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).attr("href"); //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); // little extra magic $("a.next_link").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class var activeTab = $(this).attr("href"); $('ul.tabs li a[href|="'+activeTab+'"]').parent().addClass("active"); $(".tab_content").hide(); //Hide all tab content //Find the href attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active ID content return false; }); // On load, show the first panel in each accordion. $('.accordion').each(function(){ $(this).find('.accordion-block').eq(0).addClass('open'); $(this).find('.accordion-block').eq(0).find('.accordion-content').show(); }); $('.accordion-block h3').click(function(){ if($(this).parent().hasClass('open')){ $('.accordion-block .accordion-content').slideUp('fast',function(){ $('.accordion-block').removeClass('open'); }); } else { $('.accordion-block .accordion-content').slideUp('fast'); $(this).parent().find('.accordion-content').slideDown('fast'); $('.accordion-block').removeClass('open'); $(this).parent().addClass('open'); } }); // Add Fancybox lightboxing to each of the images. try { $('.fancybox').fancybox(); } catch(e) {} // On window resize, adjust the sizing. $(window).resize(function(){ setTimeout("resizeChosenWidths()",50); setTimeout("generateGraphs()", 50); }); // Custom file field $('form.styled input[type=file]').each(function(){ $(this).before('Browse...'); }); $('form.styled input[type=file]').animate({'opacity':0},0); $('form.styled input[type=file]').hover(function(){ $(this).parent().find('.browse').addClass('hover'); },function(){ $(this).parent().find('.browse').removeClass('hover'); }); $('form.styled input[type=file]').change(function(){ $(this).parent().find('.file-field').val($(this).val().replace('C:\\fakepath\\','')); }); // "Chosen" field // http://harvesthq.github.com/chosen/ try { $('form.styled').find('.chosen').chosen(); } catch(err){} $('.mobile-navigation').change(function(){ var url = $(this).val(); location.href = url; return false; }); $('a.fancybox').click(function(){ if ( !$(this).hasClass('fancybox') ){ var href = $(this).attr('href'); if (href) { var firstChar = href.substring(0,1); } if (href && href != '#' && firstChar != '#') { location.href = href; return false; } else { return false; } } }); setTimeout("resizeChosenWidths()",50); setTimeout("generateGraphs()", 50); }); function log(str){ if( (window['console'] !== undefined) ){ console.log(str); } } /* CHARTS */ /* -------------------------------------------------------------------- */ function generateGraphs(){ $("table.statics").each(function() { var widthOfParent = $(this).parent().width(); $(this).hide(); $(this).parent().find('.flot-graph').remove(); var colors = []; $(this).find("thead th:not(:first)").each(function() { colors.push($(this).css("color")); }); $(this).graphTable({ series: 'columns', position: 'before', width: widthOfParent, /* width: '1000px', */ height: '200px', colors: colors }, { xaxis: {mode: "time", timeformat: "%d", tickSize: [1, "day"], minTickSize: [1, "day"], position: "bottom", color: "#545454" } }); }); $('.flot-graph').before('
'); function showTooltip(x, y, contents) { $('
' + contents + '
').css({ position: 'absolute', display: 'none', top: y + 5, left: x + 5 }).appendTo("body").fadeIn("fast"); } var previousPoint = null; $(".flot-graph").bind("plothover", function(event, pos, item) { $("#x").text(pos.x); $("#y").text(pos.y); if (item) { if (previousPoint != item.dataIndex) { previousPoint = item.dataIndex; $("#tooltip").remove(); var x = item.datapoint[0], y = item.datapoint[1]; showTooltip(item.pageX, item.pageY, "" + item.series.label + ": " + y); } } else { $("#tooltip").remove(); previousPoint = null; } }); } /* /// END - CHARTS /// */ function resizeChosenWidths(){ $('form.styled').each(function(){ $(this).find('.chzn-container').width('100%'); var containerWidth = $(this).find('.chzn-container').width(); $(this).find('.chzn-drop').width(containerWidth - 2); var searchWidth = $(this).find('.chzn-search').width(); $(this).find('.chzn-search input').width(searchWidth - 26); }); } function draw_messages(msg,type){ var closebutton = 'Close'; if(msg.length > 0){ if($(".alert-text").length > 0){ var alertdiv = $(".alert-text").parents(".alert-wrapper"); // We have an alert already alertdiv.removeClass("confirm error warning info").addClass(type); } else { if($("#vdCrumbs").length > 0){ var element = $("#vdCrumbs").parent("div"); } else { var element = $(document).find(".header-wrap"); } } if(typeof alertdiv != "undefined"){ // Append info to existing div $(".alert-text").html(msg + closebutton).parents(".alert-wrapper").slideDown(300); } else { $('
\
'+ msg + closebutton +'
\
').insertAfter(element); } } }