function menu_create(cl){
var m,menu,f,i,w=BACK.w,rec_count=recs.length;
	layout = css.ABSOLUTE.using( {top:120,height:12,width:w} );
	menu_layer=document.createObject('div',{className:'card_menu'},layout);
	
menu=main_title+" ("+rec_count+" cards)<span class='sub_menu'>";
		if ( rec_count > 4 ){
		menu+="<a id='sort' href='javascript:;' onmouseover='menuLayers.show(\"menu0\", event)' onmouseout='menuLayers.hide()'>Sort Cards</a>"	
		menu0=document.createObject( 'div',{id:'menu0',className:'popmenu'} );
		m='Sort by:-<ul>';
		m+='<li><a href="javascript:cards_sort(\'price\')">Price</a></li>';
			if (flds.indexOf('Distance') > -1){
			m+='<li><a href="javascript:cards_sort(\'Distance\')">Distance</a></li>';
			}
		m+='<li><a href="javascript:cards_sort(\'Make\')">Make</a></li>';
		m+='<li><a href="javascript:cards_sort(\'type\')">Type</a></li>';
		m+='</ul>';
		menu0.write(m);
	}
menu+='<a id="rollup" title="scroll up - or use keyboard" alt="scroll up - or use keyboard" href="javascript:cards_up(this)">scroll cards</a>';
menu+='<a id="rolldown" title="scroll down - or use keyboard" alt="scroll down - or use keyboard" href="javascript:cards_down(this)">scroll cards</a>';
menu+='</span>';
menu_layer.write(menu);
}	

//______________________________________
function cardwritenew(c,d){

if (c>=cards.length){return;}

d = d || c; 	//c is cardno, d is recno
var VALS=card_data(d);
if (!VALS['Ref']){return;}

var bcols=ltov("#CCCC99|silver|#e3e099|white|#ffffcc|#e1d29e|#ffed99|#d3b888");

var r=Math.floor( Math.random() * 8 ); 
//$flds="Ref,sector,category,type,Make,Model,Detail,Description,price,pix";
var p=ROOT+"/images/market/"+VALS['pix'];

var a='<p class=typ>'+VALS['Make']+' '+VALS['type']+'</p>';
	a+='<img alt="photo" src="'+p+'"></img>';
	a+='<div class=descrip>'+VALS['Description']+'</div>';
	cards[c].cont.write(a);
	cards[c].setVisible(1);
	cards[c].recno=d;
	
if (VALS['sector']==0){
	cards[c].action="location.href='"+ROOT+"/diy-members/index.php?p=card_submit'";
	a="Click to find out more ";		
}else{
	a=VALS['currencya']+' '+VALS['price'];
	if(VALS['Distance'] && VALS['Distance']!='n/a'){a+=' &nbsp; '+VALS['Distance']+dist_units;}	
}	
a+=' &nbsp; >>';
cards[c].tip.write(a);
cardBcol(cards[c],bcols[r]);
}
//______________________________________

function cardreadrecs(sel,usebuff){
cardswrite();
}

//______________________________________

function card_big_write(c){
c=cards[c].recno;
var VALS=card_data(c);

var pic=ROOT+"/images/market/";
pic+=(!VALS['bigpix']) ? VALS['pix'] : 'big/'+VALS['bigpix'];

var d="<a href='"+ROOT+"/diy-members/index.php?p=howfar'>how far</a>";;
if(VALS['Distance']){d=VALS['Distance'];d+=(d!='n/a') ? dist_units : '';}	
var a='<h1>'+VALS['Make']+' '+VALS['type']+'</h1><hr>';
a+='<div id=bigleft><img alt="photo" src="'+pic+'"></img>';
a+='<h4>Model : '+VALS['Model']+'</h4><h4>Distance : '+d+'</h4></div>';
a+='<div id=bigright><h2>'+VALS['Description']+'</h2><hr><h3>'+VALS['Detail']+'</h3>';
a+='<h4>Price : '+VALS['currencya']+' '+VALS['price']+'</h4>';
var r=VALS['Ref'];
if(VALS['clientref']){
	a+='<a href="'+ROOT+'/diy-members/index.php?p=card_amend&r='+r+'">Amend Card</a>';
	}else{
	d=(VALS['status']<9) ? "make_offer" : "offer"; // 9 is for test cards
	a+='<a href="'+ROOT+'/diy-members/index.php?p=offer&r='+r+'">Make an Offer!</a>';
	}
card_big.write(a+'</div>');
card_big.setVisible(1);
DOING=0;
}