function showpic(pGallery) 
{

    //showpicx(pGallery, 1);
    
    /*    
    var d = document.createElement("div");
    d.id = "divTemp";

    var d1 = document.createElement("div")
    d1.id = "divPicBackground";
        
    d1.innerHTML = 
    '<a id="aClose" href="javascript:hidepic()">Bezárás</a>' +

                    '<object type="application/x-silverlight-2" data="data:application/x-silverlight-2," width="640" height="480">' +
    '<param name="background" value="#000" />'+
    '<param name="source" value="sl/ss/ClientBin/Vertigo.SlideShow.xap" />' +
    '<param name="initParams" value="ConfigurationProvider=XmlConfigurationProvider;Path=Configuration.xml,DataProvider=XmlDataProvider;Path=Data_xml.php?gall=' + pGallery + '" />' +
    '<a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"><img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /></a>'+
    '</object>';
                     
    d.appendChild(d1);
    document.body.appendChild(d);
    
    d1.style.opacity = 0.7;
    d1.style.filter = 'alpha(opacity=' + 70 + ')';
    */
}




function imgPic_onload()
{
    var ximg = document.getElementById( 'imgPic' );
    var xdivPicImg = document.getElementById( 'divPicImg' );   
    xdivPicImg.style.width = ximg.naturalWidth + 'px';
    xdivPicImg.style.height = ximg.naturalHeight + 'px';
    ximg.style.display = 'inline';
}

var gStartPic=''; 

function showpicx( pGallery, pStartPicture )
{   
    var d = document.createElement( "div" );
    d.id = "divTemp";
    d.innerHTML = '<div id="divPicBackground"></div>' +
                    '<div id="divPic">' +
                         '<div id="divPicNavigator">' +
                            '<a id="aPrev" href="javascript:loadImgNext(-1)">Előző</a>' +
                            '<a id="aNext" href="javascript:loadImgNext(1)">Következő</a>' +
                            '<a id="aClose" href="javascript:hidepic()">Bezárás</a>' +
                         '</div>' +


                      '<div id="divPicImg" >' +
                         '<p id="pPicImgTop"><span></span></p>' +
                         /* '<div id="divPicImgImg" >' +*/
                            '<img id="imgPic" alt="" onload="imgPic_onload()" />' +
                         /* '</div>' +*/
                         '<div id="divPicTitle">' +
                         '</div>' +                        
                         '<p id="pPicImgBottom"><span></span></p>' +
                         '<div id="divPicImgLoading" >Kép betöltése... </div>' +
                      '</div>' + 
                     
                     
                      '<div id="divPicList">' +
                         '<div id="divPicListDiv">' +
                            '<a id="aNavScrollLeft" href="javascript:navscroll(1)"><-</a>' +
                            '<a id="aNavScrollRight" href="javascript:navscroll(-1)">-></a>' +
                            '<div id="divPicListDivDiv">' +
                            '</div>' +
                         '</div>' +
                      '</div>' +
                   '</div>';
    document.body.appendChild( d );
    
    
    
  var x = document.getElementById( "divPicBackground" );
  x.style.opacity = 0.7;
  x.style.filter = 'alpha(opacity=' + 70 + ')';
 
  document.getElementById( "divPicListDivDiv" ).innerHTML = "";
  if( pStartPicture != null )
  {
    gStartPic = pGallery+'/'+pStartPicture;
  }
  betolt( pGallery );
}


function hidepic()
{
    var x = document.getElementById("divTemp");
    document.body.removeChild( x );
}


function loadImg( pImage, pImageTitle, pImgListImg )
{
    var y = document.getElementById( "imgPic" );
    y.style.display = 'none';
    y.src = pImage;
    
    y.ImgListIndex = pImgListImg.substr( 7, 5 );
    if( y.ImgListImg != null )
    {
        document.getElementById( y.ImgListImg ).className = 'unselected';
    }
    
    
    
    y.ImgListImg = pImgListImg;
    var z = document.getElementById( pImgListImg );
    z.className = 'selected';
    
    //y = document.getElementById( "divPicTitle" );
    //y.innerHTML = pImageTitle;
    
    //y.innerHTML = z.style.left;   
    //document.getElementById( 'divPicListDivDiv' ).style.left  = (-1*z.x)+'px';
}


function loadImgNext( p )
{
    var x = document.getElementById( "imgPic" );
    var next = parseInt( x.ImgListIndex ) + parseInt( p );
    var y = document.getElementById( "imgList" + next );
    if( y != null )
    {
       loadImg( y.Lfile, y.title, y.id );
    }
}

   
var xmlhttp;
function processReqChange()
{  
   if( xmlhttp.readyState == 4 )// only if req shows "loaded"
   {  
       if( xmlhttp.status == 200 ) // only if "OK"
       {
           var x = xmlhttp.responseXML;               
           var Sfiles = x.getElementsByTagName("Sfile");
           var Lfiles = x.getElementsByTagName("Lfile");
           var titles = x.getElementsByTagName("title");
           for( i=0; i<Sfiles.length; i++ )
           {
              var Sfile = Sfiles[i].childNodes[0].nodeValue;                  
              var Lfile = Lfiles[i].childNodes[0].nodeValue;   
              var imgtitle = '';
              try
              {
                imgtitle = titles[i].childNodes[0].nodeValue;
              }
              catch(e)
              {
              }
              
              var imgLink = document.createElement( 'a' );
              imgLink.href = 'javascript:loadImg(\''+ Lfile +'\', \''+ imgtitle +'\', \'imgList'+ i +'\')';
              
               
              var x_img = document.createElement( 'img' );
              x_img.id = 'imgList' + i;
              x_img.title = imgtitle;
              x_img.src = Sfile;
              x_img.Lfile = Lfile;
              x_img.style.position = 'relative';
              x_img.className = 'unselected';
              imgLink.appendChild( x_img );           
              document.getElementById( 'divPicListDivDiv' ).appendChild( imgLink );
              if( x_img.Lfile == gStartPic )
              {
                loadImg( Lfile, x_img.title, x_img.id );
              }              
           }
       }
       else
       {
           alert('There was a problem retrieving the XML data:\n' + xmlhttp.statusText);
       }
   }
}   


function betolt( pGallery )
{
        if( window.XMLHttpRequest )
        {
          // code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp = new XMLHttpRequest();
        }
        if (window.ActiveXObject)
        {
           // code for IE6, IE5
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        
        xmlhttp.onreadystatechange = processReqChange;
        xmlhttp.open("GET", "xml_gallery.php?gall="+pGallery, true);
        xmlhttp.send("");
}

function navscroll( pOffset )
{
    var xxx = document.getElementById( 'divPicListDivDiv' );
    if(  xxx.style.left == "" )
    {
        xxx.style.left = '0px'; 
    }
    var lx =  parseInt( xxx.style.left ) + (pOffset*100);
    if( lx > 0 )
    {
        lx = 0;
    }
    /*
    if( lx < document.getElementById( 'divPicListDiv' ).offsetWidth - xxx.scrollWidth )
    {
        //alert( xxx.offsetWidth )
        lx = document.getElementById( 'divPicListDiv' ).offsetWidth - xxx.scrollWidth;
    }
    alert(  lx );
    */
    xxx.style.left = lx + 'px';     
}
