/* 
** Pthumbs
**
** Created by Pierre Lecocq <pierre.lecocq@gmail.com>
** Under LGPL License
** If you want to use it, keep this header.
*/

var current_idx = 0;
var thumbs_timer = 0;
var id_stack = new Array();
var images_stack = new Array();
var movies_stack = new Array();
var suffix_stack = new Array();

function seqthumb_on(id)
{   	
	current_idx = (current_idx == 9) ? 1 : current_idx + 1; 
	thumbs_timer = window.setTimeout("document.getElementById('cover_movie_" + id + "').src='" + images_stack['' + id + ''][current_idx] + "'; seqthumb_on(\'" + id + "\');", 500);
}

function seqthumb_off(id)
{   
	window.clearTimeout(thumbs_timer);
	current_idx = ((movies_stack['' + id + ''] == 1) ? 0 : 0);
	document.getElementById('cover_movie_' + id).src = images_stack['' + id + ''][current_idx]
	//document.getElementById('pthumb_' + id).src = "medias/images/cover_bg.png";
}

function seqthumb(infos, images)
{   
	var unique_id = infos['id'] /*+ '-' + Math.floor(Math.random() * 100000)*/; 
	id_stack['' + unique_id + ''] = infos['id'];	
	images_stack['' + unique_id + ''] = images;	
	movies_stack['' + unique_id + ''] = infos['is_sequence'];
	suffix_stack['' + unique_id + ''] = Math.floor(Math.random() * 100000);
	
   document.getElementById('cover_movie_'+unique_id).src = images_stack[unique_id][0] ;  
	
}

function overthumb_on(id)
{   	
	current_idx = (current_idx == 9) ? 1 : current_idx + 1; 
	thumbs_timer = window.setTimeout("document.getElementById('pthumb_" + id + "').src='" + images_stack['' + id + ''][current_idx] + "'; overthumb_on(\'" + id + "\');", 500);
}

function overthumb_off(id)
{   
	window.clearTimeout(thumbs_timer);
	current_idx = ((movies_stack['' + id + ''] == 1) ? 1 : 0);
	document.getElementById('pthumb_' + id).src = images_stack['' + id + ''][current_idx]
	//document.getElementById('pthumb_' + id).src = "medias/images/cover_bg.png";
}

function overthumb(infos, images)
{   
	var unique_id = infos['id'] + '-' + Math.floor(Math.random() * 100000); 
	id_stack['' + unique_id + ''] = infos['id'];	
	images_stack['' + unique_id + ''] = images;	
	movies_stack['' + unique_id + ''] = infos['is_sequence'];
	suffix_stack['' + unique_id + ''] = Math.floor(Math.random() * 100000);
 	var str = '<div class="pthumb" onmouseover="overthumb_on(\'' + unique_id + '\');" onmouseout="overthumb_off(\'' + unique_id + '\');" onclick="window.location=\'movies.php?id=' + infos['id'] + '\'">';
	if (infos['is_sequence'] == 1)
	{
		str += '<img id="pthumb_' + unique_id + '" src="' + images_stack[unique_id][1] + '" width="238" height="174" />';
	}
	else
	{
		str += '<div style="background: transparent url(\''+images_stack[unique_id][0]+'\') no-repeat top center; width: 238px; height: 174px; text-align: center;"><img style="width: 238px; height: 174px" id="pthumb_' + unique_id + '" src="' + images_stack[unique_id][0] + '"  /></div>';
		//str += '<div style="background: url(\'' + images_stack[unique_id][0] + '\') no-repeat 5px 4px;"><img id="pthumb_' + unique_id + '" src="medias/images/cover_bg.png" width="238" height="174" /></div>';		
	}
	str += '</div>'; 
	document.write(str);  
} 
   
function overthumb2(infos, images)
{   
	var unique_id = infos['id'] + '-' + Math.floor(Math.random() * 100000); 
	id_stack['' + unique_id + ''] = infos['id'];	
	images_stack['' + unique_id + ''] = images;	
	movies_stack['' + unique_id + ''] = infos['is_sequence'];
	suffix_stack['' + unique_id + ''] = Math.floor(Math.random() * 100000);
 	var str = '<div class="pthumb" onmouseover="overthumb_on(\'' + unique_id + '\');" onmouseout="overthumb_off(\'' + unique_id + '\');" onclick="window.location=\'movies.php?id=' + infos['id'] + '\'">';
	if (infos['is_sequence'] == 1)
	{
		str += '<img id="pthumb_' + unique_id + '" src="' + images_stack[unique_id][1] + '" width="238" height="174" />';
	}
	else
	{
		str += '<div style="background: transparent url(\''+images_stack[unique_id][0]+'\') no-repeat top center; width: 238px; height: 174px; text-align: center;"><img style="width: 238px; height: 174px" id="pthumb_' + unique_id + '" src="' + images_stack[unique_id][0] + '"  /></div>';
		//str += '<div style="background: url(\'' + images_stack[unique_id][0] + '\') no-repeat 5px 4px;"><img id="pthumb_' + unique_id + '" src="medias/images/cover_bg.png" width="238" height="174" /></div>';		
	}
	str += '</div>'; 
	return str;  
}  
