function init_jquery()
{
	if ($.browser.opera)
	{
		$("#add_favorite").attr({
			rel: 'sidebar',
			title: document.title,
			href: page_url
		});
	}
	
	//return false;
} 

function confirm(message, callback) {
	$('#confirm').modal({
		position: ["30%",],
		overlayId:'confirm-overlay',
		containerId:'confirm-container', 
		onShow: function (dialog) {
			//$('.message1', dialog.data[0]).append(message);

			// if the user clicks "yes"
			$('.yes', dialog.data[0]).click(function () {
				// call the callback
				if ($.isFunction(callback)) {
					callback.apply();
				}
				// close the dialog
				$.modal.close();
			});
		}
	});
}

function reminder(listing_id, url)
{	
//alert(getCookie("listing_click"));
	$.ajax({
		type: "POST",
		url: baseURL+"/index.php?page=count_click&address="+url+"&id="+listing_id,
		dataType: "text"
		
	});
	
	var today = new Date();
	var todaySec = (today.getTime())/1000; 
	
	var clickCookie = getCookie("listing_click");
	
	expiresDate = new Date(today.getTime() + 365*24*60*60*1000);
	var expires =  expiresDate.toGMTString();
	
	
	document.cookie = "listing_click=" + todaySec + "; path = /; expires=" + expires + ";";
	
	//alert(todaySec + " - " + clickCookie + " > " + reminderTime);
	if (!clickCookie || (clickCookie && todaySec - clickCookie > reminderTime))
	{
		confirm("", function () {
			window.location.href = baseURL+"user_feedback/"+listing_id+"#submit_feedback";
			listingWindow=window.open(url);
		});
		return false;
	}
	
	return true;	
}

function getCookie(name) 
{
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1) return false;
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}
