bcolormin = 60;
bcolormax = 255;
bcolor = 100;
bplus = true;
bginc = 3;

cid = '';
gg1 = 150;
gg2 = 150;
gg3 = 150;
gg4 = 150;
gg5 = 150;
mm6 = 0;
mm11 = 0;
mm12 = 0;
mm13 = 0;
mm14 = 0;

lpos = 0;

browser = navigator.appName;
b_version = navigator.appVersion;
version = parseFloat(b_version);

function parseGET(url) {  
        if(!url || url == '') url = document.location.search;
        if(url.indexOf('?') < 0) return Array();
        url = url.split('?');
        url = url[1];
        var GET = [];
        var params = [];
        var keyval = [];
        if(url.indexOf('#')!=-1) {    
                anchor = url.substr(url.indexOf('#')+1);
                url = url.substr(0,url.indexOf('#'));
        }
        if(url.indexOf('&') > -1) params = url.split('&');
        else params[0] = url;
        for (i=0; i<params.length; i++) {
                if(params[i].indexOf('=') > -1) keyval = params[i].split('=');
                else { keyval[0] = params[i]; keyval[1] = true; }
                GET[keyval[0]]=keyval[1];
        }
        return (GET);
}

var $_GET = parseGET();

function str_replace(search, replace, subject) {
  return subject.split(search).join(replace);
} 

function blinkText(id) {
  if (document.getElementById(id)) {
    document.getElementById(id).style.color = 'rgb(' + bcolor + ', ' + bcolor + ', ' + bcolor + ')';
    if (bplus) {
      if (bcolor <= bcolormax) bcolor = bcolor + bginc;
      else bplus = false;
    }
    else {
      if (bcolor >= bcolormin) bcolor = bcolor - bginc;
      else bplus = true;
    }
    window.setTimeout("blinkText('"+id+"')",1); 
  }
} 


function hideAll() {
  for (i=1; i<=20; i++) hideItem('phone_' + i);
  if (document.getElementById('select_large')) document.getElementById('select_large').style.display = 'none';
}

function showItem(obj) {
  hideAll();
  if (document.getElementById(obj.id + '_info'))
    document.getElementById(obj.id + '_info').style.display = 'block';
}

function hideItem(id) {
  if (document.getElementById(id + '_info'))
    document.getElementById(id + '_info').style.display = 'none';
  if (document.getElementById('select_large')) document.getElementById('select_large').style.display = 'block';
}

function line (uv1) {
  if (lpos <= 10) {
    document.getElementById(uv1).style.paddingLeft = lpos + 'px';
    lpos++;
    setTimeout('line("'+uv1+'")',50); 
  }
}

function slider(first, inc) {
  if ($_GET['speed']) speed = $_GET['speed'];
  else speed = 0;
  speed *= 1;

  if (speed == 0) speed = 5000;

  var pos = document.getElementById('index_data_cell').style.backgroundPosition;
  pos = str_replace('px 50%', '', pos);
  pos *= 1;
  if (first) {
    if (inc) {
      if (browser == "Opera") pos += 8;
      else if (b_version.indexOf('iPad', 0) > 0) pos += 1024;
      else pos += 32;
    }
    else {
      if (browser == "Opera") pos -= 8;
      else if (b_version.indexOf('iPad', 0) > 0) pos -= 1024;
      else pos -= 32;
    }
    document.getElementById('index_data_cell').style.backgroundPosition = pos + 'px 50%';
  }
  if ((pos % 1024 == 0)||(pos == 0))
    indexTimeout = setTimeout('slider(true, ' + inc + ')', speed);
  else
    indexTimeout = setTimeout('slider(true, ' + inc + ')', 1);
}

function init() {
  blinkText('welcome');
  var uri = window.location.href;
  uri = str_replace('www.', '', uri);
  if ((uri == 'http://spblux.ru/')||(uri == 'http://spblux.ru/index.php')||($_GET['speed'])) {
    slider(false, true);
    document.getElementById('index_data_cell').innerHTML += '<img src="/images/arrow_flypage_left.png" class="arrow_flypage_left" onclick="clearTimeout(indexTimeout); slider(true, false)" /><img src="/images/arrow_flypage_right.png" class="arrow_flypage_right" onclick="clearTimeout(indexTimeout); slider(true, true)" />';
  }
  if ((browser == 'Netscape')&&(document.getElementById('showAdditionalImgNamesDiv'))) {
    showAdditionalImgNames();
  }
}

function showAdditionalImgNames() {
  m_top = -40;
  if (document.getElementById('vmMainPage').getElementsByTagName('div')[2])
    elements = document.getElementById('vmMainPage').getElementsByTagName('div')[2].getElementsByTagName('a');
  else
    elements = document.getElementById('vmMainPage').getElementsByTagName('div')[1].getElementsByTagName('a');
  j = 1;
  y = 1;
  k = 1;
  for(i = 0, s = elements.length; i < s; i++) {
    if ((elements[i].rel != '')&&(elements[i].rel != 'lightbox[product1]')) {
      if (browser == "Microsoft Internet Explorer") {
	if ((b_version.replace("MSIE 8", "") != b_version)||(b_version.replace("MSIE 9", "") != b_version)) {
          if (j == 1) m = 0;
          if (j == 2) m = 225;
          if (j == 3) m = 450;
	}
	else m = -225;
      }
      else {
        if (j == 1) m = 0;
        if (j == 2) m = 225;
        if (j == 3) m = 450;
	if (browser == "Opera") {
	  if (j == 1) {
	    if (y == 1) {
              if (version < 9.8) {
		if (version = 9.61) m_top = -40;
		else m_top = 164;
	      }
	      else m_top = -28;
	    }
	    else m_top = 152;
	  }
	  else m_top = -40;
          if (version >= 9.8) {
	    m_top -= 10;
	    if (y == 1) m_top -= 20;
	  }
	}
      }
      if ((browser == 'Opera')&&(y == 1)) m_top += 10;
      if (browser == 'Microsoft Internet Explorer') {
	if (y == 1) m_top = 145;
	else m_top = 145;
	if ((b_version.replace("MSIE 8", "") != b_version)||(b_version.replace("MSIE 9", "") != b_version)) m_top = -40;
      }
      elements[i].innerHTML = elements[i].innerHTML + '<div id="abs_item_' + k + '" style="position:absolute; margin-left:' + m + 'px; margin-top:' + m_top + 'px; width:225px; text-align:center; font-weight:bold; height:20px; text-decoration:none!important">' + str_replace(', ', '<br/><span style="color:#FDE0C0">', elements[i].title) + '</span></div>';
      if ((browser == 'Opera')&&(version == 9.8)&&((k == 2)||(k == 3))) {
        if (document.getElementById('abs_item_' + k).offsetTop != document.getElementById('abs_item_1').offsetTop) {
          m_top += 12;
          document.getElementById('abs_item_' + k).style.marginTop = m_top + 'px';
        }
      }
      k++;
      j++;
      if (j == 4) {
	j = 1;
	y++;
      }
    }
  }
}

function zoomin (uv1, position, image) {
  if (cid.indexOf(uv1) + 1) return;
  if (image) ssr=170;
  else ssr = 10;
  if (ssr > position) { 
     if(navigator.appName == "Microsoft Internet Explorer") step = 4; 
     else step = 1;
     position = position+step;
  } 
  else return;

  if (uv1 == 'g1') gg1 = position;
  if (uv1 == 'g2') gg2 = position;
  if (uv1 == 'g3') gg3 = position;
  if (uv1 == 'g4') gg4 = position;
  if (uv1 == 'g5') gg5 = position;
  if (uv1 == 'mm_6') mm6 = position;
  if (uv1 == 'mm_11') mm11 = position;
  if (uv1 == 'mm_12') mm12 = position;
  if (uv1 == 'mm_13') mm13 = position;
  if (uv1 == 'mm_14') mm14 = position;

  if (image) document.getElementById(uv1).width = position; 
  else document.getElementById(uv1).style.paddingLeft = position + 'px';

  if (image) setTimeout('zoomin("'+uv1+'",'+position+', '+image+')',1); 
  else setTimeout('zoomin("'+uv1+'",'+position+', '+image+')',20); 
}

function zoomout (uv1, position, image) {
  if (uv1 == 'g1') position = gg1;
  if (uv1 == 'g2') position = gg2;
  if (uv1 == 'g3') position = gg3;
  if (uv1 == 'g4') position = gg4;
  if (uv1 == 'g5') position = gg5;
  if (uv1 == 'mm_6') position = mm6;
  if (uv1 == 'mm_11') position = mm11;
  if (uv1 == 'mm_12') position = mm12;
  if (uv1 == 'mm_13') position = mm13;
  if (uv1 == 'mm_14') position = mm14;

  if (image) ssd=150;
  else ssd=0;
  if (ssd < position) {
     if (!(cid.indexOf(uv1) + 1)) cid += uv1;
     if(navigator.appName == "Microsoft Internet Explorer") step = 4; 
     else step = 1;
     position = position-step; 
  } 
  else {cid = str_replace(uv1, "", cid); return;}

  if (uv1 == 'g1') gg1 = position;
  if (uv1 == 'g2') gg2 = position;
  if (uv1 == 'g3') gg3 = position;
  if (uv1 == 'g4') gg4 = position;
  if (uv1 == 'g5') gg5 = position;
  if (uv1 == 'mm_6') mm6 = position;
  if (uv1 == 'mm_11') mm11 = position;
  if (uv1 == 'mm_12') mm12 = position;
  if (uv1 == 'mm_13') mm13 = position;
  if (uv1 == 'mm_14') mm14 = position;

  if (image) document.getElementById(uv1).width = position; 
  else document.getElementById(uv1).style.paddingLeft = position + 'px';

  if (image) setTimeout('zoomout("'+uv1+'",'+position+','+image+')',1);
  else setTimeout('zoomout("'+uv1+'",'+position+','+image+')',20);
} 

if (navigator.userAgent.indexOf("Chrome") != -1)
  document.write('<link href="/css/styles_chrome.css" rel="stylesheet" type="text/css" />');

if (navigator.userAgent.indexOf("Linux") != -1) {
  document.write('<link href="/css/styles_nix.css" rel="stylesheet" type="text/css" />');
  if (browser == "Opera") document.write('<link href="/css/styles_o_nix.css" rel="stylesheet" type="text/css" />');
}
if (b_version.indexOf('iPad', 0) > 0) document.write('<link href="/css/styles_ipad.css" rel="stylesheet" type="text/css" />');
if (b_version.indexOf('iPhone', 0) > 0) document.write('<link href="/css/styles_iphone.css" rel="stylesheet" type="text/css" />');

var uri = window.location.href;
uri = str_replace('www.', '', uri);
if (((uri == 'http://spblux.ru/gallery-view.html')||(uri.indexOf('/body/') != -1))&&(browser == 'Opera'))
  document.write('<link href="/css/styles_o.css" rel="stylesheet" type="text/css" />');

