function wowarmoryWindow(server, playername){
  window.open('http://www.wowarmory.com/character-sheet.xml?r=' + server + '&n=' + playername ,'wowarmory')
}

$(function(){
    $('.rounded').corners();
    $('a.hideLeft').click(function(){
        $('td.menuLeft').hide("fast");
        $('td.menuLeft').css("display", "none");
    });
    $('a.showLeft').click(function(){
       $('td.menuLeft').css("display", "");
       $('td.menuLeft').show("fast");
    });
    $('a.hideRight').click(function(){
        $('td.menuRight').hide("fast");
        $('td.menuRight').css("display", "none");
    });
    $('a.showRight').click(function(){
        $('td.menuRight').css("display", "");
        $('td.menuRight').show("fast");
    });
    
    $('#set1 *').tooltip();
    
    
    //$('sub.playerLootIcon').tooltip();
    
   $('#slide_holder').agile_carousel({
    first_last_buttons: "yes",
      hover_next_prev_buttons: "yes",
      next_prev_buttons: "yes",
      slide_buttons: "yes",
      pause_button: "yes",
      slide_captions: "Easily track in-game data|Simple, copy &amp; paste into LC|Raid data|Attendance Management| Need a Happy Ending TOO? :-)", 
      slide_directory: "images/carousel2",
      slide_links: ",,,http://www.lootcouncil.com/guildData.php?demo=yes,http://www.lootcouncil.com/gettingStarted.php",
      slide_number_display: "yes",
      timer_length: "14000",
    transition_duration: 2500,
    transition_easing: "easeOutCubic",	
      transition_type: "carousel",
    water_mark: "no"
	 });
   
    var div = $('.sc_menu'),
    ul = $('table.sc_menu'),
    ulPadding = 15;
    var divWidth = div.width();
    var headerWidth = $("table.sc_menu").width();
    div.css({overflow: 'hidden'});
    var lastLi = ul.find('td:last-child');
    div.mousemove(function(e){
      var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
      var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
      div.scrollLeft(left);
    });
    
    $("input.emailVerify").blur(function(){
       $(this).next().css("display","inline");
       $.getJSON("/ajax/verify.php?email=" + $(this).val(),
        function(data){
          var found = data.found;
          var html = data.html;
          $("div.errorNotices").html( html );
        });
    });
    $("input.usernameVerify").blur(function(){
       $(this).next().css("display","inline");
       $.getJSON("/ajax/verify.php?username=" + $(this).val(),
        function(data){
          var found = data.found;
          var html = data.html;
          $("input.usernameVerify").next().html( html );
        });
    });
    
    $("input.password2").blur(function(){
      $(this).next().css("display","inline");
      var pass1 = $(this).val();
      var pass2 = $("input.password").val();
      if(pass1 == pass2){
        $(this).next().html( "OK: Passwords match" );
      }else{
        $(this).next().html( "Error: Passwords do not match" );
      }
    });
    $("input.guildServer").keyup(function(){
        $(this).next().removeClass();
        $(this).next().addClass("notificationList");
       $(this).next().css("display","inline");
       $.getJSON("/ajax/verify.php?servername=" + $(this).val(),
        function(data){
          var found = data.found;
          var html = data.html;
          $("input.guildServer").next().html( html );
        });
    });
    $("input.guildServer").blur(function(){
       $(this).next().removeClass();
        $(this).next().addClass("notification");
        $(this).next().css("display","inline");
       $.getJSON("/ajax/verify.php?servernameverify=" + $(this).val(),
        function(data){
          var found = data.found;
          var html = data.html;
          $("input.guildServer").next().html( html );
        });
    });
    $("li.guildServer").live('mouseover', function(event){
      $("li.guildServer").css("border-bottom","0");
      $(this).css("border-bottom","1px solid #003366");
      $("input.guildServer").val($(this).html());
    });
    
    $("input.guildName").keyup(function(){
        $(this).next().removeClass();
        $(this).next().addClass("notificationList");
       $(this).next().css("display","inline");
       $.getJSON("/ajax/verify.php?guildname=" + $(this).val(),
        function(data){
          var found = data.found;
          var html = data.html;
          $("input.guildName").next().html( html );
        });
    });
    $("input.guildName").blur(function(){
       $(this).next().removeClass();
        $(this).next().addClass("notification");
        $(this).next().css("display","inline");
       $.getJSON("/ajax/verify.php?guildnameverify=" + $(this).val(),
        function(data){
          var found = data.found;
          var html = data.html;
          $("input.guildName").next().html( html );
        });
    });
    $("input.guildPasscode").blur(function(){
        $(this).next().css("display","inline");
       $.getJSON("/ajax/verify.php?passcode=" + $(this).val() + "&guildName=" +  $("input.guildName").val() + "&guildServer=" +  $("input.guildServer").val(),
        function(data){
          var found = data.found;
          var html = data.html;
          var players = data.players;
          $("input.guildPasscode").next().html( html );
          $("#playerList").html(players);
        });
    });
    $("li.collapse h4").click(function(){
        $("li.collapse div").hide("slow");
        $(this).siblings().show("fast");
    },
    function(){
      
    });
    $("div.statContainer div.playerHeading").click(function(){
    		$("div.statContent").hide("slow");
        $(this).siblings().show("fast");
    },function(){
    	
    });
    $("div.gettingStarted div.heading").click(function(){
    		$("div.gettingStarted div.content").hide("slow");
        $(this).siblings().show("fast");
    },function(){
    	
    });
    
    
    
    
    $("div.quickViewGraph div.heading").click(function(){
    		$("div.quickViewGraph div.content").css("display","none");
        
        switch ($(this).attr("id")){
        case "heading1":
          $("#graph1").fadeIn( "slow" );
          break;
        case "heading2":
          $("#graph2").fadeIn( "slow" );
          break;
        case "heading3":
          $("#graph3").fadeIn( "slow" );
          break;
        case "heading4":
          $("#graph4").fadeIn( "slow" );
          break;
        case "heading5":
          $("#graph5").fadeIn( "slow" );
          break;
        case "heading6":
          $("#graph6").fadeIn( "slow" );
          break;
        case "heading7":
          $("#graph7").fadeIn( "slow" );
          break;
        case "heading8":
          $("#graph8").fadeIn( "slow" );
          break;
        case "heading9":
          $("#graph9").fadeIn( "slow" );
          break;
          
        }
    },function(){
    	
    });
    
    
	$("div.overviewClickable").click(function(){
	var playerID = $(this).children("input.playerID").val();
	var raidID = $(this).children("input.raidID").val();
	$("div.playerDetails div.statContentDetail").load("<img src='/images/ajax_loader.gif' alt='Fetching data, please wait.'>");
	$("div.playerDetails div.statContentDetail").load("/ajax/playerRaidDetail.php?playerID=" + playerID + "&raidID=" + raidID);
	
	},function(){
	
	});
	$('div.ajax-loaded').live('mouseover', function(event){
	//alert($(this).attr("title"));
	if( $(this).attr("title") != ""){
	}
	$(this).tooltip();
	$("#tooltip").css("display","block");
	});
	
	$("#eventStartDateTime").keypress(function(){
	//alert($(this).val());
	});
	$("#eventEndDateTime").keypress(function(){
	//alert($(this).val());
	});
	
	$("input.deletePlayer").click(function(){
	if( $(this).is(":checked") ){
            $(this).parent().fadeTo("slow", 0.2);
          }else{
            $(this).parent().fadeTo("slow", 1.0);
          }
	});
	
	
$("#searchInput").keyup(function(){
  $.getJSON("/ajax/search.php?criteria=" + $(this).val(),
  function(data){
    var html = data.html;
    $("#searchInputResult").html( html );
    $("#searchInputResult").show( "fast" );
  });
});
$("#searchInput").blur(function(){
  var now = new Date();
  while( (now + 500) > Date()){
    //we're in zzz land.
  }
  $("#searchInputResult").hide( "slow" );
});
$("#searchInput").focus(function(){
   if($(this).val() != ""){
     $("#searchInputResult").show( "fast" );
   }
});



$("div.quickViewGraph div.content").hide("fast");
$("#graph1").fadeIn( "slow" );



});
