//ssi смотрелка
function ImgSSI(pic,w,h)
{
//  var X=Math.round( (screen.availWidth-w)/2 );
//  var Y=Math.round( (screen.availHeight-h)/2 );
  X=( (screen.availWidth-w)/2 );
  Y=( (screen.availHeight-h)/2 );
  var win = window.open('/i/ssiopen.shtml?'+pic,'ImgSSI','width='+w+',height='+h+',top='+Y+',left='+X);
//  win.focus();
  return false;	
}

//ролловеры
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function TvdPop(url){
X=Math.round((screen.availWidth-466)/2);
Y=Math.round((screen.availHeight-283)/2);
window.open("portfolio/tvd/"+url+".htm","tvd1","left="+X+",top="+Y+",width=466,height=285");
}

function SizeWin(url,w,h){
X=Math.round((screen.availWidth-w)/2);
Y=Math.round((screen.availHeight-h)/2);
window.open(url,"new_window","left="+X+",top="+Y+",width="+w+",height="+h);
}

function PicPop(pic,w,h,title)
{
  var X=Math.round((screen.availWidth-w)/2);
  var Y=Math.round((screen.availHeight-h)/2);

  var win=window.open("","PicPop","resizable=no,left="+X+",top="+Y+",menubar=no,status=no,scrollbars=no,width="+w+",height="+h);
  win.document.write("<html><title>"+title+"</title><body leftmargin=0 topmargin=0 marginwidth='0' marginheight='0'>");
  win.document.write("<img src='"+pic+"' width='"+w+"' height='"+h+"'>"); 
  win.document.write("</body></html>");
}

//мылопрятка
function HideM( User,Description,Subj ) 
{
  Domain = "dimsun.ru";
  Eml = User+'@'+Domain;
  document.write('<a href="mai'+'lto:'+Eml);
  if( typeof Subj != "undefined" ) document.write( '?subject='+Subj );
  document.write( '">' );
  if( (typeof Description == "undefined") || (Description == "") ) document.write( Eml );
  else document.write( Description );
  document.write('</a>');
}

//ssi смотрелка gallery
function Gall(pic)
{
 w=560;
 h=390;
 var X=Math.round( (screen.availWidth-w)/2 );
 var Y=Math.round( (screen.availHeight-h)/2 );
 var win=window.open('gall.shtml?'+pic,'Gall','width='+w+',height='+h+',top='+Y+',left='+X);
// win.focus();
 return false;	
}

/* TOOLTIPS START */

/*
originally written by paul sowden <paul@idontsmoke.co.uk> | http://idontsmoke.co.uk
modified and localized by alexander shurkayev <alshur@narod.ru> | http://htmlcoder.visions.ru
*/

window.onerror = null;
var tooltip_attr_name = "tooltip";
var tooltip_blank_text = "(откроется в новом окне)"; // текст для ссылок с target="_blank"
var tooltip_newline_entity = "  "; // укажите пустую строку (""), если не хотите использовать в tooltip'ах многострочность; ежели хотите, то укажите тот символ или символы, которые будут заменяться на перевод строки

var tooltip_max_width = "400" // максимальная ширина tooltip'а в пикселах; обнулите это значение, если ширина должна быть нелимитирована


window.onload = function(e){
	if (document.createElement) tooltip.d();
}

function LoadTooltips(){
	if (document.createElement) tooltip.d();
}


tooltip = {

	t: document.createElement("DIV"),
	c: null,
	g: false,

	m: function(e){
		if (tooltip.g){
			oCanvas = document.getElementsByTagName(
			(document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY"
			)[0];
			x = window.event ? event.clientX + oCanvas.scrollLeft : e.pageX;
			y = window.event ? event.clientY + oCanvas.scrollTop : e.pageY;
			tooltip.a(x, y);
		}
	},

	d: function(){
		tooltip.t.setAttribute("id", "tooltip");
//		tooltip.t.style.filter = "alpha(opacity=85)"; // buggy in ie5.0

		document.body.appendChild(tooltip.t);
		a = document.all ? document.all : document.getElementsByTagName("*");
		aLength = a.length;
		for (var i = 0; i < aLength; i++){
			tooltip_title = a[i].getAttribute("title");
			tooltip_alt = "";                   //a[i].getAttribute("alt");
			tooltip_blank = a[i].getAttribute("target") && a[i].getAttribute("target") == "_blank" && tooltip_blank_text;
			if (tooltip_title || tooltip_blank){
				a[i].setAttribute(tooltip_attr_name, tooltip_blank ? (tooltip_title ? tooltip_title + " " + tooltip_blank_text : tooltip_blank_text) : tooltip_title);
				if (a[i].getAttribute(tooltip_attr_name)){
					a[i].removeAttribute("title");
					if (tooltip_alt && a[i].complete) a[i].removeAttribute("alt");
					tooltip.l(a[i], "mouseover", tooltip.s);
					tooltip.l(a[i], "mouseout", tooltip.h);
				}
			}else if (tooltip_alt && a[i].complete){
				a[i].setAttribute(tooltip_attr_name, tooltip_alt);
				if (a[i].getAttribute(tooltip_attr_name)){
					a[i].removeAttribute("alt");
					tooltip.l(a[i], "mouseover", tooltip.s);
					tooltip.l(a[i], "mouseout", tooltip.h);
				}
			}
			if (!a[i].getAttribute(tooltip_attr_name) && tooltip_blank){
				//
			}
		}
		document.onmousemove = tooltip.m;
		window.onscroll = tooltip.h;
	},

	s: function(e){
		d = window.event ? window.event.srcElement : e.currentTarget;
if (!d.getAttribute(tooltip_attr_name)) return;
if (tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
tooltip.t.appendChild(document.createTextNode(d.getAttribute(tooltip_attr_name)));

   r = d.getAttribute(tooltip_attr_name);
   re = /  /ig;
   tooltip.t.innerHTML = r.replace(re, "<br />");
	
	tooltip.c = setTimeout("tooltip.t.style.visibility = 'visible';", 1);
	tooltip.g = true;

	},

	h: function(e){
		tooltip.t.style.visibility = "hidden";
		if (!tooltip_newline_entity && tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
		clearTimeout(tooltip.c);
		tooltip.g = false;
		tooltip.a(-99, -99);
	},

	l: function(o, e, a){
		if (o.addEventListener) o.addEventListener(e, a, false); // was true--Opera7b workaround!
		else if (o.attachEvent) o.attachEvent("on" + e, a);
			else return null;
	},

	a: function(x, y){
		oCanvas = document.getElementsByTagName(
		(document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY"
		)[0];

		w_width = window.innerWidth ? window.innerWidth + window.pageXOffset : oCanvas.clientWidth + oCanvas.scrollLeft;
		w_height = window.innerHeight ? window.innerHeight + window.pageYOffset : oCanvas.clientHeight + oCanvas.scrollTop;

		tooltip.t.style.width = "auto";

		t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth;
		t_height = window.event ? tooltip.t.clientHeight : tooltip.t.offsetHeight;

		if (t_width > tooltip_max_width){
			tooltip.t.style.width = tooltip_max_width + "px";
			t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth;
		}

		t_extra_width = 7; // CSS padding + borderWidth;
		t_extra_height = 5; // CSS padding + borderWidth;

		tooltip.t.style.left = x + 8 + "px";
		tooltip.t.style.top = y + 8 + "px";

		while (x + t_width + t_extra_width > w_width){
			--x;
			tooltip.t.style.left = x + "px";
			t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth;
		}

		while (y + t_height + t_extra_height > w_height){
			--y;
			tooltip.t.style.top = y + "px";
			t_height = window.event ? tooltip.t.clientHeight : tooltip.t.offsetHeight;
		}
	}
}
/* TOOLTIPS FINISH */

