<!--   	08/05/2016		wsstock.def 		//->
/******************************************************************************
This page provides formatting information for vserver.js and data.dat
******************************************************************************/
/* debugmessage	
confirm('start wsstock.def'); 
*/

/******************************************************************************
Declare default global system variables				
******************************************************************************/
databaseName 	= '';
searchField 	= '1|2';	// partid; fields selected to match DEFAULT search str - may be overwritten
indexField 	= '3';	 // sort field for search output - may be overwritten
searchPath 	= '"","'+searchField+'","'+indexField+'"';
docFootTxt 	= '';
docText 		= '';

homeUrl 		= 'wsshome.htm';
baseUrl 		= 'wsspage1.htm';
renderUrl 		= 'vipage.shtml';
imgRoot		= 'images/';
cssRoot		= 'styles/';
jsRoot		= 'script/';
docJs 		= jsRoot+'wss.js';
docCss		= cssRoot+'wss.css';
docTitle 		= document.title;

pgLngth		= new Array('tdx',20,'mdx',10,'pdx',30);
breaks 		= new Array('0','1','2');
folders		= new Array('nc');
icons 		= new Array();
icons['spc'] 	= new Array('spc2','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'] 	= 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 					
******************************************************************************/
pic 	= new Image(); pic.src 	= imgRoot+'pic.gif';
pic2 	= new Image(); pic2.src 	= imgRoot+'pic2.gif';
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';
ndoc 	= new Image(); ndoc.src  	= imgRoot+'ndoc.gif';
ndoc2 = new Image(); ndoc2.src 	= imgRoot+'ndoc2.gif';
www 	= new Image(); www.src 	= imgRoot+'www.gif';
www2 	= new Image(); www2.src 	= imgRoot+'www2.gif';
spc2 	= new Image(); spc2.src 	= imgRoot+'default.gif';
nl 	= new Image(); nl.src 	= imgRoot+'nl.gif';
nfc 	= new Image(); nfc.src 	= imgRoot+'nfc.gif';
nfo 	= new Image(); nfo.src 	= imgRoot+'nfo.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+'nc1.gif';
nc2 	= new Image(); nc2.src 	= imgRoot+'nc2.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';

function defineFields() {
/******************************************************************************
Syntax: defineFields(recnum)
Retrieve & format data values for each record in dataset
******************************************************************************/
	defineDataFields('dBase',arguments[0]);
	}

function defineDataFields() {
/******************************************************************************
Syntax: defineDataFields(dbase,recnum)
Retrieve & format data values for each record in dataset
******************************************************************************/
	dBase				= eval(arguments[0]);
	//confirm(selfUrl()+'/defineDataFields/Line88:'+'\narguments[0] = '+arguments[0]+'\narguments[1] = '+dBase[arguments[1]]+'\narguments[1].split = '+dBase[arguments[1]].split('|'));
	dBase['$field'] 		= dBase[arguments[1]].split('|');
	dBase['$parent'] 		= dBase.$field[0];
	dBase['$docAddr'] 	= dBase.$field[1];
	dBase['$partid'] 		= dBase.$field[1];
	dBase['$uri'] 		= dBase.$field[2];
	dBase['$name'] 		= dBase.$field[3];
	dBase['$descr'] 		= dBase.$field[4];
	dBase['$qty'] 		= '1';if(dBase.$field[5]>1){dBase['$qty']= dBase.$field[5]};
	dBase['$rsp']		= '';if(dBase.$field[6].replace(/\s/g,"")!=""){dBase['$rsp'] = dBase.$field[6];}
	//dBase['$rsp'] 		= dBase.$field[6];
	dBase['$sell0'] 		= trim(dBase.$field[7]);
	dBase['$sell']		= '';if(dBase.$field[7].length>0){dBase['$sell'] = dBase.$field[7];}
	//confirm(selfUrl()+'/defineDataFields/Line81:\narguments[0]|dBase='+arguments[0]+'\narguments[1]|qrystr='+arguments[1]+'\ndBase[$field]='+dBase['$field']);
	dBase['$ur'] 		= '';
	$imgsrc 			= new Image(); 
	$thumbsrc 			= new Image(); 
	$thumbsrc.src 		= eval(icons['doc'][0]+'.src');
	if(dBase.$uri!=''){
		$thumbsrc.src 	= imgRoot+dBase['$uri']+'.jpg';
		//$imgsrc.src 	= imgRoot+dBase['$uri']+'.jpg';
		//dBase['$img']	= $imgsrc.src;
		dBase['$ur'] 	= dBase.$uri;
		if(dBase.$uri.indexOf("?")!=-1){dBase.$ur=dBase.$uri.substring(0,dBase.$uri.indexOf("?"));}
		}
	dBase['$thumb']	= $thumbsrc.src;
	dBase['dLink']='';if(dBase.$uri!=''){dBase['dLink']= dBase.$uri+".htm";}
	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
					+'"';}
	//iconStr='<img src="'+eval(icons['doc'][0]+'.src')+'" />';
	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>';}
	qq='';if(dBase.$qty>1){qq=' for '+trim(dBase.$qty);}
	zz='<br />';if(dBase.$sell.length>0){zz='$&nbsp;'+trim(dBase.$sell);}
	rr='';if(dBase.$rsp.length>0){rr=trim(dBase.$rsp);}
	}

function definePage() {
/******************************************************************************
Format Page headers & footers
Syntax: defineHeader(target,calling_obj)
virtual page:
		writeln(docInit+docHead);
		writeln(docFoot+docExit);
div ID=searchResult:
		writeln(docHead);
		writeln(docFoot);
******************************************************************************/
//confirm(selfUrl()+'/definePage/Line181:'+'\narguments[0] = '+arguments[0]+'\narguments[1] = '+arguments[1]);
last1=0;last2=0;last3=0;

docInit = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
	+'\n<html>\n<head>\n<title>'+docTitle+'</title>'
	+'\n<link rel="stylesheet" href="'+parent.docCss+'" type="text/css"'+' /'+'>'
	+'\n</head>'
	+'\n<body class="backGround">';

docExit= '\n</body>\n</html>';

docHead='';
docFoot='';

if(arguments[0].indexOf("menutree")!=-1){
	docHead	= '<div id="searchResult">\n<table width="100% cellspacing="0" cellpadding="0">';
	docFoot	= '</table></div>';
	}

if(arguments[0].indexOf("menutree")==-1){
	//if(arguments[0].indexOf("main")!=-1){
		docHead+='<div id="searchResult">';
		if(arguments[1]=="idx"){docHead+='<div class="textBox">';}
		if(arguments[1]!="idx"){docHead+='<div class="box">';}
		//}
	//if(arguments[1]=="idx"){docHead+='<div class="printonly" style="position:absolute;left:0;padding:1px;text-align:left;z-index:12;"><img src="'+parent.logo3.src+'" name="image1" alt="Home Page" /></div><div class="printonly" style="margin:20px 0 10px 0;padding:0;text-align:center;"></div>'}

	docHead+='\n<div class="dColor" style="text-align:center;margin:0;padding:0;">';
	docHead+='\n<div class="noprint" style="position:absolute;left:0;"><a href="'+parent.backUrl+'" accesskey="b" title="Back to '+parent.backUrl+'"><img style="padding:0 0 0 5px;" src="'+back_arrow.src+'" alt="Back to previous page" /></a></div>';
	docHead+='\n<h1>'+docTitle+'</h1>';
	docHead+='\n</div>';

	if(arguments[1]!="idx"){
		docHead+='\n<div class="blueline"></div>';
		if(arguments[1]!="err"){
			docHead+='\n<table width="100%" border="0" cellspacing="0" cellpadding="0">'
			+'\n<tr class="bColor" valign="bottom"><th>'
			+'<h5>Click to Buy Now!</h5>'
			+'</th><th align="left">'
			+'<h5>Item</h5>'
			+'</th><th><h5><br />'
			+'</h5>'
			+'</th><th><h5><br />'
			+'</h5>'
			//+'</td><td><h5>Qty</h5>'
			+'</th><td align="right" colspan="2"><h5>'+databaseName+' Price</h5>'
			+'</th></tr>';

			docFoot='</table>';
			docFoot+='\n<div class="dColor" style="margin:0;padding:0;text-align:center;">\n'
			docFoot+=navObj;
			docFoot+='\n<div class="blueline"></div>';
			docFoot+='\n<div style="position:relative;float:left;width:15%;margin:0;padding:0;text-align:left;">&nbsp;<br /></div>';
			docFoot+='\n<div style="position:relative;float:right;width:15%;margin:0;padding:0;text-align:right;">'+(parent.printPagePrompt())+'</div>';
			docFoot+='\n<div style="position:relative;width:70%;margin:0px auto;padding:0;">\n<p><em>'+docFootTxt+'</em></p>\n</div>';
			docFoot+='\n</div>';
			}
		}
	//if(arguments[0].indexOf("main")!=-1){
		if(arguments[1]=="idx"){docHead+='</div>';}
		if(arguments[1]!="idx"){docFoot+='</div>';}
		docFoot+='</div>';
	//	}
	}
//confirm(selfUrl()+'/definePage/Line179:'+'\narguments[1] = '+arguments[1]+'\ndocHead = '+docHead+'\n\ndocFoot = '+docFoot);
//confirm(selfUrl()+'/definePage/Line180:'+'\ndocFoot = '+docFoot);
}

function definePrintPage() {
/******************************************************************************
Format Print headers & footers
Syntax: defineHeader(target,calling_obj)
	Performed for each print page
	Called at top of dataset loop
******************************************************************************/
	prnHead='<div class="text"><div class="textBox">';
	prnHead+='\n<div style="position:relative;float:left;width:15%;margin:0;padding:0;text-align:left;">'
		+'<a href="'+$homeUrl+'" target="_parent" title="Go to Warehouse Sound Systems Home Page" accesskey="h" style="position:relative;display:block;">'
		+'<img src="'+parent.logo3.src+'" name="image1" alt="Home Page" style="display:block;padding:5px;" /></a>'
		+'</div>';
	prnHead+='\n<div style="position:relative;float:right;width:50%;margin:0;padding:0;text-align:right;">'+$docAddres+docEmail()+'</div>';
	prnHead+='\n<div style="position:relative;float:left;width:70%;margin:0;padding:0;text-align:center;background-color:#ffffff;"><h2>'+docTitle+'</h2></div>';
	prnHead+='\n<div style="position:relative;clear:right;float:right;width:15%;margin:0;padding:10px 0;text-align:left;background-color:#ffffff;">'+printPrompt()+'</div>';
	prnHead+='\n</div>';
	prnHead+='\n<table width="100%" cellspacing="0" cellpadding="0" border="0">'
		+'<tr valign="top"><td align="center" colspan="3"><h4>'+navObj+'</h4></td></tr>'
		+'<tr valign="bottom"><td align="left"><h4>Item</h4></td><td align="right"><h4>Qty</h4></td><td align="right"><h4>'+databaseName+' Price</h4></td></tr>'

	prnFoot='<tr valign="top"><td align="center" colspan="3"><h4>'+navObj+'</h4></td></tr>';
	prnFoot+='\n<div class="dColor" style="margin:0;padding:0;text-align:center;">\n'
	prnFoot+='</table>';
	prnFoot+='\n<div class="textBox">';
	//prnFoot+='\n<div style="position:relative;float:left;width:15%;margin:0;padding:0;text-align:left;">&nbsp;<br /></div>';
	//prnFoot+='\n<div style="position:relative;float:right;width:15%;margin:0;padding:0;text-align:right;">'+(parent.printPrompt())+'</div>';
	prnFoot+='\n<div style="position:relative;width:70%;margin:0px auto;padding:0;">\n<p><em>'+docFootTxt+'</em></p>\n</div>';
	prnFoot+='\n</div></div>';
	}

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

function lineFormat(){
/******************************************************************************
Format result of query string for innerhtml
******************************************************************************/
	//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+'"';}
	return(text$Format());}

function textFormat(){
/******************************************************************************
Format result of query string for frames.main
******************************************************************************/
	dBase['sLink']="javascript:parent.vPage('"+dBase.$partid+"');";
	return(text$Format());
	}

function text$Format(){
/******************************************************************************
Format plain html output 
******************************************************************************/
	qq='<br />';if(dBase.$qty>1){qq=dBase.$qty;}
	rr='<br />';if(dBase.$rsp>0){rr=dBase.$rsp;}
	iconStr='<a href="'
		+'htm3mail.htm'
		+'?subject='+document.title
		+'&n='+dBase.$uri
		+'&name='+urlencode(dBase.$name)
		+'&descr='+urlencode(dBase.$descr)
		+'&qty='+dBase.$qty
		+'&sell='+dBase.$sell
		+'&sell0='+dBase.$sell0
		+'" title="Buy '+dBase.$name
		+'"><img src="'+dBase['$thumb']
		+'" alt="Buy '+dBase.$name
		+' Now!" /></a>';
	var $str = '<tr valign="top"><td align="center">'
		+iconStr 
		+'</td><td align="left" colspan="3"><p>'
		+xs+' '+dBase.$descr 
		+'</p></td><td><p>'
		+qq 
		+'</p></td><td align="right"><p>' 
		+zz
		+'</p></td></tr>'; 
	return($str);
	}

function printFormat(){
/******************************************************************************
Format result of query string for virtual page
******************************************************************************/
	return('<tr valign="top"><td align="left"><p>'
		+xs+' '+dBase.$descr 
		+'</p></td><td align="right"><p>'
		+dBase.$qty 
		+'</p></td><td align="right"><p>' 
		+zz 
		+'</p></td></tr>'); 
	}

function textboxFormat(){
/******************************************************************************
Format result of query string for single textbox output 
******************************************************************************/
	//confirm(selfUrl()+'/textboxFormat/Line314:'+'\nxd = '+xd);
	///////////////////////////////////////////////////////
	var $str='';
	if(dBase.$sell.length>0){
		$str='<div class="headerDiv"><div class="bColor">';
		$str+='\n<b>'+xd+'</b> '+dBase.$descr;
		$str+='\n<br />';
		$str+='\n'+databaseName+' price inc gst: <b>'+zz+'</b>';
		$str+='</div></div>';
		}
	return($str);
	}

function textboxFormatOld(){
/******************************************************************************
Format result of query string for single textbox output 
******************************************************************************/
	//confirm(selfUrl()+'/textboxFormat/Line314:'+'\nxd = '+xd);
	///////////////////////////////////////////////////////
	var $str='';
	if(dBase.$sell.length>0){
		$str='<div class="headerDiv"><div class="dColor">';
		$str+='\n<b>'+xd+'</b> '+dBase.$descr;
		$str+='\n</div>';
		$str+='\n<div class="blueline"></div>';
		$str+='<div class="bColor">';
		$str+='\n'+(printPrompt());
		//$str+='\n'+databaseName+' price inc gst: <b>'+zz+qq+'</b>';
		$str+='\n'+databaseName+' price inc gst: <b>'+zz+'</b>';
		$str+='</div></div>';
		}
	return($str);
	}

function mtextFormat(){
/******************************************************************************
Format result of query string for multi textbox output 
******************************************************************************/
	//confirm(selfUrl()+'/textboxFormat/Line314:'+'\nxd = '+xd);
	///////////////////////////////////////////////////////
	var $str='';
	if(dBase.$sell.length>0){
		$str='<div class="headerDiv"><div class="bColor">';
		$str+='\n<b>'+xd+'</b> '+dBase.$descr;
		$str+='\n<br />';
		$str+='\n'+databaseName+' price inc gst: <b>'+zz+'</b>';
		$str+='</div></div>';
		}
	return($str);
	}

function mtextFormatOld(){
/******************************************************************************
Format result of query string for multi textbox output 
******************************************************************************/
	var $str='';
	if(dBase.$sell.length>0){
		$str='<div class="headerDiv">';
		$str+='\n<div class="bColor"><h4 class="center">'+databaseName+' price inc gst: '+zz+qq+'</h4></div>';
		$str+='</div>';
		}
	return($str);
	}
//confirm('end wsstock.def');
