// Event.observe( document, 'dom:loaded', setupPins );

var gDisplayPinTime = 350;
if ( 0 ) {
	gDisplayPinTime = 5;
}

var displayedImgID = '';
var displayedElement = '';

var pinOffset = 0;
var pinData = [
	[25, 221, 'switchers', 'Switchers', 'A clipboard history, named clipboards, and an application & window switcher extend your control even further.'],
	[60, 67, 'editor', 'Macro Groups', 'Macro Groups control when and where a macro is available.'],
	[260, 67, '', 'Macros', 'Macros allow you to automate many different tasks.'],
	[416, 489, 'actions', 'Wide Range of Actions', 'A plethora of actions is available, everything from clicking a mouse to running automator workflows.'],
	[438, 160, '', 'A Variety of Triggers', 'Triggers define how you will execute a macro.'],
	[460, 3, '', 'New User Interface', 'With a completely updated interface you will be working even faster.'],
	[550, 317, '', 'Actions', 'Actions: Actions define what a macro will do.  They can be as simple as launching an application or as powerful as executing a script.'],
	[630, 489, '', 'Recording', 'Record your own actions to quickly get your macro started.'],
	[790, 92, '', 'Enable/Disable', 'You can enable or disable Macro Groups, Macros, or individual actions.'],
	[833, 489, 'tutorial', 'Lots of Help', 'With a quick start guide, in-application tutorial, videos, and great support, you will be able to do amazing things.'],
]

function setupPin() {
//	$('output').update( 'setupPins'+pinOffset );
	if ( pinOffset < pinData.length ) {
		e = $('kmsstemplate').cloneNode( true );
		d = pinData[pinOffset];
		pinOffset++;
		e.style.left = d[0]+"px";
		e.style.top = d[1]+"px";
		e.id = undefined;
		e.select('h3')[0].update( d[3] );
		e.select('p')[0].update( d[4] );
  	$('kmscreenshot').appendChild(e);
//		$('output').update( 'pinOffset'+$('kmscreenshot').children.length);
		if ( d[2] == '' ) {
			e.imgid = '';
		} else {
			e.imgid = 'kmss'+d[2];
		}
		e.select('div.kmscreenshottext')[0].style.display = "none";
		setTimeout("setupPin()", gDisplayPinTime)
	}
}

function setupPins() {
		setTimeout("setupPin()", gDisplayPinTime)
}

function removehilight() {
	if ( displayedImgID != '' ) {
		$( displayedImgID ).removeClassName( 'kmoverlayvisible' );
		displayedImgID = '';
	}
	if ( typeof(displayedElement) == 'object' ) {
		displayedElement.removeClassName( 'kmscreenshottextvisible' );
		var nonify = displayedElement.select('div.kmscreenshottext')[0];
		setTimeout(function(){nonify.style.display = "none";},0.3);
		displayedElement = '';
	}
}

function addhilight( e ) {
	e.select('div.kmscreenshottext')[0].style.display = "block";
	displayedImgID = e.imgid;
	if ( displayedImgID != '' ) {
		$( displayedImgID ).addClassName( 'kmoverlayvisible' );
	}
	displayedElement = e;
	displayedElement.addClassName( 'kmscreenshottextvisible' );
}

function overpin(src) {
//	$('output').update( 'overpin '+src+' old '+displayedImgID+" new "+src.parentNode.imgid );
	removehilight();
	addhilight( src.parentNode );
} 

function outpin(src) {
//	$('output').update( 'outpin '+src+' old '+displayedImgID + ' typeof ' + typeof( displayedElement ));
	removehilight();
	src.parentNode.removeClassName( 'kmscreenshottextvisible' );
} 

function clickpin(src) {
//	$('output').update( 'clickpin '+src.parentNode.imgid );
	if ( src.parentNode != displayedElement ) {
		removehilight();
		addhilight( src.parentNode );
	}
} 


