/* *****************************************
//  WebTank javascript File
//  Title: 2012_prosman.js
//  File updated: 2012-01-12 13:08:20
// 
//  Do NOT manually edit this generated file
// **************************************** */


/* VARS */

var portfolio_click = null; 
var node_id = null;
var first_video = null;
var all_projects = new Object();
var all_projects_ordered = new Array();
var all_images = new Array();
var all_image_objects = new Array();
var current_project = -1;
var current_product_id = 0;
var current_interval = 0;

/* FUNCTIONS */

function click_photo( editorial_id ) {
	
	$('#right_content').fadeOut('fast',function () {
		
		$('#right_content').empty();
		
		if( $('#hidden_text_'+current_product_id+' .bottom_right').html() != null ) {
		
			$('#right_content').html('<div class="bottom_right">' + $('#hidden_text_'+current_product_id+' .bottom_right').html() + '</div>');
		
		}
		
		$('#right_content').html($('#right_content').html() + '<div class="large_photo"><img src="/images/editorial/id=' + editorial_id + '.jpg" width="560" /></div>');
		
		$('#right_content').fadeIn();
		
	} );

}

function click_text( product_id ) {

	$('#right_content').fadeOut('fast',function () {
	
		$('#right_content').empty();
		$('#right_content').html('<div class="bottom_right">' + $('#hidden_text_' + product_id + ' .bottom_right').html() + '</div>' );
		$('#right_content').html($('#right_content').html() + '<div class="large_text">' + $('#hidden_text_'+product_id).html() + '</div>');
		$('#right_content').fadeIn();
		$('#right_content .bottom_right').remove();
		
		$('.large_text').jScrollPane();
	
	} );

}

function click_video( editorial_path ) {

	$('#right_content').fadeOut('fast',function () {
			
		$('#right_content').empty();
		
		$('#right_content').html('<div class="bottom_right">' + $('#hidden_text_'+current_product_id+' .bottom_right').html() + '</div>');
		$('#right_content').html( $('#right_content').html() + '<div id="large_video"></div>' );
		
		//
		
		var flashvars = false;
		
		var params = {
			menu: 'false',
			allowfullscreen: 'true',
			flashvars: 'autostart=true&file='+editorial_path.substr(1,editorial_path.length-1)
		};
		var attributes = {
			id: 'large_video',
			name: 'large_video'
		};
		
		swfobject.embedSWF('./flash/mediaplayer.swf', 'large_video', 557, 412, '9.0.0','expressInstall.swf', flashvars, params, attributes);
		
		//
		
		$('#right_content').fadeIn();

	} );
	
}

function click_project( product_id ) {
	
	current_product_id = product_id;

	window.clearInterval(current_interval);
	
	$('.thumbnails').slideUp('fast');
	
	$('#thumbnails_' + product_id).slideDown(500, function() { 
		$('#left_content').jScrollPane( {
			verticalDragMaxHeight: 150
		} );
	} );
	
	$('#thumbnails_'+product_id).slideDown('fast');							
	$('#left_content').hide();
	$('#left_content').show();
	
	if( node_id != 1 && all_projects && all_projects[product_id] && all_projects[product_id].length > 0 ) {
	
		click_photo( all_projects[product_id][0] );
		
	}
							
}

function slideshow_next() {

	var next_image = get_next_image();
	
	if( next_image != '' ) {
	
		click_photo( next_image );
		
	}
	
}

function get_next_image() {

	if( current_project + 1 >= all_projects_ordered.length ) {
	
		current_project = -1;
		var image_id = get_next_image();
		
		return image_id;
		
	}
	
	for( i = current_project + 1 ; i < all_projects_ordered.length ; i++ ) {
	
		if( all_projects_ordered[ i ] && all_projects[ all_projects_ordered[ i ] ] && all_projects[ all_projects_ordered[ i ] ].length > 0 ) {
		
			current_project = i;
			
			return all_projects[ all_projects_ordered[ i ] ][ 0 ];
			
		}
		
	}
	
	return "";
}

/* INIT */

$(document).ready( function() {
							
	if( all_projects_ordered.length > 0 ) {
	
		$('.thumbnails').hide();
			
		//
		
		if( node_id != null && node_id == 1 && first_video != '' ) {
		
			click_video( first_video );
			
		} else {
			
			slideshow_next();
			
//			current_interval = window.setInterval( 'slideshow_next()' , 0.7 * 1000 );
		}
		
		//
		
		if( portfolio_click === true) {
		 
			$('#all_products .item a:first').click();			
			
		}
		
	}
	
	//
	
	if( $("#left_content").length > 0 ) {
	
		$("#left_content").jScrollPane( {
			verticalDragMaxHeight: 150
		} );
	
	}
	
} );


/*

function click_photo( editorial_id, extra_text ) {
	$('#right_content').fadeOut('fast',function () {
		$('#right_content').empty();
		$('#right_content').html('<div class="large_photo"><img src="/images/editorial/id='+editorial_id+'.jpg" width="560" /></div>'+ extra_text);
		$('#right_content').html( $('#right_content').html()+'<div class="bottom_right">'+$('#hidden_text_'+current_article_id+' .bottom_right').html()+'</div>' );
		$('#right_content').fadeIn();								
	});

}

function click_text( article_id ) {
	$('#right_content').fadeOut('fast',function () {
		$('#right_content').empty();								
		$('#right_content').html('<div class="large_text">'+$('#hidden_text_'+article_id).html()+'</div>');
		$('#right_content').fadeIn();
		$('#right_content .bottom_right').remove();
		$('#right_content').html( $('#right_content').html()+'<div class="bottom_right">'+$('#hidden_text_'+article_id+' .bottom_right').html()+'</div>' );
		$('.large_text').jScrollPane();
	});
}

function click_video( editorial_path ) {
	$('#right_content').fadeOut('fast',function () {
		$('#right_content').empty();
		$('#right_content').html('<div id="large_video"></div>');
		
		var flashvars = false;
		var params = {
			menu: 'false',
			allowfullscreen: 'true',
			flashvars: 'autostart=true&file='+editorial_path.substr(1,editorial_path.length-1)
		};
		var attributes = {
			id: 'large_video',
			name: 'large_video'
		};
		swfobject.embedSWF('./flash/mediaplayer.swf', 'large_video', 533, 320, '9.0.0','expressInstall.swf', flashvars, params, attributes);
		$('#right_content').html( $('#right_content').html()+'<div class="bottom_right">'+$('#hidden_text_'+current_article_id+' .bottom_right').html()+'</div>' );
		$('#right_content').fadeIn();
	});			
}

function click_project( article_id ) {

	current_article_id = article_id;

	window.clearInterval(current_interval);						
	$('.thumbnails').slideUp('fast');
	$('#thumbnails_'+article_id).slideDown(500, function() { $('#left_content').jScrollPane( {
		verticalDragMaxHeight: 150
	}); });
	$('#left_content').hide();
	$('#left_content').show();
	$('#right_content .bottom_right').remove();
	if ( all_projects && all_projects[article_id] && all_projects[article_id].length > 0 ) {
		click_photo( all_projects[article_id][0], '<div class="bottom_right">'+$('#hidden_text_'+article_id+' .bottom_right').html()+'</div>' );
	}
	
}
function slideshow_next() {
	var next_image = get_next_image();
	if ( next_image != '' ) {
		click_photo( next_image );
	}
}
function get_next_image() {
		if ( current_project + 1 >= all_projects_ordered.length ) {
			current_project = -1;
			var image_id = get_next_image();
			return image_id;
		}
		for ( i = current_project + 1 ; i < all_projects_ordered.length ; i++ ) {
			if ( all_projects_ordered[ i ] && all_projects[ all_projects_ordered[ i ] ] && all_projects[ all_projects_ordered[ i ] ].length > 0 ) {
				current_project = i;
				return all_projects[ all_projects_ordered[ i ] ][ 0 ];
			}
		}
	return '';							
}
$(document).ready(function(){
	if ( all_projects_ordered.length > 0 ) {
		$('.thumbnails').hide();
		slideshow_next();
		current_interval = window.setInterval( 'slideshow_next()' , [[content_preferences::get('slideshow_speed')]] * 1000 );
	}
	else if ( parseInt( $(document).getUrlParam("project_id") ) != 0 ) {
			click_project( parseInt( $(document).getUrlParam("project_id") ) );
		}
	$('#left_content').jScrollPane( {
		verticalDragMaxHeight: 150
	});
});

$(window).load( function() {
	
	$('#all_products .item a:first').click();
							
});
*/
