var ie=ns=op=sf = false;
var iePng = false;
var FrameSet = false;

var ContentFlashVersion = 8;
var FlashCanPlay = false;
var curPhoto = false;

if (navigator.userAgent.indexOf ("Opera") != -1) {op=true}
else if (navigator.userAgent.indexOf ("MSIE") != -1) {ie=true; var n = navigator.userAgent.indexOf("MSIE")+5; iePng = (navigator.userAgent.substring(n, n+1) >= 7) ? true : false}
else if (navigator.userAgent.indexOf ("Safari") != -1) {sf=true}
else if (navigator.userAgent.indexOf ("Netscape") != -1 ||
         navigator.userAgent.indexOf ("Gecko") != -1 ||
         navigator.userAgent.indexOf ("Mozilla") != -1 ||
         navigator.userAgent.indexOf ("Firefox") != -1) {ns=true}

if (top.window.frames['PLAYER'] && top.window.frames['CONTENT'])
 {
  FrameSet = true;
 }

if (ie)
 {
  var axObj = true;
  var version = 5;
  while(axObj)
   {
    try
     {
      version++;
      axObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+version);
     }
    catch(e)
     {
      axObj = null;
      version--;
     }
   }
  if (version >= ContentFlashVersion)
   {
    FlashCanPlay = true;
   }
 }
else
 {
  var FlashPlugin = navigator.plugins["Shockwave Flash"];
  if (FlashPlugin && FlashPlugin.description)
   {
    FlashCanPlay = parseInt(FlashPlugin.description.replace(/^(.*\s+)(.*)\..*$/, "$2")) >= ContentFlashVersion;
   }
 }


function PreloadImages()
{ if (document.images)
  {   var preloadArray = new Array();
   for (var i = 1; i < arguments.length; i++)
    {     preloadArray[i-1] = new Image();
     preloadArray[i-1].src = arguments[0]+"_gfx/"+arguments[i];
    }
  }
}


function pngNavOver(elem, n)
{
 elem.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='_gfx/nav"+n+"-ovr.png')";
}


function pngNavOut(elem, n)
{
 elem.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='_gfx/nav"+n+".png')";
}


function ShowPopupWindow(id)
{
 var par="copyhistory=0,directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0";
 PopupW=window.open("popup.php?id="+id, "PopupWindow", [par]);
 PopupW.focus();
}


function ShowPaperWindow(id)
{ var par="copyhistory=0,directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0";
 PaperW=window.open("paper.php?id="+id, "PaperWindow", [par]);
 PaperW.focus();
}


function ShowPhoto(th, evt)
{	evt = (evt) ? evt : window.event;
	if (curPhoto)
		{			ClosePhoto(curPhoto);
		}

	if (th.nextSibling && th.nextSibling.tagName == 'SPAN' && th.nextSibling.className == 'hid')
		{
			var width = getDocumentWidth();
			var height = getDocumentHeight();

			var obj = th.nextSibling;
			obj.className = 'photo';

			var btn = document.createElement("IMG");
			curPhoto = btn;
			btn.className = 'close';
			btn.src = '/_gfx/ss-close.gif';
			btn.onclick = function() {ClosePhoto(this)};
			btn.onmouseover = function() {this.src='/_gfx/ss-close-ovr.gif'};
			btn.onmouseout = function() {this.src='/_gfx/ss-close.gif'};
			obj.insertBefore(btn, obj.firstChild);

			if (evt.clientX + obj.offsetWidth > width)
				{
					obj.style.left = width - evt.clientX - obj.offsetWidth + 'px';
				}

			if (evt.clientY + obj.offsetHeight > height)
				{
					obj.style.top = height - evt.clientY - obj.offsetHeight + 'px';
				}
		}
}


function ClosePhoto(th)
{	if (th.parentNode && th.parentNode.tagName == 'SPAN' && th.parentNode.className == 'photo')
		{			curPhoto = false;
			var obj = th.parentNode;
			obj.removeChild(th);
			obj.className = 'hid';
		}
}


function getDocumentWidth()
{	var width = (ie) ? document.body.clientWidth : window.innerWidth
	return width - width / 2 + 400;
}


function getDocumentHeight()
{
	return Math.max((document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight, ((document.compatMode || ie) && !op) ? ((document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight) : (document.parentWindow || document.defaultView).innerHeight) - document.body.scrollTop;
}

/*function SetCssProperty(selName, pName, pVal, tCount)
{ var count = 0;
 var re = new RegExp(selName, "i");
 var arrSht = document.styleSheets;
 for (var i = 0; i < arrSht.length; i++)
  {
   var sRules = (ie) ? arrSht[i].rules : arrSht[i].cssRules;
   for (var j = 0; j < sRules.length; j++)
    {
     var sRule = sRules[j];
     if (re.test(sRule.selectorText))
      {       sRule.style[pName] = pVal;
       count++;
       if (tCount == count)
        {
         return;
        }
      }
    }
  }
}*/