﻿//ROTATING IMAGE

var i = -1;
var count ;
function runRotateimg(){
xhttp=new XMLHttpRequest()
xhttp.open("GET","imgfile.xml",false);
xhttp.send("");
xmlDoc=xhttp.responseXML;
count = xmlDoc.documentElement.childNodes.length;
setInterval("rotateimage()",2000);
}


function rotateimage(){
i ++;
if (i > count - 1){i=0;}
var img = document.getElementById('rImage'); 
var value = xmlDoc.getElementsByTagName("image")[i].attributes[0].nodeValue;
img.src= value
}

//END


//MODAL

$(document).ready(function() {    
  
    //select all the a tag with name equal to modal  
    $('a[name=modal]').click(function(e) {  
        //Cancel the link behavior  
        e.preventDefault();  
        //Get the A tag  
        var id = $(this).attr('href');  
      
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width();  
      
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth,'height':maskHeight});  
          
        //transition effect       
        $('#mask').fadeIn(0000);      
        $('#mask').fadeTo("fast",0.8);    
      
        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  
                
        //Set the popup window to center  
        $(id).css('top',  winH/2-$(id).height()/2);  
        $(id).css('left', winW/2-$(id).width()/2);  
      
        //transition effect  
        $(id).fadeIn(100);   
        
        
         //image gallery
        if(id == "#picviewer"){
          var src = $(this).context.children[0].src;  
          var alt = $(this).context.children[0].alt; //image alt
          $("#picimg").attr('src',src);
          $("#fullview").attr('href',src);
          $("#h3name").text(alt);
        }
      
      
    });  
      
    //if close button is clicked  
    $('.window .close').click(function (e) {  
        //Cancel the link behavior  
        e.preventDefault();  
        $('#mask, .window').hide();  
    });       
      
    //if mask is clicked  
    $('#mask').click(function () {  
        $(this).hide();  
        $('.window').hide();  
    });   
    
          
});  



//var i = -1;
//var count ;
//function runRotateimg(){
//xhttp=new XMLHttpRequest()
//xhttp.open("GET","imgfile.xml",false);
//xhttp.send("");
//xmlDoc=xhttp.responseXML;
//count = xmlDoc.documentElement.childNodes.length;
//setInterval("rotateimage()",2000);
//}


//function rotateimage(){
//i ++;
//if (i > count - 1){i=0;}
//var img = document.getElementById('rImage'); 
//var value = xmlDoc.getElementsByTagName("image")[i].attributes[0].nodeValue;
//img.src= value
//}
