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;

} 
function display(start_image,number_of_images,col_count) {
var start_image;
var number_of_images;
var col_count;
cell_counter= 0;

xmlDoc.load("akhbar_comment_fotos.xml");

x=xmlDoc.getElementsByTagName("IMAGE");

        // get the reference for the body
		var body = document.getElementById("de_tabel");

        // creates a <table> element and a <tbody> element
        var tbl     = document.createElement("table");
        var tblBody = document.createElement("tbody");
		var k=0;
        // 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;
                var cell = document.createElement("td");	
				var image = document.createElement("img");
				var my_div = document.createElement("div");
				var name = x[start_image].getElementsByTagName("SMALL")[0].childNodes[0].nodeValue;
				//alert(name+ "-----" + start_image+ "length" + x.length);
				image.setAttribute("src", x[start_image].getElementsByTagName("SMALL")[0].childNodes[0].nodeValue);	
				image.setAttribute("alt", x[start_image].getElementsByTagName("SMALL")[0].childNodes[0].nodeValue);
				image.setAttribute("vspace", '20');
				
				var deposter = (x[start_image].getElementsByTagName("DEPOSE")[0].childNodes[0].nodeValue);
		                var thetext = (x[start_image].getElementsByTagName("COMM")[0].childNodes[0].nodeValue);
				var txt = thetext +"<br />" + deposter ;
				my_div.className="ak_images";
				//my_div.innerHTML=txt;
				var w = Number(image.width);
				var h =  Number(image.height);
				image.onclick=Function("setCookie('"+start_image+"','"+w+"','"+h+"')");
				image.style.cursor='pointer';
				//setTimeout("",300);
				//image.setAttribute("height", "150");
				//image.setAttribute("width", "80");
				image.id="image_" + cell_counter;																								
				cell.appendChild(image);
				cell.appendChild(my_div);
                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,ww,hh)
{
var exdate=new Date();
var expiredays = 1;
var c_name="akhbar";
var ww;
var hh;
ww=Number(ww)+50;
hh=Number(hh)+200;
//alert(ww+"---"+hh);
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
c_name="akhbarww";
document.cookie=c_name+ "=" +escape(ww)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
c_name="akhbarhh";
document.cookie=c_name+ "=" +escape(hh)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
my_window=window.open("akhbar_foto.html", "_blank",  "scrollbars=yes, resizable=yes,width=800, height=800");
my_window.resizeTo(800,800);
setTimeout("",50);
}
function show_popup(num) {
var num;
day = new Date();
id = day.getTime();
url="image" + num + ".html";
eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800,height=800');");
}
function show_popup_new(value)
{
var exdate=new Date();
var expiredays = 1;
var c_name="akhbar";
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
my_window=window.open("akhbar_foto_new.html", "_blank",  "scrollbars=yes, resizable=yes,width=800, height=800");
my_window.resizeTo(800,800);
setTimeout("",50);
}
