/*
COLOR PALATTE

F2D93D- yellow
F2B83D - rust orange
E3364F - red orange
A30A0D - Very Red
5C0D26 - maroon
D44F75 - dark pink
4582A1 - ocean blue
1C8C99 - teal
A8C9D9 - baby blue
7ACC9C - light green
5C8F70 - olive green
008033 - dark green
430E61 - purple
5B5959 - slate

*/
var colors = [
    '#F2D93D',
    '#F2B83D',
    '#E3364F',
    '#A30A0D',
    '#5C0D26',
    '#D44F75',
    '#4582A1',
    '#1C8C99',
    '#7ACC9C',
    '#5C8F70',
    '#008033',
    '#430E61'
];


/**
 * Returns a random number between min and max
 */
function getRandomArbitary (min, max) {
    return Math.random() * (max - min) + min;
}

/**
 * Returns a random integer between min and max
 * Using Math.round() will give you a non-uniform distribution!
 */
function getRandomInt (min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

// global if exists plugin
jQuery.fn.exists = function(){return jQuery(this).length>0;}
// show body
function chShowBody(){
    $('body').hide().css({visibility:'visible'});
    $('body').fadeIn('fast');
}
$(document).ready(function() {

    chShowBody();
    //timeline editing
    if ($('#timeline-entry').exists()){
        $.getScript('/javascripts/filter.js');
        $.getScript('/javascripts/entry.js');
    }

    //timeline poll
    if ($('#time-line-container').exists()){
        $.getScript('/javascripts/timeline.js');
    }
    //timeline explorers
    if ($('#main').exists()){
    $.getScript('/javascripts/scrollto.js');
    $.getScript('/javascripts/application.js');
  }

    // // region (distributors page)
    // $('#q_region').change(function(){
    //     if($(this).val()!=""){
    //         document.location.href='/distributors?q=' + escape($(this).val());
    //     }
    // });

    // faq accordion
    if ($('#accordion-faq').exists()){
        $("#accordion-faq").accordion({
            clearStyle: true,
            autoHeight: false
        });

    }
    // forms
    $('#btn-sign-in').click(function(){
        document.forms[0].submit();
    });
    window.setInterval(hide_flash, 10000);

    function hide_flash(){
        $('.success_flash,.notice_flash').slideUp('slow');
    }

    $('a#start_exploring').click(function(){
        $('form:first').submit();
    });
    $('a#submit-btn').click(function(){
        $('form:first').submit();
    });
    // end forms

  $("td > input").keypress(function(e)
  {
          // if the key pressed is the enter key
          if (e.which == 13)
          {
                $('form:first').submit();
          }
  });

  $('#right-nav a').click(function(){
    $('#right-nav a').removeClass('active');
    $(this).addClass('active');
    var l = $(this).attr('href')
    $('.pure-spirit-content').stop().fadeOut(600);
    $(l).delay(700).fadeIn('fast');
    return false;
  });

  $('.pure-spirit-content').eq(0).delay(900).fadeIn('fast');



});

