// JavaScript Document
$(function(){
		   
		   	
	
		
		//load all dynamic elements
$.ajax({ type : "GET", url : "index.php", data : { wt_action : "users_online"}, success : function(response){ $("#wt_users_online").html(response); }});
//$.ajax({ type : "GET", url : "index.php", data : { wt_action : "count_all_wyncc"}, success : function(response){ $("#wt_count_all_wyncc").html(response); }});
//$.ajax({ type : "GET", url : "index.php", data : { wt_action : "the_barslinger"}, success : function(response){ $("#wt_the_barslinger").html(response); }});
$.ajax({ type : "GET", url : "index.php", data : { wt_action : "the_weekly_hotty"}, success : function(response){ $("#wt_the_weekly_hotty").html(response); }});
$.ajax({ type : "GET", url : "index.php", data : { wt_action : "the_winefact"}, success : function(response){ $("#wt_the_winefact").html(response); }});
		
		
wt_offset_range=0;
		   
		   
		   
		   $("#load_more_news").click(function(){
		
		wt_offset_range++;
		$("#load_more_news").text("loading").attr("id","busy_loading");

		$.ajax({ 
		type : "GET", 
		url : "index.php", 
		data : { wt_action : "more_latest_news", wt_range: wt_offset_range, wt_cat: wt_cur_cat}, 
			success : function(response){ 
			$("#wt_more_news_"+wt_offset_range).html(response); 
			$("#busy_loading").text("view more").attr("id","load_more_news");
			
			}
			});
		});
		
		

		$("#cutshort").click(function(){
			thelinklink = $("#linktocut").val();
			thelinklink = thelinklink.replace("&", "%26")
			$("#linktocut").val('crunching your link ....').attr("disabled", true).css("background-color", "#fef5cc");
			$.ajax({
			  url: "/api.php?action=chop&url="+thelinklink,
			  cache: false,
			  success: function(html){
				$("#linktocut").val(html).removeAttr("disabled").css("background-color", "#ffffff");
			  }
			});
		});
		
		$("#pressbox_follow_button").click(function(){
			$("#pressbox_signup_box").slideToggle();
		});
		
		
		
		$(".example5").colorbox({initialWidth:"300px", initialHeight:"200px"});
		//$(".example5").nyroModal();
		$(".pop_outside").colorbox({iframe:true, initialWidth:"630px", initialHeight:"500px", innerWidth:630, innerHeight:500});
		
		
		$("#pressbox_dropdown").change(function() { 
		 window.location.replace($("#pressbox_dropdown").val());
		 });
	
		$('#pressbox_dropdown').hover(function() {
		  $(this).addClass('presslist_on');
		}, function() {
		  $(this).removeClass('presslist_on');
		  $(this).addClass('presslist_off');

		});
		
		$("#big_top_pic").mouseover(function(){
			$('#director_box').show();
		});
		
		$("#big_top_pic").mouseout(function(){
			$('#director_box').hide();
		});

		$("#director_box").mouseover(function(){
			$(this).show();
	
		});
	
//hidehead
$(window).bind('scrollstart', function(){
        $('.navigation_box').css("top",'-63px');
		 $('#network').css("border-bottom",'1px solid #ccc');
		 $('.showheadtop').fadeIn();
		 $('.network_logo').fadeIn();
		 
    })


	$(window).bind('scroll', function(){
	if($(window).scrollTop() == 0){
		$('.navigation_box').css("top",'30px');
		$('#network').css("border-bottom",'none');
		$('.showheadtop').fadeOut();
		$('.network_logo').fadeOut();
		
	}
	
	if($(window).scrollTop() > 100){
		$('#sf-menu').fadeOut();
		$('#gtop').css("border-bottom","3px solid #DCEDF7");
	}
	
	if($(window).scrollTop() < 100){
		$('#sf-menu').fadeIn();
		$('#gtop').css("border-bottom","none");

	}
		
		});
	
	
	 $(document).mousemove(function(e){
		
		scollp = $(window).scrollTop();
	
									
  if(scollp > 100){
		 
 //e.pageX
		
		$("#gtop").hover(
  function () {
    $('#sf-menu').show();
  }, 
  function () {
    $('#sf-menu').hide();
  });
	
	$("#header").hover(
  function () {
    $('#sf-menu').show();
  }, 
  function () {
    $('#sf-menu').hide();
  });
	 }
	
  });
	
	
	$('.showheadtop').click(function() {
			
				$('.navigation_box').css("top",'30px');	
				$('#network').css("border-bottom",'none');
				$('#gtop').css("border-bottom","none");
				$('.showheadtop').fadeOut();
				$('#sf-menu').fadeIn();
				
											 
		});
	
		   
		   })
