//  $Id: script.js,v 1.1 2008/01/24 16:37:55 skennedy Exp $
//  Copyright (C)2006 Gorges Web Sites. All Rights Reserved.

//  popup

function popup(query) {
  mywindow = open('instance_popup.php?' + query, 'Edit', 'location=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=450');
  mywindow.location.href = 'instance_popup.php?' + query;
  mywindow.focus();
  if (mywindow.opener == null)
    mywindow.opener = self;
}

// comments
function preview_comment() {
  var message = $('#message').val();
  if (message.length > 0) {
	  var data = 'name=' + $('#name').val();
	  data += '&email=' + $('#email').val();
	  data += '&web=' + $('#web').val();
	  data += '&message=' + message;
	  $.ajax({ url     : "comment_preview.php",
	           type    : "get",
	           data    : data,
	           success : function(msg){
	                       $('#preview_comment').html(msg);
	                     }
	         });
  } else {
    alert('Please enter a message to preview.');
  }
}

function check_for_submit() {
  var errors = $('.error').size();
  if (errors > 0) {
    $('img.progress').hide();
    $('button[@type=submit]').show();
    clearInterval(timer);
  }
}
var timer = null;
try {
	$.fn.show_spinner = function() {
	  $(this).html('<img src="images/indicator.gif" class="indicator" />');
	    return this;
	}
	
	$.fn.hide_spinner = function() {
	  $(this).html('');
	}

	$(document).ready(function(){
	  $("form").submit(function(){
	    $('img.progress',this).css("display","inline");
	    $('button[@type=submit]').hide();
	    timer = setInterval("check_for_submit()",200);
	  });
      $('ul.collapsible_list h3 a').click(function(){
        $('#' + this.id + '_body').slideToggle();
      });
	  $('#comment_switch').click(function(){
	    $('#comment_form').slideToggle();
	  });
      $('div.slideshow').each(function(){$(this).slideshow();});
	});
} catch(e) {}