function PopupAnketa(artID,paramname,param) {
  var width=480;
  var height=540;
  var left=screen.width/2-width/2;
  var top=screen.height/2-height/2;
  var wnd = window.open("/default.asp?artID="+artID+"&"+ paramname+"="+escape(param), "anketapopup","left="+left+",top="+top+",width="+width+",height="+height+",resizable=0,status=0,scrollbars=1");
  if(wnd)
    wnd.focus();
}


      function OpJ()
   {
  location.href='/u.asp?j=1&reloads=1';
    
   }




function PopupPic(name, id, width, height){
  var left=screen.width/2-width/2;
  var top=screen.height/2-height/2;
  var wnd = window.open("/services/popuppic.asp?name="+ name+"&id="+id, "","left="+left+",top="+top+",width="+width+",height="+height+",resizable=0,status=0,scrollbars=0");
  if(wnd)
    wnd.focus();
}

function PrintPreview(){
  var url = window.location.href;
  var title = window.document.title;
  if(url.indexOf("#") != -1)
  	url = url.substring(0,url.indexOf("#"));
  if(url.indexOf("?") != -1)
    url = url + "&mode=print"
  else
    url = url + "?mode=print"
  var wnd = window.open( url , "PrintPreview","width=540,height=600,resizable=1,status=0,scrollbars=1");
  if(wnd)
    wnd.focus();
}

function MailLink(){
  var url = window.location.href;
  var title = window.document.title;
  var wnd = window.open("/services/maillink.asp" , "MailLink","width=472,height=501,resizable=1,status=0,scrollbars=1");
  if(wnd)
    wnd.focus();
}

function RemoveLinks(){
	if(window.opener)
	window.opener.name = "top"
	for(i=0; i<document.links.length; i++){
		var lnk = document.links[i].href;
		if(lnk.indexOf("javascript") == -1 && lnk.indexOf("#") == -1){
			document.links[i].target="top";
			document.links[i].onclick = new Function("opener.focus();");
		}
	}
}

var imagesHidden = false;
var images = null;

function HideImages(){
  if(images == null)
    images = new Array(document.images.length);
  var selfpath = document.location.href.split("/");
  for(i=0; i<document.images.length; i++){
    if(!imagesHidden){
      var path = document.images[i].src.split("/");
      if(path.length>5 || path.length==4 || selfpath[2] != path[2]){
        images[i] = document.images[i].src;
        document.images[i].src="/images/blank.gif";
      }  
    }
    else if(images[i] != null){
      document.images[i].src=images[i];
    }
  }
  imagesHidden = !imagesHidden;
  if(imagesHidden)
    document.getElementById("hide").innerText = "Show images"
  else
    document.getElementById("hide").innerText = "Hide images"
}

function GetTitle(){
  if(opener)
    if(opener.document.title)
      this.document.title = opener.document.title;
}


function Toggle(element){
  if(element.tagName == "IMG"){
    var div = element.parentNode.parentNode.parentNode.parentNode.parentNode; //TD->TR->TBODY->TABLE->DIV
    var folder = element.parentNode.nextSibling;
    if(element.src.indexOf("_minus.gif")!=-1){
      element.src = element.src.substring(0, element.src.indexOf("_minus.gif")) + "_plus.gif";
      folder.childNodes.item(0).src = "/images/tree/folder_closed.gif";
      var childs = div.childNodes;
      for(var i=1; i< childs.length; i++){
        if(childs[i].tagName == "DIV"){
          childs[i].style.display = "none";
          childs[i].style.visibility = "hidden";
        }
      }
      div.setAttribute("expanded", "false");
    }
    else{
      element.src = element.src.substring(0, element.src.indexOf("_plus.gif")) + "_minus.gif";
      folder.childNodes.item(0).src = "/images/tree/folder_open.gif";
      var childs = div.childNodes;
      for(var i=1; i< childs.length; i++){
        if(childs[i].tagName == "DIV"){
          childs[i].style.display = "block";
          childs[i].style.visibility = "visible";
        }
      }
      div.setAttribute("expanded", "true");
    }
  }
}

function ExpandVisual(table){
  var img = table.getElementsByTagName("IMG");
  if(img.length >= 2){
    var x = img[img.length-1].src.indexOf("_closed.gif");
    if(x != -1)
      img[img.length-1].src = "/images/tree/folder_open.gif";
    x = img[img.length-2].src.indexOf("_plus.gif");
    if(x != -1)
      img[img.length-2].src = img[img.length-2].src.substring(0, x) + "_minus.gif";
  }
}

function ExpandAll(){
  var rootDiv = document.getElementById("SiteMap");
  if(rootDiv){
    var childs = rootDiv.getElementsByTagName("DIV");
    for(var i=0; i<childs.length; i++){
        if(childs[i].getAttribute("expanded") != "true"){
          ExpandVisual(childs[i].childNodes.item(0));
          childs[i].setAttribute("expanded", "true")
        }
        if(childs[i].parentNode != rootDiv){
          childs[i].style.display="block";
          childs[i].style.visibility = "visible";
        }
    }
  }
}

function CollapseVisual(table){
  var img = table.getElementsByTagName("IMG");
  if(img.length >= 2){
    var x = img[img.length-1].src.indexOf("_open.gif");
    if(x != -1)
      img[img.length-1].src = "/images/tree/folder_closed.gif";
    x = img[img.length-2].src.indexOf("_minus.gif");
    if(x != -1)
      img[img.length-2].src = img[img.length-2].src.substring(0, x) + "_plus.gif";
  }
}

function CollapseAll(){
  var rootDiv = document.getElementById("SiteMap");
  if(rootDiv){
    var childs = rootDiv.getElementsByTagName("DIV");
    for(var i=0; i<childs.length; i++){
        if(childs[i].getAttribute("expanded") == "true"){
          CollapseVisual(childs[i].childNodes.item(0));
          childs[i].setAttribute("expanded", "false")
        }
        if(childs[i].parentNode != rootDiv){
          childs[i].style.display="none";
          childs[i].style.visibility = "hidden";
        }
    }
  }
}

function switchTab(id){
	var tab_table = document.getElementById(id).parentNode;
	var tabs = tab_table.childNodes;
	for(i=0; i<tabs.length; i++)
		if(tabs[i].className=="selected"){
			tabs[i].className="";
			document.getElementById(tabs[i].id+"_div").style.display="none";
			break;
		}
	document.getElementById(id).className="selected";
	document.getElementById(id+"_div").style.display="block";
}

function checkClear(obj, mask) {

	if (obj.value=mask) {
		obj.value = '';
	}
}

function EnlargePhoto(id, width, height){
	var div = document.createElement("DIV");
	div.id = "coverdiv";
	div.style.zIndex = 1000;
	div.style.position = "absolute";
	div.style.top = 0;
	div.style.left = 0;
	div.style.width = document.body.scrollWidth;
	div.style.height = document.body.scrollHeight;
	div.style.backgroundImage = "url(/images/semitransparent.png)";
	div.style.filter ="progid:DXImageTransform.Microsoft.BasicImage(Opacity=0.75, GrayScale=1)";
	if(window.addEventListener)
		div.addEventListener("mouseup", HidePhoto, false);
	else if(window.attachEvent)
		div.attachEvent("onmouseup", HidePhoto);
	document.body.appendChild(div);
	
	div = document.createElement("DIV");
	div.id = "photodiv";
	div.style.zIndex = 1001;
	div.style.display = "block";
	div.style.position = "absolute";
	div.style.borderWidth = "1px";
	div.style.borderColor = "#000";
	div.style.borderStyle = "solid";
	div.style.backgroundColor = "#FFF";
	div.style.padding = "10px";
	div.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color='#606060', Direction=135, Strength=2)";
	div.style.top =  document.body.scrollTop + (document.body.clientHeight - height)/2 - 11; 
	div.style.left =  document.body.scrollLeft + (document.body.clientWidth - width)/2 - 14;
	div.style.width = width;
	div.style.height = height;
	if(window.addEventListener)
		div.addEventListener("mouseup", HidePhoto, false);
	else if(window.attachEvent)
		div.attachEvent("onmouseup", HidePhoto);

	var img = document.createElement("IMG");
	img.src = "/img.asp?"+ id;
	div.appendChild(img);
	
	var href = document.createElement("A");
	href.href="#";
	href.style.position = "absolute";
	href.style.top = 13;
	href.style.left = width - 9;
	href.style.float = "right";
	href.style.clear = "left";
	
	var img = document.createElement("IMG");
	img.src = "/images/i-close.gif";
	img.style.border = 0;
	
	href.appendChild(img)
	div.appendChild(href);
	document.body.appendChild(div);
	
	if(window.addEventListener){
		window.addEventListener("scroll", PositionPhoto, false);
		window.addEventListener("resize", PositionPhoto, false);
	}
	else if(window.attachEvent){
		window.attachEvent("onscroll", PositionPhoto);
		//window.attachEvent("onresize", PositionPhoto);
		document.body.onresize = PositionPhoto;
	}
}

function HidePhoto(){
	var div = document.getElementById("coverdiv");
	document.body.removeChild(div);
	var div = document.getElementById("photodiv");
	document.body.removeChild(div);
	if(window.addEventListener){
		window.removeEventListener("scroll", PositionPhoto, false);
		window.removeEventListener("resize", PositionPhoto, false);
	}
	else if(window.attachEvent){
		window.detachEvent("onscroll", PositionPhoto);
		window.detachEvent("onresize", PositionPhoto);
	}
}



function PositionPhoto(){
	var div = document.getElementById("coverdiv");
	div.style.width = document.body.scrollWidth;
	div.style.height = document.body.scrollHeight;
	//div.style.width = document.body.scrollLeft + document.body.clientWidth;
	//div.style.height = document.body.scrollTop + document.body.clientHeight;
	var div = document.getElementById("photodiv");
	div.style.top =  document.body.scrollTop + (document.body.clientHeight - parseInt(div.style.height))/2 - 11; 
	div.style.left =  document.body.scrollLeft + (document.body.clientWidth - parseInt(div.style.width))/2 - 14;
}