 w = screen.width * .6;
 h = screen.height * .7;
 x = (screen.width - w) * 0.8;
 y = (screen.height - h) * .1;

var winProps = "toolbar=yes,location=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes,componentbar=no,navigationbar=no";
var args = "width=" + w + ",height=" + h
      + "," + winProps
      + ",screenx=" + x + ",screeny=" + y
      + ",left=" + x + ",top=" + y;

function popwin(url)
{
	winhandle=window.open(url,'',args);
	winhandle.focus();
	return true
}

$(document).ready(function(){

	$.fn.appendVal = function(txt) {
		return this.each(function(){
			this.value += txt;
		});
	};
	
	$(document).ready( function(){
		$('div.comment_div b span').click(function (){
			$(this).fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
			var new_text = "\r\n" + "> " + $(this).html() + ' (' + $('#' + this.id + '_data').html() + ')' + "\r\n";
			$('#comment_text').appendVal(new_text);
			$('#comment_text').fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
			destination1 = $(this).offset().top;
			destination = $('#comment_text').offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: $('#comment_text').offset().top}, 1300 ).animate({ scrollTop: $(this).offset().top-300}, 1300 );
			$(this).parent().parent().parent().addClass("active_comment_div");
		});

		$('img#secure').click(function(){
			$(this).attr('src', '/turing.php?temp='+Math.round((Math.random()* 1000000)));
			$('#comment_turing').val('');
		});

		$('#comment_text').change(function()  {
			$('img#secure').attr('src', '/turing.php?temp='+Math.round((Math.random()* 1000000)));
			$('#comment_turing').val('');
		});

	});

	$("a[rel=photo_album]").colorbox({photo:true});
	//{photo:true, slideshow:true}
});


function comment_validator ()
{
	if ($('#comment_name').val().length > 0 && $('#comment_text').val().length > 0 && $('#comment_turing').val().length == 4){
		return true;
	} else {
		$('#comment_name').fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
		$('#comment_text').fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
		$('#comment_turing').fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300);
		return false;
	}
}
