window.addEvent('load', function() {
								 
//============================================= check scroll//
// this function from lightbox (http://www.huddletogether.com/projects/lightbox/)

function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	return yScroll;
}


//============================================= open close window//
/* override the style thats been set */
$('instruction').setStyles({
	position: 'absolute',
	left:'0',
	margin:'-257px 0 0 -42px'//,
	});
$('instruction_pc').setStyle('position', 'absolute');
$('instruction_mac').setStyle('position', 'absolute');
$('instruction_screen').setStyle('position', 'absolute');


/* close all */
function close_instructionWin(){
	var myFx = new Fx.Style('instruction_pc', 'opacity').set(0);
	var myFx = new Fx.Style('instruction_mac', 'opacity').set(0);
	var myFx = new Fx.Style('instruction_screen', 'opacity').set(0);
	}
close_instructionWin();


/* adjust window position */
function ajust_instructionWin(){
	var instructionWindow_top = getPageScroll()+150 + 'px';
	$('instruction').setStyle('top', instructionWindow_top);
	}
	
	
/* add click */
function addClick(wind, windLink){
	$(windLink).addEvent('click', function(){
		close_instructionWin();
		ajust_instructionWin();
		var myFx = new Fx.Style(wind, 'opacity',{duration:300}).start(0,1);
		return false;
		});
	}
addClick('instruction_pc','instruction_pc_link');
addClick('instruction_mac','instruction_mac_link');
addClick('instruction_screen','instruction_screen_link');


/* close tag */
function createATag(divWindow){
	var aTag = document.createElement('a');
	var txt = document.createTextNode('Close');
	aTag.appendChild(txt);
	var firstElement = $E('h3', divWindow);
	$(aTag).injectBefore(firstElement);
	$(aTag).setProperty('href', '#');
	$(aTag).setProperty('onclick', 'return false');/*fix later*/
	}
	
createATag('instruction_pc');
createATag('instruction_mac');
createATag('instruction_screen');

function addClose(wind){
	$E('a', wind).addEvent('click', function(){
		close_instructionWin();
		return false;
		});
	}
addClose('instruction_pc');
addClose('instruction_mac');
addClose('instruction_screen');


//=============================================//
});


