// general.js
// This file is automatically included by javascript_include_tag :defaults

$(document).ready(function(){ 
  if ( $(window).width() < 1035 ) {
   $(".fdbk_tab_left").css("visibility","hidden");	
}
});



$(window).bind('resize', function() {
	var width = $(window).width();
    if ( width < 1035 ) {
     $(".fdbk_tab_left").css("visibility","hidden");	
	}
	else {
	 $(".fdbk_tab_left").css("visibility","visible");
	}
});




function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;

    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}


function prepareInputs() {			
   $("#term").focus ( function() {
        if ($("#term").attr("value") == "what are you looking for?") {
            $("#term").attr("value", "");	
        }        
  });
	

   $("#term").blur ( function() {
        if ($("#term").attr("value") == "") {
            $("#term").attr("value", "what are you looking for?");	
        }        
  });

   $("#search-submit").click ( function() {
       if ($("#term").attr("value") == "what are you looking for?") {
            $("#term").attr("value","");

  }
});

}

function showShare(links) {
 $('#'+links).css("display","block");
 }        

function showHide(links) {
 $('#'+links).css("display","none");
 }





		function changeLocation(date) {
			year = date.getFullYear();
			month = date.getMonth() + 1;
			day = date.getDate();
			if (month < 10) {
				month = "0" + month;
			}
			if (day < 10) {
				day = "0" + day;
			}
			location.href = '/7-Events/ads?q=' + year + '-' + month + '-' + day;
		}

		function findCookie(val){
			   var cookie = null;
			   var findVal = val + "=";
			   var dc = document.cookie;
		       if (dc.length > 0)
			{
		          var start = dc.indexOf(findVal);
		          if (start >= 0)
				{
		             		start += findVal.length;
		             		lastVal = dc.indexOf(";", start);
		             		if (lastVal == -1)
						{
		                			lastVal = dc.length;
					 	}
		             		cookie = (dc.substring(start, lastVal));
		          	}
			  else
			  	{
					return cookie;
			  	}
		       	}
		       return cookie;
		}


	function loadLight() {
	var exstatus = findCookie("exstatus")	
	if (exstatus == null ) {
	 tb_show(null,"/introducing-ajcexchange?TB_iframe=true&height=440&width=820&modal=true",null);
    setCookie();
	}
	}


	function setCookie()
	{
	var now = new Date();
	var expdate = new Date(now.getTime() + 900 * 24 * 60 * 60 * 1000);
	document.cookie = "exstatus = yes;expires="+expdate.toGMTString() +";path=/";

	}	

	function fbs_click(page,desc) { 
	window.open('http://www.facebook.com/sharer.php?u='+page+'&t='+desc,'sharer','toolbar=0,status=0,width=626,height=436');return false;}
	
	function fadeFlash() {
		$("#flash_notice").fadeOut(6500);
		
	}
	
	function showRemind() {
		$("#remind-photo").slideDown("slow");
		
	}

function fadeDibs() {
	  $("#dibs-list").css("visibility","visible");
}

function showDibs() {
	  $(".featured-ads-top").css("visibility","visible");
}


addLoadEvent(prepareInputs);
addLoadEvent(fadeFlash);
addLoadEvent(fadeDibs);
addLoadEvent(showDibs);

function popWin(url,name,size)
	{	var win = open(url,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400px,height=400px,left=100,top=100');
    	win.focus();
	}

  function fblogout(){
		FB.Connect.logoutAndRedirect("/");
	}
