var j = $.noConflict();

j(function() {
    // setup ul.tabs to work as tabs for each div directly under div.panes
    j("ul.tabs").tabs("div.panes > div");
});

$(function(){
	$(".tooltip-bottom").tipTip({maxWidth: "auto", edgeOffset: 10, defaultPosition: "bottom"});
	$(".tooltip-right").tipTip({maxWidth: "auto", edgeOffset: 10, defaultPosition: "right"});
	
	$( "input:submit, a, button", ".demo" ).button();
	
	$( "#accordion" ).accordion({
			fillSpace: true
	});


	$( "#dialog" ).dialog({
			resizable: false,
			height:340,
			width: 340,
			autoOpen: false,
			modal: true,
			buttons: {
				'Close': function() {
					$( this ).dialog( "close" );
				},
                'Go to My Account': function() {
					$( this ).dialog( "close" );
                    window.location = "myaccount";
				}
			}
	});

    $( "#dialog-confirm" ).dialog({
  			resizable: false,
            height:340,
            width: 340,
            autoOpen: false,
  			modal: true,
  			buttons: {
  				Error: function() {
  					$( this ).dialog( "close" );

  				}
  			}
  		});

    function init(){
        var nDay, b, a, diffms;
        b = new Date();
        a = new Date(b.getFullYear(), b.getMonth(), b.getDate(), b.getHours(), 0 + (Math.floor(( b.getMinutes() / 5) + 1 ) * 5), 0, 0);
        diffms = a.getTime() - b.getTime();

        nDay = new Date(b.getFullYear(), b.getMonth(), b.getDate(), b.getHours(), b.getMinutes(), b.getSeconds(), b.getMilliseconds() + diffms);
        return nDay;
    }

    $('#energyTimerGlobal').countdown({
            until: init(),
            onExpiry: function() {
                $(this).countdown('change', {until: init()});
                   var e = $("#ecurrent");
                   var tmp = e.html();
                   if ( tmp <= $("#emax").html() ){
                       //Do nothing.
                   } else {
                       e.html(Number(tmp) + 1);
                   }
            },
            layout: '{mn}:{snn}'
    });
		
	//Controls the Slider Object Animations and Transitions.
	$('.slider').advancedSlider({width:620, height:345, skin: 'curved-rounded-2', scrollbarSkin: 'scrollbar-3-light', effectType:'fade', horizontalSlices: 6, verticalSlices: 3, fadeNavigationButtons: true,
		 thumbnailsType: 'none', thumbnailSync: true, visibleThumbnails: 4, fadeThumbnailArrows: true, thumbnailButtons: true, fadeThumbnailButtons: true,
		 thumbnailScrollbar: false, fadeThumbnailScrollbar: true,
		 slideProperties:{
			 0: {captionHideEffect: 'fade', captionShowEffect: 'fade',captionHeight: 180, captionSize: 50},
			 1: {captionHideEffect: 'fade', captionShowEffect: 'fade', captionHeight: 180, captionSize: 50},
			 2: {captionHideEffect: 'fade', captionShowEffect: 'fade',captionHeight: 180, captionSize: 50},
			 3: {captionHideEffect: 'fade', captionShowEffect: 'fade',captionHeight: 180, captionSize: 50}
		 }
	});
	
    var oTable = $('#example').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "aaSorting": [[ 6, "desc" ]],
                "iDisplayLength": 50,
                "bLengthChange": false

    });

    var oTableNews = $('#exampleNews').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "aaSorting": [[ 3, "desc" ]],
                "iDisplayLength": 10,
                "bLengthChange": false,
                "fnDrawCallback": function () {
                   $("* td.col3, th.col3").hide();
                }


    });


    var oTable1 = $('#example1').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "iDisplayLength": 25,
                "bLengthChange": false


    });

    var oTable2 = $('#example2').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "aaSorting": [[ 5, "desc" ]],
                "fnDrawCallback": function () {
                   $("* td.col3, th.col3").hide();
                }
    });

    var oTable3 = $('#example3').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "bLengthChange": false,
                "iDisplayLength": 5,
                "fnDrawCallback": function () {
                   $("* td.col3, th.col3").hide();
                }
    });

    var oTable4 = $('#example4').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "bLengthChange": false,
                "iDisplayLength": 5,
                "fnDrawCallback": function () {
                   $("* td.col3, th.col3").hide();
                }
    });

    var oTable5 = $('#example5').dataTable({
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                "bLengthChange": false
    });


    $('body').contextMenu('myMenu1', {

          bindings: {

            'caf': function(t) {

                window.location = "createfighter";

            },

            'signin': function(t) {

              window.location = "signin";

            },

            'account': function(t) {

                window.location = "myaccount";

            },

            'strat': function(t) {

                window.location = "strats";

            },

            'bag': function(t) {

                window.location = "items";

            },

            'notes': function(t) {

                window.location = "notes";

            },

            'messages': function(t) {

                window.location = "messages";

            },

            'rules': function(t) {

                window.location = "rules";

            },

            'contact': function(t) {

                window.location = "contact";

            },

            'signout': function(t) {

                window.location = "signout";

            }

          }

        });

        $('#example-1').sticklr({
            animate     : true,
            showOn		: 'hover',
            size        : 16,
            relativeTo  : 'center',
            stickTo     : 'left'
        });

        $("#fighter-quick-lookup").click(function(){
            var firstname = $("#qfirstname").val();
            var lastname = $("#qlastname").val();

            window.location = "fighters?fname="+firstname+"&lname="+lastname;
            return false;
        });





});



  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28765002-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



