//shop page constants & functions
var browser= "style";
var showcodes=true;
var items= new Array();
var nitems=0;

function dp2(n){sxx=new String(n+.005);t=sxx.substring(0,3+sxx.indexOf("."));return t;}

function Item(header,code,desc,img){
this.header=header;
this.code=code;
this.desc=desc;
this.sizes=new Array();
this.prices=new Array();
this.weights=new Array();
this.avail=new Array();
this.nis=new Array();
this.ns=0;
this.size=0;
this.img=img;
++nitems;
}

function Status(i,size,price,weight,avail){
items[i].sizes[items[i].ns]=size;
items[i].prices[items[i].ns]=price;
items[i].weights[items[i].ns]=weight;
items[i].avail[items[i].ns]=avail;
items[i].nis[items[i].ns]=1000;
if(avail=="Out of Stock"){items[i].nis[items[i].ns]=0;}
++items[i].ns;
}

function doAdd(s){
if(items[s].nis[items[s].size]<1){alert("Sorry - " + items[s].avail[items[s].size]);return;}
parent.addToTrolley(items[s].code,items[s].desc,items[s].prices[items[s].size],
items[s].weights[items[s].size],items[s].sizes[items[s].size],items[s].nis[items[s].size]);
}

function doClick(i){
s='<html><head><title>Enlarge</title>'+
'<link rel="stylesheet" href="style.css"></head>'+
'<body bgcolor="#333333"><table width=500><tr valign=top>'+
'<td><form><input type=button value="Close" onClick="window.close()"></form></td>'+
'<td class="paragraph">'+items[i].desc;
if(items[i].lc>0)
{s=s+'<br><a class=aboutus href="sizes'+items[i].lc+'.htm";>Size Details</a>';}
s=s+'</td></tr>'+
'<tr><td colspan=2><img src="pics/'+items[i].img+'.jpg" hspace=0 alt="*"></td></tr>'+
'</table></body></html>';
w=window.open("","w","scrollbars=yes,status=yes,resizable=yes,width=550,height=600");
w.document.write(s)
w.document.close();
w.moveTo(50,0);
w.focus();
}

function showItems(){
//nitems=2;
for(i=0;i<nitems;++i){
ext=".jpg";
if(items[i].header !=""){
document.write('<td class=item-header colspan=3>'+items[i].header+'</td></tr>');}

c='<a href=products/'+items[i].code +'.htm class=a target=_blank>';
p=c+'<img src="pics/t-'+items[i].img+ext+'" border=0></a>';
if(pageimage != ""){p="";}
str='<tr valign=top>'+
'<td>'+p+'</td><td class=a width=200>'+c+items[i].desc+'</a>';
if(showcodes){str=str+'<br>Product Code: '+items[i].code;}
str=str+'</td><td class=a width=200><table>';

if(items[i].ns==1){
s=items[i].sizes[0];
sp=dp2(items[i].prices[0]);
//sp=items[i].prices[0];
str=str+'<tr valign=top><td class=a width=30>'+s+
'</td><td class=a width=80 nowrap>$'+sp+'</td><td class=a>'+items[i].avail[0]+'</td></tr>';}

else{
ch=" checked";
for(j=0;j<items[i].ns;++j){
str=str+'<tr><td class=a nowrap><input name="size" type=radio value="'+items[i].sizes[j]+'"'+ch+
' onClick="items['+i+'].size='+j+';">'+items[i].sizes[j]+'</td>'+
'<td class=a width=80>$'+dp2(items[i].prices[j])+'</td>'+
'<td class=a>'+items[i].avail[j]+'</td></tr>';
ch="";}
}

str=str+'</table></td><td><a href="javascript:doAdd(\''+i+'\');">'+
'<img src="img/add.jpg" border=0></a></td></tr>';
//alert(str);
document.write(str);
} //next i
}


