$(document).ready(function() {
	
	// SHOW LINK/EMBED
	$('a#linkToIt').click(function() {
		$("#linkURLBox").toggle();
		$("#embedCodeBox").hide();
		this.blur();
		return false;
	});
	
	$('a#embedVideo').click(function() {
		$("#embedCodeBox").toggle();
		$("#linkURLBox").hide();
		this.blur();
		return false;
	});
	
	$('a#addCommentLink').click(function() {
		$("#addCommentForm").toggle();
		//$("#linkURLBox").hide();
		this.blur();
		return false;
	});
	
	//var current = $('#addCommentForm');
	//var vid = $('.blogID').val();
	//setAddComment(current,vid);
	
	
});




function setAddComment(obj, vid) {
	// add comment submit button
	$(obj).find('.addButton').click(function(){
		saveChanges(obj, vid);
		return false;
	});
}

function saveChanges(obj, vid) {

	var message = $('.message').val();
	var name = $('.name').val();
	
	var m = $('.m20xd6').val();
	var n = $('.n20xd6').val();
	
	var body = $("#addCommentBody");
	
	body.fadeOut("slow", function () {
		body.load("/videos/add_comment.php",{vid:vid, message:message, name:name, n:n, m:m, from:'ajax', s20xd6:'Add Comment'},function() {
			body.fadeIn("slow", function () {
				setAddComment(obj, vid);
			});
		});
	});
}


/*
===========================================================================================
Copyright 2007 Cornettex Computer Consulting
*/
var curKeyword;
var buttonSelected;
buttonOver = new Image(); buttonOver.src = "video_button_up_over.gif";
buttonOut = new Image(); buttonOut.src = "video_button_up.gif";
buttonDown = new Image(); buttonDown.src = "video_button_down.gif";

function mouseOver(cell) {
	if (document.images != null && cell != buttonSelected) {
		cell.className = "buttonOver";
		//cell.style.backgroundImage = "url('" + buttonOver.src + "')";
	}
}

function mouseOut(cell) {
	if (document.images != null && cell != buttonSelected) {
		cell.className = "buttonUp"
		//cell.style.backgroundImage = "url('" + buttonOut.src + "')";
	}
}

function mouseDown(cell) {
	if (buttonSelected != null && buttonSelected != cell) {
		//buttonSelected.style.backgroundImage = "url('" + buttonOut.src + "')";	
		buttonSelected.className = "buttonUp"
	}
	buttonSelected=cell;
	if (document.images != null) {
		cell.className = "buttonDown"
		//cell.style.backgroundImage = "url('" + buttonDown.src + "')";
	}
	
	var link = cell.getElementsByTagName('a')[0]; 
	//window.location.href=link.href;
	//alert(curKeyword);
	document.getElementById('videoBrowser').src = link.href + '&curKeyword=' + curKeyword;
}

function init()
{

	if (document.getElementById)
		var x = document.getElementsByTagName('TD');
	else if (document.all)
		var x = document.all.tags('TD');
	for (var i=0;i<x.length;i++)
	{
		if (x[i].className=='buttonDown') {
			buttonSelected=x[i];
		}
	}
	//alert(window.location.hash.substring(1));
	if (window.location.hash != "" && window.location.hash != "#") {
		window.location = '/videos/' + window.location.hash.substring(1);
	}
}
// Copyright 2007 Cornettex Computer Consulting

