﻿function showDescription(el, goodName)
{
	hideAllDescriptions(el.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode);
	//var o = el.parentNode.previousSibling.firstChild.firstChild;
	
	//table row
	tr = el.parentNode.parentNode;
	//first cell in row
	td = tr.getElementsByTagName("td")[0];
	//first child div
	div1 = td.getElementsByTagName("div")[0];
	//tooltip div
	o = div1.getElementsByTagName("div")[0];

	if(o.innerHTML == "")
	{
	
		//make url for request
		var url = "/GoodTooltip.ashx?good=" + goodName;

		//make request object
		if(window.XMLHttpRequest) {
			try {
				req = new XMLHttpRequest();
			} catch(e) {
				req = false;
			}
		// trying to create activeX object in IE
		} else if(window.ActiveXObject) {
   			try {
    			req = new ActiveXObject("Msxml2.XMLHTTP");
  			} catch(e) {
    			try {
      				req = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch(e) {
      				req = false;
    			}
			}
		}
		//if request object was created
		if(req) {
			//req.onreadystatechange = processRequest;
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					if (req.status == 200) {
						if(req.responseText != "")
						{
							//o.filters[0].duration = 0;
							//o.filters[0].apply();
							o.innerHTML = req.responseText;
							//o.filters[0].play();
						}
					} else {
					}
				}
			};
			req.open("GET", url, true);
			req.send(null);
		}
	}
	
	if(o.filters)
	{
		o.filters[0].duration = 0.3;
		o.filters[0].apply();
		o.style.visibility = "visible";
		o.filters[0].play();
	}
	else
	{
		o.style.visibility = "visible";
	}
}

function hideDescriptions(group, e)
{
	//make sure event was not fired from child element
	var toElement = e.relatedTarget || e.toElement;
	while(toElement && toElement != group && toElement.nodeName != 'BODY')
		toElement = toElement.parentNode;
	if(toElement == group)
		return;
	hideAllDescriptions(group);
}

function hideAllDescriptions(group)
{
	var els = group.getElementsByTagName('a');
	for(i = 0; i < els.length; ++i)
	{
		//var o = els[i].parentNode.previousSibling.firstChild.firstChild;

		//table row
		tr = els[i].parentNode.parentNode;
		//first cell in row
		td = tr.getElementsByTagName("td")[0];
		//first child div
		div1 = td.getElementsByTagName("div")[0];
		//tooltip div
		o = div1.getElementsByTagName("div")[0];
		
		//o.filters[0].stop();
		//o.filters[0].duration = 0;
		//o.filters[0].apply();
		o.innerHTML = "";
		o.style.visibility = "hidden";
		//o.filters[0].play();
	}
}

function showGalleryImage(imageId)
{
	windowWidth = 400;
	windowHeight = 320;

	leftPos = 0;
	if(screen.width)
		leftPos = (screen.width - windowWidth) / 2;
	topPos = 0;
	if(screen.height)
		topPos = (screen.height - windowHeight) / 2;
	
	openUrl = "/GalleryImage/" + imageId + ".htm";
	namePrefix = "galleryImage";
	windowSettings = "height=" + windowHeight + ",width=" + windowWidth + ",top=" + topPos + ",left=" + leftPos + ",scrollbars=no,resizable";
	
	window.open(openUrl, namePrefix + imageId, windowSettings)
}

function blendimage(lnkId, imageId, imageUrl, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(lnkId).style.backgroundImage = "url(" + document.getElementById(imageId).src + ")"; 
     
    //make image transparent 
    changeOpac(0, imageId); 

     
    //make new image 
    document.getElementById(imageId).src = imageUrl; 

    //fade in image 
    for(i = 1; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageId + "')",(timer * speed)); 
        timer++; 
    }
}

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 + ")"; 
}