// JavaScript Document
$(".voting_button").live("click", function() {
var winid = $(this).attr("rel");
var tpe = $(this).attr("rel2");
var offset = $(this).offset();
if($.cookie('tname'))	{
 $.ajax({
   type: "POST",
   url: "func/voter.php",
   data: "winid="+winid+"&tpe="+tpe,
   datatype: "html",
   success: function(html){
   $.jGrowl(html);
   }
 });		
	
	} else {
var htmcontent = '<p align="left">Enter your Twitter username to cast your vote. Your Twitter username is not shown and voting is completely anonymous.</p><br /><input type="textfield" id="tname" name="tname" size="35"/><br /><input class="votebutton" name="votebutton" id="votebutton" type="button" value="Cast My Vote" /><input name="cancel" class="cancelvote" type="button"  value="Cancel Vote"/>';
$("#centerdiv").css("position","absolute").css("top",offset.top+$(this).height());
$("#centerdiv").show('slow', function() {
$("#centerdiv_content").html(htmcontent);
$(".cancelvote").click(function() { $("#centerdiv").hide("slow");});
$(".votebutton").click(function() {
var tn = $("#tname").val();
$.ajax({
   type: "POST",
   url: "func/voter.php",
   data: "tname="+tn+"&winid="+winid+"&tpe="+tpe,
   datatype: "html",
   success: function(html){
     $.jGrowl(html);
	 $("#centerdiv").hide("slow");
		
   }
 });			})	})
	
	}});	

function hunkjax(target, element, param) {
 $.ajax({
   type: "POST",
   url: target,
   data: param,
   success: function(html){
     $(element).append(html);
   }
 });	
}

$(document).ready(function()
{
    //-------------------------------------------------------
    /*shows the loading div every time we have an Ajax call*/
    $(".loading").bind("ajaxSend", function(){
           $(this).show();
     }).bind("ajaxComplete", function(){
           $(this).hide();
     });
     //-------------------------------------------------------
}) 
$(document).ready(function() {
 $(".tabclick").click(function() {
     var con = $(this).attr("rel");
	 var tar = $(this).attr("ur");
	 var act = $(con).children("ul");
	 var par = $(this).attr("pa");
	  if($(con).is(":hidden")) {
	 if($(".hidecon").is(":visible")) {
		 $(".hidecon:visible").slideUp("slow",
		function(){
			 $(act).empty();
			$(con).slideDown("slow",
						function() {
						hunkjax(tar, act, par);
								});	});
	  } else {
		  $(act).empty();
		  $(con).slideDown("slow", function() {hunkjax(tar, act, par);});}
	  } else if($(con).is(":visible")) {
		$(con).slideUp("slow");
	  }

	 	   });
  
 });

Shadowbox.init({
    players:    ["iframe"]
});

function checknom()  {
$.ajax({
   type: "POST",
   url: "func/base.php",
   dataType: "json",
   success: function(response){
var comeback = response;	   
if(comeback > "100") {
$.ajax({
type: "POST",
url: "func/nominate_write.php",
success: function(response){
var writeresult = response;
if(writeresult > 0) {
$.jGrowl("<strong>There were "+writeresult+" updates. You should refresh.</strong>", {sticky: true});
}}

	   });
}
   }
 });						   }

$(document).ready(function() {
checknom();
setInterval("checknom()", 360000)
});
$(document).ready(function() {		
$('.undermenu').hover(function() {
$('.under').toggle();					  
							  
	}, function() {							  
$('.under').toggle();					
					});	 });	
$(document).ready(function() {
$(".winner_profile").click(function() {
		 
var user = $(this).attr("rel");
var offset = $(this).offset();
$("#winner_container").css("position","absolute").css("top",offset.top+$(this).height());
$("#winner_container").show("slow", function() { $.ajax({
   type: "POST",
   url: "func/winner_profile.php",
   data: "user="+user,
   success: function(html){
     $("#winner_body").html(html);
   }
 });}	);
							  return false; });
$("#container_close").click(function () {
$("#winner_body").empty();									  
$("#winner_container").hide("slow");						  
									  });
						   });
$(document).ready(function() {
$(".voting_buttons").live("click", function() {
var winid = $(this).attr("rel");
var tpe = $(this).attr("rel2");
var offset = $(this).offset();
if($.cookie('tname'))	{
 $.ajax({
   type: "POST",
   url: "func/voter.php",
   data: "winid="+winid+"&tpe="+tpe,
   datatype: "html",
   success: function(html){
   $.jGrowl(html);
   }
 });		
	
	} else {
var htmcontent = '<p align="left">Enter your Twitter username to cast your vote. Your Twitter username is not shown and voting is completely anonymous.</p><br /><input type="textfield" id="tname" name="tname" size="35"/><br /><input class="votebutton" name="votebutton" id="votebutton" type="button" value="Cast My Vote" /><input name="cancel" class="cancelvote" type="button"  value="Cancel Vote"/>';
$("#centerdiv").css("position","absolute").css("top",offset.top+$(this).height());
$("#centerdiv").show('slow', function() {
$("#centerdiv_content").html(htmcontent);
$(".cancelvote").click(function() { $("#centerdiv").hide("slow");});
$(".votebutton").click(function() {
var tn = $("#tname").val();
$.ajax({
   type: "POST",
   url: "func/voter.php",
   data: "tname="+tn+"&winid="+winid+"&tpe="+tpe,
   datatype: "html",
   success: function(html){
     $.jGrowl(html);
	 $("#centerdiv").hide("slow");
		
   }
 });			})	})
	
	}});});
$(document).ready(function() {
});
$(document).ready(function() {
$("#go").click(function () {
var postname = $("#s").val();						 
 $.ajax({
   type: "POST",
   url: "func/winners.php",
   data: "name="+postname,
   datatype: "html",
   success: function(html){
   $("#winnerlist").html(html);
   }
 });								 
						 });
						   });
$(document).ready(function() {
$("#filler").remove();						   
						   });
$(document).ready(function() {
  $(".tip").hover(
      function () {
var offset = $(this).offset();
var ur = $(this).attr("rel");
$("#info_container").css("position","absolute").css("top",offset.top+$(this).height());
$("#info_container").show("slow", function() { $.ajax({
   type: "POST",
   url: "func/"+ur+".php",
   success: function(html){
     $("#info_body").html(html);
   }
 });}	);
      }, 
      function () {
$("#info_body").empty();									  
$("#info_container").hide("slow");
      }
    );  });