function newWindow(PopUp) {
	popUp = window.open (PopUp, 'pop');
	popUp.focus();
}

function footer(){
	var d = new Date();
	if (d.getFullYear() > 2009)
		document.write('<span id="foot">&#169; Calithumpians Theatre Company 2009-' + d.getFullYear() + '. All rights reserved.</span>');
	else
		document.write('<span id="foot">&#169; Calithumpians Theatre Company ' + d.getFullYear() + '. All rights reserved.</span>');
}

//jQuery Scripts

//drop down menu
$(document).ready(function() {
  var toggle = function(direction, display) {
    return function() {
      var self = this;
      var ul = $("ul", this);
      if( ul.css("display") == display && !self["block" + direction] ) {
        self["block" + direction] = true;
        ul["slide" + direction]("slow", function() {
          self["block" + direction] = false;
        });
      }
    };
  }
  $("li.menu").hover(toggle("Down", "none"), toggle("Up", "block"));
  $("li.menu ul").hide();
});

//Image preview script 
this.imagePreview = function(){	
	// these 2 variable determine popup's distance from the cursor		
	xOffset = 250;
	yOffset = 30;
	
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			//.css("top",(e.pageY + xOffset) + "px") //change plus to minus to move down on xOffset
			//.css("left",(e.pageX + yOffset) - "px") //change plus to minus to move left on yOffset
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	/*$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});*/			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});

//show 
$(document).ready(function() {
	$('div#show> div').hide();  
	$('div#show> h3').click(function() {
		var $nextDiv = $(this).next();
		var $visibleSiblings = $nextDiv.siblings('div:visible');

		if ($visibleSiblings.length ) {
			 $visibleSiblings.slideUp('fast', function() {
				 $nextDiv.slideToggle('fast');
			});
		} else {
			 $nextDiv.slideToggle('fast');
		}
	});
});

//show 2
$(document).ready(function() {
	$('div#show2:eq(0)> div:gt(0)').hide();
	$('div#show2:eq(0)> h3').click(function() {
		$(this).next('div:hidden').slideDown('fast')
		.siblings('div:visible').slideUp('fast');
	}); 
});