var ie=ns=op=sf = false;
var iePng = false;
var FrameSet = false;

/*var ContentFlashVersion = 8;
var FlashCanPlay = false;*/

var FlashVersion = 9;
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 >= FlashVersion)
			{
				FlashCanPlay = true;
			}
	}
else
	{
		var FlashPlugin = navigator.plugins["Shockwave Flash"];
		if (FlashPlugin && FlashPlugin.description)
			{
				FlashCanPlay = parseInt(FlashPlugin.description.replace(/^(.*\s+)(.*)\..*$/, "$2")) >= FlashVersion;
			}
	}


function FlashObject(objID, swf, width, height, ID, clName, params, vars, altContent)
{
	var obj = document.getElementById(objID);
	if (!obj)
		{
			return false;
		}

	var content;
	if (FlashCanPlay)
		{
			var em_params = "";
			var fl_vars = "";
			content = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"" + width + "\" height=\"" + height + "\"" + ((ID) ? " id=\"" + ID + "\"" : "") + ((clName) ? " class=\"" + clName + "\"" : "") + ">";
			content += "<param name=\"movie\" value=\"" + swf + "\" />";

			for (var key in params)
				{
					content += "<param name=\"" + key + "\" value=\"" + params[key] + "\" />";
					em_params += " " + key + "=\"" + params[key] + "\"";
				}

			for (var key in vars)
				{
					fl_vars += key + "=" + vars[key] + "&";
				}

			if (fl_vars)
				{
					fl_vars = fl_vars.substring(0, fl_vars.length - 1);
					content += "<param name=\"flashvars\" value=\"" + fl_vars + "\" />";
				}
			content += "<embed type=\"application/x-shockwave-flash\" src=\"" + swf + "\" width=\"" + width + "\" height=\"" + height + "\"" + ((ID) ? " id=\"" + ID + "\" name=\"" + ID + "\"" : "") + ((clName) ? " class=\"" + clName + "\"" : "") + em_params + ((fl_vars) ? " flashvars=\"" + fl_vars + "\"" : "") + " />";
			content += "</object>";
			obj.innerHTML = content;
			return true;
		}
	else
		{
			obj.innerHTML = altContent;
			return false;
		}
}


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);

			obj.style.left = evt.clientX + 'px';
			obj.style.top = evt.clientY + 'px';
			/*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 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;
        }
      }
    }
  }
}*/
