﻿// JScript File
function changeBG(id, bg) { 
    document.getElementById(id).style.opacity = "0";
    element = document.getElementById(id); 
    newImage = "url('" + bg + "')";
    document.getElementById(id).style.backgroundImage = newImage;

    shiftOpacity('subImg', 1200);
}

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 shiftOpacity(id, millisec) { 
    //if an element is invisible, make it visible
    if(document.getElementById(id).style.opacity == 0) { 
        opacity(id, 0, 100, millisec); 
    }
    
} 
function shiftBackOpacity(id, millisec) { 
    // else make it ivisible 
    if(document.getElementById(id).style.opacity != 0) { 
        opacity(id, 100, 0, millisec); 
    } 
}
var currentGalleryLink = new Array();
function LoadPicture(pictureName,imageFile,captionID,captionText)
{
	if (document.all)
	{
		document.getElementById(pictureName).style.filter="blendTrans(duration=1)";
		document.getElementById(pictureName).filters.blendTrans.Apply();
	}
  if(imageFile != "") {
    //document.getElementById(pictureName).style.border = "5px solid #D1D0CE";
  } else {
    document.getElementById(pictureName).style.border = "";
  }
	
	document.getElementById(pictureName).src = imageFile;
	document.getElementById(pictureName).style.visibility = "visible";
	if (document.all)
	{
		document.getElementById(pictureName).filters.blendTrans.Play();
	}
	document.getElementById(captionID).innerHTML=captionText;
	// Which link is currently selected?
	for (i=0; i < document.links.length;i++)
	{
	   	var l=document.links[i];
	   	var n=l.getAttributeNode('onmouseover');
		if (n)
		{
			var onclick = n.value;
	   		if ((onclick) &&
	   			(onclick.indexOf(pictureName) > 0) &&
	   			(onclick.indexOf(imageFile) > 0))
	   		{
			    currentGalleryLink[pictureName] = i;
			    break;
			}
		}
	}
}
function LoadPrev(pictureName)
{
	var current = currentGalleryLink[pictureName];
	if (current == null) current = document.links.length+1;
	var alt = null;
	for (i=document.links.length-1;i>0;i--)
	{
		var link=document.links[i];
		var node = link.getAttributeNode('onmouseover');
		if (node)
		{
			var onclick = node.nodeValue;
			if ((onclick) &&
				(onclick.indexOf('LoadPicture') >= 0) &&
				(onclick.indexOf(pictureName) > 0))
			{
				if (i < current)
				{
					eval(onclick);
					return;
				} else if (alt == null)
					alt = onclick;
			}
		}
	}
	if (alt) eval(alt);
}
function LoadNext(pictureName)
{
	var current = currentGalleryLink[pictureName];
	if (current == null) {
		currentGalleryLink[pictureName]=-1;
		LoadNext(pictureName);
		current = currentGalleryLink[pictureName];
	}
	var alt = null;
	for (i=0;i<document.links.length;i++) {
		var link = document.links[i];
		var node = link.getAttributeNode('onmouseover');
		if (node)
		{
			var onclick = node.value;
			if ((onclick) &&
				(onclick.indexOf('LoadPicture') >= 0) &&
				(onclick.indexOf(pictureName) > 0))
			{
				if (i > current)
				{
					eval(onclick);
					return;
				} else if (alt == null)
					alt = onclick;
			}
		}
	}
	if (alt) {
		eval(alt);
	}
}

function swapHref(urlInput) {
if (urlInput != ''){
document.getElementById('lnkPopUp').href= "javascript:PopupPic('" + urlInput + "')";
}
}