function closeFancyBox(){
    parent.location.reload();
}


$(document).ready(function(){

	$(".content_block").oneTime(10000, function() {
		if (!$('#video').hasClass('active')) {
			$('.have_you_seen').fadeIn();
		}
	});
	$(".map").hide();
	$("#video").hide();
	$("#comments").hide();
	$("#comment_form").hide();
	$("#share").hide();
	$("#show_menu").hide();
	$("#hide_map").hide();
	$("#hide_comments").hide();
	$("#hide_share").hide();
	$("#hide_video").hide();
	$(".have_you_seen").hide();
	
	$("#video_link").fancybox({
		'width'				: 785,
		'height'			: 510,
		'padding'			: 0,
		'autoDimensions'	: true,
        'autoScale'     	: true,
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayOpacity'	:  '0.8',
		'type'				: 'iframe'
	});
	
	
	$("#video_link_box").fancybox({
		'width'				: 785,
		'height'			: 510,
		'padding'			: 0,
		'autoDimensions'	: true,
        'autoScale'     	: true,
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayOpacity'	:  '0.8',
		'type'				: 'iframe'
	});
			
	
	$(".iframe_login").fancybox({
		'width'				: 349,
		'height'			: 457,
		'padding'			: 0,
		'autoDimensions'	: true,
        'autoScale'     	: true,
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayOpacity'	:  '0.3',
		'type'				: 'iframe',
		onClosed			: closeFancyBox
	});
	
	$(".iframe_vote").fancybox({
		'width'				: 349,
		'height'			: 90,
		'padding'			: 0,
		'autoDimensions'	: true,
        'autoScale'     	: true,
        'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayOpacity'	:  '0.3',
		'type'				: 'iframe',
		onClosed			: closeFancyBox
	});	


	$('.iframe_login').qtip({ 
		content: 'Show this guide some love',
		position: {corner: {target: 'rightMiddle',tooltip: 'leftMiddle'}},
      	style: {
                  border: {
					  color:'#393939',
                     width: 5,
                     radius: 10
                  },
                  padding: 10, 
				  color: '#fff',
				  background:'#393939',
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'dark' // Style it according to the preset 'cream' style
               }
	});
	
	
	$('.place_vote').qtip({ 
		content: 'Show this guide some love',
		position: {corner: {target: 'topMiddle',tooltip: 'bottomMiddle'}},
      	style: {
                  border: {
                     width: 5,
                     radius: 10
                  },
                  padding: 10, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'dark' // Style it according to the preset 'cream' style
               }
	});
	

	$("#map_link").click(function(event) {
		event.preventDefault();
		$(".active").hide();
		$("a").removeClass("active_link");
		$("#map").addClass("active");
		$("#map_link").addClass("active_link");
		$(".map").show();	
		$("#hide_map").show();
		$("#hide_map").addClass("active");
		$("#have_you_seen").hide();
	});
	
	$("#share_link").click(function(event) {
		event.preventDefault();
		$(".active").hide();
		$("a").removeClass("active_link");
		$("#share").addClass("active");
		$("#share_link").addClass("active_link");
		$("#share").show();	
		$("#hide_share").show();
		$("#hide_share").addClass("active");
		$("#have_you_seen").hide();
	});	
	
	$("#comments_link").click(function(event) {
		event.preventDefault();		
		$(".active").hide();
		$("a").removeClass("active_link");
		$("#comments").addClass("active");
		$("#comments_link").addClass("active_link");
		$("#comments").show();	
		$("#hide_comments").show();
		$("#hide_comments").addClass("active");
		$("#have_you_seen").hide();
		
	});	
	
	$("#post_comment_link").click(function(event) {
		event.preventDefault();		
		$("#comment_results").hide();
		$("#comment_form").show();	
		
	});	
		
	$("#hide_menu").click(function(event) {
		event.preventDefault();
		$("#menu").hide();
		$("#hide_menu").hide();
		$("#show_menu").show();
	});
	
	$("#show_menu").click(function(event) {
		event.preventDefault();
		$("#hide_menu").show();
		$("#menu").show();
		$("#show_menu").hide();
	});
	
	$("#hide_comments").click(function(event) {
		event.preventDefault();
		$(".active").hide();
	});	
	
	$("#hide_map").click(function(event) {
		event.preventDefault();
		$(".active").hide();
	});	
	
	$("#hide_share").click(function(event) {
		event.preventDefault();
		$(".active").hide();
	});			
	$("#hide_video").click(function(event) {
		event.preventDefault();
		$(".active").hide();
	});	

	
	$(".scrollable").scrollable();
		
	
});

$(function() { 
	$("#comment_button").click(function(event) { 
		event.preventDefault();
		var comments = $("#frmComment").serialize();
		$.ajax({
			type: 'GET',
			url: '/ajax/post-comment.php',
			data: 'comments=' + comments,
			dataType: 'html',
			beforeSend: function() {
				$('#comment_form').hide();	
				$('#comment_results').show();	
				$('#comment_results').html('Please wait...');	
			},
			success: function(response) {
				
				$('#comment_results').html(response);
			}
		});
	});
});

