var d=document;

var ua = navigator.userAgent;
var ie = (ua.indexOf("MSIE") >= 0);
var ie5_6 = (ie && (ua.indexOf("MSIE 5") >= 0 || ua.indexOf("MSIE 6") >= 0));
var ns = ((ua.indexOf("Netscape") >= 0) || (ua.indexOf("Firefox") >= 0) || (ua.indexOf("Gecko") >= 0));
var op = (ua.indexOf("Opera") >= 0);
if (op) {
 ie = false;
 ie5_6 = false;
}

var shopImg = new Array;

function el(id) {
 if(d.getElementById)return d.getElementById(id);
 if(d.all)return d.all(id);
 if(d.layers)return d.layers(id);
}

function getSource(e) {
 return (ua.indexOf("Gecko") != -1) ? e.target : window.event.srcElement;
}

function isShIm(o) {
 if (o.id.substr(0,5) == 'shop_') return true;
 return false;
}

function fMouseOver(e) {
 var o = getSource(e);
 if (isShIm(o)) imgChange(o, 'on');
}

function fMouseOut(e) {
 var o = getSource(e);
 if (isShIm(o)) imgChange(o, 'off');
}

function fLoad(e) {
 var o = getSource(e);
 if (isShIm(o)) preLoad(o);
}

function preload() {
 im = d.images;
 for (var i=0; i<im.length; i++) {
  if (isShIm(im[i])) {
   var shop = im[i].id.substr(5);
   shopImg[shop] = new Image();
   shopImg[shop].src = main_domain+'img/shop/'+shop+'/a_hover.png';
  }
 }
}

function imgChange(obj, toDo) {
 var shop = obj.id.substr(5);
 if (shop !== current_domain) {
  var p = main_domain + 'img/shop/' + shop;
  var i = d.getElementById('shop_' + shop);
  if (toDo == 'on') i.src = p + '/a_hover.png';
  else i.src = p + '/a.png';
 }
}

function auth() {
 var f = d.forms.auth;
 var n = f.user_name;
 var p = f.user_pass;
 if (!ie) {p.type = 'text'; p.value = 'пароль';}
 if (n.value == 'имя') {n.onfocus = function() {n.value = ''}}
 if (p.value == 'пароль') {p.onfocus = function() {if (!ie) p.type = 'password'; p.value = ''; p.focus();}}
}

d.onmouseover = fMouseOver;
d.onmouseout = fMouseOut;

function showPhoto(o) {
 var phgwin = open(o.href, 'phg', "minimizable=yes,scrollbars=yes");
 phgwin.focus();
 return false;
}

