window.onload=modifylinks

var id_link=/(^|\s+)sv($|\s+)/i //регулярное выражение на экране для имя_класса в элемент
var id_img=/(^|\s+)sv($|\s+)/i

// Функция замены
function str_replace(search, replace, subject) {
return subject.split(search).join(replace);
}

function modifylinks()
{

  for (i=0; i<document.links.length; i++)
  {
    if (typeof document.links[i].className=="string" && document.links[i].className.search(id_link)!=-1)
    {
      of_img(this.id)
    }
  }

  for (i=0; i<document.links.length; i++)
  {
    if (typeof document.links[i].className=="string" && document.links[i].className.search(id_link)!=-1)
    {
    document.links[i].onmouseover=function()
                                           {
                                            on_link(this.id);
                                            on_img(this.id)
                                           }
    document.links[i].onmouseout=function()
                                          {
                                           of_link(this.id);
                                           of_img(this.id)
                                          }
    }
  }

    for (i=0; i<document.images.length; i++)
  {
     if (typeof document.images[i].className=="string" && document.images[i].className.search(id_img)!=-1)
    {
    document.images[i].onmouseover=function()
                                           {
                                            on_link_r(this.id);
                                            on_img(this.id);
                                            document.getElementById(this.id).style.border = '1px solid FF0000'
                                           }
    document.images[i].onmouseout=function()
                                          {
                                           of_link(this.id);
                                           of_img(this.id);
                                           document.getElementById(this.id).style.border = '1px solid FFFFFF'
                                          }
    }
  }
}

function on_img(n){
  if(n)
  {
//   document.images[n].style.filter='progid:DXImageTransform.Microsoft.BasicImage(grayscale=0)'
//   document.getElementById(n).style.border = '1px solid FF0000'
   document.images[n].style.border = '1px solid FF0000'
  ;}
}

function of_img(n){
  if(n)
  {
//   document.images[n].style.filter='progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)'
//   document.getElementById(n).style.border = '1px solid FFFFFF'
   document.images[n].style.border = '1px solid FFFFFF'
 ;}
}


function on_link(n){
  if(n){document.getElementById(n).style.color = "#0099FF";}
}

function on_link_r(n){
  if(n){document.getElementById(n).style.color = "#FF0000";}
}

function of_link(n){
  if(n){document.getElementById(n).style.color = "#000099";}
}


function img_order_show()
{
 var uri = 'http://localhost/order/0-0-n.html'
 if (document.Form_img_order_show.myCheckBox.checked)
 {
 document.getElementById("img_order_show").value = 1;
 go_to_(uri);
 }else{
 document.getElementById("img_order_show").value = 0;
 go_to_(uri);
 }
}

function go_to_(tr_url)
{

location.href=tr_url; // ячейки r-вертикаль с-горизонт
return false;

}

function show_jur(obj)
{
	if (document.getElementById(obj).style.display == 'none') {
		document.getElementById(obj).style.display = 'block';
	} else {
		document.getElementById(obj).style.display = 'none';
	}
}

function show_address(obj)
{
  if (document.getElementById("receipt").value == 1) {
		document.getElementById(obj).style.display = 'none';
	} else {
		document.getElementById(obj).style.display = 'block';
	}
}

function show_jur1(id)
{
  if (this.st == 1) return true;
  var obj = document.getElementById(id);
  obj.style.display = 'block';
  this.maxh = obj.offsetHeight;
  obj.style.display = 'none';

  function resize()
  {
    if (obj.offsetHeight >= this.maxh)
    {
      obj.style.height = this.maxh; this.st = 0;
    }
    else
    {
      this.st = 1;
      var h = obj.offsetHeight + 13;
      obj.style.height = h + 'px';
      setTimeout(resize, 3);
    }
  }
  resize();
  obj.style.display = 'block';
}

  //Функция, которая делает видимым наш слой и вкладывает в него необходимый текст.
  function helpBox1(id, title, text) {
  r=getAbsolutePosition(document.getElementById(id));
  document.getElementById('help1').style.left = r.x + 395 + "px";
  document.getElementById('help1').style.top = r.y + 25 + "px";
      //Вкладываем текст
    document.getElementById('helpTitle1').innerHTML = title;
    document.getElementById('helpText1').innerHTML = text;
  //Делаем видимым\невидимым
    if(document.getElementById('help1').style.display == 'none'){
      document.getElementById('help1').style.display = 'block';
    }else{
      document.getElementById('help1').style.display = 'none';
    }
  }

  function getAbsolutePosition ( elem ) {
  var r = {x:0,y:0};

  while (elem) {
  r.x += (elem.offsetLeft + elem.clientLeft);
  r.y += (elem.offsetTop + elem.clientTop);
  elem = elem.offsetParent;
  }

  return r;
  }
  
function scrollToTop() {
   if (document.body.scrollTop > "0") {
      document.body.scrollTop -= "1000";
      scroll(0,document.body.scrollTop);
      setTimeout("scrollToTop()",10);
   }
}

var bigsize = "500";
var smallsize = "150";
var img_height;
var img_width;

function changeSizeImage(im) {
  if((im.height > smallsize)||(im.width > smallsize))
  {
    SizeImage(im, smallsize);
    im.height = img_height;
    im.width = img_width;
    f_im('t_'+im.id);
  }else{
    im.removeAttribute("height");
    im.removeAttribute("width");
    if(im.width>bigsize)
    {
      SizeImage(im, bigsize);
      im.height = img_height;
      im.width = img_width;
      f_im('t_'+im.id);
    }
  }
}

function SizeImage(im, im_size) {
  if (im.width>im.height)
  {
    img_height=Math.round(im.height / (im.width / im_size));
    img_width=im_size;
  }
  if (im.width<im.height)
  {
    img_width=Math.round(im.width / (im.height / im_size));
    img_height=im_size;
  }
  if (im.width==im.height)
  {
    img_width=im_size;
    img_height=im_size;
  }
}

function f_im(id)
{
document.getElementById(id).focus();
}

