function xmlhttpPost(divName,file,cat,album) {
    var xmlHttpReq = false;
    //var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	
    xmlHttpReq.open('POST', divName + ".php?dir=" + cat, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.onreadystatechange = function() {
        
		if (xmlHttpReq.readyState != 4)
		{
			if ( divName == "photo" ) 
			{
				  var mytext="<br><br><br><br><br><font style='font-size:11px;' face='Verdana'><img src=images/indicator.gif> loading</font>"	;
			 	  updatepage(divName,mytext,cat);
			}
		}
		
		
		if (xmlHttpReq.readyState == 4) {
            updatepage(divName, xmlHttpReq.responseText,cat);
		}
        
    }

	if(album=="yeni"){
	xmlHttpReq.send(getquerystring2(file));
	}else{
	xmlHttpReq.send(getquerystring(file));	
	}

}


var red_link="";

var file="";

var page=1;

function refresh(linkName,afile,cat) {
	
	 file=afile;
//foto aciklamasi icin, array tanimi
var remzi=0;
var albumarray = new Array()

//women
	albumarray[0]=["r1_bg.jpg", "Zip Front Chenille Robe Style #40018"]
	albumarray[1]=["r2_bg.jpg", "Rib Chenille Hooded Robe Style #40027"]
	albumarray[2]=["r3_bg.jpg", "Chenille Shawl Collar Robe Style#31170"]
	
	albumarray[9]=["r4_bg.jpg", "Shawl Collar Chenille Robe Style #20911"]
	albumarray[10]=["r5_bg.jpg", "Zip Front Rib Chenille Robe Style#40010"]
	albumarray[11]=["r6_bg.jpg", "Cooljam Moisture Wicking Pajamas"]
//men

	albumarray[3]=["25_G.jpg","Shawl Collar Robe Style#FUN285"]
	albumarray[4]=["Ekinok14.jpg","Style #11131 Women's Shawl Collar & Style #11132 Men's Shawl Collar"]
	albumarray[5]=["Ekinok15.jpg", "  Shawl Collar Robe Style #11120"]
	albumarray[6]=["Ekinok21.jpg", "Kimono Robe Style #15260"]
	albumarray[7]=["Ekinok22.jpg", "Hooded Robe Style#12580"]
	albumarray[8]=["Ekinok23.jpg", "Kimono Style#17840"]
while (remzi<albumarray.length)
{

	
	if (albumarray[remzi][0]==file)
	{
		
		document.getElementById('foto_aciklama').innerHTML=albumarray[remzi][1];
		
	
	}
	remzi=remzi+1;
	
}

	
   


    obj=document.getElementById(linkName);
    if ( obj.className == "redcellborder" )
        {  return; }
    obj.className='redcellborder';
    obj.onmouseover="null" ;
    obj.onmouseout="null" ;

    xmlhttpPost("photo",file,cat);

    if ( red_link != "" ) {
        obj=document.getElementById(red_link);
        obj.className="cellborder";
        obj.onmouseover=function() { this.className="cellover"; } ;
        obj.onmouseout=function() { this.className="cellborder"; } ;
    }

    red_link=linkName;

    xmlhttpPost("exif",file,cat);

    }

function getquerystring(file) {
    qstr = 'ifile=' + escape(file) + '&page=' + page;  // NOTE: no '?' before querystring
    return qstr;
}

function getquerystring2(file) {
	page=1;
    qstr = 'ifile=' + escape(file) + '&page=1' //+ page;  // NOTE: no '?' before querystring
    return qstr;
}


function nextpage(cat) {
    page++;
    firstLoad(cat);
}

function prevpage(cat) {
    page--;
    firstLoad(cat);
}


function firstpage() {
    page=1;
    firstLoad();
}

function lastpage() {
    page=maxpage;
    firstLoad();
}

function firstLoad(cat)  {
goster('album_layer');
gizle('yaziburada');
gizle('flash_main');
   xmlhttpPost("thumb",file,cat);  
}


function firstLoad2(cat,album)  {
goster('album_layer');
gizle('yaziburada');
gizle('flash_main');
   xmlhttpPost("thumb",file,cat,album);  
}



function updatepage(divName, str,cat){
    if ( divName == "thumb" ) {
        var data=str.split("|");
        file = data[0]; maxpage=data[1];
		
		//undefined yazısı thumbs div inde gorunmesin diye..
		
		if(data[2] != null)
		{ 
			document.getElementById(divName).innerHTML = data[2]; 
		}
        refresh("a_0",file,cat);
    }
    else {
        document.getElementById(divName).innerHTML = str;
		
    }
}

function gizle(divadi){
	//document.getElementById(divadi).style.visibility = "hidden";	
	document.getElementById(divadi).innerHTML="";
	}
	
function goster(divadi){
	//document.getElementById(divadi).style.visibility = "visible";
	document.getElementById(divadi).innerHTML="<table cellpadding=0 cellspacing=0 border=0<tr><td width=27></td><td width=300 height=200 valign=top bgcolor=#FFFFFF><div id='thumb'></div></td><td valign=top><div class=style3 id='foto_aciklama' align='left'></div><div id='photo'></div><div id='exif'></div></td><td width=30></td></tr></table>";
	}

 
	
