// 8/3/11 11:59 pm

$(function() {
	// Load typekit fonts
	try{Typekit.load();}catch(e){}
  
	// Input box default text
/*	var default_search = 'Begin Your Search Here';
	$("input#search").focus(function() {
		if ($(this).val() == default_search) {
			$(this).val("");
		}
	});
	
	$("input#search").blur(function() {
		if ($(this).val() == "") {
			$(this).val(default_search);
		}
	});
    
	$("input#search").blur(); 

	// Input box autocomplete
	$('input#search').autocomplete({
		position: {
			offset: '-49 0'
		},
		source:['travel','india','china','europe','japan','south america','venezuela', 'dubai']
	});
*/
	// Lightboxes
	//$('a[rel="#lightbox"]').overlay();

	// Slideshow
	$(".slidetabs").tabs(".images > div", {
		effect: 'fade',
		fadeOutSpeed: "slow",
		rotate: true
	});
	//$('.slidetabs').data('slideshow').play();

	/* Photo gallery
	$(".scrollable").scrollable();

	$(".items img").click(function() {
		if ($(this).hasClass("active")) { return; }
		var url = $(this).attr("src").replace("_t", "");
		var wrap = $("#image_wrap").fadeTo("medium", 0.5);
		var img = new Image();

		img.onload = function() {
			wrap.fadeTo("fast", 1);
			wrap.find("img").attr("src", url);
		};

		img.src = url;
		$(".items img").removeClass("active");
		$(this).addClass("active");
	}).filter(":first").click();
  */

  // Stars
  $("#rating-stars:not[.view-rating]").stars({
    inputType: "select",
    showTitles: true,
    disabled: false,
    disableValue: false
  });

  $(".view-rating").stars({
    inputType: "select",
    disabled: true
  });

/*
	// Amb Notification Message on Dashboard
	$('#notification .notification_close').click(function() {
		$(this).parent().siblings('#bangor').fadeOut();
		$(this).parent().parent().fadeTo('slow', 0, function() {
			$(this).slideUp('slow', function() {
				$(this).remove();
			});
		});
		return false;
	});

	// Dashboard Items
	$('#dashboard_items .close').click(function() {
		$(this).parent().fadeTo('slow', 0, function() {
			$(this).slideUp('slow', function() {
				var id = $(this).parent().attr('id');
				var section = '#dashboard_sections #link_' + id + ' .count';
				var section_val = $(section).html();
				var selected = '#dashboard_selected #link_' + id + ' .count';
				$(section).html(section_val - 1);
				$(selected).html(section_val - 1);
				$(this).remove();
			});
		}).pngFix({blankgif: 'blank.gif'});
		return false;
	});

	$('#dashboard_sections > div > div').click(function() {
		// Fix for IE because it doesn't handle typekit correctly
		if ($.browser.msie && parseInt($.browser.version) < 9) {
			$(this).parent().slideUp('slow', function() {
				$(this).siblings().each(function() {
					$(this).slideDown(function() { });
				});
			});
		} else {
			$(this).parent().fadeTo('slow', 0, function(){
				$(this).slideUp('slow', function() {
					$(this).siblings(':hidden').each(function() {
						$(this).slideDown(function() {
							$(this).fadeTo('slow', 100);
						});
					});
				});
			});
		}

    // KE
    $('#dashboard_settings > span').hide();
		var new_selection = '#dashboard_settings [rel="#' + $(this).attr('id') + '"]';
		$(new_selection).show();
    // End KE


		$('#dashboard_selected > div').fadeOut('slow').delay(1000);
		var new_selection = '#dashboard_selected #' + $(this).attr('id');
		$(new_selection).fadeIn('slow');

		// Fix for IE because it doesn't handle typekit correctly
		if ($.browser.msie && parseInt($.browser.version) < 9) {
			$('#dashboard_items ul.rows:visible').slideUp('slow').hide();

			var new_list = $(this).attr('id');
			new_list = '#dashboard_items #' + new_list.substr(5);
			$(new_list).slideDown('slow').show();;
		} else {
			$('#dashboard_items ul.rows:visible').fadeTo('slow', 0, function() {
				$(this).slideUp('slow');
			});

			var new_list = $(this).attr('id');
			new_list = '#dashboard_items #' + new_list.substr(5);
			$(new_list).slideDown(function() {
				$(this).fadeTo('slow', 100);
			});
		}
	});

	// 'Been Here' button
	$('.wbh .me a').toggle(function() {
		$(this).addClass('active');
	},function() {
		$(this).removeClass('active');
	});
*/
	// Categories
	$('#categories div').hover(function() {
		$(this).children('.title,.count').addClass('up');
	}, function() {
		$(this).children('.title,.count').removeClass('up');
	});
/*
	// Delete all
	$('#dashboard_settings #delete_all').click(function() {
		$(this).parent().parent().children('ul:visible').each(function() {
			var id = $(this).attr('id');
			var section = '#dashboard_sections #link_' + id + ' .count';
			var section_val = $(section).html();
			var selected = '#dashboard_selected #link_' + id + ' .count';
			$(section).html(0);
			$(selected).html(0);

			$(this).children('li').each(function() {
				$(this).fadeTo('slow', 0, function() {
					$(this).parent().slideUp('slow', 0, function() {
						$(this).children().remove();
					});
				});
			});
		});

		return false;
	});
	*/
	
	$('a[href*=pleaseLogin]').attr('rel','#blocked');
	$.youplanet.overlay.bind('#signup');
	$.youplanet.overlay.bind('a[rel=#lightbox]');
});

function reloadReviewList(aurl)
{
  $.ajax({
    url: aurl,
    success: function (data) {
      jQuery('#review-partner-ajax-list').html(data);
      $("#review-partner-ajax-list .view-rating").stars({
        inputType: "select",
        disabled: true
      });
      $.youplanet.overlay.bind('#review-partner-ajax-list a[rel=#lightbox]');
     
    }
  });
}
