window.onload = function(e) { //читаем куку для стиля
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
  if (document.getElementById("Rambler")) {document.getElementById("Rambler").firstChild.src = "/i/1.gif";}
  anchorsBlank();
}
var ie = (document.all)? true : false
var nn6 = (!ie && document.getElementById)? true : false
var nn4 = (document.layers)? true : false
function ppp(){
	popup('order','/index.sema?a=questionnaire&no_design=1',550,500);
}
function popup(name, uri, wdt, hgt) {
var pos = ''
if (nn4 || nn6 || ie) {
if ( (screen.height < 481) && (hgt > 400) ) { hgt = 400 }
posX = Math.round((screen.width - wdt) / 2)
posY = Math.round((screen.height - hgt) / 2)
pos = (nn4 || nn6)? ",screenX="+posX+",screenY="+posY : ",left="+posX+",top="+posY
}
popupWindow = window.open(uri, name, "status=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes,location=no,width="+wdt+",height="+hgt+pos)
popupWindow.focus()
}
window.onunload = function(e) { // кидаем куку со стилем при выходе со страницы
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}


function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}
function getActiveStyleSheet() {
var i, a;
 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
  if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}
 function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}





////////////////

function anchorsBlank(){
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i < anchors.length; i++) {
		if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "blank") {
		anchors[i].target = "_blank";
		}
	}
}


/////////////////////




function view(wurl,ww,wh,wname) {

	wleft=window.screenLeft;
	wtop=window.screenTop;

	w=document.body.clientWidth;
	h=document.body.clientHeight;

	w1=wleft+(w/2)-(ww/2);
	h1=wtop-40;

	feat='"toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=no,scrollbars=yes,resizable=yes,width='+ww+',height='+wh+',left='+w1+',top='+h1+'"';

	newWindow=window.open(wurl,wname, feat);
//	newWindow.resizeTo(ww+28, wh+27);
}

// hide mail address function
var myMail = 'office';
var myDomain = 'r-e-k-l-a-m-a.ru';
function insertMail(cl, pic) {
	var mailString = myMail+'@'+myDomain;
	document.write(' <a href="mailto:'+mailString+'"');
	if (cl)	document.write(' class="'+cl+'"');
	document.write('>');
	if (!pic) {
	document.write(mailString);
	} else {
	document.write(pic);
	}
	document.write('</a> ');
}


function kuda(tuda) { document.location.replace(tuda); return false; }
