// (c) UK 2003 Scannex Electronics Ltd
// Author: Matt Page


// Icon type definitions
BTITACROBAT = 0;
BTITEXE = 1;
BTITZIP = 2;

// Page location flags
ScannexCOM = 0;
LocalDisk = 0;

// Output a table divider
function btdiv() {document.write('<tr><td colspan=3><hr></td></tr>');}

// Create a group
function btgroup(Fragment, GroupName, ImageName, ImageName2) {
	document.write('<tr><td colspan="3" valign="bottom" class="tgroup">');
	if (ImageName2) {
		document.write('<img src="');
		document.write(ImageName2);
		document.write('" border=0 align="right">');
	}
	if (ImageName != '') {
		document.write('<img src="');
		document.write(ImageName);
		document.write('" border=0 align="right">');
	}
	if (Fragment != '') {
	  document.write('<a name="');
	  document.write(Fragment);
	  document.write('">');
	  document.write(GroupName);
	  document.write('</a>');
	}
	else {
	  document.write(GroupName);
	}
	document.write('</td>');
	document.write('</tr>');
}

// Create heading
function bthead(Head1, Head2, Head3) {
	document.write('<tr>');
	if (Head2 != '') {
	  document.write('<td class="theadc">');
	  document.write(Head1);
	  document.write('</td>');
	  document.write('<td class="theadc">');
	  document.write(Head2);
	  document.write('</td>');
	}
	else {
	  document.write('<td colspan="2" class="theadc">');
	  document.write(Head1);
	  document.write('</td>');
	}
	document.write('<td class="thead">Description</td></tr>');
}


// Begin the table
function btbegin() {
	pageloc = location.href;
	LocalDisk = (pageloc.substr(0, 5) == 'file:');
	//LocalDisk = 0;
        ScannexCOM = (pageloc.indexOf('www.scannex.com') >= 0);
	document.write('<table border="0" width="100%" cellspacing="3" cellpadding="2">');
	document.write('<tr><td width="10%"></td><td width="10%"></td><td width="80%"></td></tr>');
}

// End the table
function btend() {
	document.write('</table>');
}

function btExtension(Filename) {
	if (Filename.charAt(Filename.length-1) == '/') {return ''}	// URL
	if (Filename.substr(0, 7) == 'mailto:') {return ''}		// email
	dotplace = Filename.lastIndexOf('.');
	if (dotplace < 0) {return ''}					// Couldn't find a dot
	else {return Filename.substr(dotplace+1, 3)}			// Return the extension
}

function btImageName(extension) {
	switch (extension) {
		case 'pdf' : imgname = '../images/iconacrobat.gif'; break;
		case 'exe' : imgname = '../images/iconexe.gif'; break;
		case 'zip' : imgname = '../images/iconzip.gif'; break;
		case 'lua' : imgname = '../images/iconlua.gif'; break;
		case 'php':
		case 'htm':
		case 'html': imgname = '../images/iconlink.gif'; break;
		case '' : imgname = '../images/iconlink.gif'; break;
		default : imgname = '../images/iconfile.gif';
	}
	document.write('<img src="');
	document.write(imgname);
	document.write('" border="0" width="16" height="16">');
}

function btGAAction(extension) {
	switch (extension) {
		case 'pdf' : return extension; break;
		case 'exe' : return extension; break;
		case 'zip' : return extension; break;
		case 'lua' : return extension; break;
		case 'php' : return extension; break;
		case 'htm' :
		case 'html': return "html"; break;
		case '' : return "URL"; break;
		default : return "OTHER";
	}
}

function btGAcode(Filename) {
// return " onClick=\"javascript: pageTracker._trackEvent('Downloads','"+btGAAction(btExtension(Filename))+"','"+Filename+"');\" ";
 return " onClick=\"javascript: _gaq.push(['_trackPageview', '"+Filename+"']);\" ";
// return " onClick=\"javascript: pageTracker._trackPageview('"+Filename+"');\" ";
// return "";
}

function btSecure(Filename) {
	if (Filename.indexOf('pwpa/') >= 0) {
		document.write('<img src="../images/iconsecure.gif" border="0">');
	}
}

function btNorm(Filename) {
	if ((Filename.indexOf('://') < 0) &&
		  (!LocalDisk && !ScannexCOM) &&
	    ((Filename.substr(3, 5) == 'pwpa/') || (Filename.substr(3, 6) == 'files/'))) {
		return ('http://www.scannex.com/') + (Filename.substr(3, Filename.length));
	}
	else {
		return Filename;
	}
}

function btentry(Download1, Download2, Title, Info, Version, Size) {
	Extension1 = btExtension(Download1);
	Extension2 = btExtension(Download2);
	if (Download2 != '') {
		document.write('<tr><td class="tcellc">');
		document.write('<a href="'+btNorm(Download1)+'"');
		if (Extension1 == 'pdf') {document.write(' target="datasheet"' );}
		document.write(btGAcode(Download1));
		document.write('>');
		btImageName(Extension1)
		btSecure(Download1);
		document.write('</a></td><td class="tcellc">');
		document.write('<a href="'+btNorm(Download2)+'"');
		if (Extension2 == 'pdf') {document.write(' target="datasheet" ');}
		document.write(btGAcode(Download2));
		document.write('>');
		btImageName(Extension2);
		btSecure(Download2);
		document.write('</a>');
	}
	else {
		document.write('<tr><td class="tcellc" colspan="2">');
		document.write('<a href="'+btNorm(Download1)+'"');
		if (Extension1 == 'pdf') {document.write(' target="datasheet" ');}
		else if (Download1.indexOf('://')>=0){document.write(' target="_blank"');}
		document.write(btGAcode(Download1));
		document.write('>');
		btImageName(Extension1);
		btSecure(Download1);
		document.write('</a>');
	}
	document.write('</td><td class="tcell">');
	if (Download2 == '') {
		document.write('<a href="'+btNorm(Download1)+'"');
		if (Download1.indexOf('.pdf')>0) {document.write(' target="datasheet" ');}
		document.write(btGAcode(Download1));
		document.write('><b>');
		document.write(Title);
		document.write('</b></a>&nbsp;');
	}
	else {
		document.write('<b>');
		document.write(Title);
		document.write('</b>&nbsp;');
	}
	if (Version != '') {
		document.write('<span class="tcellv">[');
		document.write(Version);
		document.write(']</span>');
	}
	if (Size != '') {
		document.write('&nbsp;<span class="tcells">');
		document.write(Size);
		document.write('</span>');
	}
	if (Info != '') {
		document.write('<br><span class="tcelli">');
		document.write(Info);
		document.write('</span>');
	}
	document.write('</td></tr>');
}

function btfrags() {
	document.write('<tr><td colspan="2"></td><td class="tcell">');
	document.write('<a href="#top">top of page</a>');
	document.write('</td></tr>');
}

function prodnav(baseurl, pn, fn) {
	var pagesuff=new Array(4)
	var pagename=new Array(4)
	pagesuff[1]='';		pagename[1]='Overview';
	pagesuff[2]='_d';	pagename[2]='Detail';
	pagesuff[3]='_s';	pagename[3]='Spec';
	
	document.write('<table align="right" border="0" padding="1"><tr valign="top">');
	
	for (page=1; page<=3; page++) {
		if (page==pn) {
			document.write('<td class="pnavh">[');
			document.write(pagename[page]);
			document.write(']</td>');
		}
		else {
			document.write('<td class="pnav"><a href="');
			document.write(baseurl);
			document.write(pagesuff[page]);
			document.write('.html">[');
			document.write(pagename[page]);
			document.write(']</a></td>');
		}
	}
	document.write('<td class="pnav">');
	document.write('<a href="downloads.html#');
	document.write(fn);
	document.write('">[Downloads]</a>');
	document.write('</td></tr></table>');
}


function _psblock() {
	document.write('<tr><td>&nbsp;</td>');
	document.write('<td width="20%" class="pselc"><a href="pipb.html"><img src="../images/smallip4.gif" border="0"><br>ip.4-128.m</a></td>');
	document.write('<td width="20%" class="pselc"><a href="pipb.html"><img src="../images/smallip1.gif" border="0"><br>ip.1-32(m)</a></td>');
	document.write('<td width="20%" class="pselc"><a href="pub.html"><img src="../images/smallub.gif" border="0"><br>MicroBuffer</a></td>');
	document.write('</tr>');
}

function psbegin() {
	document.write('<table border="0" align="left" cellpadding="2">');
	_psblock();
}

function _ps(d) {
	if (d=='+') {
		document.write('<img src="../images/psy.gif" border="0">');
	}
	else {
		if (d=='-') {
			document.write('<img src="../images/psn.gif" border="0">');
		}
		else {
			document.write(d);
		}
	}
}

function psentry(detail,ip4,ip1,ub) {
	document.write('<tr><td class="pseli">');
	document.write(detail);
	document.write('</td><td class="pselc">');
	_ps(ip4);
	document.write('</td><td class="pselc">');
	_ps(ip1);
	document.write('</td><td class="pselc">');
	_ps(ub);
	document.write('</td></tr>');
}

function psend() {
	_psblock();
	document.write('</table>');
}

function sel_buildemail(u, s) {
	document.write('<a href="mailto:');
	document.write(u);
	document.write('@');
	document.write(s);
	document.write('">');
	document.write(u);
	document.write('@');
	document.write(s);
	document.write('</a>');
}

function sel_buildemailn(u,s,n) {
	document.write('<a href="mailto:');
	document.write(u);
	document.write('@');
	document.write(s);
	document.write('">');
	document.write(n);
	document.write('</a>');
}


