var faceTimer = '';	
var facePeriod = 5000;
window.addEvent('domready', function() {
	
	var subpage = $('isSubPage').get('value');
	var faceMode = $('faceMode').get('value');
	
	faceTimer = loadNewFace.pass(['0', faceMode]).periodical(facePeriod);
	
	
	var corner_blue_fx = new Fx.Morph('corner-blue' , {
		duration: 300,
		link: 'cancel'
		
	});
	
	var corner_white_fx = new Fx.Morph('corner-white' , {
		duration: 300,
		link: 'cancel'
	});
	
	$('corner-blue').addEvent('mouseenter', function() {
		
		corner_blue_fx.start({
			'width': 139,
			'height': 149
		});
		corner_white_fx.start({
			'width': 136,
			'height': 137
		});
				
		$('head-menu-box').setStyle('z-index', 1);
	});
	
	
	$('corner-blue').addEvent('mouseleave', function() {
	
		corner_blue_fx.start({
			'width': 34,
			'height': 36
		});
		
		corner_white_fx.start({
			'width': 34,
			'height': 34
		});
		
		$('head-menu-box').setStyle('z-index', 100);		
	});	
	
	
});

function loadNewFace(idArt, faceMode) {
	var url = host_url + '/www/ajax.php';
	var params = '';
	
	params += 'ajaxAction=loadNewFace';
	params += '&id_art=' + idArt;
	
	if ($defined(faceMode)) {
		params += '&faceMode=' + faceMode;
	}
	
	var myRequest = new Request({
		url: url,
		method: 'get',
		data: params,
		onSuccess: function (responseText) {
			
			id = 'face-box';
			if ($(id)) {			
				$(id).set('tween', {
					onComplete: function(id) {
						$(id).set('tween', { onComplete: Class.empty });
						$(id).set('html', responseText);
						$(id).tween('opacity', 1);
					},
					duration: 200
				});
				$(id).tween('opacity', 0);				
			} 		
			
		}
	});
	myRequest.send();
	$clear(faceTimer);
	
	faceTimer = loadNewFace.pass(['0', faceMode]).periodical(facePeriod);
	
}

/* NAROŻNIK =================================== */
function cornerIn(){
	var corner_blue = $('corner-blue');
	var corner_white = $('corner-white');
		
	corner_blue.morph({
		'width':139,
		'height':149
	});
	corner_white.morph({
		'width':136,
		'height':137
	});
	
	$('head-menu-box').setStyle('z-index', 1);
}

function cornerOut(){
	var corner_blue = $('corner-blue');
	var corner_white = $('corner-white');
	
	corner_blue.morph({
		'width':34,
		'height':36
	});
	corner_white.morph({
		'width':34,
		'height':34
	});
	$('head-menu-box').setStyle('z-index', 100);
}

function showCorner() {
	cornerIn();
	setTimeout('cornerOut();', 400);
}

/* OTHERS PAGE ======================= */

/**
 * Laduje zawartosc aktualnie wcisnietego tab'a
 * @param {string} id_box
 * @param {int} id_tab
 */
function loadTab(id_box, id_tab) {
	
	var id_tab_list = id_box + '-list';
	var id_tab_item = id_box + '-item-' + id_tab;
	var id_tab_display_content = id_box + '-' + id_tab;
	var tab_list = $$('ul#' + id_tab_list + ' li');
	var bookmark_href_value = $(id_box + '-bookmark-href-value-' + id_tab).get('value');
	var bookmark_href = $(id_box + '-bookmark-href-' + id_tab);
	bookmark_href.set('href', bookmark_href_value);
	
	var i;
	
	//najpierw ustawi wszystkie linki nieaktywne i contenty niewidoczne
	for(i = 0; i < tab_list.length; i++) {
				
		tab_list[i].set('class', 'tab-item set-left');
		//alert(tab_list[i].get('html'));
		
		$(id_box + '-' + (i)).setStyle('display', 'none');
		
		if(i != id_tab) {
			$(id_box + '-bookmark-href-' + i).set('href', "javascript: loadTab('" + id_box + "', " + i + ");" );
		}
	}
	$(id_tab_item).set('class', 'tab-item-active set-left');
	$(id_tab_display_content).setStyle('opacity', '0.0');	
	$(id_tab_display_content).setStyle('display', 'block');	
	$(id_tab_display_content).tween('opacity', 1);

}

function loadNewMember(id_member) {
	
	var url = host_url + '/www/ajax.php';
	var params = '';
	
	params += 'ajaxAction=loadNewMember';
	params += '&id_art=' + id_member;
	
	var myRequest = new Request({
		url: url,
		method: 'get',
		data: params,
		onSuccess: function (responseText) {
			
			id = 'member-container';
			if ($(id)) {			
				$(id).set('tween', {
					onComplete: function(id) {
						$(id).set('tween', { onComplete: Class.empty });
						$(id).set('html', responseText);
						$(id).tween('opacity', 1);
					},
					duration: 200
				});
				$(id).tween('opacity', 0);				
			} 		
			
		}
	});
	myRequest.send();
	
} 


function showPicAuthor(id){
	var pic_author = $('pic-author-' + id);
	pic_author.setStyle('display','block');
}

function hidePicAuthor(id){
	var pic_author = $('pic-author-' + id);
	pic_author.setStyle('display','none');
}

function showArtPicAuthor(id){
	var pic_author = $('art-pic-author-' + id);
	pic_author.setStyle('display','block');
}

function hideArtPicAuthor(id){
	var pic_author = $('art-pic-author-' + id);
	pic_author.setStyle('display','none');
}























