﻿
var loading;
var began = false
var LPar = "";
var lang = "";
var sMenu = "";
var sMobile = "";
var sPayDoxURL = "";
var strShowFolder="";
var strSingleFile="";
var strIsMobile="";

slogin="";
sbuilt="";

var sDOCS_FindContext='';
var DOCS_More='';
var DOCS_SlideShow='';
var DOCS_Pause='';
var DOCS_MakeChoice='';

var DOCS_Slower='';
var DOCS_ShowPrev='';
var DOCS_Close='';
var DOCS_ShowNext='';
var DOCS_Faster='';
var DOCS_Backward='';
var DOCS_ChangeSize='';
var sMouseMessageID='MouseMessageID';

var SetInitVarsName='';

var nThumbW=120;
var nMaxIMGW=600;
var nRecordsToReturn=100;
var timerFlag = false;
var cT;

var nSlideMaxIMGWidth=800;
var nSlideMaxIMGHeight=600;

var jsStarted = false;

//*** slide-show vars & functions start
// time to show image
var iDelayBetweenImageChange = 3000;
// delay between transparency steps 
var iDelayBetweenImageAlphaChange = 50;
// transparency step time
var iAlphaChange = 10;
// window id where slide shows (to close window)
var sParentID = 'newDialogWindowSlide';
// current counter to show image (to close window)
var iDelayCurrent = 0;
// current counter of transparency 
var iAlpha = 0;
// current counter of image
var iCurrentImg = 0;
var iCount = 0;
var sCurrentMenuID='';
var sCurSlideShowButtonIDPar='';
var sTempImg = new Image();
var bSlideShowPlayPause = true;
//var bSlideShowPlayPause = false;
var bSlideShowPlayBack = true;
//var bSlideShowPlayBack = false;
var ssTimer;
var sSlideShowButtonID='';
var bImageLoaded=false;
var slideshowFirstID='';
var slideshowLastID='';

var oCurPos;
//var bmousemove = true;
var sImgID = "ssImg";
var sImgCurLID = "ssImgCurL";
var sImgCurRID = "ssImgCurR";
//var iImgCurSizeH = 32;
var iImgCurSizeW = 32;

if (document.all) {
	var winWidth = window.screen.availWidth;
	var winHeight = window.screen.availHeight - 200;
}
else {
	var winWidth = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
	var winHeight = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
}
//alert(window.screen.availWidth + "x" + window.screen.availHeight + '\n' + winWidth + "x" + winHeight);

function GetNextMenuIDSlide(){
var bdone=false;
var iLoop=0;
while (!bdone){
	var obj=document.getElementById("ITH"+sCurrentMenuID);
	if(!obj)
		{
		sCurrentMenuID=slideshowFirstID;
		bdone=true;
		}
	else
		{
		if(iLoop>0 && obj.getAttribute('IsImage')=='y')
			bdone=true
		else
			sCurrentMenuID=obj.getAttribute('idNext');
		}
	iLoop+=1;
	if(iLoop>1000)
		bdone=true;
		}
}

function GetPrevMenuIDSlide(){
var bdone=false;
var iLoop=0;
while (!bdone){
//alert('sCurrentMenuID:'+sCurrentMenuID+', iLoop:'+iLoop);
	var obj=document.getElementById("ITH"+sCurrentMenuID);
//alert(obj);
	if(!obj)
		{
		sCurrentMenuID=slideshowLastID;
//alert('sCurrentMenuID=slideshowLastID:'+sCurrentMenuID);
		bdone=true;
		}
	else
		{
//alert('sCurrentMenuID:'+sCurrentMenuID+', iLoop:'+iLoop+', IsImage:'+obj.getAttribute('IsImage')+', ItemName:'+obj.getAttribute('ItemName'));
		if(iLoop>0 && obj.getAttribute('IsImage')=='y')
		//if(obj.getAttribute('IsImage')=='y')
			bdone=true
		else
			sCurrentMenuID=obj.getAttribute('idPrev');
//alert(obj.getAttribute('IsImage'));
//alert('bdone:'+bdone);
//alert('sCurrentMenuID=obj.getAttribute(idPrev):'+sCurrentMenuID);
		}
	iLoop+=1;
	if(iLoop>1000)
		bdone=true;
//alert('bdone:'+bdone);
		}
}

function CheckNextImageInStore(bForward){
//alert('CheckNextImageInStore, bForward:'+bForward);
var obj=document.getElementById("ITH"+sCurrentMenuID);
var sMenuIDMore='';
if(bForward)
	sMenuIDMore=obj.getAttribute("idNext")
else
	sMenuIDMore=obj.getAttribute("idPrev")
;
obj=currentimginstore(sMenuIDMore);
var sloaded = obj.getAttribute("loaded");
//alert('CheckNextImageInStore, sloaded:'+sloaded);
if(sloaded=='')
	return false
else
	return true
;
}

function SlideShowPlayPause() {
bSlideShowPlayPause=!bSlideShowPlayPause;
//alert(bSlideShowPlayPause);
if(!bSlideShowPlayPause)
	{
	document.getElementById('imgSlideShowPlayPause').src='Images/Pict_Play_anim.gif'
	document.getElementById('imgSlideShowPlayPause').title=DOCS_SlideShow
	//ssTimer = setTimeout("hideImageSleep()", iDelayBetweenImageAlphaChange);
	}
else
	{
	document.getElementById('imgSlideShowPlayPause').src='Images/Pict_Pause_anim.gif';
	document.getElementById('imgSlideShowPlayPause').title=DOCS_Pause;
	hideImage(bSlideShowPlayBack);
	}
//return false;
}

function SlideShowPlayBack() {
bSlideShowPlayPause=true;
//bSlideShowPlayPause=false;
bSlideShowPlayBack=!bSlideShowPlayBack;
//document.getElementById('imgSlideShowPlayPause').src='Images/Pict_Pause_anim.gif';
document.getElementById('imgSlideShowPlayPause').src='Images/Pict_Pause.gif';
document.getElementById('imgSlideShowPlayPause').title=DOCS_Pause;
document.getElementById('imgSlideShowPlayBack').src='Images/Pict_MoveBack_anim.gif';
//hideImage(bSlideShowPlayBack);
}

function SlideShowFaster() {
if(iDelayBetweenImageChange<500)
	return;
iDelayBetweenImageChange=parseInt(iDelayBetweenImageChange*0.8);
bSlideShowPlayPause=true;
document.getElementById('imgSlideShowPlayPause').src='Images/Pict_Pause.gif';
document.getElementById('imgSlideShowPlayPause').title=DOCS_Pause;
document.getElementById('imgFaster').src='Images/Pict_FastMoveRight_anim.gif';
clearTimeout(ssTimer);
hideImage(bSlideShowPlayBack);
//alert(iDelayBetweenImageChange);
//return false;
}

function SlideShowSlower() {
iDelayBetweenImageChange=parseInt(iDelayBetweenImageChange/0.8);
bSlideShowPlayPause=true;
document.getElementById('imgSlideShowPlayPause').src='Images/Pict_Pause.gif';
document.getElementById('imgSlideShowPlayPause').title=DOCS_Pause;
document.getElementById('imgSlower').src='Images/Pict_FastMoveLeft_anim.gif';
//return false;
}

function SlideShowNext() {
if(itWasResize)
{
itWasResize=false;
return;
}

clearTimeout(ssTimer);
//iDelayCurrent = iDelayBetweenImageChange;
bSlideShowPlayPause=false;
document.getElementById('imgSlideShowPlayPause').src='Images/Pict_Play.GIF';
document.getElementById('imgSlideShowPlayPause').title=DOCS_SlideShow;
document.getElementById('imgNext').src='Images/Pict_MoveNext_anim.gif';
//GetNextMenuIDSlide()
//showImage(true);
bSlideShowPlayBack=true;
hideImage(true);
}

function SlideShowPrev() {
if(itWasResize)
{
itWasResize=false;
return;
}

clearTimeout(ssTimer);
bSlideShowPlayPause=false;
document.getElementById('imgSlideShowPlayPause').src='Images/Pict_Play.GIF';
document.getElementById('imgSlideShowPlayPause').title=DOCS_SlideShow;
document.getElementById('imgPrev').src='Images/Pict_MovePrev_anim.gif';
//GetPrevMenuIDSlide()
//showImage(true);
bSlideShowPlayBack=false;
hideImage(false);
}

function getdivimg() {
var odivimg=getObj('divimgstore');
if(!odivimg)
	{
	odivimg=document.createElement("div");
	odivimg.id='divimgstore';
	odivimg.style.display='none';
	document.getElementsByTagName('BODY').appendChild(odivimg);
	}
return odivimg;
}

function GetUrlFileSlide(){
//alert('GetUrlFileSlide, sCurrentMenuID:'+sCurrentMenuID);
var obj=document.getElementById("ITH"+sCurrentMenuID);
//alert(obj);
if(obj)
{
	var sURL=obj.getAttribute("url")+"&hash="+Math.random();
	//var sURL=sBaseURL+"GetThumbnailImage.aspx?filename="+encodeURI(obj.getAttribute("ItemName"))+"&width=800&hash="+Math.random();

//alert(sURL);
	return sURL;
}
}

function ShowSlideShowButton(sparentid1, slideshowFirst){
//return;
//alert('ShowSlideShowButton, slideshowFirst:'+slideshowFirst);
var oss=document.getElementById("IMGSS"+sparentid1);
//alert(oss);
if(oss)
	//if(oss.style.display=='none')
		{
		oss.style.display='';
		oss.setAttribute("slideshowFirst", slideshowFirst);
//alert(oss.getAttribute("slideshowFirst"));
		if(slideshowFirstID=='')
			slideshowFirstID=slideshowFirst;
		}
	//else
	//	oss.style.display='none'
  //alert('slideshowFirstID:'+slideshowFirstID);
}

function PutslideshowLast(slideshowLast){
slideshowLastID=slideshowLast;
//alert("PutslideshowLast, slideshowLast:"+slideshowLast);
}

function currentimginstore(sMenuID) {
//alert("currentimginstore, sMenuID 1:"+sMenuID);
var sMenuIDToPerform='';
if(sMenuID=='')
	sMenuIDToPerform=sCurrentMenuID
else
	sMenuIDToPerform=sMenuID;
//alert("currentimginstore, sMenuID 2:"+sMenuID);
var obj=document.getElementById("ITH"+sMenuIDToPerform);
if(!obj)
	{
	if(bSlideShowPlayBack)
		{
		obj=document.getElementById("ITH"+slideshowFirstID);
		sMenuIDToPerform=slideshowFirstID;
		if(sMenuID=='')
			sCurrentMenuID=sMenuIDToPerform;
		}
	else
		{
		obj=document.getElementById("ITH"+slideshowLastID)
		sMenuIDToPerform=slideshowLastID;
		if(sMenuID=='')
			sCurrentMenuID=sMenuIDToPerform;
//alert("slideshowLastID:"+slideshowLastID);
//alert(obj);
//alert('Last:'+obj.getAttribute("ItemName"));
//alert('url:'+obj.getAttribute("url"));
		}
//alert("error ITH"+sMenuID);
//alert("bSlideShowPlayBack:"+bSlideShowPlayBack);
//alert("slideshowFirstID:"+slideshowFirstID);
//alert('Last:'+obj.getAttribute("ItemName"));
	}
if(obj)
	var sURL=obj.getAttribute("url");
//alert('sURL:'+sURL);
//var sURL=sBaseURL+"GetThumbnailImage.aspx?filename="+encodeURI(obj.getAttribute("ItemName"))+"&width=800&hash="+Math.random();
//alert(sURL);
var oImg=document.getElementById("IMGLoaded"+sMenuIDToPerform);
//alert(oImg);
if(!oImg)
	{
	oImg = new Image();
	oImg.setAttribute("loaded", "");
	oImg.style.display = "none";
	oImg.id = "IMGLoaded"+sMenuIDToPerform;
	//oImg.onload=function() {alert('oImg.onload');this.setAttribute("loaded", "y");alert(this.getAttribute("loaded"));}
	oImg.onload=function() {this.setAttribute("loaded", "y");}
	oImg.onerror=function() {this.setAttribute("loaded", "error");}
	oImg.src = sURL;
	document.getElementById('divimgstore').appendChild(oImg);
//alert(document.getElementById('divimgstore').innerHTML);
	}
return oImg;
}

function getClientCenterX()
{
	return parseInt(getClientWidth()/2)+getBodyScrollLeft();
}

function getClientCenterY()
{
	return parseInt(getClientHeight()/2)+getBodyScrollTop();
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function getBodyScrollTop() 
{
	return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
	return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}


function CheckIfChangeOpacity(oIMG) {
//if (oIMG.width==nSlideMaxIMGWidth || oIMG.height==nSlideMaxIMGHeight)
if (oIMG.getAttribute("resized")=="y")
{
	if (document.all)
		oIMG.style.filter = "alpha(opacity=100)"
	else
		oIMG.style.opacity = 1;
	return false
}
else
	{
	return true
	}
}

function showImage(bShow) {
//alert('showImage, bShow:'+bShow+', sCurrentMenuID:'+sCurrentMenuID);

	if (false) 
	if (!bShow) 
	if (iAlpha != 0) 
	if (getObj(sParentID).style.display == 'none') {
//alert('close');
		iAlpha = 0;
		iCurrentImg = 0;
		clearTimeout(ssTimer);
		return;
	}

	if (iAlpha == 0){
		var curimg=currentimginstore('');
//alert(curimg);
		var sloaded = curimg.getAttribute("loaded");
//alert('sloaded:'+sloaded);
		if(sloaded=='')
		{
		if(iCount>300)
			{
			alert('Error: slow connection, or image too big (1)')
			return;
			}
		ssTimer = setTimeout("showImage(true)", 2*iDelayBetweenImageAlphaChange);
		iCount+=1;
		return;
		}
		else
			iCount=0;
	}

	var ssImg = getObj("ssImg");

			if (iAlpha == 0){
				//ssImg.src = imgURLs[iCurrentImg].src;
				//sTempImg.onload="changeDialogWindowPosition('"+sParentID+"', ("+winHeight+" - this.height)/2, ("+winWidth+" - this.width)/2);getObj('ssImg').src = this.src;";
				//sTempImg.src = '';
				//sTempImg.onload=function() {changeDialogWindowPosition(sParentID, (winHeight - GetImageNormalHeight(this.height))/2, (winWidth - GetImageNormalWidth(this.width))/2);getObj('ssImg').src = this.src;getObj('ssImg').width=GetImageNormalWidth(this.width);getObj('ssImg').height=GetImageNormalHeight(this.height);if (bShow) getObj('newDialogWindowSlide').style.display = '';bImageLoaded=true;};
				//alert(sTempImg.onload);
				//sTempImg.src = GetUrlFileSlide();

				if(ssImg.src!=curimg.src)
					{
					//getObj("ssImg").onload="";
					//getObj("ssImg").src="images/ajaxloading.gif";
					//alert('');
					//if (document.all)
					//	ssImg.style.filter = "alpha(opacity=100)"
					//else
					//	ssImg.style.opacity = 1;

					ssImg.width=curimg.width;
					ssImg.height=curimg.height;

					changeDialogWindowPosition(sParentID, GetImageNormalHeight(curimg.height), GetImageNormalWidth(curimg.width));
					ssImg.onload=function() {if(this.src.indexOf('DownloadFile.asp')>=0)this.setAttribute("loaded", "y");} //alert(this.src);alert(this.src.indexOf('DownloadFile.asp'));
					//ssImg.onload=function() {if(this.src.indexOf('GetThumbnailImage.aspx')>=0)this.setAttribute("loaded", "y");} //alert(this.src);alert(this.src.indexOf('DownloadFile.asp'));
					ssImg.onerror=function() {this.setAttribute("loaded", "error");}
					ssImg.setAttribute("loaded", "");
					ssImg.src = curimg.src;
					getObj("newDialogWindowSlideBody").width=GetImageNormalWidth(curimg.width);
//alert(getObj("newDialogWindowSlideBody").width);
				//changeDialogWindowPosition(sParentID, (winHeight - GetImageNormalHeight(curimg.height))/2, (winWidth - GetImageNormalWidth(curimg.width))/2);

					}
				if(ssImg.getAttribute("loaded")=="")
					{
					if(iCount>300)	{
						alert('Error: slow connection, or image too big (3)')
						return;
						}
					ssTimer = setTimeout("showImage(true)", 2*iDelayBetweenImageAlphaChange);
					iCount+=1;
					return;
					}

					if (document.all)
						ssImg.style.filter = "alpha(opacity=0)"
					else
						ssImg.style.opacity = 0;


				//getClientCenterY
				//alert(getObj("ssImgDiv").height);
				//alert(getObj("ssImgDiv").width);
				
				//ssImg.width=GetImageNormalWidth1(curimg.width, curimg.height);
				//ssImg.height=GetImageNormalHeight1(curimg.width, curimg.height);
				ResizeImageToNormal(ssImg);
				//getObj("areaL").coords = "0,0,"+(ssImg.width/2)+","+ssImg.height;
				//getObj("areaR").coords = (ssImg.width/2) +",0,"+ssImg.width+","+ssImg.height;
				getObj("areaL").coords = "0,0,"+parseInt(ssImg.width/2)+","+parseInt(ssImg.height/2);
				getObj("areaR").coords = parseInt(ssImg.width/2) +",0,"+ssImg.width+","+parseInt(ssImg.height/2);
				//getObj("areaZ").coords = "0,"+parseInt(ssImg.height/2)+","+ssImg.width+","+ssImg.height;

				if (bShow) 
					getObj('newDialogWindowSlide').style.display = '';
				var ocurimgOrig=document.getElementById("ITH"+sCurrentMenuID);
				var ossText=getObj('ssText');
				var oText= document.getElementById("IDM_"+sCurrentMenuID);
					//ossText.innerHTML="<pre>"+oText.innerHTML+"</pre>"
					//ossText.innerHTML=oText.innerHTML.replace(/\n/g, "")
				if(oText)
					ossText.innerHTML=oText.innerHTML //.replace(/&nbsp;/g, " ");
				else
					ossText.innerHTML='';
				oText= document.getElementById("IDADD_"+sCurrentMenuID);
				if(oText)
					ossText.innerHTML=ossText.innerHTML+oText.innerHTML;
					//ossText.innerHTML=ossText.innerHTML+'<div align1="left">'+oText.innerHTML+'</div>';

				//alert(sTempImg.src);
				//changeDialogWindowPosition(sParentID, (winHeight - sTempImg.height)/2, (winWidth - sTempImg.width)/2);
				//ssImg.src = sTempImg.src;
				//alert(imgURLs[iCurrentImg].width + "x" + imgURLs[iCurrentImg].height);
				//changeDialogWindowPosition(sParentID, (winHeight - imgURLs[iCurrentImg].height)/2, (winWidth - imgURLs[iCurrentImg].width)/2);
//alert(ssImg.src);

				//alert(sCurSlideShowButtonIDPar);
				var oss=document.getElementById(sCurSlideShowButtonIDPar);
				//alert(oss);
				if(oss)
					oss.setAttribute("slideshowFirst", sCurrentMenuID);
			}

	if (iAlpha < 100 && CheckIfChangeOpacity(ssImg)) {
		if (document.all){
			ssImg.style.filter = "alpha(opacity=" + iAlpha + ")";	
		}
		if (document.getElementById && !document.all) {			
//alert("ssImg.style.opacity:"+iAlpha/100);
			ssImg.style.opacity = iAlpha/100;	
//alert("ssImg.style.opacity OK");
		}
		iAlpha += iAlphaChange;
		ssTimer = setTimeout("showImage(false)", iDelayBetweenImageAlphaChange);
	}
	else {
		clearTimeout(ssTimer);
		ssTimer = setTimeout("hideImageSleep()", iDelayBetweenImageAlphaChange);

//alert('pause');
	}

	if (document.layers) {
		clearTimeout(ssTimer);
		//ssImg.src = imgURLs[iCurrentImg].src;
		ssImg.src = GetUrlFileSlide();

		//iCurrentImg++;
		//if (iCurrentImg >= imgURLs.length) {
		//	iCurrentImg = 0;
		//}
		if(bSlideShowPlayBack)
			GetNextMenuIDSlide()
		else
			GetPrevMenuIDSlide()
		;
		ssTimer = setTimeout("showImage(false)", iDelayBetweenImageChange);
	}           

}

function hideImage(bForward) {        

//alert('hideImage, bForward:'+bForward);
	if (false) {
	//if (getObj(sParentID).style.display == 'none') {
		iAlpha = 0;
		iCurrentImg = 0;
		clearTimeout(ssTimer);
		return;
	}

	if(!CheckNextImageInStore(bForward))
		{
		if(iCount>300)
			{
			alert('Error: slow connection, or image too big (2)')
			return;
			}
//alert('!CheckNextImageInStore');
		ssTimer = setTimeout("hideImage("+bForward+")", 2*iDelayBetweenImageAlphaChange);
		iCount+=1;
		return;
		}
//alert('After CheckNextImageInStore, next image has been loaded');
	
	imgOff('L');
	imgOff('R');

	var ssImg = getObj("ssImg");
	
	if (iAlpha >= 0 && CheckIfChangeOpacity(ssImg)) {
		if (document.all){
			ssImg.style.filter = "alpha(opacity=" + iAlpha + ")";	
		}
		if (document.getElementById && !document.all) {
			ssImg.style.opacity = iAlpha/100;	
        }
		iAlpha -= iAlphaChange;
		ssTimer = setTimeout("hideImage("+bForward+")", iDelayBetweenImageAlphaChange);
	}
	else {
		clearTimeout(ssTimer);
		//iCurrentImg++;
		//if (iCurrentImg >= imgURLs.length)
		//	iCurrentImg = 0;
		iAlpha = 0;
		iCount = 0;
		if(bForward)
			GetNextMenuIDSlide()
		else
			GetPrevMenuIDSlide()
;
		showImage(true);
	}
}

function hideImageSleep() {

	if (getObj(sParentID).style.display == 'none') {
		iAlpha = 0;
		iCurrentImg = 0;
		clearTimeout(ssTimer);
		return;
	}


	if (!bSlideShowPlayPause) {
		iDelayCurrent = 0;
	}

	var bRet=CheckNextImageInStore(true);

    if (iDelayCurrent < iDelayBetweenImageChange) {
		iDelayCurrent += iDelayBetweenImageAlphaChange;
		ssTimer = setTimeout("hideImageSleep()", iDelayBetweenImageAlphaChange);
	}
	else {
		iDelayCurrent = 0;
		if(bSlideShowPlayBack)
		{
		document.getElementById('imgNext').src='Images/Pict_MoveNext_anim.gif';
		hideImage(true);
		}		
		else
		{
		document.getElementById('imgPrev').src='Images/Pict_MovePrev_anim.gif';
		hideImage(false);
		}		
	}
}

// move arrow for new image
function checkImgCurReplace()
{
  var oImgPos = getCurrentImagePos();

  if ((oCurPos.x < oImgPos.left) || (oCurPos.x > oImgPos.left + oImgPos.width))
    return;
  if ((oCurPos.y < oImgPos.top) || (oCurPos.y > oImgPos.top + oImgPos.height))
    return;

  sPos = "L";
  if (oCurPos.x > oImgPos.left + oImgPos.width/2) 
    sPos = "R";
  imgOff(sPos=="L"?"R":"L");
  imgOn(sPos);
}

function imgOn(sPos)
{
  var oImgPos = getCurrentImagePos();
//alert('oImgPos.width:'+oImgPos.width);
  if(oImgPos.width<256)
	return;
var oImgCurheight=128;
var oImgCurwidth=128;

  var oImgCur = getObj(sPos=='L'?sImgCurLID:sImgCurRID);

//alert(oImgPos.left);
//alert(oImgPos.right);
//alert(oImgPos.height);
  // FF: div abs pos 
  // IE & Safari rel pos
 if(oImgPos.width<256)
	{
	oImgCurheight=parseInt(oImgPos.width/2);
	oImgCurwidth=parseInt(oImgPos.width/2);
//alert('oImgCur.width:'+oImgCur.width);
	}

oImgCur.width=oImgCurwidth;
oImgCur.height=oImgCurheight;

  if (isFF())
  {
    //oImgCur.style.left = oImgPos.left + oImgPos.width*(sPos=='L'?1:3)/4 - iImgCurSizeW/2;
    if(oImgPos.width<256)
	    oImgCur.style.left = oImgPos.left + (sPos=='L'?0:oImgPos.width-oImgCurwidth)
    else
	    oImgCur.style.left = oImgPos.left + (sPos=='L'?10:oImgPos.width-oImgCurwidth-10)
;
    oImgCur.style.top = oImgPos.top + parseInt(oImgPos.height/2 - oImgCurheight/2);
  }
  else
  {
    if(oImgPos.width<256)
	    oImgCur.style.left = (sPos=='L'?0:oImgPos.width-oImgCurwidth);
    else
	    oImgCur.style.left = (sPos=='L'?10:oImgPos.width-oImgCurwidth-10);
;
    oImgCur.style.top = parseInt(oImgPos.height/2 - oImgCurheight/2);
  }

  oImgCur.style.display = '';

oImgCur.width=oImgCurwidth;
oImgCur.height=oImgCurheight;

  if (isFF())
  {
    //oImgCur.style.left = oImgPos.left + oImgPos.width*(sPos=='L'?1:3)/4 - iImgCurSizeW/2;
    if(oImgPos.width<256)
	    oImgCur.style.left = oImgPos.left + (sPos=='L'?0:oImgPos.width-oImgCurwidth)
    else
	    oImgCur.style.left = oImgPos.left + (sPos=='L'?10:oImgPos.width-oImgCurwidth-10)
;
    oImgCur.style.top = oImgPos.top + parseInt(oImgPos.height/2 - oImgCurheight/2);
  }
  else
  {
    if(oImgPos.width<256)
	    oImgCur.style.left = (sPos=='L'?0:oImgPos.width-oImgCurwidth);
    else
	    oImgCur.style.left = (sPos=='L'?10:oImgPos.width-oImgCurwidth-10);
;
    oImgCur.style.top = parseInt(oImgPos.height/2 - oImgCurheight/2);
  }
}

function imgOff(sPos)
{
  var obj=getObj(sPos=='L'?sImgCurLID:sImgCurRID);
  if (obj)
  	obj.style.display = 'none';
}

// image current position
function getCurrentImagePos()
{
    var oObj = getObj(sImgID);
	
    var w = getObj("ssImg").width;
    var h = getObj("ssImg").height;
    var l = Left(oObj);
    var t = Top(oObj);

    return {"left":l, "top":t, "width": w, "height":h};
}

// mouse position
function mousePageXY(e)
{
  var x = 0, y = 0;

  if (!e) e = window.event;

  if (e.pageX || e.pageY)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
    x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
    y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }
//alert(e.clientY+"|"+document.documentElement.scrollTop+"|"+document.body.scrollTop+"|"+document.documentElement.clientTop);
  return {"x":x, "y":y};
}

function getElementPosition(elemId)
{
    var elem = document.getElementById(elemId);
	
    var w = elem.offsetWidth;
    var h = elem.offsetHeight;
	
    var l = 0;
    var t = 0;
	
    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
//pos = getElementPosition("myDiv");
//var left = pos.left;
//var top = pos.top;
}

// FF check
function isFF()
{
  var UA=window.navigator.userAgent;
  return UA.toLowerCase().indexOf('firefox')>0?true:false;
}

// IE check
function isIE()
{
  var UA=window.navigator.userAgent;
  return UA.toLowerCase().indexOf('MSIE')>0?true:false;
}

function OpenSlideShowParent(sparentid1) {
//alert('OpenSlideShowParent, sparentid1:'+sparentid1);
var oss=document.getElementById("IMGSS"+sparentid1);
//alert(oss);
//alert(oss.onclick+';onclick();');
if(oss)
	eval(oss.onclick+';onclick();')
else
	alert('OpenSlideShowParent error');
}

function OpenSlideShow(sSlideShowButtonIDPar, winX, winY, winW, winH, slideshow)
{
//alert('sSlideShowButtonIDPar:'+sSlideShowButtonIDPar);
	iAlpha = 0;
	bSlideShowPlayPause = true;
	clearTimeout(ssTimer);
	sTable = '';
	sTable += '<div id="ssImgDiv" align="center"><img id="ssImg" name="ssImg" ';
	sTable += 'maxW="1600" maxH="1200" minW="0" minH="0" ';
	sTable += 'title="'+DOCS_ChangeSize+'" ';
	//sTable += 'onload1="onLoadPic('ssImg')" ';
	sTable += 'onMouseUp="myMouseUp(this);" onmousemove="myMouseMove(this, event);" onmousedown="myMouseDown(this, event);" onMouseOut="myMouseOut(this);" ';
	//sTable += 'onclick="closeDialogWindow(\'newDialogWindowSlide\');" ';
	sTable += 'border="0" USEMAP="#ssMap"><br/><span id="ssText" border="0" style="word-break:break-all;"></span>';

	if (slideshow=='y')	{
	sTable += '<img onclick="SlideShowPrev();" TITLE="'+DOCS_ShowPrev+'" id="ssImgCurL" src="Images/Pict_MovePrev.png" width="128" height="128" border="0" style="cursor:pointer;cursor:hand;position:absolute;display:none" onMouseOver="imgOn(\'L\');" onMouseOut1="imgOff(\'L\');">';
	sTable += '<img onclick="SlideShowNext();" TITLE="'+DOCS_ShowNext+'" id="ssImgCurR" src="Images/Pict_MoveNext.png" width="128" height="128" border="0" style="cursor:pointer;cursor:hand;position:absolute;display:none" onMouseOver="imgOn(\'R\');" onMouseOut1="imgOff(\'R\');">';
	son=""
	}
	else
	son="1"

	sTable += '<MAP NAME="ssMap">';
	sTable += '<AREA  onMouseOver'+son+'="imgOn(\'L\');" onMouseOut'+son+'="imgOff(\'L\');" id=areaL SHAPE="RECT" COORDS="0,0,0,0" TITLE1="'+DOCS_ShowPrev+'" HREF'+son+'="javascript:SlideShowPrev();">';
	sTable += '<AREA  onMouseOver'+son+'="imgOn(\'R\');" onMouseOut'+son+'="imgOff(\'R\');" id=areaR SHAPE="RECT" COORDS="0,0,0,0" TITLE1="'+DOCS_ShowNext+'" HREF'+son+'="javascript:SlideShowNext();">';
	//sTable += '<AREA  onMouseOver'+son+'="this.style.cursor = \'col-resize\';" onMouseOut'+son+'="this.style.cursor = \'pointer\';" id=areaZ SHAPE="RECT" COORDS="0,0,0,0" >';
	sTable += '</MAP>';
	sTable += '</div>';

	insertDialogWindow('newDialogWindowSlide');
	//insertDialogWindowHeaderLine('newDialogWindowSlide');
	InitDialogWindow('newDialogWindowSlide');
	insertDialogWindowBody('newDialogWindowSlide', sTable, true, 'center');
	insertDialogWindowControlLine('newDialogWindowSlide', slideshow);
	//openDialogWindow('newDialogWindowSlide', winX, winY, 0, 0, false);
	openDialogWindow('newDialogWindowSlide', window.screen.availWidth/2, window.screen.availHeight/2, 0, 0, false);
	//sCurrentMenuID=slideshowFirst;
	//if(sCurrentMenuIDPar!=undefined)
		sCurrentMenuID=sSlideShowButtonIDPar;
	//else
	//	sCurrentMenuID=document.getElementById(sSlideShowButtonIDPar).getAttribute('slideshowFirst');
	sCurSlideShowButtonIDPar=sSlideShowButtonIDPar;
//alert('sCurrentMenuID:'+sCurrentMenuID);
	sSlideShowButtonID=sSlideShowButtonIDPar;
	iCount = 0;
	getObj("ssImg").src="images/ajaxloading.gif"
	changeDialogWindowPosition(sParentID, 100, 200);
	getObj('newDialogWindowSlide').style.display = '';
//alert('');
	SlideShowPlayPause();
    	showImage(true);
}
 
//*** slide-show vars & functions end

function PayDoxLogonNewWindow(L, sPayDoxRegID)
{
//var sTemp=sPayDoxURL+'Registration.asp?built=y&l='+L //+'&hash=' + Math.random();
//CallURLNewWindow(sTemp);
sw=''+Math.floor(screen.width/2)-140;
sh=''+Math.floor(screen.height/2)-80;
window.open('Registration.asp?l='+L+'&RegIDToShowLogin='+sPayDoxRegID, '','toolbar=0,resizable=1,location=0,directories=0,status=0,menubar=0,width=190,height=240,left='+sw+',top='+sh+',scrollBars=0');
}

function bltPayDoxGetInfo(sType, L, sPayDoxRegID)
{
//alert('bltPayDoxGetInfo');
//sPayDoxGetInfoID=sPayDoxRegID;
sURL=sPayDoxURL+'GetInfo.asp?l=' + L + '&type=' + sType + '&NoPublic=y&hash=' + Math.random()
var odetails = document.getElementById(sPayDoxRegID);
if(odetails)
	CallURLo(sURL, odetails);
}

function CallURLNewWindow(sURL, sObj)
{
//alert('CallURLNewWindow');
//var ndwid="ndwid"+Math.random();
var ndwid=sObj;
if(!ndwid)
	ndwid="ndwid"+Math.random();
var sTable = '<div id="div'+ndwid+'"></div>';
insertDialogWindow(ndwid);
InitDialogWindow(ndwid);
insertDialogWindowHeaderLine(ndwid);
insertDialogWindowBody(ndwid, sTable, true, 'center');
CallURL(sURL, "div"+ndwid);
openDialogWindow(ndwid, 0, 0, 150, 150, true);
//getObj(ndwid).style.display = '';
}

function GetLoadingMessage() 
{
//return "<%=DOCS_Loading%>";
return "<IMG src='"+sPayDoxURL+"images/Pict_Loading.gif' border=0>";
}

function loadItems(id,c,sMapFile, haschild, sBaseURL){ 
//alert('loadItems START, arguments.length:'+arguments.length);
//alert('loadItems START, id:'+id);
//alert('loadItems START, c:'+c);
//alert('loadItems START, haschild:'+haschild);
var current_el = null;
var corig=c;
//var current_id = c;
//if(arguments.length>=3)
//alert('loadItems, sMapFile:'+sMapFile);
//alert('loadItems, sBaseURL:'+sBaseURL);
if(arguments.length<=4)
	sBaseURL=sPayDoxURL;
if(sBaseURL==undefined)
	sBaseURL=sPayDoxURL;
if(sBaseURL=='')
	sBaseURL=sPayDoxURL;

	var img = null;
	//if(arguments.length<2){
	if(c!='TreeViewFiles'){
		//c = "C" + id;
		//img = document.getElementById("I"+id);
//alert("I"+c);
		img = document.getElementById("ITH"+c);
		c = "C" + c;
//alert(img);
	}
	else
	{
//alert('loadItems START, c:'+c);
		//img = document.getElementById(id);
		//img = document.getElementById("I"+c);
	}
//alert("c:"+c)
	current_el = document.getElementById(c);
if(!current_el)
	{
	if(iCount>10)
		{
		alert('loading error 14');
		return;
		}
	window.setTimeout(function(){loadItems(id,corig,sMapFile, haschild, sBaseURL);}, 100); 
	iCount+=1;
	return;
	}
	iCount=0;

//alert("document.getElementById(c) OK")
//alert('current_el.style.display: '+current_el.style.display);
	if(current_el.style.display == 'none'){
		current_el.style.display = ''
//alert('img.src 1: '+img.src);
		if(img)
			if(haschild=='1')
				{
				img.src = sPayDoxURL+"images/folder_open.png";
				}
			else
			if(haschild=='2')
				img.src = sPayDoxURL+"images/pict_lanOpen.png"
			else
			if(haschild=='3')
				img.src = sPayDoxURL+"images/pict_webOpen.png"
			;
//if(img)
//alert('img.src 2: '+img.src);

		//current_el.src = "images/folderopen.gif";
		//current_el.style.fontFamily = "arial, ans-serif"
		//current_el.style.fontSize = "12"
		//current_el.style.color = "#FF0000" //#003366
		current_el.innerHTML = GetLoadingMessage();
		//current_el.innerHTML = "<img src='"+sPayDoxURL+"images/Pict_Loading.gif' border=0>"
		//current_el.innerHTML = '';
	}else{
		current_el.style.display = 'none';
		strSingleFile="";
		if(img)
			if(haschild=='1')
				{
				img.src = sPayDoxURL+"images/folder_close.png";
				var oss=document.getElementById("IMGSS"+c);
				//alert(oss);
				if(oss)
					oss.style.display='none'
				}
			else
			if(haschild=='2')
				img.src = sPayDoxURL+"images/pict_lan.png"
			else
			if(haschild=='3')
				img.src = sPayDoxURL+"images/pict_web.png"
			;
	}
//alert(current_el.innerHTML.substring(0,4));
//alert(GetLoadingMessage());

	//if(current_el.innerHTML == GetLoadingMessage()){
	//if(current_el.innerHTML == ''){
	if(current_el.innerHTML.substring(0,4) == '<IMG' || current_el.innerHTML.substring(0,4) == '<img'){
		document.getElementById("Loading").style.display = '';
//alert('getItems 1');
		if(haschild=='3' && sBaseURL == sPayDoxURL)
			{
			sTemp=sPayDoxURL+'ShowFiles.asp?built=y&ShowSearch=n'+LPar+'&hash=' + Math.random()+'&transurl='+sMapFile;
			//alert(sTemp);
			CallURL(sTemp, c);
			}
		else		
		if(haschild=='3')
			{
			sTemp=sPayDoxURL+'ShowFiles.asp?built=y&ShowSearch=n'+LPar+'&hash=' + Math.random()+'&transurl='+sBaseURL;
			//alert(sTemp);
			CallURL(sTemp, c);
			}
		else
			getItems(c, id,'',sMapFile,sBaseURL);
//alert('getItems 1 OK');
	}

function getItems(c, input, response, sMapFile,sBaseURL){	
//alert('getItems START, sMapFile:'+sMapFile+', sBaseURL:'+sBaseURL);
//alert('getItems START, input:'+input);
//alert('getItems START, LPar:'+LPar);
//alert("unescape:"+unescape("%27"))
//alert(sPayDoxURL);

//if(sBaseURL!=sPayDoxURL)
//	sMapFile='';

//SetInitVars();

var current_el = document.getElementById(c);

	if (response != ''){ 		
	    // Response mode	
//alert(response)    
        //current_el.style.color = "#003366"
        current_el.innerHTML = response;
        loading.style.display = 'none'
	}else{
		// Input mode			
		var url  = sPayDoxURL+"GetTreeViewItems.asp?ParentFolder="+input+LPar+"&parid="+c+"&nRecToRet="+nRecordsToReturn+"&Menu="+sMenu+"&built="+sbuilt+"&Mobile="+sMobile+"&login="+encodeURI(slogin)+"&BaseURL="+encodeURI(sBaseURL)+"&SingleFile="+encodeURI(strSingleFile)+"&MapFile="+encodeURI(sMapFile)+"&hash=" + Math.random();
//alert('url 3:'+url)
		loadXMLDoc(url, current_el);
	}
//alert('getItems END');
}

}

function buildTree(id, sLPar, Menu, Mobile, sfolder){
//alert('buildTree, Menu:'+Menu);
	if (!began){
		loading = document.getElementById("Loading");
//alert(loading);
		document.getElementById(id).style.display = 'none';
		began = true;
	}
//alert('buildTree loadItems START');
	LPar=sLPar;
	sMenu=Menu;
	sMobile=Mobile;
//alert('buildTree LPar:'+LPar);
	loadItems(sfolder,id)
//alert('buildTree loadItems END');
}

function loadXMLDoc(url, current_el, c) {	
var req;

if(!current_el)
	current_el = document.getElementById(c);

var c = current_el.id;
//alert(c);

//alert('loadXMLDoc, url:'+url);
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
    //if (false) {
//alert('window.XMLHttpRequest');
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
//alert('req.send(null) OK');
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
//alert('window.ActiveXObject');
        //isIE = true;

    try
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(err)
    {
	ErrorMicrosoftXMLHTTP();
        return;
    }

	//Set req = CreateObject("Microsoft.XMLHTTP");
//alert('window.ActiveXObject OK');
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }

function getItems(c, input, response, snextrec, sShowNext, nGenMenuID){	
//alert('getItems START, input:'+input+", snextrec:"+snextrec);
//alert('getItems START, sBaseURL:'+sBaseURL);
//alert('getItems START, sShowNext:'+sShowNext);
//alert('getItems START, nGenMenuID:'+nGenMenuID);

var current_el = document.getElementById(c);

sBaseURL=sPayDoxURL;
//alert("unescape:"+unescape("%27"))
//alert(current_el.style.display)

	if (response != ''){ 		
	    // Response mode	
//alert(response)    
        //current_el.style.color = "#003366"
		if(current_el.innerHTML.substring(0,4) == '<IMG' || current_el.innerHTML.substring(0,4) == '<img')
			//current_el.innerHTML='';
current_el.innerHTML='<table border="0" valign="top" width="100%" cellpadding="0" cellspacing="0"><THEAD><TR><TD></TD></TR></THEAD><TBODY id="T'+c+'"></TBODY></table>';

		if (snextrec == '')
			{
        		//current_el.innerHTML = response;
putresponse()
			//document.getElementById("Loading").style.display = 'none';
			}
		else

		if (snextrec == '-')
			{
			//current_el.innerHTML = current_el.innerHTML+response;
			//document.getElementById("Loading").style.display = 'none';
putresponse()
			}

		else
			{
        		//current_el.innerHTML = current_el.innerHTML+response;
putresponse()
			if(current_el.style.display=='none')
				return;
			//var url  = sPayDoxURL+"GetTreeViewItems.asp?ParentFolder="+LPar+"&nnextrecpoz="+input+"&Menu="+sMenu+"&built="+sbuilt+"&Mobile="+sMobile+"&login="+encodeURI(slogin)+"&BaseURL="+encodeURI(sBaseURL)+"&SingleFile="+encodeURI(strSingleFile)+"&MapFile="+encodeURI(sMapFile)+"&hash=" + Math.random();

			if(sShowNext!='y')
			{
			var url  = sPayDoxURL+"GetTreeViewItems.asp?ParentFolder="+encodeURI(input)+LPar+"&parid="+c+"&nnextrecpoz="+snextrec+"&GenMenuID="+nGenMenuID+"&Menu="+sMenu+"&built="+sbuilt+"&Mobile="+sMobile+"&login="+encodeURI(slogin)+"&BaseURL="+encodeURI(sBaseURL)+"&SingleFile="+encodeURI(strSingleFile)+"&MapFile=&hash=" + Math.random();
//alert('url 2:'+url)
			loadXMLDoc(url, current_el);
			}

			}
        //loading.style.display = 'none'
	}else{
		// Input mode			
		//var url  = "GetTreeViewItems.asp?ParentFolder=" + input + LPar+ "&hash=" + Math.random();
		var url  = sPayDoxURL+"GetTreeViewItems.asp?ParentFolder="+input+LPar+"&parid="+c+"&nRecToRet="+nRecordsToReturn+"&Menu="+sMenu+"&built="+sbuilt+"&Mobile="+sMobile+"&login="+encodeURI(slogin)+"&BaseURL="+encodeURI(sBaseURL)+"&SingleFile="+encodeURI(strSingleFile)+"&MapFile="+encodeURI(sMapFile)+"&hash=" + Math.random();
//alert('url 1:'+url)
		loadXMLDoc(url, current_el);
	}

function putresponse(){
var oRow=document.getElementById('TMore'+c);
//alert(oRow);
//alert(sShowNext);
if(oRow)
	document.getElementById('T'+c).removeChild(oRow);

oRow = document.createElement("TR");
var oCell = document.createElement("TD");
oCell.innerHTML = response;
oRow.appendChild(oCell);
document.getElementById('T'+c).appendChild(oRow);

if(sShowNext=='y')
	{
	oRow = document.createElement("TR");
	oCell = document.createElement("TD");
var url  = sPayDoxURL+"GetTreeViewItems.asp?ParentFolder="+encodeURI(input)+LPar+"&nnextrecpoz="+snextrec+"&GenMenuID="+nGenMenuID+"&Menu="+sMenu+"&built="+sbuilt+"&Mobile="+sMobile+"&login="+encodeURI(slogin)+"&BaseURL="+encodeURI(sBaseURL)+"&SingleFile="+encodeURI(strSingleFile)+"&MapFile=&hash=" + Math.random();
//oCell.innerHTML = 'More...';
oCell.innerHTML = '';
oCell.innerHTML = oCell.innerHTML + '<IMG id="TLoading'+c+'" style="display:none;" src="images/Pict_Loading.gif" border="0">';
oCell.innerHTML = oCell.innerHTML + '<BUTTON onclick="javascript:this.style.display=\'none\';document.getElementById(\'TLoading'+c+'\').style.display=\'\';loadXMLDoc(\''+url+'\', null, \''+c+'\');" TYPE="button" border="2" title="'+DOCS_More+'..." style="cursor:pointer;cursor:hand;background-color:#d4d0c8;font-size:11px;FONT-WEIGHT:normal;color:#000000;font-family:Arial;border-style1:none;">'+DOCS_More+'...</BUTTON>';
	oRow.appendChild(oCell);
	oRow.id='TMore'+c;
	document.getElementById('T'+c).appendChild(oRow);
	}
}

//alert('getItems END');
}

function processReqChange(){
	// only if req shows "complete"
	if (req.readyState == 4) {
		// only if "OK"
//alert(req.status)		
		if (req.status == 200) {		
//alert(req.responseText.substring(req.responseText.indexOf('<div>')))			
//alert(req.responseText)			
			// ...processing statements go here...

			var start = req.responseText.indexOf('<alert>') + 7
			var stop = req.responseText.indexOf('</alert>')
			salert = req.responseText.substring(start,stop);
			if(start>-1 && stop>start)
			if(salert!='')
				{
				alert(salert);
				if (current_el) 
					{
					current_el.innerHTML="";
					current_el.style.display='none';
					}
				return;
				}

			response  = req.responseXML.documentElement;
//alert(req.responseText);
//if(current_el.innerHTML.substring(0,4) == '<IMG' || current_el.innerHTML.substring(0,4) == '<img'){


			method =
				response.getElementsByTagName('method')[0].firstChild.data;
			
			//result = response.getElementsByTagName('result')[0].firstChild.data;
			var start = req.responseText.indexOf('<result>') + 8
			var stop = req.responseText.indexOf('</result>')
			result = req.responseText.substring(start,stop);

			var start = req.responseText.indexOf('<nnextrecpoz>') + 13
			var stop = req.responseText.indexOf('</nnextrecpoz>')
			nnextrecpoz = req.responseText.substring(start,stop);

			var start = req.responseText.indexOf('<ParentFolder>') + 14
			var stop = req.responseText.indexOf('</ParentFolder>')
			sParentFolder = req.responseText.substring(start,stop);
//alert(sParentFolder);
//alert(nnextrecpoz);
			var start = req.responseText.indexOf('<ShowNext>') + 10
			var stop = req.responseText.indexOf('</ShowNext>')
			sShowNext = req.responseText.substring(start,stop);
//alert(sShowNext);

			var start = req.responseText.indexOf('<GenMenuID>') + 11
			var stop = req.responseText.indexOf('</GenMenuID>')
			nGenMenuID = req.responseText.substring(start,stop);
//alert(nGenMenuID)

			//eval(method + '(\'\', result)');
			//eval(method + '(\''+nnextrecpoz+'\', result)');
			if(nnextrecpoz=='')
				getItems(c, '', result, '', '', '')
			else
				getItems(c, sParentFolder, result, nnextrecpoz, sShowNext, nGenMenuID);
		} else if (req.status == 12029){
			alert("ERROR\n Web-server Unavailable");
		} else if (req.status == 12007){
			alert("ERROR\n No connection");
		} else if (req.status == 0){
			alert("ERROR\n Web-access error");
		} else {
			alert("ERROR\n" + req.statusText + " ("+req.status + "): ");
		}

		if (req.status != 200) 
			if (current_el) 
			{
			current_el.innerHTML="";
			current_el.style.display='none';
			}
	}
}		

}

function CR() 
{
return (unescape("%0A")+unescape("%0D"));
}

function trim(str)
{
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function CallURL(sURL, sObj)
{
var odetails, req;
var SetInitVarsNameInt=SetInitVarsName;
SetInitVarsName='';

//alert('CallURL, sURL:'+sURL+', sObj:'+sObj);

if(sObj!='')
odetails = document.getElementById(sObj);

//alert(odetails);
odetails.innerHTML = GetLoadingMessage();
//alert(odetails.innerHTML);
odetails.style.display='';

    if (window.XMLHttpRequest) 
	{
        req = new XMLHttpRequest();
    	} 
	else if (window.ActiveXObject) 
	{
		try
    		{
	        req = new ActiveXObject("Microsoft.XMLHTTP");
    		}
    	
		catch(err)
    		{
		ErrorMicrosoftXMLHTTP();
        	return;
    		}

	}
	
	//SetInitVars();

        if (req) 
	{
	       req.onreadystatechange = processCallURL;
//sURL="http://127.0.0.1:81/ShowFiles.asp?l=ru";
//alert(sURL);
    try
    {
        	req.open("GET", sURL, true);
		//odetails.innerHTML = GetLoadingMessage();
		//odetails.style.display='';
    }
    catch(err)
    {
	//alert(err.description+" "+sURL);
	//alert(odetails);
	//alert(odetails.innerHTML);
	odetails.innerHTML="";
	odetails.style.display='';
        return;
    }
        	req.send(null);
	}
return;

function processCallURL(){
	if (req.readyState == 4) {
//alert(req.statusText + " ("+req.status + ")");
//alert(req.responseText);
//alert(req.status);
		if (req.status == 200) {
				if(odetails)
				{
				//alert('req.responseText:'+req.responseText);
				//alert(sObj);
				//if(sObj=='bltPayDox')
				//	odetails.innerHTML=req.responseText+'<font style="FONT-SIZE: 1px;"><br></font><div align="right"><font style="FONT-FAMILY: Arial, sans-serif; FONT-SIZE: 11px; COLOR: #808080;">Powered by </font><a href="http://www.paydox.ru" style="FONT-FAMILY: Arial, sans-serif; FONT-SIZE: 11px; COLOR: #808080;">PayDox</a></div>'
				//else
					odetails.innerHTML=req.responseText;
//alert('SetInitVarsNameInt:'+SetInitVarsNameInt+', sURL:'+sURL);
					if(SetInitVarsNameInt!='')
						{
						SetInitVars(SetInitVarsNameInt);
						}
//if(sObj=='bltVoting')
//	alert(odetails.innerHTML);

				if(req.responseText.length<=20)
					odetails.style.display='none';
				//if(sObj=='bltPayDox')
//buildTree('TreeViewFiles', LPar, 'N', '', '');
//buildTree('TreeViewFiles', '<%=LPar()%>', '<%=Request("Menu")%>', '<%=Request("Mobile")%>', '<%=URLEncode(MakeJSSafe(objTreeView.NoFSFolder(Trim(Request("FOpen")))))%>');
				}
				return;
		} else if (req.status == 12029){
			alert("ERROR\n Web-server Unavailable");
		} else if (req.status == 0){
			alert("ERROR\n Web-access error");
		} else if (req.status == 12007){
			alert("ERROR\n No connection");
		} else {
			alert("ERROR\n" + req.statusText + " ("+req.status + "): "+sURL); //
		}
		odetails.innerHTML="";
		odetails.style.display='';
	}
}
}

function CallURLo(sURL, odetails)
{
var req;

//alert(odetails);
odetails.innerHTML = GetLoadingMessage();
//alert(odetails.innerHTML);
odetails.style.display='';

    if (window.XMLHttpRequest) 
	{
        req = new XMLHttpRequest();
    	} 
	else if (window.ActiveXObject) 
	{
		try
    		{
	        req = new ActiveXObject("Microsoft.XMLHTTP");
    		}
    	
		catch(err)
    		{
		ErrorMicrosoftXMLHTTP();
        	return;
    		}

	}
	
	//SetInitVars();

        if (req) 
	{
	       req.onreadystatechange = processCallURLo;
//sURL="http://127.0.0.1:81/ShowFiles.asp?l=ru";
//alert(sURL);
    try
    {
        	req.open("GET", sURL, true);
		//odetails.innerHTML = GetLoadingMessage();
		//odetails.style.display='';
    }
    catch(err)
    {
	alert(err.description+" "+sURL);
	//alert(odetails);
	//alert(odetails.innerHTML);
	odetails.innerHTML="";
	odetails.style.display='';
        return;
    }
        	req.send(null);
	}
return;

function processCallURLo(){
	if (req.readyState == 4) {
//alert(req.statusText + " ("+req.status + ")");
//alert(req.responseText);
//alert(req.status);
		if (req.status == 200) {
				if(odetails)
				{
				//alert('req.responseText:'+req.responseText);
				//alert(sObj);
				//if(sObj=='bltPayDox')
				//	odetails.innerHTML=req.responseText+'<font style="FONT-SIZE: 1px;"><br></font><div align="right"><font style="FONT-FAMILY: Arial, sans-serif; FONT-SIZE: 11px; COLOR: #808080;">Powered by </font><a href="http://www.paydox.ru" style="FONT-FAMILY: Arial, sans-serif; FONT-SIZE: 11px; COLOR: #808080;">PayDox</a></div>'
				//else
					odetails.innerHTML=req.responseText
;
				//if(req.responseText.length<=20)
				//	odetails.style.display='none';
				//if(sObj=='bltPayDox')
//buildTree('TreeViewFiles', LPar, 'N', '', '');
//buildTree('TreeViewFiles', '<%=LPar()%>', '<%=Request("Menu")%>', '<%=Request("Mobile")%>', '<%=URLEncode(MakeJSSafe(objTreeView.NoFSFolder(Trim(Request("FOpen")))))%>');
				}
				return;
		} else if (req.status == 12029){
			alert("ERROR\n Web-server Unavailable");
		} else if (req.status == 0){
			alert("ERROR\n Web-access error");
		} else if (req.status == 12007){
			alert("ERROR\n No connection");
		} else {
			alert("ERROR\n" + req.statusText + " ("+req.status + "): "+sURL); //
		}
		odetails.innerHTML="";
		odetails.style.display='';
	}
}
}

function GetThumbnailImage(thisp, sfilename, smenuid, sBaseURL, CatalogueType, SingleFile)
{
//var tmblimg=new Image();
//thisp.onload="javascript:alert('onload');document.getElementById('IMGW"+smenuid+"').width=77;";
if(SingleFile=='')
	thisp.onload=""
else
	{
	thisp.onload=thisp.onclick //+"this.style.display='none';alert(this.onload);";
	//thisp.style.display='none';
	}
//thisp.onload="javascript:alert('1');document.getElementById('IMGW"+smenuid+"').width=77;alert('2');";

//thisp.src="<%=GetPayDoxURL()%>GetThumbnailImage.aspx?filename="+sfilename+"&hash="+Math.random();
thisp.src=sBaseURL+"GetThumbnailImage.aspx?filename="+encodeURI(sfilename)+"&CatalogueType="+encodeURI(CatalogueType)+"&hash="+Math.random();
//sPayDoxURL
//document.getElementById('IMGW'+smenuid).width=77;
//alert('IMGW'+smenuid);
//alert(document.getElementById('IMGW'+smenuid));
}

function GetFileAsIs(sFile){
return sPayDoxURL+"DownloadFile.asp?file="+encodeURI(sFile)+"&fileout="+encodeURI(sFile)+"&FilePath=-"+LPar+"&hash="+Math.random();
}

function GetThumbnailAnimated(thisp, sfilename)
{
//alert('GetThumbnailAnimated, thisp.src:'+thisp.src)
//alert('GetThumbnailAnimated, sfilename:'+sfilename)
if(thisp.src.indexOf('pict_video48x48.png')>=0 || thisp.src.indexOf('pict_error.gif')>=0)
	return;
//var spath=sURL.substring(0,sURL.lastIndexOf("/")+1);
var spath=sfilename.substring(0,sfilename.lastIndexOf("/")+1);
//alert('GetThumbnailAnimated, spath:'+spath)
var sfilenamenopath=sfilename.substring(sfilename.lastIndexOf("/")+1);
sfilenamenopath=sfilenamenopath.substring(0,sfilenamenopath.lastIndexOf("."));
//alert('GetThumbnailAnimated, sfilenamenopath:'+sfilenamenopath)
//alert(GetFileAsIs(spath+'_Thumbnails/'+sfilenamenopath+'_Thumb7.GIF'));
thisp.src = GetFileAsIs(spath+'_Thumbnails/'+sfilenamenopath+'_Thumb7.GIF');
}

function GetVideoFrame(thisp, sfilename, smenuid, sBaseURL, CatalogueType, SingleFile)
{
//alert('GetVideoFrame, sfilename:'+sfilename);
//alert('thisp.src 1:'+thisp.src);
//alert('thisp.onload 1:'+thisp.onload);
//thisp.onload="alert(\'onload\');this.width=120;this.height=96;this.onmouseover='this.src=\'"+GetThumbnailAnimated(sfilename)+"\';';alert(1);";
//thisp.onload="";
//thisp.onload="function (){alert(1);}";
//alert('thisp.onload 2:'+thisp.onload);
//document.getElementById('ITH'+smenuid).onload='function (){alert(1);}';
//thisp.onload='function (){this.height=96;}';
//thisp.onload='this.height=96;';
thisp.src=sBaseURL+"GetVideoFrame.aspx?FileName="+encodeURI(sfilename)+"&TimePoints=00:00:30,00:01:00,00:01:15,00:01:30,00:01:45,00:02:00,00:02:20&width=180&hash="+Math.random();
//return sBaseURL+"GetVideoFrame.aspx?FileName="+encodeURI(sfilename)+"&TimePoints=00:00:30,00:01:00,00:01:15,00:01:30,00:01:45,00:02:00,00:02:20&width=120&hash="+Math.random();
//thisp.onerror="this.src='Images/pict_error.gif';thisp.width=48;thisp.height=48;thisp.onmouseover='';";

//var oITH=document.getElementById('ITH'+smenuid);
//var oITH=getImagePos('ITH'+smenuid);

//alert(oITH);
//alert(oITH.left);
//alert(oITH.top);
//var oITHPLAY=document.getElementById('ITHPLAY'+smenuid);
//alert(oITHPLAY);

//  if (isFF())
//	{
//	oITHPLAY.style.left = oITH.left + 16;
//	oITHPLAY.style.top = oITH.top + 16;
//	//oITHPLAY.style.left = 0;
//	//oITHPLAY.style.top = 0;
//	}
//  else
//	{
//	oITHPLAY.style.left = 16;
//	oITHPLAY.style.top = 16;
//	}

//oITHPLAY.style.display='';

}

function getImagePos(sIMGID1)
{
    var oObj = getObj(sIMGID1);
	
    var w = oObj.width;
    var h = oObj.height;
    var l = Left(oObj);
    var t = Top(oObj);

    return {"left":l, "top":t, "width": w, "height":h};
}

function ChPic(oTmp, iorigwidth) 
{
//alert(iorigwidth);

if (!oTmp.width)  
{
return (true);
}

if (oTmp.width==0 || oTmp.height==0)  
{
return (true);
}

var iHeight=oTmp.height;

if (oTmp.width==200)  
{
oTmp.width=400;
oTmp.height=iHeight*400/200;
return (true);
}
if (oTmp.width==400)  
{
oTmp.width=600;
oTmp.height=iHeight*600/400;
return (true);
}
if (oTmp.width==600)
{
oTmp.width=800;
oTmp.height=iHeight*800/600;
return (true);
}
if (oTmp.width==800)
{
oTmp.width=1200;
oTmp.height=iHeight*1200/800;
return (true);
}
if (oTmp.width==1200 && iorigwidth>1)
{
oTmp.width=iorigwidth;
//oTmp.width=200;
oTmp.height=iHeight*iorigwidth/1200;
return (true);
}

oTmp.height=iHeight*200/oTmp.width;
oTmp.width=200;
return (true);
}

function IsChPic(oTmp) 
{
if (oTmp.width>1 && oTmp.width!=200 && oTmp.width!=400 && oTmp.width!=600 && oTmp.width!=800)
	ChPic(oTmp, sFileAll, 0);
return (true);
}

function ImageOnload(oTmp, sImageName) 
{
oTmp.title=sImageName
//+" - <%=LCase(DOCS_ChangeSize)%>";
return (true);
}

function spanonclick(sMenuID, sIsFolderMarked, sWriteAccess, URLEncodesFolderOrFileMarked, sFolderOrFileMarkedToShow, But_Delete)
{
//alert('spanonclick');
//alert(FolderOrFileForm.IDMarked.value);
//alert(sFolderOrFileMarkedToShow);
IDMarkedobj=document.getElementById('IDMarked');
//alert(IDMarkedobj);
if(IDMarkedobj)
{
if(IDMarkedobj.value!='')
	{
	obj=document.getElementById(IDMarkedobj.value);
	if(obj)
		obj.style.color='#000000';
	}


obj=document.getElementById('FolderOrFileMarked');
if(obj)
	obj.value='';
obj=document.getElementById('FolderOrFileMarkedToShow');
if(obj)
	obj.value='';
}
document.all.DeleteFolderID.title=''; 

if(IDMarkedobj.value!='IDM_' + sMenuID)
	{
	obj=document.getElementById('IDM_' + sMenuID);
	if(obj)
		obj.style.color='#FF0000';
//alert(obj.style.color);

	IDMarkedobj.value='IDM_' + sMenuID; 
	document.getElementById('IsFolderMarked').value=sIsFolderMarked;
	document.getElementById('IsWriteAccess').value=sWriteAccess;
	document.getElementById('FolderOrFileMarked').value=URLEncodesFolderOrFileMarked;
	document.getElementById('idbtnmark').value=sFolderOrFileMarkedToShow;
	document.getElementById('DeleteFolderID').title=But_Delete + ': '+document.getElementById('FolderOrFileMarkedToShow').value;
	}
else
	{
	document.getElementById('IDMarked').value='';
	}

if(sWriteAccess == "n")
	{
	document.getElementById('CUFTF').disabled=true;
	document.getElementById('DeleteFolderID').disabled=true;
	document.getElementById('CreateFolderID').disabled=true;
	document.getElementById('RenameFolderID').disabled=true;
	}
else
	{
	document.all.CUFTF.disabled=false;
	document.all.DeleteFolderID.disabled=false;
	document.all.CreateFolderID.disabled=false;
	document.all.RenameFolderID.disabled=false;
	}
}


function doubleClick(){
clearTimeout(cT); 
timerFlag = false;
     //if(timerFlag){
	alert('Double Click!, timerFlag'+timerFlag);
      //} 
} 


function sLinkFast(SID, sPayDoxURL, rsImageName, sLink, sStr1, sparentid1)
{
	//alert('sLinkFast, SID:'+SID);
	timerFlag = true; 
	//cT=window.setTimeout(function(){sLinkFastTimer('"+SID+"', '"+sPayDoxURL+"', '"+rsImageName+"', '"+sLink+"', '"+sStr1+"');}, 1400); 
	var cT=window.setTimeout(function(){sLinkFastTimer(SID, sPayDoxURL, rsImageName, sLink, sStr1, sparentid1);}, 400); 
}

function sLinkFastTimer(SID, sPayDoxURL, rsImageName, sLink, sStr1, sparentid1)
{
var oIP, oI;
//alert('sLinkFast, timerFlag:'+timerFlag);
if(!timerFlag)
	return;
timerFlag = false; 

oI=document.getElementById('ITH' + SID);
oIP=document.getElementById('IP' + SID);
oIPTEMP=document.getElementById('IPTEMP' + SID);
//alert('sLinkFast, SID:'+SID);
//alert(oI);
//alert(oIP);
//alert(oIPTEMP);
//alert(oIP.src);
//alert(sPayDoxURL + 'Images/1x1.GIF');

//if (oIP.src==sPayDoxURL + 'Images/1x1.GIF') 
//if (oIP.src==sPayDoxURL + 'Images/1x1.GIF' || oIP.src=='') 
//if (oIP.src=='') 
//alert(oIP.width);

//alert(oIP.style.display);
//if (oIP.width==0 || oIP.width==nThumbW) 
if (oIP.style.display=='none') 
	{
	//oI.src=sPayDoxURL + 'Images/' + rsImageName;
	oI.style.display='none';

	if(oI.src!=sPayDoxURL + 'Images/' + rsImageName && oIP.src!=sLink+'&hash=' + Math.random()) //???
{
		oIPTEMP.src=oI.src;
		oIPTEMP.style.display='';
}

	//document.getElementById('PN' + SID).style.display='';
	//document.getElementById('PC' + SID).style.display='';
	//document.getElementById('PP' + SID).style.display='';
	loadPic(SID, sLink+'&hash=' + Math.random());

	//loadPic('IP'+SID, sLink+'&hash=' + Math.random());

	//oIP.style.display='block';
//alert('sLinkFast, oIP.style.display:'+oIP.style.display);
	//oIP.src=sLink+'&hash=' + Math.random();
	//oIP.width=nThumbW;
//alert(oIP.width);

	var oss=document.getElementById("IMGSS"+sparentid1);
//alert(oss);
	if(oss)
		oss.setAttribute("slideshowFirst", SID);
	
	} 
else 
	{
	//document.getElementById('PN' + SID).style.display='none';
	//document.getElementById('PP' + SID).style.display='none';
	//document.getElementById('PC' + SID).style.display='none';

	closePic('IP' + SID, SID)
	//GetThumbnailImage(document.getElementById('I' + SID), sStr1, SID);
    	//setTimeout(function(){GetThumbnailImage(document.getElementById('ITH' + SID), sStr1, SID);}, 1000);
	//oI.style.display='';

	//oIP.style.display='none';
	//oIP.width=1;
	//oIP.height=1;
	//oIP.src=sPayDoxURL + 'Images/1x1.GIF';
	//oIP.src='';
	//oIP.width=1;
	};
}

function ShowNextIMG(SID, SIDNext)
{

//alert('ShowNextIMG, SID:'+SID+', SIDNext:'+SIDNext);
//return;

var oIP, oI;
oI=document.getElementById('ITH' + SID);
oINext=document.getElementById('ITH' + SIDNext);

CurrentPicID='#ILNK'+SIDNext;
eval(oI.onclick+';onclick();');
//alert(oINext);
if(oINext)
    	//setTimeout(eval('+oINext.onclick+';onclick();'), 1000);
    	//setTimeout(eval(oINext.onclick+';onclick();'), 1000);
	{
	//alert(oINext.onclick);
	//eval(oINext.onclick+';onclick();');
	var stemp=oINext.onclick+';onclick();';
	setTimeout(stemp, 500);
	}

return;

var aIMGs = document.getElementsByTagName("IMG");
var iLength=aIMGs.length;
for(var i=0;i < iLength;i++)
	{
		sitemid=aIMGs[i].id;
		if(sitemid.substring(0,2)=='IP')
		{
		if(aIMGs[i].width>0)
			aIMGs[i].style.display='none';
		}
	}

}

function ShowPrevIMG(SID, SIDPrev)
{

//alert('ShowNextIMG');
//return;

var oIP, oI;
oI=document.getElementById('ITH' + SID);
oIPrev=document.getElementById('ITH' + SIDPrev);
CurrentPicID='#ILNK'+SIDPrev;
eval(oI.onclick+';onclick();');
if(oIPrev)
	{
	//eval(oIPrev.onclick+';onclick();');
	var stemp=oIPrev.onclick+';onclick();';
	setTimeout(stemp, 500);
	}

return;
}

function CloseIMG(SID)
{

var oIP, oI;
oI=document.getElementById('ITH' + SID);

if(strIsMobile=='y')
{
	oIP=document.getElementById('IP' + SID);
	maxW = oIP.getAttribute("maxW");
	maxH = oIP.getAttribute("maxH");
	if(oIP.width==1200)
		eval(oI.onclick+';onclick();')
	else
		ChPic(oIP, maxW)
}
else
	eval(oI.onclick+';onclick();');

return;
}

//--- image resize start --------------------------------
//var numSteps = 10;
var numSteps = 10;
//var nDelay = 40; // milliseconds
var nDelay = 4; // milliseconds
var mT;
var mTDown;
var isBusy = false;
var isBusyDown = false;
var CurrentPicID = '';

function reSizeUp(imgID, maxW, maxH, ITH)
{

  //alert(isBusy);

  if (isBusy)
    return;
  if (isBusyDown)
{
    setTimeout(function(){reSizeUp(imgID, maxW, maxH, ITH);}, 100);
    return;
}

  //alert("imgID=" + imgID + ", maxW=" + maxW+ ", maxH=" +maxH);

  var oImg, minW, minH, deltaW, deltaH;

  oImg = document.getElementById(imgID);

  minW = oImg.width;
  minH = oImg.height;

  deltaW = Math.round((maxW - minW) / numSteps);
  deltaH = Math.round((maxH - minH) / numSteps);

  //alert("deltaW=" + deltaW + ", deltaH=" + deltaH);

  if (oImg.width < maxW || oImg.height < maxH)
  {
    mT = setTimeout(function(){increase(oImg, maxW, maxH, deltaW, deltaH, ITH);}, nDelay);
    isBusy = true;
  }
  oImg.style.display="";
}

function reSizeDown(imgID, minW, minH, ITH)
{
  //alert("reSizeDown, isBusyDown=" + isBusyDown + ", isBusy=" + isBusy)

  if (isBusyDown)
    return;

  if (isBusy)
    return;

  //alert("imgID=" + imgID + ", maxW=" + maxW+ ", maxH=" + maxH);

  var oImg, maxW, maxH, deltaW, deltaH;

  oImg = document.getElementById(imgID);

  maxW = oImg.width;
  maxH = oImg.height;

  deltaW = Math.round((maxW - minW) / numSteps);
  deltaH = Math.round((maxH - minH) / numSteps);

  //alert("minW=" + minW + ", minH=" + minH);
  //alert("oImg.width=" + oImg.width + ", nThumbW=" + nThumbW + ", oImg.height=" + oImg.height);
  //alert("deltaW=" + deltaW + ", deltaH=" + deltaH);

  if (oImg.width >= minW || oImg.height >= minH)
  {
    mTDown = setTimeout(function(){deincrease(oImg, minW, minH, deltaW, deltaH, ITH);}, nDelay);
    isBusyDown = true;
  }
}

function increase(oImg, maxW, maxH, deltaW, deltaH, ITH)
{
  var obj;

  if(oImg.getAttribute("resized")=="y")
	{
    	oImg.height = maxH;
    	oImg.width = maxW;
	}
  else
	{
	oImg.height = oImg.height + deltaH;
  	oImg.width = oImg.width + deltaW;
	}

  if (oImg.width < maxW || oImg.height < maxH)
  {
    if (oImg.width + deltaW > maxW || oImg.height + deltaH > maxH)
    {
      deltaW = maxW - oImg.width;
      deltaH = maxH - oImg.height;   
    }
    mT = setTimeout(function(){increase(oImg, maxW, maxH, deltaW, deltaH, ITH);}, nDelay);
    //alert ("mT=" + mT);
  }
  else
  {
    oImg.height = maxH;
    oImg.width = maxW;
    clearTimeout(mT);
    //alert ("mT=" + mT);
    isBusy = false;
    //alert(isBusy);
    obj=document.getElementById('ITH'+ITH);
    //alert('ITH'+ITH);
    //alert(obj.style.display);
    if(obj)
      obj.style.display='none';
      //document.getElementById('ITH'+ITH).style.display='none';
	document.getElementById('PN' + ITH).style.display='';
	document.getElementById('PP' + ITH).style.display='';
	document.getElementById('PC' + ITH).style.display='';
	document.getElementById('PSS' + ITH).style.display='';
	document.getElementById('PLNK' + ITH).style.display='';
 }
}

function deincrease(oImg, minW, minH, deltaW, deltaH, ITH)
{
  var obj;

	document.getElementById('PN' + ITH).style.display='none';
	document.getElementById('PP' + ITH).style.display='none';
	document.getElementById('PC' + ITH).style.display='none';
	document.getElementById('PSS' + ITH).style.display='none';
	document.getElementById('PLNK' + ITH).style.display='none';
  if(oImg.getAttribute("resized")=="y")
	{
    	oImg.height = minH;
    	oImg.width = minW;
	}
  else
	{
	oImg.height = oImg.height - deltaH;
  	oImg.width = oImg.width - deltaW;
	}

  //alert("oImg.height="+oImg.height+", oImg.width="+oImg.width);
  //alert("oImg.width="+oImg.width+", nThumbW="+nThumbW);

  if (oImg.width > minW || oImg.height > minH)
  {
    if (oImg.width - deltaW < minW || oImg.height - deltaH < minH)
    {
      deltaW = oImg.width - minW;
      deltaH = oImg.height - minH;   
    }
    mTDown = setTimeout(function(){deincrease(oImg, minW, minH, deltaW, deltaH, ITH);}, nDelay);
  }
  else
  {
  //alert("minW="+minW+", minH="+minH);

    oImg.height = minH;
    oImg.width = minW;

    if(CurrentPicID!='')
	    window.location=CurrentPicID;

    clearTimeout(mTDown);
    oImg.style.display="none";

    setTimeout(function(){isBusyDown = false;}, 4);
    //isBusyDown = false;

    //alert(isBusy);
    obj=document.getElementById('ITH'+ITH);
    //alert(obj);
    if(obj)
	{
      	obj.style.display='';
	}
  }
}

function loadPic(imgID, imgSrc)
{
  if (isBusy)
    return;

  //alert("loadPic, imgSrc=" + imgSrc);

  oImg = document.getElementById('IP' + imgID);
  //oImg = document.getElementById(imgID);
  oITH = document.getElementById('ITH' + imgID);

  //alert("oImg.src="+oImg.src);
  //if (oImg.src != imgSrc)
  if (oImg.src == "" || oImg.src == oITH.src)
  {
    //document.getElementById('PC'+imgID).src=sPayDoxURL+'images/Pict_Loading.gif';

    document.getElementById('PL' + imgID).style.display='';
//alert("imgSrc="+imgSrc);
    oImg.src = imgSrc;
//alert("oImg.src="+oImg.src);
    //oImg.onload = function() {onLoadPic(imgID);}
    //alert("OK-1");
  }
  else
  {
    onLoadPic(imgID);
    //alert("OK-2");
  }
}

function onLoadPic(imgID)
{
//alert("onLoadPic, this=" + imgID);

  //document.getElementById('PC'+imgID).src=sPayDoxURL+'images/Pict_PageClose.GIF';
  //oImg = document.getElementById(imgID);

  document.getElementById('PL' + imgID).style.display='none';
//alert(document.getElementById('PL' + imgID).style.display);

  oImg = document.getElementById('IP' + imgID);
  oITH = document.getElementById('ITH' + imgID);
  oIPTEMP=document.getElementById('IPTEMP' + imgID);

//alert(oImg);
//alert(oImg.src);
//alert(oImg.width);
//alert(oImg.height);
//alert(oImg.style.display);

oIPTEMP.style.display='none';

  //if(oImg.style.display=="none")
	//return;

  if (oImg.src == oITH.src)
	return;

//alert('more');

  maxW = oImg.getAttribute("maxW");
  maxH = oImg.getAttribute("maxH");

//alert('oImg.width:'+oImg.width);
  if (maxW == 0 || maxH == 0)
  {
    maxW = oImg.width;
    maxH = oImg.height;

    if (maxW == 0 || maxH == 0)
    {
      var tmpImg = new Image();
      tmpImg.src = oImg.src;

      maxW = tmpImg.width;
      maxH = tmpImg.height;
    }

    if (maxW > nMaxIMGW)
    {
      maxH = Math.round(maxH/maxW*nMaxIMGW);
      maxW = nMaxIMGW;
      oImg.setAttribute("resized", "y");
//alert('maxW:'+nMaxIMGW);
    }
    else
      oImg.setAttribute("resized", "");

    oImg.setAttribute("maxW", maxW);
    oImg.setAttribute("maxH", maxH);
  }

  if(oImg.width>nThumbW || oImg.width==0)
{
      minW = nThumbW;
      minH = Math.round(maxH/maxW*minW);
}
  else
{
      minW = oImg.width;
      minH = oImg.height;
}

  //alert ("maxW=" + maxW + ", maxH=" + maxH);
  //alert ("minW=" + minW + ", minH=" + minH);

//alert(oImg.width);

  oImg.width = minW;
  oImg.height = minH;   

  oImg.setAttribute("minW", minW);
  oImg.setAttribute("minH", minH);

//alert(oImg.width);

  oImg.style.display="block";

  reSizeUp('IP' + imgID, maxW, maxH, imgID);
}

function closePic(imgID, ITH)
{
//alert('closePic');
//alert(itWasResize);
  if (itWasResize == true)
  {
    return;
  }

  oImg = document.getElementById(imgID);

  maxW = oImg.width;
  maxH = oImg.height;

  minW = nThumbW;
  minH = Math.round(maxH/maxW*minW);

  reSizeDown(imgID, minW, minH, ITH);
  //reSizeDown(imgID, 0, 0, ITH);
}
//--- image resize end --------------------------------

//--- manual image resize start --------------------------------

var isDown = false;
var itWasResize = false;

var curX = 0, curY = 0;
var maxW, maxH, minW, minH;

document.ondragstart = dragProhibited;

function dragProhibited() 
{
//alert('dragProhibited');
  return false;
}

function fixEvent(e) 
{
  // получить объект событие для IE
  e = e || window.event;

  // добавить pageX/pageY для IE
  if ( e.pageX == null && e.clientX != null ) 
  {
    var html = document.documentElement;
    var body = document.body;
    e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0);
    e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0);
  }

  // добавить which для IE
  if (!e.which && e.button) 
  {
    e.which = e.button & 1 ? 1 : ( e.button & 2 ? 3 : ( e.button & 4 ? 2 : 0 ) );
  }

  return e;
}

function isLeftButtonDown(event)
{

  if (event.which < 2)
  {
    return true;
  }
  else
  {
    return false;
  } 
}

function myMouseClick(oImg)
{
  if (itWasResize == true)
  {
    return;
  }

alert('onMouseClick!');
}

function myMouseOut(oImg)
{
  myMouseUp(oImg);
}

function myMouseDown(oImg, event)
{
//alert('myMouseDown');
  event = fixEvent(event);

  if (isLeftButtonDown(event) == false)
  {
    return;
  }
  isDown = true;
  itWasResize = false;

  oImg.style.cursor = "col-resize";

  curX = event.pageX;
  curY = event.pageY;

  maxW = 3*oImg.getAttribute("maxW");
  maxH = 3*oImg.getAttribute("maxH");

  minW = oImg.getAttribute("minW");
  minH = oImg.getAttribute("minH");

}

function myMouseUp(oImg)
{
  isDown = false;

  curX = 0;
  curY = 0;

  maxW = 0;
  maxH = 0; 
  minW = 0;
  minH = 0;

  //oImg.style.cursor="default";
  oImg.style.cursor="pointer";
  setTimeout(function(){itWasResize=false;}, 400);
}

function myMouseMove(oImg, event)
{
  var tmpX , tmpY;

  if (isDown != true) 
    return;

  event = fixEvent(event);

  tmpX = event.pageX;
  tmpY = event.pageY;

  deltaW = tmpX - curX;
  deltaH = Math.round(oImg.height / oImg.width * deltaW);

  curX = tmpX;
  curY = tmpY;

  if ((oImg.width + deltaW <= minW)||(oImg.height + deltaH <= minH))
  {
    deltaW = minW - oImg.width;
    deltaH = minH - oImg.height;
  }

  if ((oImg.width + deltaW >= maxW)||(oImg.height + deltaH >= maxH))
  {
    deltaW = maxW - oImg.width;
    deltaH = maxH - oImg.height;
  }

  oImg.height = oImg.height + deltaH;
  oImg.width = oImg.width + deltaW;

  itWasResize = true;
}

//--- manual image resize end --------------------------------

function treetoggle(id,p,prefix)
{
//alert('JScripts.js treetoggle, id:'+id+', p:'+p+', prefix:'+prefix);
var myChild = document.getElementById(id);
var ofolder=document.getElementById(p);
//alert(p);
if(myChild.style.display!='block')
	{
	myChild.style.display='block';
	//document.getElementById(p).className='folderOpen' + prefix;
	if(ofolder)
		ofolder.src=sPayDoxURL+'images/folder_open.png';
	}
else
	{
	myChild.style.display='none';
	//document.getElementById(p).className='folder' + prefix;
	if(ofolder)
		ofolder.src=sPayDoxURL+'images/folder_close.png';
	}
//alert(document.getElementById(p).src);
}

function GetFolderMap(sMapFile)
{
alert('GetFolderMap, sMapFile:'+sMapFile);
}

function FolderOrFileFormSearchSubmit(strShowFolder, strSingleFile)
{
//return;
CatCatSwitch('q');
var obj=document.getElementById("idSearchContext");
//alert(obj);

if(trim(obj.value)=="")
{
	//alert(sDOCS_FindContext);
	obj.focus();
	obj=document.getElementById("IMGSearchContext");
	obj.src=sPayDoxURL+"Images/explyellowblink.gif";
	obj.style.display="";
	return;
}

var obj=document.getElementById("TreeViewFiles");
var fulltextobj=false;
if(FolderOrFileFormSearch.FullTextSearch)
	if(FolderOrFileFormSearch.FullTextSearch.checked)
		fulltextobj=true;

if(fulltextobj)
{
	if(sbuilt=="y")
	{
	HideByID('idCatalogueTitle');
	HideByID('idCategories');
	HideByID('idCategoriesTitle');
	CallURL('FilesListIndex.asp?SearchContext='+encodeURI(FolderOrFileFormSearch.SearchContext.value)+"&built="+sbuilt+LPar+"&Menu="+sMenu +"&Mobile="+sMobile+'&hash=' + Math.random(), 'TreeViewFiles');
	}
	else
	{
	FolderOrFileFormSearch.action=sPayDoxURL+'FilesListIndex.asp?built=n'+LPar
	FolderOrFileFormSearch.submit();
	}
}
else
{
//alert(FolderOrFileFormSearch.SearchContext.value);
CallURL('ShowListFiles.asp?SearchContext='+encodeURI(FolderOrFileFormSearch.SearchContext.value)+LPar+'&menu='+sMenu+'&built='+sbuilt+'&hash=' + Math.random(), 'TreeViewFiles');
HideByID('idCatalogueTitle');
//document.getElementById('idCatalogue').style.display='none';
HideByID('idCategoriesTitle');
HideByID('idCategories');
//alert(document.getElementById('idCategories').style.display);
}

}

function ShowFile(sParentFolder,sFile,sMapFile,haschild){

clearTimeout(cT); 
timerFlag = false;

//alert('ShowFile, sFile:'+sFile+', sMapFile:'+sMapFile+', haschild:'+haschild+', sParentFolder:'+sParentFolder);
//if(haschild=='0')
//	sMapFile='';
//alert('sMapFile:'+sMapFile);

	if(sbuilt=="y")
	{
	HideByID('idCatalogueTitle');
	HideByID('idCategories');
	HideByID('idCategoriesTitle');
//alert('URL:'+sPayDoxURL+'ShowFiles.asp?SingleFile='+encodeURI(sFile)+LPar+"&MapFile="+encodeURI(sMapFile)+'&menu='+sMenu+'&built='+sbuilt+'&hash=' + Math.random());
	//CallURL(sPayDoxURL+'ShowFiles.asp?SingleFile='+encodeURI(sFile)+LPar+"&MapFile="+encodeURI(sMapFile)+'&menu='+sMenu+'&built='+sbuilt+'&hash=' + Math.random(), 'bltPayDox') //+'&ParentFolder='+encodeURI(sParentFolder)
//alert(locationAddPar('SingleFile',encodeURI(sFile)));
	window.location=locationAddPar('SingleFile',encodeURI(sFile))
	//window.location=sPayDoxURL+'ShowFiles.asp?SingleFile='+encodeURI(sFile)+LPar+'&MapFile='+encodeURI(sMapFile)+'&menu='+sMenu+'&built='+sbuilt //+'&ParentFolder='+encodeURI(sParentFolder)
	}
	else
	{
	window.location=sPayDoxURL+'ShowFiles.asp?SingleFile='+encodeURI(sFile)+LPar+'&MapFile='+encodeURI(sMapFile)+'&menu='+sMenu+'&built='+sbuilt //+'&ParentFolder='+encodeURI(sParentFolder)
	}
}

function locationAddPar(sPar, sItem)
{
//alert(location.href);
//alert(location.hostname);
//alert(location.host);
//alert(location.pathname);
//alert(location.search);
//alert(location.search.length);
//alert(location.search.substring(0,1));
//alert(location.protocol);

//return;

//var surlpars=location.search.substring(1);
//alert(surlpars);
//if (surlpars!='') 
var sParAdd='&'+sPar+'='
var iStart=location.search.indexOf(sParAdd);
if (iStart==-1) 
	{
	sParAdd='?'+sPar+'='
	iStart=location.search.indexOf(sParAdd);
	}
//alert(iStart);
var iEnd=-1;
if (iStart>-1) 
{
 	iEnd=location.search.indexOf('&', iStart+1);
//alert(iEnd);
}
if (iEnd==-1) 
 	iEnd=location.search.length;
//alert(iEnd);
//alert(location.search.length);

if (iStart==-1)
	if(location.search.length>0)
		return location.href+'&'+sPar+'='+sItem
	else
		return location.href+'?'+sPar+'='+sItem
else
	{
	//alert(location.search.substring(0,iStart+sPar.length+1));
	//alert(location.search.substring(iEnd+1));
	//alert(location.protocol+'//'+location.host+location.pathname+location.search.substring(0,iStart+sPar.length+2)+sItem+location.search.substring(iEnd))
	return location.protocol+'//'+location.host+location.pathname+location.search.substring(0,iStart+sPar.length+2)+sItem+location.search.substring(iEnd)
	}
}

function bltPayDox(sURL, l){
//alert('bltPayDox');
var obj=document.getElementById("bltPayDox");

var sSingleFile='';
var surlpars=location.search.substring(1);
//alert(surlpars);
if (surlpars!='') 
{
 i=surlpars.indexOf('SingleFile=');
 if (i>-1) 
	{
	surlpars=surlpars.substring(i+11);
 	i=surlpars.indexOf('&');
 	if (i>-1)
  		surlpars=surlpars.substring(0,i);
	sSingleFile=surlpars;
	//alert(sSingleFile);
	}
}

sPayDoxURL=sURL
LPar="&l="+l
slogin="public"
sMenu="N"
sbuilt="y"
CallURL(sPayDoxURL+'ShowFiles.asp?login1=public'+LPar+'&menu=N&SingleFile='+sSingleFile+'&built=y&cats=y&ShowSearch=y&hash=' + Math.random(), 'bltPayDox')
}

function bltPayDoxDocs(l, othis){
//alert('bltPayDoxDocs');

if(!othis)
	alert('bltPayDox1 obj error 0');
var sURL = othis.src;
var odiv = othis.parentNode;
if(!odiv)
	alert('bltPayDox1 obj error');

sURL=sURL.substring(0,sURL.lastIndexOf("/")+1);
//alert('bltPayDox1, sURL:'+sURL);
var sSingleFile='';
var surlpars=location.search.substring(1);
//alert(surlpars);
if (surlpars!='') 
{
 i=surlpars.indexOf('SingleFile=');
 if (i>-1) 
	{
	surlpars=surlpars.substring(i+11);
 	i=surlpars.indexOf('&');
 	if (i>-1)
  		surlpars=surlpars.substring(0,i);
	sSingleFile=surlpars;
	//alert(sSingleFile);
	}
}

sPayDoxURL=sURL
LPar="&l="+l
slogin="public"
sMenu="N"
sbuilt="y"
CallURLo(sPayDoxURL+'ListDoc.asp?UserIDToSee=Admin&UserName1=&VisaDocs=y'+LPar+'&menu=N&built=y&hash=' + Math.random(), odiv);
}

function GetPayDoxURL()
{
//alert(sPayDoxURL);
return sPayDoxURL;
}

function ReturnFalse()
{
return false;
}

function bltPayDox1(l, othis){
if(jsStarted)
	return;
jsStarted=true;
//odiv.id="test";
//alert('bltPayDox1, odiv:'+odiv);
//return;
//var obj=document.getElementById("bltPayDox");

//alert('bltPayDox1, oscript.src:'+oscript.src);
//alert('bltPayDox1, sURL:'+sURL);

if(!othis)
	alert('bltPayDox1 obj error 0');
var sURL = othis.src;
var odiv = othis.parentNode;
if(!odiv)
	alert('bltPayDox1 obj error');

sURL=sURL.substring(0,sURL.lastIndexOf("/")+1);
//alert('bltPayDox1, sURL:'+sURL);
var sSingleFile='';
var surlpars=location.search.substring(1);
//alert(surlpars);
if (surlpars!='') 
{
 i=surlpars.indexOf('SingleFile=');
 if (i>-1) 
	{
	surlpars=surlpars.substring(i+11);
 	i=surlpars.indexOf('&');
 	if (i>-1)
  		surlpars=surlpars.substring(0,i);
	sSingleFile=surlpars;
	//alert(sSingleFile);
	}
}

sPayDoxURL=sURL
LPar="&l="+l
slogin="public"
sMenu="N"
sbuilt="y"
loadfilecss(sPayDoxURL+'FilesStyle.css');
//alert('');
//CallURLo(sPayDoxURL+'ShowFiles.asp?login=public'+LPar+'&menu=N&SingleFile='+sSingleFile+'&built=y&cats=y&ShowSearch=n&hash=' + Math.random(), odiv)
CallURLo(sPayDoxURL+'ShowFiles.asp?login=public'+LPar+'&menu=N&built=y&cats=y&ShowSearch=y&hash=' + Math.random(), odiv);
}

function myencodeURI(sItem)
{
sItem=encodeURI(sItem);
//sItem=sItem.replace(/#/g, '%23');
sItem=sItem.replace(new RegExp("&",'g'),"%26");
sItem=sItem.replace(new RegExp("/",'g'),"%2F");
sItem=sItem.replace(new RegExp("#",'g'),"%23");
//sItem=sItem.replace(new RegExp("\?",'g'),"%3F");
//sItem=sItem.replace(new RegExp("\\",'g'),"%5C");
sItem=sItem.replace(new RegExp(";",'g'),"%3B");
sItem=sItem.replace(new RegExp(" ",'g'),"+");
return sItem;
}

function GetFileURL(sParentFolder,sFile,sMapFile,haschild){
var slink='ShowFiles.asp?SingleFile='+sFile+LPar+'&MapFile='+sMapFile+'&menu='+sMenu+'&built='+sbuilt;
slink=myencodeURI(slink);
//alert(slink);
return slink;
}

function ShowFolder(FullPath){
//alert('ShowFolder, FullPath:'+FullPath);
	if(sbuilt=="y")
	{
	HideByID('idCatalogueTitle');
	HideByID('idCategories');
	HideByID('idCategoriesTitle');
	CallURL(sPayDoxURL+'ShowFiles.asp?ShowFolder='+encodeURI(FullPath)+LPar+'&menu='+sMenu+'&built='+sbuilt+'&hash=' + Math.random(), 'bltPayDox')
	}
	else
	{
	window.location=sPayDoxURL+'ShowFiles.asp?ShowFolder='+encodeURI(FullPath)+LPar+'&menu='+sMenu+'&built='+sbuilt
	}
}

function ShowCategory(sCategory){
//alert('ShowCategory, sCategory:'+sCategory);
	//if(sbuilt=="y")
	{
	CatCatSwitch('q');
	HideByID('idCatalogueTitle');
	HideByID('idCategories');
	HideByID('idCategoriesTitle');
	DisplayByID('idShowAll');
	CallURL(sPayDoxURL+'ShowListFiles.asp?Categ='+encodeURI(sCategory)+LPar+'&showtit=y&menu='+sMenu+'&built='+sbuilt+'&hash=' + Math.random(), 'TreeViewFiles');
	}
	//else
	//{
	//window.location=sPayDoxURL+'ShowListFiles.asp?Categ='+encodeURI(sCategory)+LPar+'&menu='+sMenu
	//}
//return(false);
}

function HideByID(sid)
{
var obj;
//alert('HideByID:'+sid)
obj=document.getElementById(sid)
//alert(obj)
if(obj)
{
	obj.style.display='none'
}
}

function DisplayByID(sid)
{
var obj;
obj=document.getElementById(sid)
if(obj)
{
	obj.style.display=''
}
}


function FolderOrFileFormSearchSubmit1()
{
var obj;
obj=document.getElementById('idSearchContext');

alert(obj);
//alert(trim(obj.value));
return;

//if(trim(FolderOrFileFormSearch.SearchContext.value))=='')
//{
//	alert(sDOCS_FindContext);
//	FolderOrFileFormSearch.SearchContext.focus();
//	return;
//}
//var obj=document.getElementById("TreeViewFiles");
//alert(obj);

if(FolderOrFileFormSearch.FullTextSearch.checked)
{
	if(sbuilt=="y")
	{
	CallURL('FilesListIndex.asp?SearchContext='+encodeURI(FolderOrFileFormSearch.SearchContext.value)+"&built="+sbuilt+LPar+"&Menu="+sMenu +"&Mobile="+sMobile+'&hash=' + Math.random(), 'TreeViewFiles');
	document.getElementById('idCatalogueTitle').style.display='none';
	document.getElementById('idCatalogue').style.display='none';
	}
	else
	{
	FolderOrFileFormSearch.action=sPayDoxURL+'FilesListIndex.asp?built=n'+LPar
	FolderOrFileFormSearch.submit();
	}
}
else
{
//alert(FolderOrFileFormSearch.SearchContext.value);
CallURL('ShowListFiles.asp?SearchContext='+encodeURI(FolderOrFileFormSearch.SearchContext.value)+"&built="+sbuilt+LPar+"&Menu="+sMenu +"&Mobile="+sMobile+'&hash=' + Math.random(), 'TreeViewFiles');
document.getElementById('idCatalogueTitle').style.display='none';
document.getElementById('idCatalogue').style.display='none';

alert(document.getElementById('idCatalogueTitle'));
}

}

//strShowFolder=""


function FileOutput(sLink) 
{
//alert('FileOutput, sLink:'+sLink);
sLink=sLink+'&hash=' + Math.random();
document.all.uReset.src=sLink
}

function ShowFolders(FullPath, sItemName, smenuid, surl, shaschild) 
{
 //alert('ShowFolders, FullPath:'+FullPath+', strSingleFile:'+strSingleFile);
SetInitVars();
if(shaschild=='2' || shaschild=='3')
	strSingleFile='';

//alert('ShowFolders, FullPath:'+FullPath+', strShowFolder:'+strShowFolder);
//alert('ShowFolders:'+shaschild);

//if (strShowFolder)
if (strShowFolder!='')
if (strShowFolder.toLowerCase().substr(0,FullPath.length) == FullPath.toLowerCase())
{
//alert('OK');
//window.setTimeout("loadItems('"+sItemName+"','"+smenuid+"','"+surl+"','"+shaschild+"');",1000);
loadItems(sItemName,smenuid,surl,shaschild);
}
else
return '';
}

function SetInitVars(sinitvars) 
{
 //alert('SetInitVars');
 //alert(sinitvars);
//if (!sinitvars) sinitvars = 'initvars';
if (sinitvars==undefined) sinitvars = 'initvars';
 //alert(sinitvars);
var obj = document.getElementById(sinitvars);
 //alert(obj);
if(obj)
{
	var sTemp='';
	cpar=obj.getAttribute("sPayDoxURL");
	if (cpar) sPayDoxURL=cpar;
	strShowFolder=obj.getAttribute("strShowFolder");
//alert("SetInitVars, strShowFolder:"+strShowFolder);
	strSingleFile=obj.getAttribute("strSingleFile");
 //alert('SetInitVars, strSingleFile:'+strSingleFile);
	strIsMobile=obj.getAttribute("strIsMobile");
	DOCS_More=obj.getAttribute("DOCS_More");
	DOCS_SlideShow=obj.getAttribute("DOCS_SlideShow");
	DOCS_Pause=obj.getAttribute("DOCS_Pause");
	DOCS_Slower=obj.getAttribute("DOCS_Slower");
	DOCS_ShowPrev=obj.getAttribute("DOCS_ShowPrev");
	DOCS_Close=obj.getAttribute("DOCS_Close");
	DOCS_ShowNext=obj.getAttribute("DOCS_ShowNext");
	DOCS_Faster=obj.getAttribute("DOCS_Faster");
	DOCS_Backward=obj.getAttribute("DOCS_Backward");
	DOCS_MakeChoice=obj.getAttribute("DOCS_MakeChoice");
//alert(DOCS_MakeChoice);
	DOCS_ChangeSize=obj.getAttribute("DOCS_ChangeSize");
	DOCS_ALREADYEXISTS=obj.getAttribute("DOCS_ALREADYEXISTS");

	sTemp=obj.getAttribute("nMaxIMGW");
	if(sTemp!='')
		nMaxIMGW=sTemp;
//alert(nMaxIMGW);
//alert(strIsMobile);
	LPar=obj.getAttribute("LPar");
	lang=obj.getAttribute("l");
//alert(LPar);
	if(strIsMobile=='y')
	{
	numSteps = 1;
	//alert('numSteps = 1');
	}
//alert('numSteps:'+numSteps);
//alert('sPayDoxURL:'+sPayDoxURL);
//alert('strShowFolder:'+strShowFolder);
//alert('strSingleFile:'+strSingleFile);
//alert(strIsMobile);
}

}

function GetInitVar(sinitvar, sinitvars) 
{
 //alert('GetInitVar, sinitvar:'+sinitvar);
if (sinitvars==undefined || sinitvars=='') sinitvars = 'initvars';

var obj = document.getElementById(sinitvars);
 //alert(obj);
if(obj)
	{
	var sTemp=obj.getAttribute(sinitvar);
 //alert(sTemp);
	return sTemp;
	}
else
	return '';
}

function NoHandLink(btn) 
{
//alert('NoHandLink');
}

function GoToBpCategoryItem(sItem, sGUID, sFieldID)
{
 //alert('GoToBpCategoryItem JScripts.js, sItem:'+sItem+', sGUID:'+sGUID+', sFieldID:'+sFieldID);
//return;
var obj;
//alert(obj.style.display);
if(sFieldID!='')
{
	obj=window.opener.document.getElementById(sFieldID);
	if(obj)
	{
		if(obj.value!='')
			obj.value=obj.value+'\r';
		obj.value=obj.value+sItem;
		window.close;
	}
}
else
{
	obj=document.getElementById("PLOUT"+sGUID);
if(obj.style.display=='')
{
	obj.style.display='none';
	obj.innerHTML='';
}
else
{
s2Cat="";
obj=document.getElementById("idCategories");
if(obj)
	s2Cat=obj.getAttribute("s2Cat");
	CallURL('ShowListFiles.asp?GUID='+sGUID+'&Categ='+encodeURI(sItem)+'&s2Cat='+encodeURI(s2Cat)+LPar+'&menu='+sMenu+'&built=y&hash=' + Math.random(), 'PLOUT'+sGUID);
	//obj.style.display='none';
}
}
}

function MarkCategory(sCategory, sGUID, sSpanID)
{
//alert('MarkCategory, sGUID:'+sGUID+', sCategory:'+sCategory+', sCategory:'+sSpanID);
//alert('MarkCategory, sCategory:'+sCategory);
//alert('MarkCategory, sSpanID:'+sSpanID);
var obj=document.getElementById("idCategories");
//alert(obj);
var objspan;

if(obj.getAttribute("s2CatSpan")!="")
{
objspan=document.getElementById(obj.getAttribute("s2CatSpan"));
objspan.style.color="black";
}

objspan=document.getElementById(sSpanID);

if(obj.getAttribute("s2Cat")==sCategory)
{
obj.setAttribute("s2Cat", "");
obj.setAttribute("s2CatSpan", "");
objspan.style.color="black";
}
else
{
obj.setAttribute("s2Cat", sCategory);
obj.setAttribute("s2CatSpan", sSpanID);
objspan.style.color="red";
}
//alert(obj.getAttribute("s2Cat"));
}

function CatCatSwitch(sw){
//alert('CatCatSwitch');

var obj = document.getElementById('initvars');
if(obj)
{
	sDOCS_Catalogue=obj.getAttribute("DOCS_Catalogue");
	sDOCS_CATEGORIES=obj.getAttribute("DOCS_CATEGORIES");
	obj = document.getElementById('idCatCat');
	if(obj)
	{
	//alert(obj.innerHTML)

	if(sw=='')
		if(obj.innerHTML==sDOCS_CATEGORIES)
			sw='r'
		else
			sw='q';
//alert(sw);
	if(sw=='r')
		{
		obj.innerHTML=sDOCS_Catalogue;
		obj = document.getElementById('idCatTitle');
		if(obj)
			obj.innerHTML=sDOCS_CATEGORIES;

		HideByID('idCatalogue');
//obj=document.getElementById('idCatalogue')
//alert(obj)
//obj.style.display='none'
//return;
		//HideByID('TreeViewFiles');
		//HideByID('FullTextSearch');
		//HideByID('SearchButton');
		//HideByID('idSearchContext');
		//HideByID('IMGSearchContext');
		DisplayByID('idCategories'); 
		DisplayByID('idCatNote');
		HideByID('idbtns');
		obj = document.getElementById('idbtnmark');
		if(obj)
			obj.value='';
		}
	else
		{
		//obj.innerHTML=sDOCS_CATEGORIES;
		obj.value=sDOCS_CATEGORIES;
		obj = document.getElementById('idCatTitle');
		if(obj)
			obj.innerHTML=sDOCS_Catalogue
			HideByID('idCategories');
			HideByID('idCatNote'); 
			//DisplayByID('FullTextSearch');
			//DisplayByID('SearchButton');
			//DisplayByID('idSearchContext');
			//DisplayByID('IMGSearchContext');
			DisplayByID('idCatalogue'); 
			//DisplayByID('TreeViewFiles'); 

			DisplayByID('idbtns');
			DisplayByID('idbtnmark');
		}

	}
}

}

function GetHTMLContent(sMenuID, sFile){
//alert('GetHTMLContent, sMenuID:'+sMenuID+', sFile:'+sFile);
//var obj=document.getElementById("C"+sMenuID);
//alert(obj);
//var sUrl=sPayDoxURL+"DownloadFile.asp?ContentTypePar=text/html&file="+sFile+"&fileout="+sFile+"&FilePath="+sPath+LPar+"&hash="+Math.random();

var sUrl=sPayDoxURL+"DownloadFile.asp?ContentTypePar=text/html&file="+encodeURI(sFile)+"&fileout="+encodeURI(sFile)+"&FilePath=-"+LPar+"&hash="+Math.random();

//alert('sUrl:'+sUrl);
CallURL(sUrl, "C"+sMenuID);
}

function DownloadFile(sMenuID, sURL)
{
	timerFlag = true; 
	cT=window.setTimeout(function(){DownloadFileTimer(sMenuID, sURL);}, 400); 
}

function DownloadFileTimer(sMenuID, sURL){
//alert('DownloafFile, sMenuID:'+sMenuID+', sURL:'+sURL);
if(!timerFlag)
	return;
timerFlag = false; 

var obj=document.getElementById("ifr"+sMenuID);
//alert(obj);
if(obj)
{
	//CallURL(sURL, "C"+sMenuID);
	//obj.style.display='';
	obj.src=sURL+"&hash="+Math.random();
}
//obj.src
//CallURL(sURL, "C"+sMenuID);
}

function CallURLByCommand(sMenuID, sURL, sBaseURL, sFile, sCommand, sParameters){
//return;
//alert('CallURLByCommand, sURL:'+sURL+', sBaseURL:'+sBaseURL+', sFile:'+sFile+', sCommand:'+sCommand+', sParameters:'+sParameters);
//if(sBaseURL == sPayDoxURL)
if(sBaseURL == sURL || sURL=='')
	{
	sTemp=sPayDoxURL+'ShowFiles.asp?built=y&ShowSearch=n'+LPar+'&Command='+sCommand+'&Pars='+encodeURI(sParameters)+'&hash=' + Math.random() //+'&transurl='+sMapFile;
	if(sBaseURL != sPayDoxURL)
		sTemp=sTemp+'&transurl='+sBaseURL
	CallURL(sTemp, "C"+sMenuID);
	}
//else		
//	{
//	sTemp=sPayDoxURL+'ShowFiles.asp?built=y&ShowSearch=n'+LPar+'&hash=' + Math.random()+'&transurl='+sBaseURL;
//	CallURL(sTemp, "C"+sMenuID);
//	}

}

//*** BPs **********************

var ImagesFolderBase='Images/BPM/';
var ImagesFolder='';
var inst='y';
var DocID='';

//*** BPs Copy from JSBP.js START **********************

function LoadItemMenuBuilt(ItemID, sID, sGUID, sGUIDInstanceItem, sLinkGUID, sLinkPar, ParItemID, ParGUID, bLoading, sBaseURL)
{
var odetails;
var odetailsTD;
var odetailsTD2;
var req;

//alert(sBaseURL);
//alert(ItemID);
odetails = document.getElementById("details"+sID);
//tabodetails = document.getElementById("tabdetails"+sID);
odetailsTD = document.getElementById("detailsTD"+sID);
odetailsSTD2 = document.getElementById("ST2"+sID);

//alert('LoadItemMenuBuilt START, arguments.length:'+arguments.length);
//alert(odetailsSTD2.src);

if(arguments.length<9)
	bLoading=true;

if(!bLoading)
	sOnLoad=""
else
	sOnLoad="n";

if(odetails.style.display == '' && bLoading)

{
//alert(odetails.style.display);
odetailsTD.innerHTML='';
//odetails.style.display = 'block';
//odetails.height = 1;
odetails.style.display = 'none';
//tabodetails.style.display = 'none';
//alert('*');
//tabodetails.style.display = 'block';
//odetailsTD.style.display = 'none';
//alert(odetails.height);
odetailsSTD2.src = ImagesFolderBase+ImagesFolder+'/BP_Pict_ShowDown.gif';
}

else

{

	if(sLinkGUID!=ItemID)
	{sLink='y'}
	else
	{sLink=''}

	if(sGUIDInstanceItem!='')
	{
		sItem=sGUIDInstanceItem;
	}
	else
	{
		sItem=ItemID;
	}

//alert(bLoading);
	odetails.style.display = '';

	if(bLoading)
	{
	odetails.style.fontFamily = "arial, ans-serif"
	odetails.style.fontSize = "12"
	odetails.style.color = "#FF0000"
//return;
//alert(odetailsTD);
	odetailsTD.innerHTML=GetLoadingMessage();
//alert('GetLoadingMessage OK');
	}
	url=sPayDoxURL+'BPShowItemMenu.asp?built=y&OnLoad='+sOnLoad+'&ItemID='+sItem+'&LinkPar='+sLinkPar+'&Link='+sLink+'&menuid='+sID+LPar+'&inst='+inst+'&GUIDInst='+sGUID+'&DocID='+DocID+'&ParItemID='+ParItemID+'&ParGUID='+ParGUID+'&DocPrintableView='+'&hash=' + Math.random();
	if(sPayDoxURL != '')
		if(sBaseURL != sPayDoxURL)
			url=url+'&transurl='+sBaseURL

        //req = new XMLHttpRequest();

//alert(1);
    if (window.XMLHttpRequest) 
	{
        req = new XMLHttpRequest();
    	} 
	else if (window.ActiveXObject) 
	{
		try
    		{
	        req = new ActiveXObject("Microsoft.XMLHTTP");
    		}
    	
		catch(err)
    		{
		ErrorMicrosoftXMLHTTP();
        	return;
    		}

	}

        if (req) 
	{
	        req.onreadystatechange = processReqChangeBuild;
        	req.open("GET", url, true);
        	req.send(null);
	}

	odetailsSTD2.src = ImagesFolderBase+ImagesFolder+'/BP_Pict_ShowUp.gif';
}
return;

function processReqChangeBuild(){
	// only if req shows "complete"
	if (req.readyState == 4) {
		if (req.status == 200) {		
			odetailsTD.innerHTML=req.responseText;
		} else if (req.status == 12029){
			alert("ERROR\n Web-server Unavailable");
		} else {
			//alert("ERROR\n" + req.statusText);
			//alert(req.status == 12029);
			alert("ERROR\n" + req.statusText + " ("+req.status + ")");
		}
	}
}

}

function drawact(nMaxChoiceLevel, NextOrderid, sType, currentrootmenuid, sNoAng){
var current_el;
var bChoiceTD; 
var imgangArrowLeft;
//alert('drawact, currentrootmenuid:'+currentrootmenuid);
//alert(NextOrderid);
//alert(sType);
//alert(sNoAng);
//alert(sLeftTDWidth);
//sNoAng=NoAng;

if(sType.indexOf('FORM')>=0)
	return;

if(currentrootmenuid=='')
{
return;
}
//alert(currentrootmenuid);
current_el = document.getElementById("C"+currentrootmenuid);

if(!current_el)return;

//current_el = document.getElementById(currentrootmenuid);
//alert(current_el);
tdang = document.getElementById("angtd"+currentrootmenuid);
tdang7 = document.getElementById("angtd7"+currentrootmenuid);
cang=currentrootmenuid.substring(0,currentrootmenuid.indexOf('_'));
cangN=currentrootmenuid.substring(currentrootmenuid.indexOf('_')+1);
cangNext=Number(cangN)+1;
cang=cang+"_"+cangNext;

imgangNext = document.getElementById("angch"+cang);
//alert(imgangNext);

//alert("tdangch"+cang);
tdangNext0 = document.getElementById("tdangch"+cang);
//alert(tdangNext0);
//if(!tdangNext0)
//	alert("tdangch"+cang);

simgangNext='BPM/BP_VerticalCh.GIF';

//if(imgangNext)
if(tdangNext0)
	//if(nMaxChoiceLevel>0)
	//	sAngleNext='BP_AngleNextChoice2.gif'
	//else
	{
//alert("tdangch"+cang);
	sAngleNext='BP_AngleNextChoice1.gif'
	bChoiceTD=true;
	trangNext = document.getElementById("trangch"+cang);
//alert(sType);
	if(trangNext)
		if(sType.substring(0,3)!='END' && sType.substring(0,4)!='GOTO')
			trangNext.style.display='' //block - not for tr & Mozilla
		else
			trangNext.style.display='none'
	//else
		//alert("trangch"+cang)
	}
	//angtab = document.getElementById("angtab"+cang);
	//if(angtab)
	//	angtab.style.display='none';
else
	{
	imgangNext = document.getElementById("ang"+cang);
	tdangNext0 = document.getElementById("angtd"+cang);
	sAngleNext='BP_AngleNextLong.gif'
	bChoiceTD=false;
	simgangNext='1x1.gif';
	imgangArrowLeft = document.getElementById("ArrowLeft"+cang);
	}

//tdangNext = document.getElementById("angtd1"+cang);
tdangNext = document.getElementById("angtd1"+currentrootmenuid);
//alert(tdangNext);

//angtd = document.getElementById("angtd1"+cang);
imgang = document.getElementById("ang"+currentrootmenuid);
//alert("imgang:"+"ang"+currentrootmenuid);
//alert(imgang);

//if(imgangNext)
if(tdangNext0)
{
//alert("imgangNext");
//alert(imgangNext.ParGUID);
	if(imgangNext.ParGUID!='')
	{
//alert();
		//if(angtd)
		//{
		//	angtd.background = 'images/1x1.GIF';
			//alert(angtd.background);
		//}
			//else
			//{alert('NO angtd')}
		//if(sType.substring(0,3)='END' || sType.substring(0,4)=='GOTO')
		if(sType.substring(0,3)=='END')
		{
			imgangNext.src = 'images/'+simgangNext;
		}
		else
		{
			if(current_el.style.display != 'none')
			{
//alert(imgangNext.src);
//alert(tdangNext.style.background);
			//tdangNext.background = 'images/1x1.GIF';

			//tdangNext.style.backgroundImage = 'url(images/1x1.GIF)';
//alert(tdangNext.style.background);
			
			tdangNext0.style.backgroundImage = 'url('+ImagesFolderBase+ImagesFolder+sAngleNext+')';
//alert(tdangNext0.style.backgroundImage);
			if(bChoiceTD)
			{
				imgangch2 = document.getElementById("angch2"+cang);
				if(imgangch2)
					{
					imgangch2.src = ImagesFolderBase+ImagesFolder+'BP_AngleNextChoice0.gif';
					if(nMaxChoiceLevel>0)
						{
						imgangch2.height=2;
						imgangch2.width=43+nMaxChoiceLevel*17;
						}
					}
			}
			else
			{
				//if(nMaxChoiceLevel>0)
					tdangNext0.width=36+nMaxChoiceLevel*17;

				if(imgangArrowLeft)
				{
//alert("imgangArrowLeft");
					imgangArrowLeft.src = ImagesFolderBase+ImagesFolder+'BP_ArrowLeft.gif';
					imgangArrowLeft.style.display='block';
//alert(imgangArrowLeft.src);
//alert(tdangNext.style.backgroundImage);
//tdangNext.style.backgroundColor = 'yellow';
					imgangNext.height=48;
					imgangNext.width=36+nMaxChoiceLevel*17;
					//imgangNext.src = ImagesFolderBase+ImagesFolder+'/'+sAngleNext;
//alert(imgangNext.src);
				}
			}
			}
		}
	}
}

//alert(current_el.style.display);

if(current_el.style.display != 'none')
//if(true)
{
//alert(imgang);
	if(imgang)
	{
//alert("imgang");
//alert(sNoAng);
	if(sNoAng == '')
	{
		//if(sLeftTDWidth == '0')
		//	imgang.src = ImagesFolderBase+ImagesFolder+"/BP_Angle.gif"
		//else
		//	imgang.src = ImagesFolderBase+ImagesFolder+"/BP_Angle17.gif"
		//;

		//tdang.width=48+nMaxChoiceLevel*17;
		imgang.height=48;
		imgang.width=48+nMaxChoiceLevel*17; //??? 46? 48?

		if(sType.indexOf('FORM')<0)
			{
			tdang.style.backgroundImage = 'url('+ImagesFolderBase+ImagesFolder+'BP_AngleLong.gif)'
			}
		else
			tdang.style.backgroundImage = 'url('+ImagesFolderBase+ImagesFolder+'BP_AngleLongForm.gif)'

		if(tdangNext)
			{
			tdangNext.style.backgroundImage = 'url('+ImagesFolderBase+ImagesFolder+'BP_Vertical117.GIF)';
//if(sType.substring(0,12)=='HEADERCHOICE')
//	alert(imgang.width);
			//tdangNext.innerHTML='***';
			//imgang.height=48;
			//imgang.width=48+nMaxChoiceLevel*17;
			}
//alert(imgang.width);
	}
	else
	{
		//imgang.src = "images/1x1.GIF";
		tdang.style.backgroundImage = '';
		//tdang.width=0;
	}
//alert(imgang.src);
	}
	if(tdang)
	{
//alert(tdang.style.backgroundImage);
		//tdang.style.backgroundImage1 = 'url('+ImagesFolderBase+ImagesFolder+'BP_Vertical.gif)';
//alert(tdang.style.backgroundImage);
	}
	//current_el.style.backgroundImage = 'url('+ImagesFolderBase+ImagesFolder+'BP_Vertical1.gif)';

	if(tdang7)
	{
	if(sNoAng == '')
	{
		//if(sLeftTDWidth == '0')
		//	tdang7.style.backgroundImage = 'url('+ImagesFolderBase+ImagesFolder+'BP_Vertical1.gif)';
		//else


			//tdang7.style.backgroundImage = 'url('+ImagesFolderBase+ImagesFolder+'BP_Vertical117.gif)';


		//;
	}
	}
}

	//if(NoAng = 'y')
	//{
	//NoAng = '';
	//}
}

function ShowPictByID(oimage,i,sWinPrefix,spict,stitle,sitemid,sItemsInfo)
{
var oInfo,sitemmenuid,sItemsInfoItem,oInfoText;

//alert('ShowPictByID 1');
//oimage.src=GetImagesFolderFull()+'/BP_Pict_Expl.GIF';
oimage.src=GetImagesFolderFull()+spict;
//alert(oimage.src);
oimage.title=stitle;
//alert('GetSound()');
GetSoundStatus();
//alert('GetSound() OK');
//window.setTimeout(sWinPrefix+'document.images['+i+'].src="'+GetImagesFolderFull()+spict+'";', 1000);

//get info to put in: info{$GUID} style.display='block';info{$MenuID}.innerHTML=<text>

//alert('ShowPictByID, sItemsInfo:'+sItemsInfo);
//alert('ShowPictByID, sitemid:'+sitemid);

//if(0)
if(sItemsInfo!='')
{
//alert('ShowPictByID, sitemid:'+sitemid);
//alert('ShowPictByID, sItemsInfo:'+sItemsInfo);

if(sItemsInfo.indexOf(sitemid)>=0)
{
	oInfo = document.getElementById('info'+sitemid);

//alert(oInfo);

	if(oInfo)
	{
		sItemsInfoItem=sItemsInfo.substring(sItemsInfo.indexOf('{'+sitemid+'}'));
		sItemsInfoItem=sItemsInfoItem.replace('{'+sitemid+'}', '');
		sItemsInfoItem=sItemsInfoItem.replace('{', '');
//alert('sItemsInfoItem 1:'+sItemsInfoItem);
		sItemsInfoItem=sItemsInfoItem.substring(0,sItemsInfoItem.indexOf('}'));
//alert('sItemsInfoItem 2:'+sItemsInfoItem);
		sItemsInfoItem=sItemsInfoItem.replace(/}/g, '');
		sItemsInfoItem=sItemsInfoItem.replace(/{/g, '');
//alert('sItemsInfoItem:'+sItemsInfoItem);

		oInfoText = document.getElementById('infospan'+sitemid);
//alert(oInfoText);
		if(oInfoText)
		{
			oInfoText.innerHTML=sItemsInfoItem;
//alert('oInfoText OK');
			if(sItemsInfoItem!='')
			{
				oInfo.style.display='block';
			}
			else
			{
				oInfo.style.display='none';
			}
		}
	}
	
}

}

}

//***
function changeimages(sWinPrefix,sItems,sItemsInfo)
{
//alert('changeimages, sItems:'+sItems);
//alert(sWinPrefix);
if(0)
if(sItems!='&OtherItemsModified=')
{
//alert('changeimages, sItems:'+sItems);
//alert('changeimages, sItemsInfo:'+sItemsInfo);
}
//alert('changeimages, ImagesFolderBase+ImagesFolder:'+ImagesFolderBase+ImagesFolder);
//alert('changeimages, oDoc:'+oDoc);

//return;
var sitemid,sid;
//var sitemid1;

if(sItems=='' || sItems=='&OtherItemsModified=')
{
	return;
}
if(sWinPrefix=='')
	oDoc=document
else
	oDoc=window.opener.document;

var iLength=oDoc.images.length;
   for(var i=0;i < iLength;i++)
   {
//alert('before sitemid');
		//sitemid=oDoc.images[i].itemid;
		sitemid=oDoc.images[i].id;
		
		//sid=oDoc.images[i].id;
		if(sitemid!=undefined && sitemid!='' && sitemid.substring(0,1)=='{')
		{
//alert('sitemid:'+sitemid);
		if(sItems.indexOf('DocID'+sitemid)>=0)
		{
sItem=GetItemFromStr(sItems, 'DocID'+sitemid, '}');
//alert(sItem);
//alert('DocIDTD'+sitemid);
oDocIDTD=oDoc.getElementById('DocIDTD'+sitemid);
oDocIDA=oDoc.getElementById('DocIDA'+sitemid);

//alert(oDocIDTD);
//alert(oDocIDA);

if(oDocIDTD && oDocIDA)
{
if(sItem=='')
	oDocIDTD.style.display="none";
else
	{
oDocIDTD.style.display="block";
oDocIDA.innerHTML=sItem;
oDocIDA.title=sItem;
oDocIDA.href="ShowDoc.asp?docid="+encodeURI(sItem)+FLPar()+'&hash=' + Math.random();
	}
}

		}


sTempC="";
iTemp=sItems.indexOf('DATETOCOMPGREEN'+sitemid);
if(iTemp>=0)
	sTempC="GREEN";
if(sTempC=='')
{
iTemp=sItems.indexOf('DATETOCOMPYELLOW'+sitemid);
if(iTemp>=0)
	sTempC="YELLOW";
}
if(sTempC=='')
{
iTemp=sItems.indexOf('DATETOCOMPRED'+sitemid);
if(iTemp>=0)
	sTempC="RED";
}


		if(sTempC!='')
		{
sItem=GetItemFromStr(sItems, 'DATETOCOMP'+sTempC+sitemid, '}');
oDATETOCOMPTD=oDoc.getElementById('DATETOCOMPTD'+sitemid);
oDATETOCOMPIMG=oDoc.getElementById('DATETOCOMPIMG'+sitemid);
oDATETOCOMPSPAN=oDoc.getElementById('DATETOCOMPSPAN'+sitemid);

//alert(sTempC);
//alert(sItem);

if(oDATETOCOMPTD && oDATETOCOMPIMG && oDATETOCOMPSPAN)
{
if(sItem=='')
	oDATETOCOMPTD.style.display="none";
else
	{
oDATETOCOMPTD.style.display="block";
if(sTempC=='GREEN')
oDATETOCOMPIMG.src="Images/TimeGreen.GIF"
else
if(sTempC=='RED')
oDATETOCOMPIMG.src="Images/TimeExp.GIF"
else
if(sTempC=='YELLOW')
oDATETOCOMPIMG.src="Images/TimeExpiring.GIF"
else
oDATETOCOMPIMG.src="Images/Time.GIF"
;
oDATETOCOMPSPAN.innerHTML="&nbsp;&nbsp;"+sItem;
	}
}

		}


		if(sItems.indexOf(sitemid + '*')>=0)
		{
//alert('sitemid:'+sitemid);

ShowPictByID(oDoc.images[i],i,sWinPrefix,'/BP_pict.gif',GetDOCS_Properties(),sitemid,sItemsInfo);

if(sItems.indexOf("{"+sitemid+"NOC2}")<0)
ObjDisplay(sWinPrefix,'BUTTCOMP'+sitemid)
else
if(sItems.indexOf("{"+sitemid+"NOC2}")>=0)
ObjNoDisplay(sWinPrefix,'BUTTCOMP'+sitemid)

ObjDisplay(sWinPrefix,'ChoiceSelect'+sitemid);

//alert('ShowPictByID OK');

//oDoc.images[i].src=GetImagesFolderFull()+'/BP_Pict_Expl.gif';
//GetSound();
//Delay(500);
//oDoc.images[i].src=GetImagesFolderFull()+'/BP_pict.gif';
//oDoc.images[i].title=GetDOCS_Properties();

//osel = document.getElementById('ChoiceSelect'+sitemid);
//alert(osel);
//if(osel)osel.style.display='block';

//alert('* - '+sitemid);

		}

		if(sItems.indexOf(sitemid + 'OK')>=0)
		{
ShowPictByID(oDoc.images[i],i,sWinPrefix,'/Bp_Pict_OK.gif',GetDOCS_Properties(),sitemid,sItemsInfo);
ObjNoDisplay(sWinPrefix,'BUTTCOMP'+sitemid);

//alert('OK - '+sitemid);
		}

		if(sItems.indexOf(sitemid + 'X')>=0)
		{
ShowPictByID(oDoc.images[i],i,sWinPrefix,'/Bp_Pict_Cancelled.gif',GetDOCS_Properties(),sitemid,sItemsInfo);
ObjNoDisplay(sWinPrefix,'BUTTCOMP'+sitemid);

//alert('X - '+sitemid);
		}

		if(sItems.indexOf(sitemid + '-}')>=0)
		{
ShowPictByID(oDoc.images[i],i,sWinPrefix,'/BP_Pict_Inactive.gif',GetDOCS_Properties(),sitemid,sItemsInfo);
ObjNoDisplay(sWinPrefix,'BUTTCOMP'+sitemid);

//ObjNoDisplay(sWinPrefix,'ChoiceSelectYes'+sGUIDInstanceItem);
ObjNoDisplay(sWinPrefix,'ch'+sitemid);
ObjResetChoice(sWinPrefix,'ChoiceSelect'+sitemid);

//if(!oDATETOCOMPTD)
{
oDATETOCOMPTD=oDoc.getElementById('DATETOCOMPTD'+sitemid);
if(oDATETOCOMPTD)
	oDATETOCOMPTD.style.display="none";
}
//alert('inactive - '+sitemid);
		}
      	}
   }

}

//*** BPs Copy from JSBP.js END **********************

function GetBPForm(sGUIDInstanceItem, sGUID, sType, sSuffix, sBaseURL) 
{
//alert('GetBPForm, sGUID:'+sGUID);

if(sBaseURL==undefined)
	sBaseURL=sPayDoxURL;
if(sBaseURL=='')
	sBaseURL=sPayDoxURL;

if(sType=='@FORMHTML')
{
sWidth=840;
sHeight=600;
sTop=12;
sLeft=document.body.clientWidth/2-sWidth/2+240;
sLink=sBaseURL+'BPGetForm.asp?built=y&inwin=y&l='+LPar+'&GUIDInstanceItem='+sGUIDInstanceItem+'&GUID='+sGUID+'&hash=' + Math.random()+'&showform=y';
swin=window.open(sLink, 'FHTML','toolbar=0,resizable=1,location=0,directories=0,status=1,menubar=0,width='+sWidth+',height='+sHeight+',screenX1=180,screenY1=50,left='+sLeft+',top='+sTop+',scrollBars=1');
}
else
{
sLink=sBaseURL+'BPGetForm.asp?built=y&GUIDInstanceItem='+sGUIDInstanceItem+LPar+'&GUID='+sGUID+'&hash=' + Math.random()+'&showform=y';
//document.all.uReset.src=sLink;
obj = document.getElementById('ifr'+sSuffix);
if(obj)
	obj.src=sLink;

//alert(document.all.uReset.src);
}
return;
}

function SlideShow(slideshowFirst) {
//alert('SlideShow:'+slideshowFirst);
//var objSlide = document.getElementById("newDialogWindow");
//insertDialogWindow("newDialogWindow");
//DrawPic(slideshowFirst)
//myOpenSlideShow(50,50,250,400);
//openDialogWindow("newDialogWindow", Top(document.all[sField]), Left(document.all[sField]), 0, 0);
//openDialogWindow("newDialogWindow", 100, 100, 100, 100);
return;
}

	// -------------------- window functions
	function getObj(objID){
		if (document.getElementById) {
			return document.getElementById(objID);
		}
		else if (document.all) {
			return document.all[objID];
		}
		else if (document.layers) {
			return document.layers[objID];
		}
	}


	function getObjOpener(objID){
		if (window.opener.document.getElementById) {
			return window.opener.document.getElementById(objID);
		}
		else if (window.opener.document.all) {
			return window.opener.document.all[objID];
		}
		else if (window.opener.document.layers) {
			return window.opener.document.layers[objID];
		}
	}

	function Left(obj){
		var curleft = 0;
		if (obj.offsetParent){
			while (obj.offsetParent){
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}

	function Top(obj){
		var curtop = 0;
		if (obj.offsetParent){
			while (obj.offsetParent){
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

	function checkClick(e){
		e?evt=e:evt=event;
		sObjId = 'newDialogWindow';
		CSE=evt.target?evt.target:evt.srcElement;
		if (getObj(sObjId))
			if (!isChild(CSE,getObj(sObjId)) && CSE.id != 'newDialogWindow_Click')
				getObj(sObjId).style.display='none';
	}

	function isChild(s,d){
		while(s){
			if (s==d) 
				return true;
			s=s.parentNode;
		}
		return false;
	}

	function insertDialogWindow(sDialogId){
		//alert('insertDialogWindow');
		if (!getObj(sDialogId)){
			oTable = document.createElement('table');
			oTable.id = sDialogId;

			//oTable.onmouseover="javascript:stopdissappear();" 
			//oTable.onmouseover="javascript:alert(\'onmouseout\');" 
 
			oTable.style.position = 'absolute';
			oTable.style.background = '#FFFFFF';

			oTable.style.borderTop = '2px solid #CCCCCC';
			oTable.style.borderLeft= '2px solid #CCCCCC';    
			oTable.style.borderRight = '2px solid #808080';
			oTable.style.borderBottom = '2px solid #808080';

			//oTable.style.border = '1px solid #303030';
			oTable.style.display = 'none';
			oTable.style['border-collapse'] = 'collapse';
			oTable.style['-moz-user-select'] = 'none';
			oTable.style['-khtml-user-select'] = 'none';
			oTable.style['user-select'] = 'none';
			if(sDialogId=='newDialogWindowSlide')
				oTable.cellpadding = 2
			else
				{
				oTable.cellpadding = 0;
				oTable.cellspacing = 0;
				}
			//oTable.onkeydown = 'alert(event.keyCode);';
			oTable.valign = "top";
			var tbody = document.createElement('TBODY');
			oTable.appendChild(tbody);
			document.body.appendChild(oTable);
		   	document.all?document.attachEvent('onclick',checkClick):document.addEventListener('click',checkClick,false);
		}
		//alert('insertDialogWindow OK');
		return;
	}

	function openDialogWindow(sDialogId, iTop, iLeft, iWidth, iHeight, bShow){
		//alert(iWidth);
		//alert(iHeight);isIE()?oCurPos.y:oCurPos.y
		//alert(iTop);
		//alert(iTop);
		//alert(getClientHeight());
		//alert('getBodyScrollTop():'+getBodyScrollTop());
		//alert('iTop:'+iTop);

		oTable = getObj(sDialogId);
		oTable.style.left = iLeft>0?iLeft+getBodyScrollLeft():getClientCenterX()-parseInt(iWidth/2); 
		//alert(oTable.style.top);
		oTable.width = iWidth>0?iWidth:'';
		//oTable.style.height = iHeight>0?iHeight:'';
		oTable.style.top = iTop>0?iTop:getClientCenterY()-parseInt(iHeight/2); //+getBodyScrollTop()
		oTable.height = iHeight>0?iHeight:'';

		if(bShow)
			{
		//alert('oTable.clientHeight:'+oTable.clientHeight);
			oTable.style.display = '';
		//alert('oTable.clientHeight:'+oTable.clientHeight);


		if(iTop>0)
			{
		//alert('iTop 1:'+iTop);
		//alert('getClientHeight():'+getClientHeight());
		//alert('oTable.clientHeight:'+oTable.clientHeight);
			//var iTopshift=getClientHeight()-oTable.clientHeight-5; //+getBodyScrollTop(); //
		//alert('iTopshift:'+iTopshift);
			//if(iTop>iTopshift)
			if(iTop+oTable.clientHeight+5>getClientHeight()+getBodyScrollTop())  //iTop+oTable.clientHeight+5-getClientHeight()>0
				{
				//iTop=iTopshift;
				iTop=getClientHeight()-oTable.clientHeight; //-5
		//alert('iTop 2:'+iTop);
				if (iTop<5)
					iTop=5;
				}
				oTable.style.top = iTop; //+getBodyScrollTop()
			}
		//alert('iTop 3:'+iTop);




			oTable.focus();
			}
		else
			oTable.style.display = 'none'
		;
		//alert('oTable.style.height:'+oTable.style.height);
	}

	function ResizeImageToNormal(oImg){
		var rMaxWidth=nSlideMaxIMGWidth;
		var rMaxHeight=nSlideMaxIMGHeight;
		var rw=oImg.width;
		var rh=oImg.height;
//alert('oImg.width:'+oImg.width)
//alert('oImg.height:'+oImg.height)
		if(rw>rMaxWidth)
			{
			rh=parseInt(rh*rMaxWidth/rw);
			rw=rMaxWidth;
			oImg.setAttribute("resized", "y");
			}
		if(rh>rMaxHeight)
			{
			rw=parseInt(rw*rMaxHeight/rh);
			rh=rMaxHeight;
			oImg.setAttribute("resized", "y");
			}

		if(oImg.width != rw || oImg.height != rh)
			{
			oImg.width=rw;
			oImg.height=rh;
//alert('oImg.width new:'+oImg.width)
//alert('oImg.height new:'+oImg.height)
			}
	}


	function GetImageNormalWidth(rWidth){
		if(rWidth>nSlideMaxIMGWidth)
			return nSlideMaxIMGWidth
		else
			return rWidth
	}

	function GetImageNormalHeight(rHeight){
		if(rHeight>nSlideMaxIMGHeight)
			return nSlideMaxIMGHeight
		else
			return rHeight
	}
	
	function changeDialogWindowPosition(sDialogId, curimgheight, curimgwidth){
	//alert('iTop:'+iTop);
	//alert('iLeft:'+iLeft);
		oTable = getObj(sDialogId);
		oSlideShowButton = getObj(sSlideShowButtonID);
//alert(oSlideShowButton);		
//alert(Top(oSlideShowButton));		
		//oTable.style.top = iTop > 0 ? iTop : 0;
		//oTable.style.left = iLeft > 0 ? iLeft : 0;

		//oTable.style.top = Top(oSlideShowButton)-2;
		//oTable.style.left = Left(oSlideShowButton)+26;
		var rtop=parseInt(getClientCenterY()-curimgheight/2 - 10);
		if(rtop < 10)
			rtop = 10;
		//if(rtop+>getClientHeight());
//alert(rtop);
//alert(oTable.style.height);
//alert(getClientHeight());
		oTable.style.top = rtop;
		oTable.style.left = parseInt(getClientCenterX()-curimgwidth/2);
		//window.onscroll=function(){changeDialogWindowPosition(sDialogId,curimgheight,curimgwidth)}
	}

	function closeDialogWindow(sDialogId){
//alert('closeDialogWindow');
		if (itWasResize == true)
  		{
    		return;
  		}
  		itWasResize = false;

		oTable = getObj(sDialogId);
		oTable.style.display = 'none';
		clearTimeout(ssTimer);
		//document.body.removeChild(oTable);
		//window.onscroll="";
	}

	function insertDialogWindowHeaderLine(sDialogId){
		//alert('insertDialogWindowHeaderLine');
		oTable = getObj(sDialogId);
		oTable.replaceChild(document.createElement('TBODY'), oTable.getElementsByTagName('TBODY')[0]);
		var tbody = oTable.getElementsByTagName('TBODY')[0];
		var row = document.createElement("TR");
		row.style.background = '#AAAAAA';
		var td = document.createElement("TD");
		td.align = "right";
		td.height = 12;
		var sTd = '<a style="font:12px Arial;color:black;" href="javascript:closeDialogWindow(\''+sDialogId+'\');">[x]</>';
		td.innerHTML = sTd;
		row.appendChild(td);
		tbody.appendChild(row);
		//alert('insertDialogWindowHeaderLine OK');
		return;
	};

	function InitDialogWindow(sDialogId){
		//alert('InitDialogWindow');
		oTable = getObj(sDialogId);
		oTable.replaceChild(document.createElement('TBODY'), oTable.getElementsByTagName('TBODY')[0]);
		return;
	};

	function insertDialogWindowControlLine(sDialogId, slideshow){
		//alert('insertDialogWindowLine, slideshow:'+slideshow);
		oTable = getObj(sDialogId);
		//oTable.replaceChild(document.createElement('TBODY'), oTable.getElementsByTagName('TBODY')[0]);
		var tbody = oTable.getElementsByTagName('TBODY')[0];
		var row = document.createElement("TR");
		row.style.background = '#AAAAAA';
		var td = document.createElement("TD");
		//td.align = "right";
		td.align="center";
		td.vAlign="middle";
		td.noWrap = true;
		td.height = 12;
	if (slideshow=='y')		if (document.all)
			{
			sstyle="cursor:pointer;cursor:hand;filter:alpha(opacity=100)";
			son="";
			}
		else
			{
			sstyle="cursor:pointer;cursor:hand;opacity:1";
			son="";
			}
	else
		if (document.all)
			{
			sstyle="filter:alpha(opacity=50)";
			son="1";
			}
		else
			{
			sstyle="opacity:0.5";
			son="1";
			}

		var sTd = '';
		sTd += '<table border="0" width="100%" cellpadding="0" cellspacing="0"><tr><td valign="middle" align="center" width="99%" nowrap><img border="0" src="IMAGES/1x1.GIF" width="32" height="1">';
		sTd += '<span onclick'+son+'="javascript:SlideShowSlower();"><img style="'+sstyle+'" id="imgSlower" border="0" src="IMAGES/Pict_FastMoveLeft.GIF" title="'+DOCS_Slower+'" width="32" height="32"></span>';
		sTd += '<span onclick'+son+'="javascript:SlideShowPrev();"><img style="'+sstyle+'" id="imgPrev" border="0" src="IMAGES/Pict_MovePrev.GIF" title="'+DOCS_ShowPrev+'" width="32" height="32"></span>';
		sTd += '<span onclick'+son+'="javascript:SlideShowPlayPause();"><img style="'+sstyle+'" id="imgSlideShowPlayPause" border="0" src="IMAGES/Pict_Pause.gif" title="'+DOCS_Pause+'" width="32" height="32"></span>';
		sTd += '<span onclick'+son+'="javascript:SlideShowPlayBack();"><img style="'+sstyle+'" id="imgSlideShowPlayBack" border="0" src="IMAGES/Pict_MoveBack.gif" title="'+DOCS_Backward+'" width="32" height="32"></span>';
		sTd += '<span onclick="javascript:document.getElementById(\'imgclose\').src=\'Images/Pict_Close_anim.gif\';setTimeout(function(){closeDialogWindow(\''+sDialogId+'\')}, 500);"><img style="cursor:pointer;cursor:hand" id="imgclose" border="0" src="IMAGES/Pict_Close.GIF" title="'+DOCS_Close+'" width="32" height="32"></span>';
		sTd += '<span onclick'+son+'="javascript:SlideShowNext();"><img style="'+sstyle+'" id="imgNext" border="0" src="IMAGES/Pict_MoveNext.GIF" title="'+DOCS_ShowNext+'" width="32" height="32"></span>';
		sTd += '<span onclick'+son+'="javascript:SlideShowFaster();"><img style="'+sstyle+'" id="imgFaster" border="0" src="IMAGES/Pict_FastMoveRight.GIF" title="'+DOCS_Faster+'" width="32" height="32"></span>';
		sTd += '</td><td width="1%" nowrap valign="bottom">';
		var sDom="com";
		if(lang=='ru')
			sDom="ru";
		sTd += '<span align="right"><a target="_blank" title="Powered by PayDox" href="http://www.paydox.'+sDom+'" style="TEXT-DECORATION: none; FONT-FAMILY: Arial, sans-serif; FONT-SIZE: 11px; COLOR: #505050;">PayDox</a></span>';
		sTd += '</td></tr></table>';
		td.innerHTML = sTd;
		row.appendChild(td);
		tbody.appendChild(row);
		//alert('insertDialogWindowHeaderLine OK');
		return;
	};

	function insertDialogWindowBody(sDialogId, sBody, isAppend, salign){
		//alert('insertDialogWindowBody');
		if (typeof isAppend == 'undefined' ) isAppend = true;

		oTable = getObj(sDialogId);
		var row = document.createElement("TR");
		row.style.background = '#EEEEEE';
		var td = document.createElement("TD");
		td.style.font = "12px Arial";
		td.vAlign="middle";
		td.noWrap=false;
		td.id=sDialogId+'Body';
		if(salign && salign != 'undefined')
			td.align=salign
		else
			td.align="center"
		;
		if(sDialogId=='newDialogWindowSlide')
			td.height="100";
		td.innerHTML = sBody;
		if (!isAppend){
			oTable.replaceChild(document.createElement('TBODY'), oTable.getElementsByTagName("TBODY")[0])
		}
		row.appendChild(td);
		var tbody = oTable.getElementsByTagName("TBODY")[0];
		tbody.appendChild(row);
		//alert('insertDialogWindowBody OK');
		return;
	};
	
	
	// -------------------- window functions end


function loadscript(url, onload) 
{ 
s = document.createElement('script'); 
s.setAttribute('type', 'text/javascript'); 
s.setAttribute('src', url); 
 
 
s.onload = function() { // FF, Opera 
if (!s.onloadDone) // Opera 
{ 
s.onloadDone = true; 
if (onload) onload(); 
} 
}; 

s.onreadystatechange = function() { 
if ("loaded" === s.readyState && !s.onloadDone) { // IE, Opera 
s.onloadDone = true; 
if (onload) onload(); 
} 
}; 

document.getElementsByTagName('head')[0].appendChild(s); 
}

function loadfilecss(url) 
{ 
s = document.createElement('LINK'); 
s.setAttribute('href', url); 
s.setAttribute('type', 'text/css'); 
s.setAttribute('rel', 'stylesheet'); 
//alert(document.getElementsByTagName('head')[0]);
document.getElementsByTagName('head')[0].appendChild(s); 
//alert('OK');
}

function playvideo(sfile) 
{ 
	timerFlag = true; 
	var cT=window.setTimeout(function(){playvideoTimer(sfile);}, 400); 
}

function playvideoTimer(sfile) 
{ 
//alert('playvideo, sfile:'+sfile);
if(!timerFlag)
	return;
timerFlag = false; 
VideoWin=window.open('VideoPlayers.asp?pars='+LPar+'&FileURL='+sfile,'VideoWin1','toolbar=0,resizable=1,location=0,directories=0,status=0,menubar=0,width=800,height=600,screenX=550,screenY=50,left=250,top=50,scrollBars=0');
VideoWin.focus();
}

function bltVoting(sURL, l, sObjSuffix){
if(sObjSuffix==undefined)
	sObjSuffix='';
var obj=document.getElementById("bltVoting"+sObjSuffix);
//alert('bltVoting, Filename:'+obj.getAttribute("VotingFilename"));
sPayDoxURL=sURL
LPar="&l="+l
slogin="public"
sMenu="N"
sbuilt="y"
//SetInitVarsName='initvarsVoting';
CallURL(sPayDoxURL+'Voting.asp?menu=N'+LPar+'&built=y&Filename='+encodeURI(obj.getAttribute("VotingFilename"))+'&VoteResp='+obj.getAttribute("VoteResp")+'&VoteRespCat='+obj.getAttribute("VoteRespCat")+'&Question='+encodeURI(obj.getAttribute("VotingQuestion"))+'&Responses='+encodeURI(obj.getAttribute("VotingResponses"))+'&CategoryName='+encodeURI(obj.getAttribute("CategoryName"))+'&CategoryValues='+encodeURI(obj.getAttribute("CategoryValues"))+'&Name='+encodeURI(obj.getAttribute("VotingName"))+'&GraphWidth='+encodeURI(obj.getAttribute("VotingGraphWidth"))+'&Statuses='+encodeURI(obj.getAttribute("Statuses"))+'&ObjSuffix='+sObjSuffix+'&hash=' + Math.random(), 'bltVoting'+sObjSuffix)
}

function bltVotingStat(sURL, l, sObjSuffix){
if(sObjSuffix==undefined)
	sObjSuffix='';
var obj=document.getElementById("bltVoting"+sObjSuffix);
//alert('bltVoting, Filename:'+obj.getAttribute("VotingFilename"));
//alert('bltVoting, sPayDoxURL:'+sPayDoxURL);
//alert('bltVoting, sURL:'+sURL);
sPayDoxURL=sURL
LPar="&l="+l
slogin="public"
sMenu="N"
sbuilt="y"
//SetInitVarsName='initvarsVoting';
CallURL(sPayDoxURL+'Voting.asp?menu=N'+LPar+'&built=y&Filename='+encodeURI(obj.getAttribute("VotingFilename"))+'&VotingStat=y&CategoryName='+encodeURI(obj.getAttribute("CategoryName"))+'&GraphWidth='+encodeURI(obj.getAttribute("VotingGraphWidth"))+'&Statuses='+encodeURI(obj.getAttribute("Statuses"))+'&ObjSuffix='+sObjSuffix+'&hash=' + Math.random(), 'bltVoting'+sObjSuffix)
}

function CheckRadioChoice(oRadio, oselect, sCategoryName, sObjSuffix){
//alert('CheckRadioChoice, oRadio:'+oRadio);
//alert(oRadio.checked);
//alert(oRadio.value);
//alert(oselect);
//alert(oRadio);
if(sObjSuffix==undefined)
	sObjSuffix='';

if(oselect)
	if(oselect.value=='')
{
alert(sCategoryName+" ?");
return false;
}

//alert(oRadio.length);
for (i=0;i<oRadio.length;i++){
//alert(oRadio[i].checked);
	if (oRadio[i].checked)
{
//alert(oRadio[i].value);
		var obj=document.getElementById("bltVoting"+sObjSuffix);
		obj.setAttribute('VoteResp', oRadio[i].value); 
		if(oselect)
			obj.setAttribute('VoteRespCat', oselect.value); 
		return true;
}
}

var obj = document.getElementById('initvarsVoting');
//alert(obj);
//if(obj)
alert(obj.getAttribute("DOCS_MakeChoice"));
return false;
}

function ShowVotingItem(sid, val, nMax)
{
//alert('ShowVotingItem, val:'+val);
var idelayStep=3;
var idelay=10;
var j;
var nwidth=1;
for (j=1;j<=nMax;j++){
	if(nwidth>val) break; 
	nwidth+=1;
	if(nwidth>val)
		nwidth=val;
	if(nwidth>nMax)
		nwidth=nMax;
	setTimeout("var obj=document.getElementById('"+sid+"');if (obj)obj.width="+nwidth+";", idelay);
	idelay=idelay+idelayStep;
	if(nwidth>=nMax) break; 
} 

} 

function HideVotingItem(sid)
{
var obj=document.getElementById(sid);
if(obj)obj.width=1;
 //alert('HideVotingItem, obj:'+obj);
} 

function evalbyidatt(sid, satt)
{
var obj=document.getElementById(sid);
if(obj)
	eval(obj.getAttribute(satt));
} 

function showdetailvotings1(NumberOfChoices, NumberOfChoicesCat){
var obj=document.getElementById('idsum2');
var sstatus;
if(obj.style.display=='none')
	sstatus=''
else
	{sstatus='none';
//obj.style.display='none';
	}
var idelayStep=20;
var idelay=10;
var j;
for (j=1;j<=NumberOfChoicesCat;j++){

setTimeout("var obj=document.getElementById('idsum"+j.toString()+"');if (obj)obj.style.display='"+sstatus+"';", idelay);
idelay=idelay+idelayStep;

for (i=1;i<=NumberOfChoices;i++){
	setTimeout("var obj=document.getElementById('idstat"+j.toString()+i.toString()+"');if (obj)obj.style.display='"+sstatus+"'", idelay);
	idelay=idelay+idelayStep;
}

setTimeout("var obj=document.getElementById('idcat"+j.toString()+"');if (obj)obj.style.display='"+sstatus+"'", idelay);
idelay=idelay+idelayStep;
}

obj=document.getElementById('idsee');
if (obj)
	if (sstatus=='none')
		obj.src=sPayDoxURL+'/Images/SeeBelow16x16.gif'
	else
		obj.src=sPayDoxURL+'/Images/SeeUp16x16.gif'
}

function showdetailvotings(NumberOfChoices, NumberOfChoicesCat, sObjSuffix){
 //alert('showdetailvotings, NumberOfChoices:'+NumberOfChoices);
if(sObjSuffix==undefined)
	sObjSuffix='';
var obj=document.getElementById('idsum2'+sObjSuffix);
var sstatus;
if(obj.style.display=='none')
	sstatus=''
else
	{sstatus='none';
//obj.style.display='none';
	}
var idelayStep=20;
var idelay=10;
var j;
var sPayDoxURL=GetInitVar('sPayDoxURL1', 'initvarsVoting')
for (j=(sstatus==''?1:NumberOfChoicesCat);(sstatus==''?j<=NumberOfChoicesCat:j>=1);(sstatus==''?j++:j--)){
//alert(j);
setTimeout("var obj=document.getElementById('idsum"+j.toString()+sObjSuffix+"');if (obj)obj.style.display='"+sstatus+"';", idelay);
idelay=idelay+idelayStep;

for (i=(sstatus==''?1:NumberOfChoices);(sstatus==''?i<=NumberOfChoices:i>=1);(sstatus==''?i++:i--)){

	if(sstatus=='')
		setTimeout("var obj=document.getElementById('idstat"+j.toString()+i.toString()+sObjSuffix+"');if (obj)obj.style.display='"+sstatus+"';evalbyidatt('idimgstat"+j.toString()+i.toString()+sObjSuffix+"','onload1') ", idelay)
	else
		setTimeout("HideVotingItem('votid"+i.toString()+j.toString()+sObjSuffix+"');var obj=document.getElementById('idstat"+j.toString()+i.toString()+sObjSuffix+"');if (obj)obj.style.display='"+sstatus+"'", idelay)
;

	idelay=idelay+idelayStep;
}

setTimeout("var obj=document.getElementById('idcat"+j.toString()+sObjSuffix+"');if (obj)obj.style.display='"+sstatus+"'", idelay);
idelay=idelay+idelayStep;
}

obj=document.getElementById('idsee'+sObjSuffix);
if (obj)
	if (sstatus=='none')
		obj.src=sPayDoxURL+'/Images/SeeBelow16x16.gif'
	else
		obj.src=sPayDoxURL+'/Images/SeeUp16x16.gif'
}

function AlertObjProperties(obj)
{
for (var key in obj) {
//if(obj[key])  
	//if(obj[key]!='')  
		alert(key+':'+obj[key])  
} 
}

//document.onmousemove = function(e){if(bmousemove)oCurPos = mousePageXY(e);
document.onmousemove = function(e){oCurPos = mousePageXY(e);
}

function CallStructureList(stagcmd, objectId, sinitvars, sGUIDStructure, sGUID) {
//alert('CallStructureList, othis:'+othis);
//alert('CallStructureList, othis.id:'+othis.id);
//alert('CallStructureList, othis.browser.ie:'+othis.browser.ie);
//alert('CallStructureList, textareaid:'+objectId);
//alert('CallStructureList, textareaid:'+document.all(textareaid));

//alert(eval(objectId+'.browser.ie'));
//alert('OK');
//alert(eval(objectId));

//alert('CallStructureList, othis 1:'+document.getElementById(objectId));
//alert('CallStructureList, othis.id 1:'+document.getElementById(objectId).id);
//alert('CallStructureList, othis.browser.ie 1:'+document.getElementById(objectId).ie);
//alert('CallStructureList, steText.browser.ie:'+steText.browser.ie);

//alert('CallStructureList, objectId:'+objectId);

if (sGUIDStructure==undefined)
	sGUIDStructure='';
if (sGUID==undefined)
	sGUID='';
if (objectId=='')
	sdatatag=''
else
	sdatatag='y';

var surl=GetInitVar('sPayDoxURL', sinitvars)+'StructureView.asp?tagcmd='+stagcmd+'&datatag='+sdatatag+'&textareaid='+objectId+'&GUIDStructure='+sGUIDStructure+'&GUID='+sGUID+'&menu=N&built=y'+GetInitVar('LPar', sinitvars)
//if(objectId=='')
//	surl=surl+"&noinsert=y";
//alert('CallStructureList:'+surl);
//alert(oCurPos.x);
sLeft=oCurPos.x+15;
if(sLeft>600)
	sLeft=600;	
DirWin=window.open(surl,'StructureList','toolbar=0,resizable=1,location=0,directories=0,status=0,menubar=1,width=640,height=480,screenX=230,screenY=400,left='+sLeft+',top=200,scrollBars=1'); //530
DirWin.focus();
return;

                if (this.browser.ie) 
			{
			var otextarea=this.frame.document.body;
//alert(document.selection.createRange().htmlText);
			//iPoz=GetMSIETextAreaCurrentPoz(otextarea)
			//if(iPoz<=0)
				otextarea.innerHTML=otextarea.innerHTML+stag
			//else
			//	otextarea.innerHTML=otextarea.innerHTML.substring(0,iPoz)+stag+otextarea.innerHTML.substring(iPoz,otextarea.innerHTML.length);
;
			//document.selection.createRange().text=stag;
			}
                else if (this.browser.gecko)
			{
			var otextarea=this.frame.document.body;
			//var otextarea=this.frame.document.body;
//alert(this.myGetSelection(this.frame));
//alert(this.myGetSelection(this.frame));
//alert(this.frame.getSelection().toString());
//alert(this.frame.getSelection());
//alert(this.frame.getSelection.selectionStart);
//alert(this.frame.document.body.selectionStart);
//alert(this.frame);
//otextarea=document.getElementById('TextID');
//alert(otextarea);
//otextarea.focus();
//alert(otextarea.getSelection());
//alert(otextarea.selectionStart);

			if ((otextarea.selectionStart)||(otextarea.selectionStart=='0'))
			{
			  var p_start=otextarea.selectionStart;
			  var p_end=otextarea.selectionEnd;
			  otextarea.value=otextarea.value.substring(0,p_start)+stag+otextarea.value.substring(p_end,otextarea.value.length);
			}
			else
			  //otextarea.value=otextarea.value+stag;
			  this.frame.document.body.innerHTML=this.frame.document.body.innerHTML+stag;
//alert(otextarea.value);
			}
//alert(this.frame.document.body.innerHTML);
                this.frame.focus();

} 

function CallDatatagDirectory(sGUIDStructure, sGUID)
{
//alert('CallDatatagDirectory, sGUIDStructure:'+sGUIDStructure+', sGUID:'+sGUID);
//CallStructureList(stagcmd, objectId, sinitvars)
CallStructureList('DSCONTENT','', 'initvarscases', sGUIDStructure, sGUID);
return;
}

function CallDatatagContent(sGUIDStructure, sGUID, sNameDirectory, sNameShort, sName)
{
  //alert('CallDatatagContent, sGUIDStructure:'+sGUIDStructure+', sGUID:'+sGUID);
//alert('CallDatatagContent, sNameDirectory:'+sNameDirectory+', sName:'+sName);
var bwclose=false;
obj=document.getElementById('searchform');
//alert(obj);
if(!obj)
	{
	obj=window.opener.document.getElementById('searchform');
	bwclose=true;
	}
//alert(obj);
if(!obj)
	{
	alert('obj error in CallDatatagDirectory');
	return;
	}
obj.pars.value='*tag';
obj.TagNameFull.value=sName;
obj.TagName.value=sNameShort;
obj.DirName.value=sNameDirectory;
obj.GUIDStructure.value=sGUIDStructure;
obj.GUIDTag.value=sGUID;
obj.submit();
 //alert(bwclose);
if(bwclose)
	window.close();
}

function ObjInsertValue(sid, svalue, biswi)
{
//alert('ObjInsertValue, sid:'+sid);
if(biswi)
	obj=window.opener.document.getElementById(sid)
else
	obj=document.getElementById(sid);
//alert(obj);
if (obj.type=='textarea' && obj.value=='')
	{
	obj.value=ToValueToInsert(svalue);
	return (false);
	}
if(obj.type=='textarea')
	{
	//obj.value=obj.value+'\r'+ToValueToInsert(svalue);
	obj.value=obj.value+'\r'+svalue;
	return (false);
	}
if(obj.value!='')
	{
	s='';
	if(!confirm(GetInitVar('DOCS_ChangeValue', '')+':\r'+obj.value+' ?'))
		if(!confirm(GetInitVar('DOCS_AddVALUE', '')+' ?'))
			return (false)
		else
			s=obj.value+'\r';
	}
	obj.value=s+searchdir.ValueToInsert.value;
	if(biswi)
		window.close();
}

function ToValueToInsert(sVal)
{
sVal=sVal.replace(new RegExp("&",'g'),"%26");
sVal=sVal.replace(new RegExp("/",'g'),"%2F");
sVal=sVal.replace(new RegExp("#",'g'),"%23");
sVal=sVal.replace(new RegExp("\\",'g'),"\\\\");
return sVal
}

function checkinputfield(obj,val, cid, spars){
//alert('checkinputfield');
//alert('x:'+oCurPos.x);
//alert('y:'+oCurPos.y);
var spic, sMessage
if(spars==undefined)
	spars='';
//alert(spars);
//alert(obj.value);
//alert(val);
//alert(obj.value.indexOf(val));
//alert(obj.value.indexOf('\r'));
//alert(obj.value.indexOf('\n'));
//if(obj.value.indexOf(val)>=0 || (obj.value.replace(';', '')).indexOf(val.replace(';', ''))>=0)
var sobjvaltocheck;
sobjvaltocheck=obj.value;

//alert(sobjvaltocheck.indexOf(val));

sobjvaltocheck=sobjvaltocheck.replace(/\n/g, '')
sobjvaltocheck=sobjvaltocheck.replace(/\r/g, '')
sobjvaltocheck=sobjvaltocheck.replace(/;/g, '')

 //alert(sobjvaltocheck);

var svaltocheck=val;
svaltocheck=svaltocheck.replace(/\n/g, '')
svaltocheck=svaltocheck.replace(/\r/g, '')
svaltocheck=svaltocheck.replace(/;/g, '')
 //alert(svaltocheck);

if(sobjvaltocheck.indexOf(svaltocheck)>=0)
	{
	sMessage=GetInitVar('DOCS_ALREADYEXISTS', 'initvarstructures')
	spic='explyellow.gif';
	}
else
	{
	sMessage='OK';
	spic='OK16.gif';
		if(spars=='inneradd')
			{
 //alert(obj);
 //alert(obj.id);
 //alert(obj.value);
			if(obj.value!='')
				obj.value+='<br>';
			obj.value+=val;
			var obj1=window.opener.document.getElementById(obj.id+'ValueToShow');
			if(obj1)
				obj1.innerHTML=obj.value;
			}
		else
			{
			if(trim(obj.value)!='')
				obj.value+='\r';
			obj.value+=val;
			}
	}
showobjmessage(cid, spic, sMessage, true)
}

function checkinputfieldNoClose(obj,val, cid){
var spic, sMessage

if(obj.value.indexOf(val)>=0)
	{
	sMessage=GetInitVar('DOCS_ALREADYEXISTS', 'initvarscases')
	spic='explyellow.gif';
	}
else
	{
	sMessage='OK';
	spic='OK16.gif';
	if(obj.value!='')
		obj.value+='\r';
	obj.value+=val;
	}
showobjmessage(cid, spic, sMessage, false)
}

function showobjmessage(cid, s1stImg, sMessage, bClose, ix, iy){

var sMouseMessageID='MMID'+Math.random();
//var sMouseMessageID=cid+'MMID';

if (ix==undefined) ix = oCurPos.x+15;
if (iy==undefined) iy = oCurPos.y;
if (ix==0) ix = oCurPos.x+15;
if (iy==0) iy = oCurPos.y;

if(!sPayDoxURL)
	sPayDoxURL=GetInitVar('sPayDoxURL', 'initvarstructures');

	sTable = '';
	sTable += '<div';
	//sTable += ' onmouseover1="javascript:stopdissappear();" onmouseover="javascript:alert(\'onmouseover\');" onmouseout="javascript:alert(\'onmouseout\');" onmouseout1="javascript:nodisplay(\''+sMouseMessageID+'\');" ';
	sTable += '>';
	sTable += '<table  ';
	sTable += ' border="0" width="100%" height="100%" cellpadding="0" cellspacing="0" ';
	
	sTable += 'style="background: -moz-linear-gradient(top, #FFFFFF, #DDDDDD); filter1:progid:DXImageTransform.Microsoft.Gradient(startColorStr=\'#FFFFFF\', endColorStr=\'#DDDDDD\', gradientType=\'0\'); background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#DDDDDD));"';

	sTable += '>';
	sTable += '<THEAD><TR><TD></TD></TR></THEAD><TBODY>'
	sTable += '<tr ';
	sTable += ' height="100%"><td valign="middle" align="center" width="100%" nowrap ';

	////sTable += 'style="background: -moz-linear-gradient(top, #B5DAE8, #EBEBEB); filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr=\'#B5DAE8\', endColorStr=\'#EBEBEB\', gradientType=\'0\'); background: -webkit-gradient(linear, left top, left bottom, from(#B5DAE8), to(#EBEBEB));"';
	sTable += '>';
	if(s1stImg!='')
		sTable += '<IMG style="vertical-align1:0px;" width="16px" height="16px" src="'+sPayDoxURL+'Images/'+s1stImg+'" border="0" />'
	sTable += '<font ';
	sTable += 'style="vertical-align:2px; FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px; COLOR: #000000;"'
	sTable += '>';

	//sTable += '<font style="FONT-SIZE: 8px;">&nbsp;</font>';
	sTable += sMessage+'</font>';
	if(bClose)
		{
		sTable += '&nbsp;<IMG style="vertical-align1:5px;" '
		//sTable += 'onclick="javascript:showobjmessage(\'\',\'pict_smile_1.png\',\''+GetInitVar('DOCS_DoNotClick', 'initvarstructures')+'\',false);" '
		sTable += 'width="16px" height="16px" '
		//sTable += 'onmouseover="javascript:this.src=\''+sPayDoxURL+'Images/Close3p.GIF\';showobjmessage(\'OK16.gif\',\''+GetInitVar('DOCS_CloseWindow', 'initvarstructures')+'\',false);setTimeout(\'window.close()\',1000);" '
		//sTable += 'onclick="javascript:this.src=\''+sPayDoxURL+'Images/Close3p.GIF\';showobjmessage(\'OK16.gif\',\''+GetInitVar('DOCS_CloseWindow', 'initvarstructures')+'\',false);window.close();" '
		sTable += 'onclick="javascript:this.src=\''+sPayDoxURL+'Images/Close3p.GIF\';setTimeout(\'window.close()\',300);" '
		sTable += 'title="'+GetInitVar('DOCS_CloseWindow', 'initvarstructures')+'" '
		//sTable += 'onmouseover="javascript:showobjmessage(\'\',\''+GetInitVar('DOCS_CloseWindow', 'initvarstructures')+'\',false);" '
		sTable += 'src="'+sPayDoxURL+'Images/Close3.GIF" border=0 title="">';
		}
	sTable += '</td></tr>';

	sTable += '</TBODY>';
	sTable += '</table>';
	sTable += '</div>';

	insertDialogWindow(sMouseMessageID);
	InitDialogWindow(sMouseMessageID);
	insertDialogWindowBody(sMouseMessageID, sTable, true, 'center');
	openDialogWindow(sMouseMessageID, iy, ix, 10, 10, true);
	dissappear(sMouseMessageID);
}

function dissappear(sobj){
if (document.all)
	{
	document.getElementById(sobj).style.filter = 'alpha(opacity=100)';
	for(var i=0;i<=10;i++)
		setTimeout("document.getElementById('"+sobj+"').style.filter = 'alpha(opacity="+(100-i*10)+")'", 3600+i*60)
	}
else
	{
	document.getElementById(sobj).style.opacity = 1;
	for(var i=0;i<=10;i++)
		setTimeout("document.getElementById('"+sobj+"').style.opacity = "+(1-i*0.1), 3600+i*60)
	}
setTimeout("document.getElementById('"+sobj+"').style.display = 'none'", 4200);
}

function stopdissappear(sobj){
alert('stopdissappear');
//alert(timeouts.length);
for(var i = 1; i < 100; i++) {
    clearTimeout(i);
}
//if (timeouts) for (var i in timeouts) if (timeouts[i]) clearTimeout(timeouts[i]);
document.getElementById(sobj).style.display = '';
}

function showmousemessage(sPict, sMessage, ix, iy){
//alert('showmousemessage');
if(!sPayDoxURL)
	sPayDoxURL=GetInitVar('sPayDoxURL', 'initvarstructures');

if (ix==undefined) ix = oCurPos.x+15;
if (iy==undefined) iy = oCurPos.y;
if (ix==0) ix = oCurPos.x+15;
if (iy==0) iy = oCurPos.y;

//alert('showmousemessage, oCurPos.y:'+oCurPos.y);
//alert('showmousemessage, iy:'+iy);
//iy = oCurPos.y;


	sTable = '';
	sTable += '<div';
	sTable += '>';
	sTable += '<table  ';
	sTable += ' border="0" width="100%" height="100%" cellpadding="0" cellspacing="0" ';
	sTable += '>';
	sTable += '<THEAD><TR><TD></TD></TR></THEAD><TBODY>'
	sTable += '<tr ';
	sTable += ' height="100%"><td valign="middle" align="left" width="100%" nowrap ';
	
	sTable += 'style="background: -moz-linear-gradient(top, #FFFFFF, #DDDDDD); filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr=\'#FFFFFF\', endColorStr=\'#DDDDDD\', gradientType=\'0\'); background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#DDDDDD));"';
	
	sTable += '>';
	sTable += '<font ';
	sTable += 'style="vertical-align:2px; FONT-FAMILY: Arial, Helvetica, sans-serif; FONT-SIZE: 12px; COLOR: #000000;"'
	sTable += '>';
	if(sPict!='')
		sTable += '<IMG style="vertical-align1:0px;" width1="16px" height1="16px" src="'+sPayDoxURL+'Images/'+sPict+'" border="0" /> '
	sTable += sMessage+'</font>';
	sTable += '</td></tr>';

	sTable += '</TBODY>';
	sTable += '</table>';
	sTable += '</div>';

	insertDialogWindow(sMouseMessageID);
	InitDialogWindow(sMouseMessageID);
	insertDialogWindowBody(sMouseMessageID, sTable, true, 'center');
	openDialogWindow(sMouseMessageID, iy, ix, 0, 0, true);
}

function showmousemessagetoggle(sPict, sMessage, sMessageID){
//var bshow=true;
var obj=document.getElementById(sMouseMessageID);
if(obj)
	{
	if(obj.style.display == '')
		{
		var sMessageIDAtt=obj.getAttribute('MessageID')
		if(sMessageIDAtt)
			if(sMessageIDAtt==sMessageID)
				{
				hidemousemessage();
				return;
				}
		}
	obj.setAttribute('MessageID', sMessageID);
	}
showmousemessage(sPict, sMessage);
if(!obj)
	obj=document.getElementById(sMouseMessageID);
if(obj)
	obj.setAttribute('MessageID', sMessageID);
}

function hidemousemessage(){
var obj=document.getElementById(sMouseMessageID);
if(obj)
	obj.style.display = 'none';
}

function nodisplay(sobj){
alert('nodisplay');
document.getElementById(sobj).style.display='none';
}

function setcookiesy(sname, svalue){
var today = new Date();
var cookie_date = new Date (today.getFullYear()+1, today.getMonth(), today.getDate());
document.cookie = sname + "=" + svalue + ";expires=" + cookie_date.toGMTString();
}

function getCookie(name) {
	var matches = document.cookie.match(new RegExp(
	  "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
	))
	return matches ? decodeURIComponent(matches[1]) : undefined 
}

function setCookie(name, value, props) {
	props = props || {}
	var exp = props.expires
	if (typeof exp == "number" && exp) {
		var d = new Date()
		d.setTime(d.getTime() + exp*1000)
		exp = props.expires = d
	}
	if(exp && exp.toUTCString) { props.expires = exp.toUTCString() }

	value = encodeURIComponent(value)
	var updatedCookie = name + "=" + value
	for(var propName in props){
		updatedCookie += "; " + propName
		var propValue = props[propName]
		if(propValue !== true){ updatedCookie += "=" + propValue }
	}
	document.cookie = updatedCookie

}

function deleteCookie(name) {
	setCookie(name, null, { expires: -1 })
}

function empty(){}

function showmousemessageTV(sMessage){
	showmousemessage('PayDox16.png', sMessage) // PayDox20.GIF pict_info.png PayDox16.png
}

function hidemousemessageTV(){
	hidemousemessage()
}

