
$(document).ready(function() {
						   
	$("ul.tabs-media").tabs("div.panes-media > div");						   

	$(".media-open").click(function () {
		$("#overlay-media-Wrapper").slideToggle("fast");
		//$("#header-holder-inner").slideToggle("fast");
		$(this).toggleClass("active");
		/*$("#overlay-media-Wrapper").hide("fast");*/
		$(".map-open").removeClass("active");
		return false;
	});


	$(".close-media").click(function () {
		if( $(this).attr('rel')=='fullscreen'){
			$(this).attr('rel','');
			$('#full_screen').hide();
			$('#player').show();
			//alert('here');
			return false;
		} else {
			$("#overlay-media-Wrapper").fadeOut();
			$(".media-open").removeClass("active");
			$(".map-open").removeClass("active");
			return false;
		}
	});

						   
	$('.video_link').live('click',function() {
		var video = $(this).attr('rel');
		videoarray = video.split('/');
		var category = videoarray[0];
		var video_number = videoarray[1];
		var url = location.href;
		var url_parts = url.split('?');
		var main_url = url_parts[0];
		$('#overlay-media-left').load(main_url+"?media=1&video="+video_number+"&cat="+category+" #video-content","");
		return false;
	});
	
	$('.side-content a').live('click',function() { 
		if(confirm('You are now leaving the Systagenix website.\r\n\r\nSystagenix accepts no responsibility for the content of other websites. This link will take you to a website where our Privacy Policy, Legal Notice, Terms and Conditions and content of ownership do not apply.\r\n\r\nFor this reason, you are solely responsible for your interaction with this site.\r\n\r\nBy clicking ok you will continue to an external website')) {
			return true;
		} else {
			return false;
		}
	});
	
	$('.full_screen').live('click',function() {
		//document.getElementById('small_video').contentDocument.location.reload(true);
		var video = $(this).attr('rel');
		videoarray = video.split('/');
		var category = videoarray[0];
		var video_number = videoarray[1];
		var url = location.href;
		var url_parts = url.split('?');
		var main_url = url_parts[0]; 
		$('#full_screen').show();
		$('#player').hide();/**/
		
		$('.close-media').attr('rel','fullscreen');
//		alert(main_url+"?video="+video_number+"&cat="+category+" #full_screen_load");
		$('#full_screen').load(main_url+"?media=1&video="+video_number+"&cat="+category+" #full_screen_load","");
		return false;
	});
	$('.back_to_videos').live('click',function() {
		$('#full_screen').hide();
		$('#player').show();/*ahhh*/
		console.log( 'show small video');
		$('.close-media').attr('rel','')
		return false;
	});
	
	$('#like').live('click', function() {
		var video = $(this).attr('title');
		$.ajax({
			type: "POST",
			url: "/send_like.php",
			data: 'video='+video,
			success: function(msg){
				$('#like').html('Liked!');
			}
		});
		return false;
	});
	$('.share_link').live('click', function() {
		$(this).parent().children('.share-links').toggle();
		return false;
	});
	$('#comment-close').live('click',function() {
		$('#video-comment').fadeOut();
		return false;
	});
	$('#comment-submit').live('click',function() {
		var name = $('#name').val();
		var comment = $('#comment').val();
		var video = $('#video_name').val();
		$.ajax({
			type: "POST",
			url: "/send_comment.php",
			data: 'name='+name+'&comment='+comment+'&video='+video,
			success: function(msg){
				$('#video-comment').fadeOut();
			}
		});
		return false;
	});
	$('.video_comment_open').live('click',function() {
		var name = $(this).attr('title');
		$('#video_name').val(name);
		$('#video-comment').fadeIn();
		return false;
	});
});
