
$(document).ready(function(){

	
	var historyPanelList = $('#historyPanelList');
	
	
	$('A#historyPanelLink').click(function() {
		
		hideUNUSUALSPlayer();
		
		//$.extend($.blockUI.defaults.pageMessageCSS, { color: '#000', backgroundColor: '#fff', border: '0px solid #333',top:'30%', left:'35%',width: '320px' });
		$.extend($.blockUI.defaults.pageMessageCSS, { color: '#000', backgroundColor: '#fff', border: '0px solid #333', top:'10%', left:'40%', width: '540px', height: '300px' });

		$.blockUI.defaults.pageMessage = historyPanelList;
		$.blockUI();
		
	});
	
	
	
	var addToMyProfile = $('#addToMyProfile');
	
	//alert(addToMyProfile);
	
	$('#addToMyProfileLink').click(function() {
	
		hideUNUSUALSPlayer();
		
		//$.extend($.blockUI.defaults.pageMessageCSS, { color: '#000', backgroundColor: '#fff', border: '0px solid #333',top:'20%', left:'40%',width: '400px', height: '300px', });
		
		$.blockUI.defaults.pageMessage = addToMyProfile;
		$.blockUI();
		
		return false;
	});


	var addToMyProfileArchive = $('#addToMyProfileArchive');

	$('#addToMyProfileArchiveLink').click(function() {
	
		hideUNUSUALSPlayer();
		
		//$.extend($.blockUI.defaults.pageMessageCSS, { color: '#000', backgroundColor: '#fff', border: '0px solid #333',top:'20%', left:'40%',width: '400px', height: '300px', });
		
		$.blockUI.defaults.pageMessage = addToMyProfileArchive;
		$.blockUI();
		
		return false;
	});


	var addMeToCredits = $('#addMeToCredits');
	
	$('#addMeToCreditsLink').click(function() {
	
		hideUNUSUALSPlayer();
		
		//$.extend($.blockUI.defaults.pageMessageCSS, { color: '#000', backgroundColor: '#fff', border: '0px solid #333',top:'20%', left:'40%',width: '400px', height: '300px', });
		
		$.blockUI.defaults.pageMessage = addMeToCredits;
		$.blockUI();
		
		return false;
	});
	
	$('#profileHomeLink').click(function() {
	
		if (window.opener){
			return true;
		} else {
			location.href = '/';
		} 
	
	});
	
	$('#joinNowIMG').click(function() {
	
		if (window.opener){
			return true;
		} else {
			location.href = '/';
		} 
	
	});
	
	$("#joinNowIMG").mouseover(function(){
    	$("#joinNowIMG").attr({src: "/fileadmin/unusuals/images/basics/SignUpButtonSelected.jpg"});

    }).mouseout(function(){
		$("#joinNowIMG").attr({src: "/fileadmin/unusuals/images/basics/SignUpButtonUnselected.jpg"});
	});


	
});




function startCopyProject(currentID){
	// update the block message
	//$("#boxContentaddToMyProfile").empty();
	//$("#boxContentaddToMyProfile").append('<h2>Copy project...</h2>');
	//alert(currentID);
	
	$('#statusDialogButtons').show();
	
	tx_ffunusuals_addProjectToMyProfile('<xjxquery><q>tx_ffunusuals_projects[copy2NewID]=' + currentID + '<\/q><\/xjxquery>');
	//tx_ffunusuals_deleteFile('<xjxquery><q>tx_ffunusuals_files[uid]=' + currentID + '&tx_ffunusuals_files[file]=' + currentFile + '<\/q><\/xjxquery>');


	location.reload();
}


function addProjectToMyProfileResponse(){

	$('#statusDialogButtons').hide();
	unBlockIt();
	
	
}

function showLoginWarning(uid){
	//alert($uid);
	
	//var loginWarning = $('#loginWarning');
	
	hideUNUSUALSPlayer();
	
	var i = 0;
	var dialogOutput = new Array();
		
	dialogOutput[i++] = '<div id="deleteDialog" class="dialog" style="display:block; cursor: default">';
	dialogOutput[i++] = '<div class="boxLeftTop"></div><div class="boxRightTop"></div><div class="boxTop"></div>';
	dialogOutput[i++] = '<div class="clear">&#160;</div>';
	dialogOutput[i++] = '<div class="boxRightBorder">';
	dialogOutput[i++] = '<div class="boxContent">';
	dialogOutput[i++] = '<h2 id="question" class="darkgray">' + str.question + '</h2>';
	dialogOutput[i++] = '<button type="button" onclick="gotoLogin(' + uid +');"><div class="button"><p class="button">' + str.login + '</p></div></button>&#160;&#160;';
	dialogOutput[i++] = '<button type="button" onclick="gotoJoinNow();"><div class="button"><p class="button">' + str.joinnow + '</p></div></button>&#160;&#160;';
	dialogOutput[i++] = '<button type="button" onclick="unBlockIt();"><div class="button"><p class="button">' + str.cancel + '</p></div></button>';
	dialogOutput[i++] = '</div>';
	dialogOutput[i++] = '</div>';
	dialogOutput[i++] = '<div class="boxLeftBottom"></div><div class="boxRightBottom"></div><div class="boxBottom"></div>';
	dialogOutput[i++] = '</div>';
				
	$.blockUI.defaults.pageMessage = dialogOutput.join('');
	$.blockUI({ width: '368px' }); 

		
	return false;
}

function gotoLoginNO(uid){
	location.href = 'profile/login.html?redirect=' + uid;
	return false;
}

function gotoJoinNow(){
	self.opener.location.href = 'metanavigation/sign_up.html';
	window.close();
}