//foodie common jquery code
var $jq = jQuery.noConflict();
$jq(document).ready(function(){
    var currUrl = location.pathname + location.search;
    
	$jq('label').labelOver('over-apply');
	
	//$jq('.bicontainer li').mouseover(function() {$jq(this).addClass("over");}).mouseout(function() {$jq(this).removeClass("over");});
	//$jq('td.ctext').expander({slicePoint:150});
	YAHOO.namespace("foodie.container");
	/**
	if($jq('a.nearby').size() > 0){
    	$jq('#showNeighborhood,#showNearByCities').cluetip({
               local:true,
               hideLocal: true,
               width: 550,
               height: 'auto',
               cursor: 'pointer',
               cluetipClass: 'foodie',
               titleAttribute:   'title',
               showTitle: true,
               arrows: false,
               dropShadow: true,
               sticky: true,
               hoverIntent: true,
               activation: 'click',
	  		   closePosition: 'title',
               closeText: '<img src="/img/close.gif"/>'});

	
		if($jq('#showNeighborhood').size() == 1){
			$jq('a.nearByNeighborhoods').click(function(){
				var displayName = $jq(this).attr("title");
				$jq('input[type=text][name=loc]').attr("value",displayName);
				$jq('input[type=hidden][name=rad]').attr("value","5");
				$jq('#cluetip-close').click();
				return false;
			});
		}
		if($jq('#showNearByCities').size() == 1){
	   	   $jq('a.nearByCities').click(function(){
				var displayName = $jq(this).attr("title");
				$jq('input[type=hidden][name=rad]').attr("value","20");
				$jq('input[type=text][name=loc]').attr("value",displayName);
				$jq('#cluetip-close').click();
				return false;
		   });
		}
	}
	**/
		
	//login redirects to current page
	if($jq('a.login').size()>0){
		if(currUrl.length > 1){
			$jq('a.login').attr("href","/webloginreq"+currUrl);
		}
	}

	if($jq('a.cluetip').size() > 0){	  
	  $jq('a.cluetip').cluetip({
	  	local:true, 
	  	width:200,
	  	cursor: 'pointer',
	  	cluetipClass: 'foodie',
	  	dropShadow: false,
	  	showTitle: false, 
	  	hoverIntent: true,
	  	mouseOutClose:true});
	}
	if ($jq('a.sharetip').size() > 0) {
			$jq('a.sharetip').cluetip({
				cluetipClass : 'foodie',
				local : true,
				width : 300,
				cursor : 'pointer',
				showTitle : false,
				hoverIntent : true,
				mouseOutClose : true,
			  	hoverIntent: {sensitivity:  3,interval: 50,timeout: 0},
				closePosition: 'title',
  			  	closeText: '<img src="/img/close.gif"/>'
			});
	}
	if($jq('a.srt').size() > 0){
			$jq('a.srt').cluetip({
			  local:true, 
			  hideLocal: true, 
			  width:200,
			  hoverClass: 'over',
			  cursor: 'pointer',
			  cluetipClass: 'foodie',
			  sticky: true,
			  mouseOutClose: true,
			  titleAttribute:   'title',
			  showTitle: true,
			  arrows: false,
			  closePosition: 'title',
  			  closeText: '<img src="/img/close.gif"/>',
  			  positionBy:'mouse'
			});
	}

	$jq.easing.easeOutQuart = function (x, t, b, c, d) {return -c * ((t=t/d-1)*t*t*t - 1) + b;};

		
	var bindMoreLikeThis = function(mlt) {
		$jq.ajax({
			url : mlt.attr("id"),
			type : "POST",
			dataType : "html",
			global : false,
			cache : true,
			success : function(data, textStatus) {
				mlt.html(data);
				//bindSpecials(mlt);
			}
		});
	}
	
	if($jq("div.morelikethis").size() > 0){
   	  bindMoreLikeThis($jq("div.morelikethis"));
	}
	
	$jq("#searchtabs li").click(function(){
	    if(!$jq(this).hasClass("current")){
			var type = $jq(this).attr("id");
			$jq(this).toggleClass("current");
			$jq(this).siblings("li").toggleClass("current");
			$jq("input[name='t'][type='hidden']").val(type);
			if(type == 'restaurant'){
				$jq("label[for='q']").html(" Restaurant Name or Cuisine");
				$jq("#search-tag-line").html("Find Menus by Restaurant Name or Cuisine");
				$jq("#fsearchmsg").html("");
			}else{
				$jq("label[for='q']").html(" Menu Item Name or Ingredient");
				$jq("#search-tag-line").html("Find Menu Items by Name or Ingredient (e.g. tandoori shrimp)");
				$jq("#fsearchmsg").html("");
			}
		}
	});
	
	$jq('.subarea h3').toggle(
	 function () {
	    $jq(this).siblings("ul").show();
	  },
	  function () {
	    $jq(this).siblings("ul").hide();
	  }
	);
	
	$jq('.subarea ul').hide();
	//$jq(".searchwrapper").show();	
	//$jq('#locationBlock ul').summarize({summaryElements: 12,expandText:'more &#187;',collapseText:'&#171; less', expandClass:'moreExpand', collapseClass:'lessCollapse'});
});