// JavaScript Document

function getHTTPObject() {
    if (typeof XMLHttpRequest != 'undefined') {
        return new XMLHttpRequest();
    }
    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            return new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
    }
    return false;
}

// Product Edit

// Gallery Slide
function showSlide(imageID,pg) {
	
	http = getHTTPObject()
	http.open("GET", "slide.asp?imageID=" +imageID+ "&pg="+pg, true);
	http.onreadystatechange = function() {//Call a function when the state changes.
		if(http.readyState == 4 && http.status == 200) {
			document.getElementById('galleryMain').innerHTML = http.responseText;
			
			if (imageID.length > 0) {
			showThumbs(imageID,'');
			}
			
			highlightSelected();

		}
	}
	http.send(null);

}

function highlightSelected() {

	var selected = document.getElementById('selected').value;
	var docName = "T"+selected;
	//document.docName.className = "selected";
		
}

function showThumbs(imageID,pg) {
	
	http2 = getHTTPObject()
	http2.open("GET", "thumbs.asp?imageID=" +imageID+"&pg="+pg, true);
	http2.onreadystatechange = function() {//Call a function when the state changes.
		if(http2.readyState == 4 && http2.status == 200) {
			document.getElementById('galleryThumbs').innerHTML = http2.responseText;
		}
	}
	http2.send(null);

}



// Animation functions for fading in the thumbnail images  
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
			for(i = opacStart; i >= opacEnd; i--) {
					setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
					timer++;
			}
	} else if(opacStart < opacEnd) {
			for(i = opacStart; i <= opacEnd; i++)
					{
					setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
					timer++;
			}
	}
}


//change the opacity for different browsers

	function changeOpac(opacity, id) {
        var object = document.getElementById(id).style;
        object.opacity = (opacity / 100);
        object.MozOpacity = (opacity / 100);
        object.KhtmlOpacity = (opacity / 100);
        object.filter = "alpha(opacity=" + opacity + ")";
	}

        function fadeOldImage(id, numColumns) {
          for (i=0;i< numColumns;i++) {
            tempDiv = "img_" + id + "_" + i;
            changeOpac(25, tempDiv);
          }
        }

