// JavaScript for DogShowGallery.com
function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}

function changeImages() {
  if (document.images && (preloadFlag == true)) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
      document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
  }
}

var preloadFlag = false;
function preloadImages() {
  if (document.images) {
    buttons_03_over = newImage("images/nav/buttons_03-over.gif");
    buttons_05_over = newImage("images/nav/buttons_05-over.gif");
    buttons_06_over = newImage("images/nav/buttons_06-over.gif");
    buttons_07_over = newImage("images/nav/buttons_07-over.gif");
    buttons_08_over = newImage("images/nav/buttons_08-over.gif");
    buttons_09_over = newImage("images/nav/buttons_09-over.gif");
    buttons_10_over = newImage("images/nav/buttons_10-over.gif");
    buttons_11_over = newImage("images/nav/buttons_11-over.gif");
    buttons_12_over = newImage("images/nav/buttons_12-over.gif");
    buttons_13_over = newImage("images/nav/buttons_13-over.gif");
		side_nav_buttons_01_over = newImage("images/side_nav_buttons_01-over.gif");
		side_nav_buttons_02_over = newImage("images/side_nav_buttons_02-over.gif");
		side_nav_buttons_03_over = newImage("images/side_nav_buttons_03-over.gif");
		side_nav_buttons_04_over = newImage("images/side_nav_buttons_04-over.gif");
		side_nav_buttons_05_over = newImage("images/side_nav_buttons_05-over.gif");
		side_nav_buttons_06_over = newImage("images/side_nav_buttons_06-over.gif");
		preloadFlag = true;
	}
}

var time_variable;
 
function getXMLObject()  //XML OBJECT
{
   var xmlHttp = false;
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   }
   catch (e) {
     try {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
     }
     catch (e2) {
       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
     }
   }
   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   }
   return xmlHttp;  // Mandatory Statement returning the ajax object created
}
 
var xmlhttp = new getXMLObject();	//xmlhttp holds the ajax object

function openGallery(gal) {
  var getdate = new Date();  //Used to prevent caching during ajax call
  if(xmlhttp) { 
  	var sendstr;
		sendstr="gallery.php?gal="+gal;
	xmlhttp.open("GET",sendstr,true); //calling testing.php using POST method
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(null); //Posting txtname to PHP File
	
  }
}

function amnav(pnum,trow,ptnum,gal) {
  var getdate = new Date();  //Used to prevent caching during ajax call
  if(xmlhttp) { 
  	var sendstr;
		sendstr="gallery.php?pageNum_photos="+pnum+"&totalRows_photos="+trow+"&pageNum_thumbs="+ptnum+"&gal="+gal;
	xmlhttp.open("GET",sendstr,true); //calling testing.php using POST method
	xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(null); //Posting txtname to PHP File
	window.location.hash = "top"
  }
}

function thumnav(pnum,trow,ptnum,gal) {
  var getdate = new Date();  //Used to prevent caching during ajax call
  if(xmlhttp) { 
  	var sendstr;
		sendstr="gallery.php?pageNum_thumbs="+pnum+"&totalRows_thumbs="+trow+"&pageNum_photos="+ptnum+"&gal="+gal;
	xmlhttp.open("GET",sendstr,true); //calling testing.php using POST method
	xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(null); //Posting txtname to PHP File
	window.location.hash = "thumbs"
  }
}

function thumbSelect(pnum,trow,pt,gal) {
  var getdate = new Date();  //Used to prevent caching during ajax call
    if(xmlhttp) { 
  	var sendstr;
		sendstr="gallery.php?pageNum_photos="+pnum+"&totalRows_photos="+trow+"&pageNum_thumbs="+pt+"&gal="+gal;
	xmlhttp.open("GET",sendstr,true); 
	xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send(null); //Posting txtname to PHP File
	window.location.hash = "top"
  }
}


function handleServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
       document.getElementById("show_gallery").style.display='block';
	   document.getElementById("show_gallery").innerHTML=xmlhttp.responseText; //Update the HTML Form element 
	   //document.getElementById("dshow").style.display="none";
     
	 }
     else {
        alert("Error during AJAX call. Please try again");
     }
   }
}

function closeGallery() {
document.getElementById("photogal").style.display="none";
document.getElementById("dshow").style.display="block";
}
