//When the DOM tree is loaded
$(document).ready(function() {
  
  var cS = $('#coda-slider-1');
  if (cS.length > 0) {
    cS.codaSlider({
      autoSlide: true,
      autoSlideInterval: 4000,
      autoSlideStopWhenClicked: true
    });
  }
  
  var nM = $('.nyroModal');
  if (nM.length > 0) {
    nM.nyroModal({
       minWidth: 250,
       minHeight: 500
      });
  }
  $(".showReelAds li").click( function() {
    var id = $(this).attr("class");
    //alert(id);
    $(".showReelFullAds").hide();
    $(".listFullAds ." + id).show();
    flowplayer().unload();
  });

  $(".showReelFullAds").hide();
  $(".showReelFullAds:first").show();
  
  var sRFA = $(".showReelFullAds");
  if (sRFA.length > 0) {
   $(".showReelFullAds a[href*=.flv]").flowplayer("/media/assets/flowplayer-3.2.4.swf",{ wmode:'transparent'});
  }

  $(".testimonialAds li").click( function() {
    var id = $(this).attr("class");
    //alert(id);
    $(".testimonial").hide();
    $(".firstshow").hide();
    $(".listFullAds ." + id).show();
    flowplayer().unload();
  });

  $(".testimonial").hide();
  if ($(".firstshow").length == 0) {
    var id = $(".testimonialAds li:first").attr("class");
    $(".listFullAds ." + id).show();
    //$(".testimonial:first").show();
  }
  
  var tA = $(".testimonial");
  if (tA.length > 0) {
    $(".testimonial a[href*=.flv]").flowplayer("/media/assets/flowplayer-3.2.4.swf",{ wmode:'transparent'});
  }
  var fA = $(".firstshow");
  if (fA.length > 0) {
    $(".firstshow a[href*=.flv]").flowplayer("/media/assets/flowplayer-3.2.4.swf",{ wmode:'transparent'});
  }
  
  if($('.cinemalink').length > 0) {
    $('.cinemalink').makeacolumnlists({cols:3,colWidth:200,equalHeight:false,startN:1});
  }
  
  $(".cinemalist tbody tr").click( function() {
    window.location = $(this).find("a").attr("href");
  })
  
  var tAMK = $("#testimonialsAll ul");
  if (tAMK.length > 0) {
    tAMK.makeacolumnlists({cols:3,colWidth:0,equalHeight:false,startN:1});
  }
  
  var dobP = $('.dob_picker');
  if (dobP.length > 0) {
    dobP.datepicker({
      changeMonth: true,
      changeYear: true,
      minDate: "-100Y",
      maxDate: 0,
      dateFormat: 'dd/mm/yy',
      yearRange: 'c-100:c+100'
    });
  }
  // Enable placeholder
  var placeholder = $('input[placeholder], textarea[placeholder]');
  if (placeholder.length > 0)
    placeholder.enablePlaceholder();

  $(".cost_input_old").keydown(function (e) {
    if (e.keyCode == 32) { 
      $(this).val($(this).val()); // append '-' to input
      return false; // return false to prevent space from being added
    }
    if (e.keyCode == 188) {
      $(this).val($(this).val()); // append '-' to input
      return false; // return false to prevent space from being added
    }
  });
  $(".cost_input").keydown(function(event) {
    // Allow: backspace, delete, tab and escape
    if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || 
       // Allow: Ctrl+A
      (event.keyCode == 65 && event.ctrlKey === true) || 
       // Allow: home, end, left, right
      (event.keyCode >= 35 && event.keyCode <= 39)) {
         // let it happen, don't do anything
         return;
    }
    else {
      // Ensure that it is a number and stop the keypress
      if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
        event.preventDefault();
        return false;
      }   
    }
  });
});

function getParameterByName( name, d_value )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return d_value;
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

jQuery(function($) {


});

