/* Colorbox initiation */
$(document).ready(function(){
  $('a[rel=slideshow]', '#photoalbum').colorbox({
    rel:'slideshow',
	slideshow:true,
	photo:true,
	maxWidth:'100%',
	maxHeight: '100%'
  });
  $('#slideshow-play-button').click(function(){
    $('a[rel=slideshow]:first').click();
	return false;
  });
  $('.colorbox-modal').colorbox({
    iframe:true,
	width:'820px',
	height:'92%'
  });
  initCommentForm();
  setTimeout(function(){showMenu();}, 1200);
});

var eVals = new Array();

function initCommentForm()
{
  $("div#commentForm .item").each(function(i, e){
    eVals[i] = $(e).val();
	$(e).focus(function(){
      if($(this).val() == eVals[i]){
	    $(this).val('');
	  }
    });
	$(e).blur(function(){
      if($(this).val() == ''){
	    $(this).val(eVals[i]);
	  }
    });
  });
}

function submitCommentForm()
{  
  var dVal = new Array();
  dVal[0] = $('div#commentForm form input[value="type"]').val();
  dVal[1] = $('div#commentForm form input[value="nid"]').val();
  
  $("div#commentForm .item").each(function(i, e){
    if($(this).val() == eVals[i])
	  $(this).val('');
  });
  $.post($('div#commentForm form').attr('action'), $('div#commentForm form').serialize(), function(data){
	$("div#commentForm").html(data);
	// Load new comments
	/*setTimeout(function(){
	  $('#comments').load(
	    $('div#commentForm form').attr('action'), 
		{action: 'getComments', type: dVal[0], nid: dVal[1]}
	  )},
	  2000);
	*/
  });
}
