
function showNextSet(collection_id,limit,img_limit){ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
         alert ("Browser does not support HTTP Request");
         return;
    }
    var url="getNextSetImages.php";

    lmt = limit+img_limit;
    
    url=url+"?limit="+lmt;
    url=url+"&collection_id="+collection_id;
    url=url+"&sid="+Math.random();
    //alert(url);
    xmlHttp.onreadystatechange=stateChanged ;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function showPrevSet(collection_id,limit,img_limit){ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
         alert ("Browser does not support HTTP Request");
         return;
    }
    var url="getNextSetImages.php";

    lmt = limit-img_limit;
    
    url=url+"?limit="+lmt;
    url=url+"&collection_id="+collection_id;
    url=url+"&sid="+Math.random();
    //alert(url);
    xmlHttp.onreadystatechange=stateChanged ;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function stateChanged() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
        document.getElementById("column").innerHTML=xmlHttp.responseText 
    } 
}
function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
     {
         // Firefox, Opera 8.0+, Safari
         xmlHttp=new XMLHttpRequest();
     }
     catch (e)
     {
         //Internet Explorer
         try
          {
              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          }
         catch (e)
         {
              xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
     }
    return xmlHttp;
}
function getDivImages(img,width,height,image_str)
{
    width=parseInt(width)+10;
    height=parseInt(height)+50;
    if(width){
        document.getElementById('light').style.width=width+'px';
    }
    if(height){
        document.getElementById('light').style.height=height+'px';
    }
    document.getElementById('light').style.display='block';
    document.getElementById('fade').style.display='block';
    var image_arr=new Array;
    image_arr=image_str.split('*');
    for(i=0;i<image_arr.length;i++)
    {
        if(image_arr[i]==img)
        {
            current=i;
            break;
        }
    }
    //current=image_arr.indexOf(img);
    if(current=="0" || current < 0){
        next=current+1;
        //nextSet=6-; nilaja
        document.getElementById('light').innerHTML="<img src='"+img+"' border='0'><br>";
        document.getElementById('light').innerHTML+="<a href = 'javascript:closeBox()'><img src='images/close.png' border='0'></a>";
        document.getElementById('light').innerHTML+="<center><img src='images/previous.png' border='0'>&nbsp;<a href=JavaScript:showNext('"+image_arr[next]+"','"+image_str+"')><img src='images/next.png' border='0'></a>&nbsp;<a href=JavaScript:showNext('"+image_arr[next]+"','"+image_str+"')><img src='images/next.png' border='0'></a>.</center>";
    } 
    else if(current==image_arr.length-1){
        prev=current-1;
        document.getElementById('light').innerHTML="<img src='"+img+"' border='0'><br>";
        document.getElementById('light').innerHTML+="<a href = 'javascript:closeBox()'><img src='images/close.png' border='0'></a>";
        document.getElementById('light').innerHTML+="<center><a href=JavaScript:showNext('"+image_arr[prev]+"','"+image_str+"')><img src='images/previous.png' border='0'></a>&nbsp;<img src='images/next.png' border='0'></center>";
    }
    else{
        prev=current-1;
        next=current+1;
        document.getElementById('light').innerHTML="<img src='"+img+"' border='0'><br>";
        document.getElementById('light').innerHTML+="<a href = 'javascript:closeBox()'><img src='images/close.png' border='0'></a>";
        document.getElementById('light').innerHTML+="<center><a href=JavaScript:showNext('"+image_arr[prev]+"','"+image_str+"')><img src='images/previous.png' border='0'></a>&nbsp;<a href=JavaScript:showNext('"+image_arr[next]+"','"+image_str+"')><img src='images/next.png' border='0'></a></center>";
    }
}
function showNext(img,image_str){ 
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
         alert ("Browser does not support HTTP Request");
         return;
    }
    var url="getImagesInfo.php";
    url=url+"?img="+img;
    url=url+"&image_str="+image_str;
    url=url+"&sid="+Math.random();
   
    xmlHttp.onreadystatechange=getResponse ;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function getResponse()
{
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
        var data=xmlHttp.responseText;
        var arr=[];
        arr=data.split('~');
        getDivImages(arr[0],arr[1],arr[2],arr[3]);
    } 
}
function closeBox()
{
    document.getElementById('light').style.display='none';
    document.getElementById('fade').style.display='none'
}
function changeImage(img_name)
{
     document.getElementById("img_display").innerHTML='<img class="img-border" src="'+img_name+'" width="388" height="530" />';
}