

function popUp(context)
{
	var pop = document.getElementById("popUpWrapper");
	pop.className = "show";

	this.context=context;

	myInterval = setInterval("fade(document.getElementById('popUpWrapper'), myInterval, .5, .1, context, function(){})",1);


}

function callback(context)
{
	
	var popWrapper = document.getElementById('popUp');
	scrollElement(popWrapper, 50);

	popWrapper.className = "show";
	popWrapper.style.display = "block";

	var popContent = document.createElement('div');
	popContent.setAttribute("id", "popUpContent");
	popContent.style.width = "100px";
	popContent.style.height = "100px";

	popWrapper.appendChild(popContent);

	var popImg = document.createElement('img');
	
	//popImg.style.display = "none";
	popContent.appendChild(popImg);

	popImg.onload = function()
	{
		this.style.display="block";
		var br1 = document.createElement('br');
		var br2 = document.createElement('br');

		var closePop = document.createElement('a');
		closePop.setAttribute("href", "javascript:closePop()");

		var closePopImg = document.createElement('img');
		closePopImg.setAttribute("src", "images/closePop.png");

		popContent.appendChild(br1);	
		popContent.appendChild(br2);
		popContent.appendChild(closePop);
		closePop.appendChild(closePopImg);
		var height = this.height;
		var width = this.width;

		popContent.style.height = height + 50 + "px";
		popContent.style.width = width + "px";	

	

	}
	
	popImg.setAttribute("src", context);
	popImg.setAttribute("id", "bigpic");

}




function closePop()
{
	var popUpWrapper = document.getElementById('popUp');
	popUpWrapper.style.display = "none";
	popUpWrapper.innerHTML = "";


	myInterval = setInterval("fade(document.getElementById('popUpWrapper'), myInterval, 0, -.1,null,function(){document.getElementById('popUpWrapper').className = 'hide';})",1);
	

}

function fade(context, interval, max, opChange, img, callbackfunc)
{
	var opacity = parseFloat(context.style.opacity);
	if(!opacity)
	{
		opacity = 0;
	}
	if(/MSIE (5|6|7)/.test(navigator.userAgent)){
		var temp = context.style.filter;
		if(temp)
		{
			var temp2 = temp.split("alpha(opacity=");
			var temp3 = temp2[1].split(")");
			opacity = parseFloat(temp3[0]/100);
		}
		else
		{
			opacity = 0;
		}
	}

	if(opChange < 0)
	{
		if (opacity>max)
		{
			opacity+=opChange;
		}
		else
		{
			clearInterval(interval);
			if(img != null) callback(img);
			callbackfunc();
			return;
		}	
	}
	else
	{
		if (opacity<max)
		{
			opacity+=opChange;
		}
		else
		{	
			clearInterval(interval);
			if(img != null) callback(img);
			callbackfunc();
			return;	
		}
	}
	context.style.opacity=opacity;
	context.style.filter = "alpha(opacity=" + opacity*100 + ")";
}
