function openBig(theimg)
{
	//window.open('bigpix.php?file=' + theimg, 'pigpix', 'location=no, menubar=no, scrollbars=no, status=no, toolbar=no, height=200, width=300');

	if (oldIE) return openBigOldIE(theimg);
	
	container = document.createElement("div");
	container.id = "largeImage";
	
	var overlay = document.createElement("div");
	overlay.className = "overlay";
	overlay.onclick = closeBig;
	
	var pos = document.createElement("div");
	pos.className = "pos";
	pos.onclick = closeBig;

	var frame = document.createElement("div");
	frame.className = "frame";
	frame.onclick = function(evnt)
		{
			if (evnt) evnt.stopPropagation();
			else window.event.cancelBubble = true;
		};
	
	var img = document.createElement("img");
	img.src = theimg;
	img.alt = "Large Picture View";
	
	var btnClose = document.createElement("a");
	btnClose.innerText = "close";
	btnClose.onclick = closeBig;
	
	container.appendChild(overlay);
	container.appendChild(pos);
	pos.appendChild(frame);
	frame.appendChild(img);
	frame.appendChild(btnClose);
	
	document.body.appendChild(container);
}

function openBigOldIE(theimg)
{
	container = document.createElement("div");
	container.id = "largeImage";
	
	var overlay = document.createElement("div");
	overlay.className = "overlay";
	overlay.onclick = closeBig;
	
	var pos = document.createElement("div");
	pos.className = "pos";
	pos.onclick = closeBig;

	var table = document.createElement("table");
	table.width = "100%";

	var tbody = document.createElement("tbody");

	var tr = document.createElement("tr");

	var td1 = document.createElement("td");
	td1.width = "50%";

	var td2 = document.createElement("td");
	td2.width = "50%";

	var frame = document.createElement("td");
	frame.className = "frame";
	frame.onclick = function(evnt)
		{
			if (evnt) evnt.stopPropagation();
			else window.event.cancelBubble = true;
		};
	
	var img = document.createElement("img");
	img.src = theimg;
	img.alt = "Large Picture View";
	
	var btnClose = document.createElement("a");
	btnClose.innerText = "close";
	btnClose.onclick = closeBig;
	
	container.appendChild(overlay);
	container.appendChild(pos);
	pos.appendChild(table);
	table.appendChild(tbody);
	tbody.appendChild(tr);
	tr.appendChild(td1);
	tr.appendChild(frame);
	tr.appendChild(td2);
	frame.appendChild(img);
	frame.appendChild(btnClose);
	
	document.body.appendChild(container);
}

function closeBig()
{
	document.body.removeChild(container);
}

function openFile(theimg)
{
	window.open('download.php?file=' + theimg, 'pigpix', 'location=no, menubar=no, scrollbars=no, status=no, toolbar=no, height=200, width=300');
}	

function showVideo(img, id)
{
	var obj = document.getElementById(id);
	
	img.style.display = "none";
	obj.style.display = null;
}

/*function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}*/

function resizetofit()
{
	//window.focus();
	var theimg = document.getElementById("theimg");
	if (window.innerWidth) window.resizeTo(theimg.width - window.innerWidth + window.outerWidth, theimg.height - window.innerHeight + window.outerHeight);
	else window.resizeTo(theimg.width + 20, theimg.height + 50);
}
