function openWIN(img,w,h) {

//to open HTML pages
//url,,width=???,height=???,resize=0,scrollbars=0,menubar=0,status=0
//url = '"viewlarger.html","view","width=400px,height=600px,resize=0,scrollbars=0,menubar=0,status=0"';
//eval('window.open('+url+').focus();')

//creating new html page and open it
var html="";
html += "<html>";
html += "<head>";
html += "  <title>gogfim.org</title>";
html += " </head>";
html += " <body topmargin=0 leftmargin=0>";
html += "	<img src='store_x/"+img+"' border=0>";
html += " </body>";
html += "</html>";

w = "width="+w+"px,";
h = "height="+h+"px,";
x = w + h + "resizable=no,scrollbars=no,menubar=no,status=no";

var newWin = window.open("store_x/viewlarger.html","view",x);
newWin.document.open();
newWin.document.write(html);

}


var xmlDoc;
// code for IE
if (window.ActiveXObject)
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	}
	// code for Mozilla, Firefox, Opera, etc.
	else {
				if (document.implementation.createDocument)
					{
						xmlDoc=document.implementation.createDocument("","",null);
					}
					else
					{
						alert('Sorry but your browser cannot handle this script technology.\n\nPlease use: IE, Mozilla, Firefox, Opera.');
					}
	}

xmlDoc.async=false;
xmlDoc.load("resources_data.xml");
var xitem=xmlDoc.getElementsByTagName("item");
var xtype=xmlDoc.getElementsByTagName("type");
var xtitle=xmlDoc.getElementsByTagName("title");
var xdesc=xmlDoc.getElementsByTagName("desc");
var xprice=xmlDoc.getElementsByTagName("price");
var xoff=xmlDoc.getElementsByTagName("off");
var xpay=xmlDoc.getElementsByTagName("pay");
var xship=xmlDoc.getElementsByTagName("ship");
var xship2=xmlDoc.getElementsByTagName("ship2");
var xcat=xmlDoc.getElementsByTagName("category");
var ximg=xmlDoc.getElementsByTagName("image");
var xw=xmlDoc.getElementsByTagName("image_width");
var xh=xmlDoc.getElementsByTagName("image_height");
var xflyer=xmlDoc.getElementsByTagName("flyer");

var tbl="";
var select="CD";
i=0;
x=0;
pv=0;
nx=0;
perpage=10;
count=0;

var pagenav = new Array();

function filter(s)
{
select=s;
i=0;
x=0;
y=0;
count=0;

//cleaning array
pagenav.length=0;

//setting range per page navegation: mark which item indexes
for (i=0; i<xitem.length; i++)
{
    if (xtype[i].childNodes[0].nodeValue==select)
			{
				if (count==0){
						pagenav[x]=i;
						}
				if (count==perpage){
					  x++; 
						pagenav[x]=i;
						count=0;
						}
				count++;
			}
}//end for
x=0;

previous();
}

function previous()
{
tbl="";

	if (pagenav.length>0){

			x--;
			if (x<0){x=0;}

			i=pagenav[x]; 
			y=x+1;
			if (y>=pagenav.length){
					y=xitem.length;
					}else{
						y=pagenav[x+1];
					}

//					alert("i="+i+" y="+y+" x="+x)

			for (i; i < y; i++)
				{
					var type=(xtype[i].childNodes[0].nodeValue);
					if (type==select){ display(); }
				}
	}//end if

	document.getElementById("show").innerHTML=tbl;

}

function next()
{
tbl="";

	if (pagenav.length>0){

			x++;
			if (x>=pagenav.length){
					x=pagenav.length-1;
					}
			i=pagenav[x]; 
  
			y=x+1;
			if (y>=pagenav.length)
					{
						y=xitem.length;
					}else{
						y=pagenav[x+1];
					}

			for (i; i < y; i++)
				{
					var type=(xtype[i].childNodes[0].nodeValue);
					if (type==select){ display(); }
				}
	}//end if

	document.getElementById("show").innerHTML=tbl;

}

function display()
{
		var item=xitem[i].childNodes[0].nodeValue;
		var type=(xtype[i].childNodes[0].nodeValue);
		var title=(xtitle[i].childNodes[0].nodeValue);
		var desc=(xdesc[i].childNodes[0].nodeValue);
		var price=(xprice[i].childNodes[0].nodeValue);
		var off=(xoff[i].childNodes[0].nodeValue);
		var pay=(xpay[i].childNodes[0].nodeValue);
		var ship=(xship[i].childNodes[0].nodeValue);
		var ship2=(xship2[i].childNodes[0].nodeValue);
		var cat=(xcat[i].childNodes[0].nodeValue);
		var img=(ximg[i].childNodes[0].nodeValue);
		var w=(xw[i].childNodes[0].nodeValue);
		var h=(xh[i].childNodes[0].nodeValue);
		var flyer=(xflyer[i].childNodes[0].nodeValue);

		tbl += '<table  width="500" align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="2" border="0" >';
		tbl += '<tr>';
		tbl += '		<td width=100 valign=top>';
		tbl += '		<a href=`javascript:openWIN("' + img + '","'+w+'","'+h+'");`  title="view image larger" ><img src="store/' + img + '" border="0">';
		tbl += '   » view larger</a>';

		if (flyer!="#")
		{
		tbl += '		<br><a href="store_x/' + flyer +'" target="_blank" title="view more info, flyer PDF file" >» view more info</a>';
		}
		tbl += '   </td>';

		tbl += '<td width=400 valign=top style="padding-left:15px; padding-top:0px;">';

		if (type == "CD"){type = 'CD';}
		if (type == "DV"){type = 'DVD';}
		if (type == "BK")	{type = 'Book';}
		if (type == "PK")	{type = 'Package';}

		tbl += type +'<br>';
		tbl += '<b>'+ title +'</b><br>';

		tbl += '<table  width="100%" align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" border="0" >';
		tbl += '<tr>';
		tbl += '		<td width=50% valign=top>';
		tbl += cat +'<br>';
		tbl += item +'<br><br>';
				if (off > 0)
				{
					tbl += '<font color="black">Our price: $<s>' + price +'</s></font><br>';
					tbl += '<font color="red">Save: ' + off + '%</font><br>';
					tbl += '<font color="green">You pay $' + pay + '</font><br>';
				}else{
					tbl += '<font color="black">Our price: $' + price +'</font><br>';
					pay=price;
				}
		tbl += '   </td>';

		tbl += '		<td width=50% valign=bottom align=right>';

		//VIEW SHOPPING CAR
		tbl += '<a	 title="view shopping cart" href=';
		tbl += '"https://www.paypal.com/cgi-bin/webscr?cmd=_cart';
		tbl += '&amp;business=mail@gogfim.org';
		tbl += '&amp;return=http://www.gogfim.org/resources.shtml';
		tbl += '&amp;cancel_return=http://www.gogfim.org/resources.shtml';
		tbl += '&amp;shopping_url=http://www.gogfim.org/resources.shtml';
		tbl += '&amp;display=1"';
		tbl += '	>» view car';
		tbl += '</a>&nbsp;&nbsp;&nbsp;';

		//BUY NOW BUTTON
		tbl += '<a	title="buy this product" href=';
		tbl += '"https://www.paypal.com/cgi-bin/webscr?cmd=_cart';
		tbl += '&amp;business=mail@gogfim.org';
		tbl += '&amp;return=http://www.gogfim.org/resources.shtml';
		tbl += '&amp;cancel_return=http://www.gogfim.org/resources.shtml';
		tbl += '&amp;shopping_url=http://www.gogfim.org/resources.shtml';
		tbl += '&amp;item_name=' + title;
		tbl += '&amp;item_number=' + item;
		tbl += '&amp;amount=' + pay;
		tbl += '&amp;shipping=' + ship;
		tbl += '&amp;shipping2=' + ship2;
		tbl += '&amp;add=1&amp;no_note=1&amp;currency_code=USD"';
		tbl += '	><img src="images/buy_now_out.gif" border="0">';
		tbl += '</a>';

/*    
							SHIPPING The cost of shipping this item if you have enabled item-specific shipping costs. 
											If shipping is used and shipping2 is not defined, this flat amount is charged regardless of the quantity of	items purchased.
											NOTE: The shipping variable takes effect only if the override checkbox is checked in your Profile. 
											See "Overriding	Shipping Calculation on Individual Transactions" on page 41.
											Default: if Profile-based shipping is enabled, customer is charged the amount or percentage defined in your Profile 
											
							SHIPPING2 The cost of shipping each additional item. 
											If omitted, and Profile-based shipping is enabled, your customer is charged the amount or 
											percentage defined in your Profile. 
*/

		tbl += '   </td>';
		tbl += '</tr>	';
		tbl += '</table>	';

		tbl += '<br>';
		tbl += '<div class="s_description">' + desc + '</div>';
								 
		tbl += '	</td>';
		tbl += '</tr>	';
		tbl += '</table>	';
		n=i+1;
		tbl += '<font color="silver">'+n+'</font>';
		tbl += '<hr>';

}

