
var xmlDoc=null;
var x;
var a;
var cell_counter=0;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("berrechid_sport.xml");
x=xmlDoc.getElementsByTagName("IMAGE");
} 
function display(start_image,number_of_images,col_count) {
var start_image;
var number_of_images;
var col_count;
cell_counter= 0;
        // get the reference for the body
        var body = document.getElementsByTagName("div")[0];

        // creates a <table> element and a <tbody> element
        var tbl     = document.createElement("table");
        var tblBody = document.createElement("tbody");
				var k=0;
				//alert(x.length);
				//alert(cell_counter);
        // creating all cells

        for (var j = 0; j < x.length; j++) {
            // creates a table row
						if (cell_counter >= number_of_images  || start_image >= x.length)break;
						//if (cell_counter >= Number(x.length) )break;
            var row = document.createElement("tr");

            for (var i = 0; i < col_count; i++) {
                // Create a <td> element and a text node, make the text
                // node the contents of the <td>, and put the <td> at
                // the end of the table row
								if (cell_counter >= number_of_images || start_image >= x.length)break;
								//if (cell_counter >= Number(x.length) )break;
                var cell = document.createElement("td");
								var image = document.createElement("img");
								image.setAttribute("src", x[start_image].getElementsByTagName("NAME")[0].childNodes[0].nodeValue);	
								image.setAttribute("alt", x[start_image].getElementsByTagName("NAME")[0].childNodes[0].nodeValue);
								image.setAttribute("height", "80");
								image.setAttribute("width", "120");										
								image.onclick=Function("setCookie('"+start_image+"')");
																								
								cell.appendChild(image);
                row.appendChild(cell);
								start_image++;
							  cell_counter++;
								
            }
						
            // add the row to the end of the table body
            tblBody.appendChild(row);
        }


        // put the <tbody> in the <table>
        tbl.appendChild(tblBody);
        // appends <table> into <body>
        body.appendChild(tbl);
        // sets the border attribute of tbl to 2;
        tbl.setAttribute("class", "img_ber");


    }
	
function setCookie(value)
{
var exdate=new Date();
var expiredays = 10;
var c_name="berrechid_sport";
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
window.open('berrechid_sport_foto.html','_self');
}
