<!--    	13/06/2015    sldata.def  	//-->
/******************************************************************************
This page provides formatting information for vserver.js and data.dat
******************************************************************************/
//confirm(selfUrl()+'\nstart of sldata.def');

/******************************************************************************
Declare default global system variables				
******************************************************************************/

docPrint		= (printPrompt());
docText		= '';

databaseName	= '';
searchField 	= '2';	// fields selected to match DEFAULT search str - may be overwritten
indexField 		= '0';	// sort field for search output - may be overwritten

pgLngth		= new Array('tdx',25,'mdx',20,'pdx',40);
folders 		= new Array('nc');
icons 		= new Array();
icons['spc'] 	= new Array('spacer','nl');
icons['node0'] 	= new Array('nc0','no0');
icons['node1'] 	= new Array('nc1','no1');
icons['node2'] 	= new Array('nc1','no1');
icons['folder']	= new Array('nfc','nfo');
//icons['doc'] 	= pics;	
icons['doc'] 	= htms;	
icons['fol0'] 	= icons['folder'];
icons['fol1'] 	= icons['folder'];
icons['fol2'] 	= icons['folder'];
icons['doc0'] 	= icons['doc'];
icons['doc1'] 	= icons['doc'];
icons['doc2'] 	= icons['doc'];
icons['doc3'] 	= icons['doc'];


/******************************************************************************
Preload images 					
******************************************************************************/
spacer = new Image(); spacer.src =$imgRoot+'default.gif';
nfc = new Image(); nfc.src 		=$imgRoot+'nfc.gif';
nfo = new Image(); nfo.src 		=$imgRoot+'nfo.gif';
//nfc 	= new Image(); nfc.src =$imgRoot+'af1.gif';
//nfo 	= new Image(); nfo.src =$imgRoot+'af2.gif';
no0 = new Image(); no0.src 		=$imgRoot+'no0.gif';
no1 = new Image(); no1.src 		=$imgRoot+'no1.gif';
no2 = new Image(); no2.src 		=$imgRoot+'no2.gif';
nc0 = new Image(); nc0.src 		=$imgRoot+'nc0.gif';
nc1 = new Image(); nc1.src 		=$imgRoot+'nc0.gif';
nc2 = new Image(); nc2.src 		=$imgRoot+'nc0.gif';
//nl 	= new Image(); nl.src 		=$imgRoot+'nl.gif';
nl 	= new Image(); nl.src 		=$imgRoot+'default.gif';
//nd0 = new Image(); nd0.src 		=$imgRoot+'nd0.gif';
//nd1 = new Image(); nd1.src 		=$imgRoot+'nd1.gif';
//nd2 = new Image(); nd2.src 		=$imgRoot+'nd2.gif';
nd0 = new Image(); nd0.src 		=$imgRoot+'default.gif';
nd1 	= new Image(); nd1.src 		=$imgRoot+'default.gif';
nd2 	= new Image(); nd2.src 		=$imgRoot+'default.gif';
//pic 	= new Image(); pic.src 	=$imgRoot+'ad1.gif';
//pic2 	= new Image(); pic2.src =$imgRoot+'ad2.gif';
pic = new Image(); pic.src 		=$imgRoot+'pic1.gif';
pic2 = new Image(); pic2.src 		=$imgRoot+'pic3.gif';
www 	= new Image(); www.src 		=$imgRoot+'www.gif';
www2 	= new Image(); www2.src 	=$imgRoot+'www2.gif';
ndoc 	= new Image(); ndoc.src 	=$imgRoot+'ndoc.gif';
ndoc2 = new Image(); ndoc2.src 	=$imgRoot+'ndoc2.gif';
//proprietry logos
pdf 	= new Image(); pdf.src 		=$imgRoot+'pdf.gif';
pdf2 	= new Image(); pdf2.src 	=$imgRoot+'pdf2.gif';
doc 	= new Image(); doc.src 		=$imgRoot+'doc.gif';
doc2 	= new Image(); doc2.src 	=$imgRoot+'doc2.gif';


function defineFields() {
/******************************************************************************
Syntax: defineFields(recnum[format])
Retrieve & format data values for each record in dataset
******************************************************************************/
	//confirm(selfUrl()+'/defineFields/line85\narguments[0]='+arguments[0]+'\narguments[1]='+arguments[1]);
	defineDataFields('dBase',arguments[0],arguments[1]);
	}


function defineDataFields() {
/******************************************************************************
Syntax: defineDataFields(dbase,recnum,[format])
Retrieve & format data values for each record in dataset
******************************************************************************/
	dBase				= eval(arguments[0]);
	//confirm(selfUrl()+'/defineDataFields/Line93:'+'\narguments[0]='+arguments[0]+'\narguments[1]='+arguments[1]);
	dBase['$field'] 	= dBase[arguments[1]].split('|');
	dBase['$docAddr'] 	= dBase.$field[0].split('.')[0];
	dBase['$name'] 		= dBase.$field[1];
	//docTitle 		= dBase.$field[1];
	dBase['$uri'] 		= dBase.$field[2];
	dBase['$publ'] 		= dBase.$field[3];
	dBase['$author'] 	= dBase.$field[4];
	dBase['$date'] 		= dBase.$field[5];
	dBase['$size'] 		= dBase.$field[6];
	dBase['$descr'] 	= dBase.$field[7];
	dBase['$descr2'] 	= dBase.$field[8];
	dBase['$ext']		= '';
	dBase['$img']		= '';
	dBase['$thumb']		= '';
	dBase['$ur'] 		= '';
	$imgsrc 			= new Image(); 
	$thumbsrc 			= new Image(); 
	$thumbsrc.src 		= eval(icons['doc'][0]+'.src');
	if(dBase.$field[9]!=''){
		$imgsrc.src 	=$imgRoot+dBase.$field[9];
		dBase['$img']	=$imgsrc.src;
		$thumbsrc.src 	=$imgRoot+dBase.$field[9];
		dBase['$thumb']	= '<img src="'+$thumbsrc.src+'" />';
		//dBase['$thumb']	= $thumbsrc.src;
		}
	if(dBase.$uri!=''){
		dBase['$ur'] 	= xtractUrl(dBase.$uri);
		dBase.$ext 	= getDoctype(dBase.$uri);
		icons['doc0'] 	= icons['doc'];
		icons['doc1'] 	= icons['doc'];
		icons['doc2'] 	= icons['doc'];
		icons['doc3'] 	= icons['doc'];
		//confirm(selfUrl()+'/defineDataFields/Line 120:'+'\ndBase.$ur='+dBase.$ur+'\ndBase.$ext='+dBase.$ext);
		}
	dBase['dLink']='';if(dBase.$uri!=''){dBase['dLink']= "javascript:vPage('"+dBase.$uri+"','"+dBase.$docAddr+"');";}
	//dBase['sLink']='';if(dBase.$uri!=''){dBase['sLink']='view.shtml?n='+dBase.$uri+'&name='+urlencode(dBase.$name)+'&descr='+urlencode(dBase.$descr)+'&qty='+(dBase.$qty<2?'':dBase.$qty)+'&dbaseName='+databaseName+'&sell='+dBase.$sell+'&sell0='+dBase.$sell0+'"';}
	dBase['sLink']	= "javascript:showMenu('"+dBase.$docAddr+"');";
	xd=dBase.$name;if(dBase.$uri !=''){xd='<a href="'+dBase.dLink+'" title="View '+dBase.$name+' page">'+dBase.$name+'</a>';}
	xs=dBase.$name;if(dBase.$uri !=''){xs='<a href="'+dBase.sLink+'" title="View '+dBase.$name+' details">'+dBase.$name+'</a>';}
	}


function definePage() {
/******************************************************************************
Format Page headers & footers
Syntax: defineHeader(target,calling_obj)
	Called at top of each new page loop
******************************************************************************/
last1=0;last2=0;last3=0;
docInit=	'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">' 
docInit+= 	'\n<html>\n<head>\n<title>\n'+docTitle+'\n</title>'
		+'\n<link rel="stylesheet" href="'+parent.$docCss+'" type="text/css"/ >'
		+'\n</head>'
		+'\n<body>';
docExit	= '\n</body>\n</html>';
if(arguments[1]=="tdx"||arguments[1]=="sdx"){
	docInit+= '\n<div id="cMenu">';
	docExit = '\n</div>'+docExit;
	}
docInTable  = '<table class="dcell" width="100%" cellspacing="0" cellpadding="0">';
docInTablend  = '</table>';
if(is.ns){docInTable  = '<table class="ncell" width="90%" cellspacing="1" cellpadding="0">';}

	docFoot = '';
	docHead = '';
	if(arguments[1]=="tdx"||arguments[1]=="sdx"){
		docHead+= '\n<ul class="menu">';
		docFoot+= '</ul>';
		}
	if(arguments[1]=="mdx"||arguments[1]=="idx"){
		docHead+= '\n<div class="center">'
			+'\n<p><em>'+docText+'</em></p>'
		+'\n</div>';
		}
	if(arguments[1]=="pdx"){
		docHead+= '\n<div class="center">'
			+'\n<h2>'+parent.docTitle+'</h2>';
			+'\n<p><em>'+docText+'</em></p>'
		+'\n</div>';
		}

	if(arguments[1]=="mdx"){
		docHead+='\n<div class="panel">'
			+'\n<div class="backArrow">\n<a href="'+backUrl+'" title="Go to '+backUrl+'" onclick="parent.popUrl();return true"></a>\n</div>'
			+'\n'+printPrompt()
			+'\n<div class="nav">\n'+navObj+'\n</div>'
			+'\n<div class="clearFloats"></div>'
		+'\n</div>';
		}

	if(arguments[1]=="pdx"||arguments[1]=="mdx"){
		if (arguments[0].indexOf("main")!=-1){
			docHead+='\n'+docInTable+'\n<tr><td colspan="4">&nbsp;</td></tr>';
			docFoot='\n'+docInTablend;
			}
		}

	if(arguments[1]=="mdx"){
		docFoot+='\n<div class="panel">'
			+'\n<div class="backArrow">\n<a href="'+backUrl+'" title="Go to '+backUrl+'" onclick="parent.popUrl();return true"></a>\n</div>'
			+'\n'+printPrompt()
			+'\n<div class="nav">\n'+navObj+'\n</div>'
			+'\n<div class="clearFloats"></div>'
		+'\n</div>';
		}
	//confirm(selfUrl()+'/definePage/Line169:\narguments[1]='+arguments[1]+'\n'+docHead+'\n'+docFoot);
}

function xdefinePage() {
/******************************************************************************
Format Page headers & footers
Syntax: defineHeader(target,calling_obj)
	Called at top of each new page loop
******************************************************************************/
last1=0;last2=0;last3=0;
docInit=	'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">' 
docInit+= 	'\n<html>\n<head>\n<title>\n'+docTitle+'\n</title>'
		+'\n<link rel="stylesheet" href="'+parent.$docCss+'" type="text/css"/ >'
		+'\n</head>'
		+'\n<body>';
docExit	= '\n</body>\n</html>';
if(arguments[1]=="tdx"||arguments[1]=="sdx"){
	docInit+= '\n<div id="cMenu">';
	docExit = '\n</div>'+docExit;
	}
docInTable  = '<table class="dcell" width="100%" cellspacing="0" cellpadding="0">';
docInTablend  = '</table>';
if(is.ns){docInTable  = '<table class="ncell" width="90%" cellspacing="1" cellpadding="0">';}

docFoot = '';
docHead = '';
	if(arguments[1]=="tdx"||arguments[1]=="sdx"){
		docHead+= '\n<ul class="menu">';
		docFoot+= '</ul>';
		}
	if(arguments[1]=="mdx"||arguments[1]=="idx"){
		docHead+= '\n<div class="center">'
			+'\n<p><em>'+docText+'</em></p>'
		+'\n</div>';
		}
	if(arguments[1]=="pdx"){
		docHead+= '\n<div class="center">'
			+'\n<h2>'+parent.docTitle+'</h2>';
			+'\n<p><em>'+docText+'</em></p>'
		+'\n</div>';
		}

	if(arguments[1]=="mdx"){
		docHead+='\n<div class="textDiv">'
			+'\n<div class="backArrow">\n<a href="'+backUrl+'" title="Go to '+backUrl+'" onclick="parent.popUrl();return true"></a>\n</div>'
			+'\n'+printPrompt()
			+'\n<div class="nav">\n'+navObj+'\n</div>'
			+'\n<div class="clearFloats"></div>'
		+'\n</div>';
		}

	if(arguments[1]=="pdx"||arguments[1]=="mdx"){
		if (arguments[0].indexOf("main")!=-1){
			docHead+='\n'+docInTable+'\n<tr><td colspan="4">&nbsp;</td></tr>';
			docFoot='\n'+docInTablend;
			}
		}

	if(arguments[1]=="mdx"){
		docFoot+='\n<br /><div class="textDiv">'
			+'\n<div class="backArrow">\n<a href="'+backUrl+'" title="Go to '+backUrl+'" onclick="parent.popUrl();return true"></a>\n</div>'
			+'\n'+printPrompt()
			+'\n<div class="nav">\n'+navObj+'\n</div>'
			+'\n<div class="clearFloats"></div>'
		+'\n</div>';
		}
	//confirm(selfUrl()+'/definePage/Line169:\narguments[1]='+arguments[1]+'\n'+docHead+'\n'+docFoot);
}


function definePrintPage() {
/******************************************************************************
Format Page headers & footers
Syntax: defineHeader(target,calling_obj)
	Called at top of each page loop
******************************************************************************/
prnHead	= prnTable	
		+'\n<br /><table width="95%" align="center" cellspacing="0" cellpadding="0" border="1"><tr><td class="dColor">'
		+'\n<table width="100%" align="center" cellspacing="0" cellpadding="4" border="0"><tr valign="middle"><td width="20%" align="center">'
			+'&nbsp;<br />'
			+'</td><td align="center">'
			+'<h2>'+docTitle+'</h2>'
			+'</td><td width="20%" align="center">'
			+'<p><em>'+(printPrompt())+'</em></p>'
		+'</td></tr></table>\n</td></tr></table>'
		+'\n<table width="95%" align="center" cellspacing="0" cellpadding="0" border="0"><tr valign="top"><td align="center" colspan="3">'
			+'\n<h4>'+navObj+'</h4>'
		+'\n</td></tr>';

prnFoot = 	'<tr valign="top"><td align="center" colspan="3">'
			+'<h4>'+ navObj +'</h4>'
		+'</td></tr>\n</table>'
		+'<table width="95%" align="center" cellspacing="0" cellpadding="0" border="1"><tr><td class="dColor">'
		+'\n<table width="100%" align="center" cellspacing="0" cellpadding="4" border="0">\n<tr valign="middle"><td colspan="3" align="right">'
			+'<p><em>'+(printPrompt())+'</em></p>'
		+'</td></tr></table>\n'
		+'</td></tr></table>\n<br />'
		+prnTablend;
	}


function lineFormat(){
/******************************************************************************
Format result of query string for innerhtml
******************************************************************************/
	return(text$Format());}



function textFormat(){
/******************************************************************************
Format plain text output 
******************************************************************************/
	dBase['sLink']="javascript:parent.vPage('"+dBase.$name+"');";
	return(text$Format());
	}


function text$Format(){
/******************************************************************************
Format plain html Menu
Both [ul, span] are turned 'on'
******************************************************************************/
	mTree();
	xx='&nbsp;'+dBase.$name;
	if(dBase.$uri!=''){
		xx='<a class="navText" href="javascript:parent.loadMenu(\''+dBase.$docAddr+'\');" title="'+dBase.$name+'"><span>'+dBase.$name+'</span></a>';
		//xx='<a class="menu" href="'+dBase.dLink+dBase.sLink+'" title="'+dBase.$name+'"><span class="'+Bg+'">'+dBase.$name+'</span></a>';
		//confirm(selfUrl()+'/text$Format/Line271:'+'\nBg='+Bg+'\nxx='+xx);
		}
	return('<li class="'+Bg+'">'+iconStr+' '+xx+'</li>');
	}


function mtextFormat(){
/******************************************************************************
Format medium text output   
******************************************************************************/
	mTree();
	iconStr='<img src="'+eval(icon1+'.src')+'" />';
	xx=iconStr;if(dBase.$thumb.length>0){xx=dBase.$thumb;}
	yy=dBase.$name+'<br />';
	if(dBase.$uri.length>0){
		xx='<a href="javascript:parent.loadMenu(\''+dBase.$docAddr+'\');" title="'+dBase.$name+'">'+xx+'</a>';
		yy='<a class="nounderline" href="javascript:parent.loadMenu(\''+dBase.$docAddr+'\');" title="'+dBase.$name+'">'+dBase.$name+'</a><br />';
		}
	return('<div class="panel"><div class="center" style="float:left;width:33%;">\n'
			+ xx
		+'\n</div><div class="inPanel" style="float:right;width:100%;max-width:60%;">\n<p>'
			+yy
			+'</p>\n<p>'+dBase.$descr
			+'</p>\n<p>'+dBase.$descr2
			+'</p>\n<p>'+dBase.$author
			+'</p>\n<p>'+dBase.$date
			+'</p>'
		+'\n</div></div>');
	}



function printFormat(){return textboxFormat();}
/******************************************************************************
Format printed output 
******************************************************************************/



function textboxFormat(){
/******************************************************************************
Format textbox 
******************************************************************************/
	xx='<img src="'+dBase['$img']+'" alt="Image of '+dBase.$name+$altTxt+'"  />';
	return('<div class="floatleft">'
			+xx
			+dBase.$descr
			+'<br />'+dBase.$author
			+'<br />'+dBase.$descr2
			+'<br />'+dBase.$date
			+'<br />'
		+'</div>');
	}


function showRes(){
/******************************************************************************
Syntax:	parent.showRes('parent.dBase','.'+nn.link);
setup default search str for showres()
******************************************************************************/
	//confirm(selfUrl()+'/showRes/Line 304:'+'\narguments[0]='+arguments[0]+'\narguments[1]='+arguments[1]);
	$ds=findEQV(arguments[0],arguments[1],arguments[2],arguments[3])
	if(dl>0){
 		for(sn=0;sn<dl;sn++ ){
			defineDataFields(arguments[0],dataSet[sn]);
			document.writeln(mtextFormat());
			}
		}
	}

//alert(selfUrl()+'\nEnd sldataf.js');
