function setMemry(){
	Memry.subTxt='Select an Image';	
	var hooA=Run.doRight('span!','catDiv');	
	for(var i=0; i<hooA.length; i++){
		var whoA=hooA[i];						
		var pa=Run.doRight('a!',whoA);
		var who=Run.doRight('img!',whoA);		
		if(!pa || !who ) continue;		
		else{
			pa[0].removeAttribute('href');				
			who=who[0];
			var n=who.getAttribute('alt');	
			Run.mrs(who,'border:5px ridge #000000;z:5;subtitle='+n);
			Run.hot.setHot(who,doBig);
			if(i==4)Run.dr('br_b4',whoA);			
		}	
	}	
}

function initLinks(){
	Memry.wait=true;
	setMemry();
	finalPrep();		
}

function waitCb(){
	Run.doBtn('hotBtnBar','catBtn','Gallery','','subtitle=Show the Gallery of Pictures',showCat);
	Run.disabler(true,'catBtn');

}

function finalPrep(){	
	Memry.wait=false;	
	mr('subTxt').onclick=showCat;	
	Run.sayWhat('subTxt','Select an Image');
	if(Run.isFun('Run.toolbar')) waitCb();
	
}

function showCat(){
	Run.mrs('catDiv','dis:block');		
	Run.mrs('preDiv','dis:none');	
	Memry.subTxt='Select an Image';	
	Run.disabler(true,'catBtn');
	elmoreOff();
}

function doBig(e){
	var who=Run.whoEver(e);	
	Run.disabler(false,'catBtn');
	Run.mrs('catDiv','dis:none');
	Run.mrs('preDiv','dis:block');
	var temS=who.getAttribute('src');			
	var tem=temS.replace(/\S*_catalog\/s_(\w+).+/,'gallery/_pic/$1_b.jpg');
	
	var n=who.getAttribute('alt');
	if(!n)n='';	
	Run.sayWhat('subTxt','Downloading '+n+'...');
	
	
	Memry.picL=new Image();
	Memry.picL.src=Memry.Rte+tem;

	setTimeout('chkPic()',500);	
}

function chkPic(){
	var el=Memry.picL;
	if(el.complete) donePic();
	else el.onload= donePic;	
}

function donePic(){
	var hoo=Run.doRight('img!','preDiv')[0];
	mr('preDiv').replaceChild(Memry.picL,hoo);
	Run.sayWhat('subTxt','Choose Another?','cursor:pointer');	
}

function goThar(e){
	var who=Run.whoEver(e);
	var lC=who.getAttribute('bigP');
	if(lC) location.href=lC;
}

function elmoreMore(e){
	if(Memry.wait)return;	
	var who=Run.whoEver(e);
	Run.sayWhat('subTxt',who.getAttribute('subtitle'));	
	
	Run.mrs(document.images,'border:5px ridge #000000');		
	if(Run.tagN(who)=='img')Run.mrs(who,'border:red ridge 5px');	
		
}

function elmoreOff(e){
	Run.mrs(document.images,'border:5px ridge #000000');
	var tx=Run.sayWhat('subTxt');
	if(tx!='' && tx.indexOf('Downloading')==-1){
		Run.sayWhat('subTxt',Memry.subTxt);	
	}
	Run.mrs('subText','vis:hidden');
}

Memry=window.Memry || {};	
Memry.env= {startfun:'Run.toolbar;initLinks'
}
if(window.Run && Run.first) Run.first.inf(Memry.env);
	
