window.addEvent('domready', function() {			
	var myMenu = new MenuMatic({opacity:98});
	initPanel();
	
	
	$('digg').addEvent(	'click',function(e){e.stop();	sbs_digg(); } );
	$('facebook').addEvent(	'click',function(e){e.stop();	sbs_facebook(); } );
	$('delicious').addEvent(	'click',function(e){e.stop();	sbs_delicious(); } );
	$('stumbleupon').addEvent(	'click',function(e){e.stop();	sbs_stumbleupon(); } );
	$('myspace').addEvent(	'click',function(e){e.stop();	shareWithMySpace(document.title.toString().clean(),$('content').get('html').clean(), window.location,'1'); } );
	
	
	
	

});	

//http://wiki.developer.myspace.com/index.php?title=How_to_Add_Post_To_MySpace_to_Your_Site
function shareWithMySpace(T, C, U, L)
{
    var targetUrl = 'http://www.myspace.com/index.cfm?fuseaction=postto&' + 't=' + encodeURIComponent(T) + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
    window.open(targetUrl);
}



var counter = 1;
function initPanel(){
	var min = 50;
	var max = 290;
	var duration = 600;
	
	$('interactPanel').store('morphEffect', new Fx.Morph('interactPanel', {duration: duration, transition: Fx.Transitions.Back.easeOut,link:'cancel'})); //.set({ 'height': min }) );
	$('interactBG').store('morphEffect', new Fx.Morph('interactBG', {duration: duration, transition: Fx.Transitions.Back.easeOut,link:'cancel'})); //.set({ 'height': min }) );
	
	restorePanel(max,min);
	
	$('interactTab').addEvents({
		'click':function(e){
			e.stop();
			openClosePanel(max,min);
			this.blur();			
		}
	});

}

function restorePanel(max,min){
	if(Cookie.read('panel') == 'closed'){
		$('interactPanel').retrieve('morphEffect').set({ 'height': min });
		$('interactBG').retrieve('morphEffect').set({ 'height': min });
	}else{
		$('interactPanel').retrieve('morphEffect').set({ 'height': max });
		$('interactBG').retrieve('morphEffect').set({ 'height': max });
	}
}

function openClosePanel(max,min){
	if(Cookie.read('panel') == 'closed'){
		$('interactPanel').retrieve('morphEffect').start({ 'height': max });
		$('interactBG').retrieve('morphEffect').start({ 'height': max });
		Cookie.write('panel', 'open');
	}else{
		$('interactPanel').retrieve('morphEffect').start({ 'height': min });
		$('interactBG').retrieve('morphEffect').start({ 'height': min });
		Cookie.write('panel', 'closed');
	}
}

