//<script>//
<!--//
var compliments_loaded = false;
function send_message(dom, to, type) {
	var top = 0;
	var left = 0;
	var send_url = '';
	if (type == 'compliment') {
		send_url = 'inc/sendcompliment.php';
	} else {
		send_url = 'inc/sendmessage.php';
	}
	if ($('#send_friend').length > 0) {
		$('#send_friend').remove();
		return false;
	} else {
		$('body').append('<div id="send_friend"><div style="margin-top: 30px"><center><img src="t/template/img/loading.gif" width="35" height="35" alt="Loading..." /><br/>Loading...</center></div></div>');
		var sEl = $('#send_friend');
		var domPos = $(dom).position();
		var docW = $(document).width();
		var docH = $(dom).height();
		if (domPos.top > docH) {
			top = domPos.top - sEl.height() - 20;
		} else {
			top = domPos.top + docH;
		}
		if (domPos.left + sEl.width() > docW) {
			left = domPos.left + (domPos.left + sEl.width() - docW - 10);
		} else {
			left = domPos.left;
		}
		sEl.css({'top': top, 'left': left});
		sEl.fadeIn();
		$(document).scrollTo(sEl, 'normal', {offset:{left: 0, top: -40}});
		$.ajax({
			type: 'GET',
			url: send_url,
			data: 'to=' + to,
			success: function (result) {
				$('#send_friend').html(result);
			}
		});
	}
	return false;
}

function e_sendmessage(dom, type) {
	var send_url = '';
	if (type == 'compliment') {
		send_url = 'inc/sendcompliment.php';
	} else {
		send_url = 'inc/sendmessage.php';
	}
	$('#message_status').html('<img src="t/template/img/loading.gif" align="left" width="35" height="35" alt="" /><div style="margin-top: 15px">Sending...</div>');
	$(dom).ajaxSubmit({target: '#message_status',
			url: send_url,
			beforeSubmit: function () {
					$(dom).find('input').attr('disabled', true);
					$(dom).find('textarea').attr('disabled', true);
					$(dom).find('select').attr('disabled', true);
			},
			success: function () {
				var result;
				result = $('#message_status').html();
				if (result == '') {
					$('#message_status').html('An error occured while sending your message. Please try again!')
				}
				if (result != 'Message sent!' && result != 'Compliment sent!') {
					$(dom).find('input').attr('disabled', false);
					$(dom).find('textarea').attr('disabled', false);
					$(dom).find('select').attr('disabled', false);
				} else {
					setTimeout(function () { $('#send_friend').fadeOut('normal', function () { $('#send_friend').remove(); }); }, 2000);
				}
			}
	});
	return false;
}

function follow(dom, to) {
	
	$(dom).html('Saving...');
	$.ajax({
		type: 'GET',
		url: 'inc/follow.php',
		data: 'user=' + to,
		success: function (result) {
			$(dom).html(result);
		}
	});
	return false;
}

function review_voting(id, vote, dom) {
	var dp = $(dom).position();
	$('#info-for-vote').remove();
	$('body').append('<div class="sort_options" id="info-for-vote">Saving...</div>');
	$('#info-for-vote').css({'top': $(dom).height() + dp.top, 'left': dp.left}).fadeIn(1000);
	$.ajax({
		type: 'GET',
		url: 'inc/vote.php',
		data: 'review=' + id + '&vote=' + vote,
		success: function (res) {
			jres = $.evalJSON(res);
			if (jres.re == 'error') {
				if (jres.m != '') {
					alert(jres.m);
				}
			} else {
				if (jres.ac == 'add') {
					$(dom).addClass('voted');
				} else {
					$(dom).removeClass('voted');
				}
				$('#vote_' + id + '_' + vote).html('(' + jres.count + ')');
				$('#info-for-vote').fadeOut(100).remove();
			}
		}
	});
	return false;
}

function bookmark(dom) {
	if (dom.href.indexOf('bookmark/') == -1) {
		return true;
	} else {
		var send_data = dom.href.substr(dom.href.indexOf('bookmark/') + 9);
	}
	var top = 0;
	var left = 0;

	if ($('#send_friend').length > 0) {
		$('#send_friend').remove();
	} else {
		$('body').append('<div id="send_friend"><div style="margin-top: 30px"><center><img src="t/template/img/loading.gif" width="35" height="35" alt="Loading..." /><br/>Loading...</center></div></div>');
		var sEl = $('#send_friend');
		var domPos = $(dom).position();
		var docW = $(document).width();
		var docH = $(dom).height();
		if (domPos.top > docH) {
			top = domPos.top - sEl.height() - 20;
		} else {
			top = domPos.top + docH;
		}
		if (domPos.left + sEl.width() > docW) {
			left = docW -sEl.width() - 30;
		} else {
			left = domPos.left;
		}
		sEl.css({'top': top, 'left': left});
		sEl.fadeIn();
		$(document).scrollTo(sEl, 'normal', {offset:{left: 0, top: -40}});
		$.ajax({
			type: 'GET',
			url: 'inc/bookmark.php',
			data: send_data,
			success: function (result) {
				$('#send_friend').html(result);
			}
		});
	}
	return false;
}

function e_bookmark(dom, id) {
	$('#message_status').html('<img src="t/template/img/loading.gif" align="left" width="35" height="35" alt="" /><div style="margin-top: 15px">Sending...</div>');
	$(dom).ajaxSubmit({target: '#bookmark-info',
			url: 'inc/bookmark.php',
			beforeSubmit: function () {
					$(dom).find('input').attr('disabled', true);
					$(dom).find('textarea').attr('disabled', true);
					$(dom).find('select').attr('disabled', true);
			},
			success: function () {
				var result;
				result = $('#bookmark-info').html();
				if (result == '') {
					$('#bookmark-info').html('An error occured while updating your bookmark. Please try again!')
				}
				if (result != 'Bookmark updated!') {
					$(dom).find('input').attr('disabled', false);
					$(dom).find('textarea').attr('disabled', false);
					$(dom).find('select').attr('disabled', false);
				} else {
					if (id != '' && id != undefined) {
						$('#' + id + ' .bookmark-label-msg').html($(dom).find('select').val());
						if ($(dom).find('textarea').val() == '') {
							$('#' + id + ' .bookmark-note-tr').fadeOut(200);
						} else {
							$('#' + id + ' .bookmark-note-msg').html($(dom).find('textarea').val());
							$('#' + id + ' .bookmark-note-tr').fadeIn(200);
						}
					}
					setTimeout(function () { $('#send_friend').fadeOut('normal', function () { $('#send_friend').remove(); }); }, 2000);
				}
			}
	});
	return false;
}

function bind_compliments() {
	$('.compliments_radio').click(function () {
		$('#compliments_body').val($('#cnt' + this.id).html());
	});
	$('#compliments_body').bind('keyup', function () {
		$('.compliments_radio').unbind('click');
	});
}

function show_options(dom) {
	var o = dom.id;
	var pos = $(dom).position();
	if ($('#' + o + '_opts').is(':hidden')) {
		$('.' + o + '_so').hide();
		if ($(document).width() < pos.left + $('#' + o + '_opts').width()) {
			pos.left = pos.left - ($(document).width() - pos.left + $('#' + o + '_opts').width());
		}
		$('#' + o + '_opts').css({'top': pos.top + $(dom).height(), 'left': pos.left}).slideDown();
		$('#' + o + '_so1').show();
		$(document).bind('mousedown', function (e) {
			if ($(e.target).hasClass('noclose')) {
				return true;
			} else {
				$('.sort_options').slideUp();
				$(document).unbind('mousedown');
			}
		});
	} else {
		$('.sort_options').slideUp();
		$(document).unbind('mousedown');
	}
}

function nav_paging(o, from, to) {
	$('#' + o + from).hide();
	$('#' + o + to).show();
}

function show_updates(dom) {
	$(dom).parent().parent().find('.review-updates').slideToggle();
	$(dom).find('span').toggle();
}

$(document).ready(function () {
	
	if (compliments_loaded == true) {
		bind_compliments();
	}
	
});

function new_captcha() {
	$('#captcha-img').animate({'width': 40}, 300).attr('src', 't/template/img/loading.gif');
	setTimeout(function () {
		var cap = new Image();
		cap.onload = function () {
			$('#captcha-img').animate({'width': 120}, 300).attr('src', this.src);
		}
		cap.src = 'captcha.php?new=a8f15eda80c50adb0e71943adc8015cf&cnt='+Math.random(0,10000);
	}, 500);
}
var addSearcher = function () {
	if (typeof window.external == 'undefined') {
		alert('Your browser does not support adding more search engines!');
	} else {
		window.external.AddSearchProvider("http://www.winespy.com/winespysearch.xml");
		alert("There are several ways to use the search add-on. To specify a location you can separate the Business Name, City, State and Zip Code with a , (comma). You can also use the combination [State] [Zip Code]. If you don't specity a location the default or last location is used. Here are a few patterns you can use:\n [Business Name], [City], [State], [Zip Code]\n [Business Name], [City], [State] [Zip Code]\n [Business Name]\n [City]\n [State]\n [Zip Code]\n [State] [Zip Code]\n [City], [State] [Zip Code]");
	}
}

function send_to_friend(dom) {
	if (typeof dom.href == 'undefined') return true;
	var top = 0;
	var left = 0;
	var send_url = 'inc/send.php';
	var get_data;
	get_data = dom.href.substr(dom.href.indexOf('settings/send-friend/')+21);
	if ($('#send_friend').length > 0) {
		$('#send_friend').remove();
		return false;
	} else {
		$('body').append('<div id="send_friend"><div style="margin-top: 30px"><center><img src="t/template/img/loading.gif" width="35" height="35" alt="Loading..." /><br/>Loading...</center></div></div>');
		var sEl = $('#send_friend');
		var domPos = $(dom).position();
		var docW = $(document).width();
		var docH = $(dom).height();
		if (domPos.top > docH) {
			top = domPos.top - sEl.height() - 20;
		} else {
			top = domPos.top + docH;
		}
		if (domPos.left + sEl.width() > docW) {
			left = domPos.left + (domPos.left + sEl.width() - docW - 10);
		} else {
			left = domPos.left;
		}
		sEl.css({'top': top, 'left': left});
		sEl.fadeIn();
		$(document).scrollTo(sEl, 'normal', {offset:{left: 0, top: -40}});
		$.ajax({
			type: 'GET',
			url: send_url,
			data: get_data,
			success: function (result) {
				$('#send_friend').html(result);
			}
		});
	}
	return false;
}

function e_send_to_friend(dom) {
	var send_url = 'inc/send.php';
	$('#message_status').html('<img src="t/template/img/loading.gif" align="left" width="35" height="35" alt="" /><div style="margin-top: 15px">Sending...</div>');
	$(dom).ajaxSubmit({target: '#message_status',
			url: send_url,
			beforeSubmit: function () {
					$(dom).find('input').attr('disabled', true);
					$(dom).find('textarea').attr('disabled', true);
					$(dom).find('select').attr('disabled', true);
			},
			success: function () {
				var result;
				result = $('#message_status').html();
				if (result == '') {
					$('#message_status').html('An error occured while sending your message. Please try again!')
				}
				if (result != 'Message sent!') {
					$(dom).find('input').attr('disabled', false);
					$(dom).find('textarea').attr('disabled', false);
					$(dom).find('select').attr('disabled', false);
				} else {
					setTimeout(function () { $('#send_friend').fadeOut('normal', function () { $('#send_friend').remove(); }); }, 2000);
				}
			}
	});
	return false;
}

function event_reminder(dom) {
	var dp = $(dom).position();
	$('#info-for-reminder').remove();
	$('body').append('<div class="sort_options" id="info-for-reminder">Saving...</div>');
	$('#info-for-reminder').css({'top': $(dom).height() + dp.top, 'left': dp.left}).fadeIn(1000);
	$.ajax({
		type: 'GET',
		url: 'inc/event_remind.php',
		data: 'event=' + dom.value,
		success: function (res) {
			if (res == 'will_remind') {
				$(dom).attr('checked', true);
				$('#info-for-reminder').css({"color":"green"}).html("Saved!");
				setTimeout(function () { $('#info-for-reminder').fadeOut(100).remove(); }, 1000);
			} else if (res == 'will_not_remind') {
				$(dom).attr('checked', false);
				$('#info-for-reminder').css({"color":"green"}).html("Saved!");
				setTimeout(function () { $('#info-for-reminder').fadeOut(100).remove(); }, 1000);
			} else {
				if ($(dom).is(":checked")) {
					$(dom).attr('checked', false);
				} else {
					$(dom).attr('checked', true);
				}
				$('#info-for-reminder').css({"color":"red"}).html("Not saved!");
				setTimeout(function () { $('#info-for-reminder').fadeOut(100).remove(); }, 1000);
			}
		}
	});
}

function make_bookmarks_priv(dom) {
	var dp = $(dom).position();
	$('#info-for-reminder').remove();
	$('body').append('<div class="sort_options" id="info-for-reminder">Saving...</div>');
	$('#info-for-reminder').css({'top': $(dom).height() + dp.top, 'left': dp.left}).fadeIn(1000);
	$.ajax({
		type: 'GET',
		url: 'inc/priv_bookmarks.php',
		success: function (res) {
			if (res == 'priv') {
				$(dom).attr('checked', true);
				$('#info-for-reminder').css({"color":"green"}).html("Saved!");
				setTimeout(function () { $('#info-for-reminder').fadeOut(100).remove(); }, 1000);
			} else if (res == 'not_priv') {
				$(dom).attr('checked', false);
				$('#info-for-reminder').css({"color":"green"}).html("Saved!");
				setTimeout(function () { $('#info-for-reminder').fadeOut(100).remove(); }, 1000);
			} else {
				if ($(dom).is(":checked")) {
					$(dom).attr('checked', false);
				} else {
					$(dom).attr('checked', true);
				}
				$('#info-for-reminder').css({"color":"red"}).html("Not saved!");
				setTimeout(function () { $('#info-for-reminder').fadeOut(100).remove(); }, 1000);
			}
		}
	});
}

if (typeof(km_scripts) == 'undefined') var km_scripts = new Object();
if (typeof(km_ready) == 'undefined') var km_ready = 0;

function km_myclass_import(imFile, imEl, imType) {
  if (km_scripts[imFile] != null) return;
  var scriptElt = document.createElement(imEl);
  scriptElt.onLoad = function () { km_ready++; if (km_ready == km_scripts.lenght) { Xload_suggestion(); } };
  scriptElt.type = imType;
  scriptElt.src = imFile;
  document.getElementsByTagName('head')[0].appendChild(scriptElt);
  km_scripts[imFile] = imFile;

}

 $(document).ready(function () { if (typeof website_resize != 'function') {var sliderHeightCentral = $('#content-central').height(); var sliderHeightRight = $('#content-right').height(); if (sliderHeightCentral > sliderHeightRight) { $('#content-right').height(sliderHeightCentral); } else { $('#content-central').height(sliderHeightRight); }} $('#loc_link').click(function () { if ($('.location-bar-recent').is(":hidden")) { $('.location-bar-recent').slideDown(); $(this).html('&laquo less'); } else {$('.location-bar-recent').slideUp(); $(this).html('more &raquo;');}}) }); //-->