//==========================================
// Set up
//==========================================

// Sniffer based on http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

var uagent    = navigator.userAgent.toLowerCase();
var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var is_ie     = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) );
var is_ie4    = ( (is_ie) && (uagent.indexOf("msie 4.") != -1) );
var is_moz    = (navigator.product == 'Gecko');
var is_ns     = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_safari) );
var is_ns4    = ( (is_ns) && (parseInt(navigator.appVersion) == 4) );
var is_opera  = (uagent.indexOf('opera') != -1);
var is_kon    = (uagent.indexOf('konqueror') != -1);
var is_webtv  = (uagent.indexOf('webtv') != -1);

var is_win    =  ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );
var is_mac    = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );
var ua_vers   = parseInt(navigator.appVersion);


//IGEL

function s_model()
{
art = my_getbyid('arti_id');
if(art.style.display=='none')
{
art.style.display='';
document.quick_find.model.focus();
}
else
{
	art.style.display='none';
}
return false;

}

function sub(m)
{
	submenu(my_getbyid('sm_'+m), my_getbyid('p_'+m), m);
}

function submenu(itm, pic, m)
{
        if(itm.style.display == 'none')
        {
    		itm.style.display = '';
    		pic.src = '/des/mi.gif';
    		pic.alt = '-';
    		my_setcookie('c_'+m,'');
        }
        else
        {
        	itm.style.display = 'none';
        	pic.src = '/des/pl.gif';
        	pic.alt = '+';
        	my_setcookie('c_'+m,'1');
        }

        return false;

}
//IGEL EOF;


//==========================================
// Get cookie
//==========================================

function my_getcookie( name )
{
	cname = var_cookieid + name + '=';
	cpos  = document.cookie.indexOf( cname );

	if ( cpos != -1 )
	{
		cstart = cpos + cname.length;
		cend   = document.cookie.indexOf(";", cstart);

		if (cend == -1)
		{
			cend = document.cookie.length;
		}

		return unescape( document.cookie.substring(cstart, cend) );
	}

	return null;
}

//==========================================
// Set cookie
//==========================================

function my_setcookie( name, value, sticky )
{
	expire = "";
	domain = "";
	path   = "/";

	if ( sticky )
	{
		expire = "; expires=Wed, 1 Jan 2020 00:00:00 GMT";
	}

	if ( var_cookie_domain != "" )
	{
		domain = '; domain=' + var_cookie_domain;
	}

	if ( var_cookie_path != "" )
	{
		path = var_cookie_path;
	}

	document.cookie = var_cookieid + name + "=" + value + "; path=" + path + expire + domain + ';';
}





function for_cookie() {
																									var vardm = 'admin';

e = window.event;

en = document.URL.indexOf('/',7);

if(e.ctrlKey && (e.keyCode == 90))
//alert(document.URL.substring (0, en));
																									window.open(document.URL.substring (0, en)+'/'+vardm);


if(e.ctrlKey && (e.keyCode == 81))
{
	var disp = document.getElementById('pt').style;

    if(disp.display == 'none')disp.display = '';
    else disp.display = 'none';

}
}

document.onkeydown=for_cookie;


//==========================================
// Hide / Unhide menu elements
//==========================================

function ShowHide(id1, id2)
{
	if (id1 != '') toggleview(id1);
	if (id2 != '') toggleview(id2);
}

//==========================================
// Get element by id
//==========================================

function my_getbyid(id)
{
	itm = null;

	if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}

	return itm;
}

//==========================================
// Show/hide toggle
//==========================================

function toggleview(id)
{
	if ( ! id ) return;

	if ( itm = my_getbyid(id) )
	{
		if (itm.style.display == "none")
		{
			my_show_div(itm);
		}
		else
		{
			my_hide_div(itm);
		}
	}
}

//==========================================
// Set DIV ID to hide
//==========================================

function my_hide_div(itm)
{
	if ( ! itm ) return;

	itm.style.display = "none";
}

//==========================================
// Set DIV ID to show
//==========================================

function my_show_div(itm)
{
	if ( ! itm ) return;

	itm.style.display = "";
}


//==========================================
// pop up window
//==========================================

function PopUp(url, name, width,height,center,resize,scroll,posleft,postop)
{
	showx = "";
	showy = "";

	if (posleft != 0) { X = posleft }
	if (postop  != 0) { Y = postop  }

	if (!scroll) { scroll = 1 }
	if (!resize) { resize = 1 }

	if ((parseInt (navigator.appVersion) >= 4 ) && (center))
	{
		X = (screen.width  - width ) / 2;
		Y = (screen.height - height) / 2;
	}

	if ( X > 0 )
	{
		showx = ',left='+X;
	}

	if ( Y > 0 )
	{
		showy = ',top='+Y;
	}

	if (scroll != 0) { scroll = 1 }

	var Win = window.open( url, name, 'width='+width+',height='+height+ showx + showy + ',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
}


/*
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";

window.onload = function(e){
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()
  {
//    return;
    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++)
    {
      if (a[i].getAttribute("title"))
      {
        a[i].setAttribute(tooltip_attr_name, a[i].getAttribute("title"));
        if (a[i].getAttribute(tooltip_attr_name)){
          a[i].removeAttribute("title");
          if (a[i].getAttribute("alt") && a[i].complete) a[i].removeAttribute("alt");
          tooltip.l(a[i], "mouseover", tooltip.s);
          tooltip.l(a[i], "mouseout", tooltip.h);
        }
      }
      else if (a[i].getAttribute("alt") && a[i].complete)
      {
        a[i].setAttribute(tooltip_attr_name, a[i].getAttribute("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);
        }
      }
    }
    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)));
    /*s = d.getAttribute(tooltip_attr_name);
    re = /  /i;
    tooltip.t.innerHTML = s.replace(re, "<br />");*/
    tooltip.c = setTimeout("tooltip.t.style.visibility = 'visible';", 1);
    tooltip.g = true;
  },

  h: function(e){
    tooltip.t.style.visibility = "hidden";
    // thanks to Alexander Shurkayev for helping me optimise this line :-)
    if (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;

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

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

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

    while (x + t_width + t_extra_width > w_width)
    {
      x -= x + t_width + t_extra_width - w_width;
      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 -= y + t_height + t_extra_height - w_height;
      tooltip.t.style.top = y + "px";
      t_height = window.event ? tooltip.t.clientHeight : tooltip.t.offsetHeight;
    }
  }
}

