art_tab_list = $$('#article_tab_strip div');
art_content_list = $$('#article_read_panel div.article_contents');
art_img_list = $$('#article_tab_strip div img');

var flag=0;

for (var i=0; i<art_tab_list.length; i++) {
	var preload = new Image();
	preload.src = 'images/' + art_tab_list[i].id + '_off.jpg';
	var preload2 = new Image();
	preload2.src = 'images/' + art_tab_list[i].id + '_hover.jpg';
}

if (document.getElementById("photo_slide_show_controls")) 
{
  // Create a new div to hold the image and add it do the div photo
  var thumbnailDiv = document.createElement("div");
  thumbnailDiv.id = 'thumbnail';
  document.getElementById("photo_slide_show_controls").appendChild(thumbnailDiv);
  Element.addClassName(thumbnailDiv, 'thumbnail');
  
  // Create a new image and add it to the div
  thumbnail= thumbnailDiv.appendChild( Builder.node('img'));		
  
  // hide the thumbnail by default
  thumbnailDiv.hide();
}

function rolloverPhoto(tab,what,image)
{
	if (what=="out")
	{
		 //Effect.Fade('thumbnail');
		 new Effect.Opacity('thumbnail', {duration:0.5, from:1.0, to:0.0});	
		// hide the thumbnail 
		//thumbnailDiv.hide();

		return true;
	}
	else
	{
		// Set the location of the image
		thumbnail.setAttribute('src', 'http://cinemaspy.ca/images/upload/'+image);

		// Set the width nad height of the image
		thumbnail.setAttribute('width',76);
		//thumbnail.setAttribute('height',75);

		// move the thumbnail div underneath the div
		thumbnailDiv.style.left = tab.offsetLeft - 30 + 'px';
		thumbnailDiv.style.top = (tab.offsetTop + tab.offsetHeight) + 'px';

		// Display the div
		thumbnailDiv.show();

		//Effect.Appear('thumbnail');
		new Effect.Opacity('thumbnail', {duration:0.5, from:0.0, to:1.0});	
	}
}
function rolloverImage(tab,what)
{
	if (tab.hasClassName('article_tab_on')) return true;
	if(tab.hasClassName("article_tab_off")) {
	  var tab_id = tab.id;
	  if ( tab.id.match(/video/) ) {
	    tab_id = 'video';
	  }
	  else if ( tab.id.match(/trailer/) ) {
	    tab_id = 'trailer';
	  }
	  
		tab.firstChild.src='images/'+tab_id+'_'+what+'.jpg';	
	}
}

function rolloverNextPrev(tab,id,action)
{
	var num=document.getElementById(id).innerHTML;
	var ID=tab.id;
	var whatPrefix=ID.substring(0,4);
	var whatSuffix=ID.substring(4);
	
	if(whatSuffix=='Read')
	{
		if(action=='over')
		{
			if(whatPrefix=='next' && num<4)
			{
				tab.src='images/'+whatPrefix+'.jpg';				
			}
			else if(whatPrefix=='prev' && num>1)
			{
				tab.src='images/'+whatPrefix+'.jpg';	
			}
		}
		else
		{
			tab.src='images/read_slide_'+whatPrefix+'.jpg';
		}
	}
	if(whatSuffix=='Photo')
	{
		if(action=='over')
		{
			tab.src='images/'+whatPrefix+'.jpg';		
		}
		else
		{
			tab.src='images/read_slide_'+whatPrefix+'.jpg';
		}
	}
}

function choose_tab(tab) {
	if (Element.hasClassName(tab, 'article_tab_on')) return true;

	for (var i=0; i<art_tab_list.length; i++) 
	{
		art_tab_list[i].removeClassName('article_tab_on');
		art_tab_list[i].addClassName('article_tab_off');
		var tab_id = art_tab_list[i].id;
		if ( art_tab_list[i].id.match(/video/) ) {
		  tab_id = 'video';
		}
		else if ( art_tab_list[i].id.match(/trailer/) ) {
		  tab_id = 'trailer';
		}
		art_img_list[i].src = 'images/' + tab_id + '_off.jpg';
	}

	for (var i=0; i<art_content_list.length; i++) {
		art_content_list[i].removeClassName('on');
		art_content_list[i].addClassName('off');
	}

	Element.removeClassName(tab, 'article_tab_off');
	Element.addClassName(tab, 'article_tab_on');
	var tab_id = tab.id;
	if ( tab.id.match(/video/) ) {
	  tab_id = 'video';
	}
	else if ( tab.id.match(/trailer/) ) {
	  tab_id = 'trailer';
	}
	tab.firstChild.src = 'images/' + tab_id + '_on.jpg';
	var content = $('content_' + tab.id);
	content.removeClassName('off');
	content.addClassName('on');
	eq_col();
}
