im1 = new Image(); im1.src = "common/im/wait_msg.gif"

function show_wait_msg(x)
{
  image_name = "wait_msg" + x
  document.images[image_name].src = "common/im/wait_msg.gif"
}


//random image arrays
top_image_array = new Array("ey2_03.jpg")
bottom_image_array = new Array("ey2_13.jpg")

function isset(variable) {
    return typeof(variable) != "undefined" && variable !== null;
}


var win1
function newWin1(url,w,h) 
{
  if (win1 && win1.open || win1 && !win1.closed){win1.close()}
  win1 = window.open(url,'win1', 'width='+w+', height='+h+', toolbar=no, location=no, menubar=no, status=no, scrollbars=no, resizable=no')
}

im_path = "im/"

function getRandomImage(which) 
{
  if (which == "top") seed = top_image_array.length - 1
  else seed = bottom_image_array.length - 1

  im = Math.round(seed*Math.random())

  if (which == "top") document.write('<img name="' + which + '_image" src="' + im_path + top_image_array[im] + '">')
  else  document.write('<img name="' + which + '_image" src="' + im_path + bottom_image_array[im] + '">')
}


function theRotator() {
	//Set the opacity of all images to 0
	$('#rotator  li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('#rotator  li:first').animate({opacity: 1.0}, 1000);
		
	//Call the rotator timer after initial period
	t0 = setTimeout('rotateTimer()',3000);
	
}

function rotateTimer() {
	clearInterval(t0);
	rotate(); //start fading and rotating
	t1 = setInterval('rotate()',9200); //rotation period from now on
}

function rotate() {	

	//Get the first image
	var current = ($('#rotator  li.show') ?  $('#rotator  li.show') : $('#rotator  li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#rotator  li:first') :current.next()) : $('#rotator  li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 9000);

	//Hide the current image
	current.animate({opacity: 0.0}, 9000)
	.removeClass('show');
	
};

//fancybox vars
$(document).ready(function() {
	$("a.fb").fancybox({
		'transitionIn'					:	'fade',
		'speedIn'						:	700, 
		'speedOut'					:	300, 
		'hideOnContentClick'	:	true,
		'overlayColor'				:	'#000000',
		'overlayOpacity'			:	0.5,
		'padding'						:	1
		
	});
});


function accordion1() {						   
	$('.slideContent').hide(); //hide everything initially
	//on title click toggle clicked item and close all the rest
	$('a.slideTitle').click(
		function() {
			$(this).blur();
			if(!$(this).next().is(':visible')) var openThis = 1;
//			$('.slideTitle').removeClass("slideTitleBold");
			$('.slideContent:visible').slideUp('fast');
			if (openThis) {
//				$(this).addClass("slideTitleBold");
				$(this).next().slideDown('fast');
			}
			return false;
		}
	);
	//on close click close all open (i.e. just this div)
	$('a.slideClose').click(
		function() {
//			$('.slideTitle').removeClass("slideTitleBold");
			$('.slideContent:visible').slideUp('fast');
			return false;
		}
	);
}
