function gen_action(p) {
  document.sel_color.action = p + document.sel_color.e.value + "/";
}

function docreset(){
 document.tform.elements[0].selectedIndex=0;
 document.tform.elements[1].selectedIndex=0;
 document.tform.elements[2].selectedIndex=0;
 document.tform.elements[3].selectedIndex=0;
}

function check_form(){
 if(document.tform.typesize.selectedIndex==0){
	err='Укажите поле "ТИПОРАЗМЕР", пожалуйста';
	alert (err)
	return false;
 };
 if(document.tform.diametr.selectedIndex==0){
	err='Необходимо указать поле "ДИАМЕТР"';
	alert (err)
        return false;
 };
}


function linklist(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute("target")=="new")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}

function antiemail(email,domain,t)
 {t = email + "@"+ domain;return t;}

function check_form_call(){
 if(document.ringing.r_name.value == ''){
	err='Укажите поле "ИМЯ", пожалуйста';
	alert (err)
	return false;
 };
 if(document.ringing.r_phone.value == ''){
	err='Необходимо указать поле "ТЕЛЕФОН"';
	alert (err)
    return false;
 };
 if(document.ringing.r_cifr.value != '111'){
	err='Необходимо указать "антиспам код"';
	alert (err)
    return false;
 };
}
function on(oid) {
        var obj = layer(oid);
        var menu = eval("layer('m"+oid+"')");
        menu.setLeft(obj.getAbsoluteLeft()-75);
        menu.setTop(obj.getAbsoluteTop()+obj.getHeight()+0);
        menu.style.display='';
}

function off(oid) {
        var obj = layer(oid);
        var menu = layer('m'+oid);
        menu.style.display='none';
}

function off_img(oid) {
        var obj = layer(oid);
        var menu = layer('m'+oid);
        menu.style.display='none';
}

function show_i(oid,e,dpict){
   var obj = layer(oid);
   var menu = layer('m'+oid);
   if (!e) e = event;
    menu.style.display = 'block';
   if (navigator.appName.indexOf("Netscape") != -1) {
    menu.style.left = e.pageX-155;
    menu.style.top = e.pageY;
   }
   if (navigator.appName.indexOf("Microsoft") != -1) {
    menu.style.left = document.body.scrollLeft + e.clientX-155;
    menu.style.top = document.body.scrollTop + e.clientY;
   }
   else {
    menu.style.left = document.body.scrollLeft + e.clientX-155;
    menu.style.top = document.body.scrollTop + e.clientY;
   }
   document['dim'].src = '/show.php?p=d/'+dpict;
}

function initKLayers(){
  isDOM=document.getElementById?true:false
  isOpera=isOpera5=window.opera && isDOM
  isOpera6=isOpera && window.print
  isOpera7=isOpera && document.readyState
  isMSIE=isIE=document.all && document.all.item && !isOpera
  isStrict=document.compatMode=='CSS1Compat'
  isNN=isNC=navigator.appName=="Netscape"
  isNN4=isNC4=isNN && !isDOM
  isMozilla=isNN6=isNN && isDOM

  if(!isDOM && !isNC && !isMSIE && !isOpera){
    KLayers=false
    return false
  }

  pageLeft=0
  pageTop=0

  KL_imgCount=0
  KL_imgArray=new Array()

  KL_imageRef="document.images[\""
  KL_imagePostfix="\"]"
  KL_styleSwitch=".style"
  KL_layerPostfix="\"]"

  if(isNN4){
    KL_layerRef="document.layers[\""
    KL_styleSwitch=""
  }

  if(isMSIE){
    KL_layerRef="document.all[\""
  }

  if(isDOM){
    KL_layerRef="document.getElementById(\""
    KL_layerPostfix="\")"
  }

  KLayers=true
  return true
}

initKLayers()

// document and window functions:

function KL_getBody(w){
  if(!w) w=window
  if(isStrict){
    return w.document.documentElement
  }else{
    return w.document.body
  }
}

function getWindowLeft(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return w.screenLeft
  if(isNN || isOpera) return w.screenX
}

function getWindowTop(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return w.screenTop
  if(isNN || isOpera) return w.screenY
}

function getWindowWidth(w){
  if(!w) w=window
  if(isMSIE) return KL_getBody(w).clientWidth
  if(isNN || isOpera) return w.innerWidth
}

function getWindowHeight(w){
  if(!w) w=window
  if(isMSIE) return KL_getBody(w).clientHeight
  if(isNN || isOpera) return w.innerHeight
}

function getDocumentWidth(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return KL_getBody(w).scrollWidth
  if(isNN) return w.document.width
  if(isOpera) return w.document.body.style.pixelWidth
}

function getDocumentHeight(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return KL_getBody(w).scrollHeight
  if(isNN) return w.document.height
  if(isOpera) return w.document.body.style.pixelHeight
}

function getScrollX(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return KL_getBody(w).scrollLeft
  if(isNN || isOpera) return w.pageXOffset
}

function getScrollY(w){
  if(!w) w=window
  if(isMSIE || isOpera7) return KL_getBody(w).scrollTop
  if(isNN || isOpera) return w.pageYOffset
}

function preloadImage(imageFile){
  KL_imgArray[KL_imgCount]=new Image()
  KL_imgArray[KL_imgCount++].src=imageFile
}

var KL_LAYER=0
var KL_IMAGE=1

function KL_findObject(what,where,type){
  var i,j,l,s
  var len=eval(where+".length")
  for(j=0;j<len;j++){
    s=where+"["+j+"].document.layers"
    if(type==KL_LAYER){
      l=s+"[\""+what+"\"]"
    }
    if(type==KL_IMAGE){
      i=where+"["+j+"].document.images"
      l=i+"[\""+what+"\"]"
    }
    if(eval(l)) return l
    l=KL_findObject(what,s,type)
    if(l!="null") return l
  }
  return "null"
}

function KL_getObjectPath(name,parent,type){
  var l=((parent && isNN4)?(parent+"."):(""))+((type==KL_LAYER)?KL_layerRef:KL_imageRef)+name+((type==KL_LAYER)?KL_layerPostfix:KL_imagePostfix)
  if(eval(l))return l
  if(!isNN4){
    return l
  }else{
    return KL_findObject(name,"document.layers",type)
  }
}

function layer(name){
  return new KLayer(name,null)
}

function layerFrom(name,parent){
  if(parent.indexOf("document.")<0) parent=layer(parent).path
  return new KLayer(name,parent)
}


// class "KLayer":

function KLayer(name,parent){
  this.path=KL_getObjectPath(name,parent,KL_LAYER)
  this.object=eval(this.path)
  if(!this.object)return
  this.style=this.css=eval(this.path+KL_styleSwitch)
}

KLP=KLayer.prototype

KLP.isExist=KLP.exists=function(){
  return (this.object)?true:false
}

function KL_getPageOffset(o){
  var KL_left=0
  var KL_top=0
  do{
    KL_left+=o.offsetLeft
    KL_top+=o.offsetTop
  }while(o=o.offsetParent)
  return [KL_left, KL_top]
}

KLP.getLeft=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera) return o.offsetLeft-pageLeft
  if(isNN4) return o.x-pageLeft
}

KLP.getTop=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera) return o.offsetTop-pageTop
  if(isNN4) return o.y-pageTop
}

KLP.getAbsoluteLeft=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera) return KL_getPageOffset(o)[0]-pageLeft
  if(isNN4) return o.pageX-pageLeft
}

KLP.getAbsoluteTop=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera) return KL_getPageOffset(o)[1]-pageTop
  if(isNN4) return o.pageY-pageTop
}

KLP.getWidth=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera7) return o.offsetWidth
  if(isOpera) return this.css.pixelWidth
  if(isNN4) return o.document.width
}

KLP.getHeight=function(){
  var o=this.object
  if(isMSIE || isMozilla || isOpera7) return o.offsetHeight
  if(isOpera) return this.css.pixelHeight
  if(isNN4) return o.document.height
}

KLP.getZIndex=function(){ //deprecated
  return this.css.zIndex
}

KLP.setLeft=KLP.moveX=function(x){
  x+=pageLeft
  if(isOpera){
    this.css.pixelLeft=x
  }else if(isNN4){
    this.object.x=x
  }else{
    this.css.left=x+"px"
  }
}

KLP.setTop=KLP.moveY=function(y){
  y+=pageTop
  if(isOpera){
    this.css.pixelTop=y
  }else if(isNN4){
    this.object.y=y
  }else{
    this.css.top=y+"px"
  }
}

KLP.moveTo=KLP.move=function(x,y){
  this.setLeft(x)
  this.setTop(y)
}

KLP.moveBy=function(x,y){
  this.moveTo(this.getLeft()+x,this.getTop()+y)
}

KLP.setZIndex=KLP.moveZ=function(z){ //deprecated
  this.css.zIndex=z
}

KLP.setVisibility=function(v){
	if (this.css) {
		this.css.visibility=(v)?(isNN4?"show":"visible"):(isNN4?"hide":"hidden")
	} else {
		// IE 5.xx fix -- the rest is waiting...
		this.style.visibility=(v)?(isNN4?"show":"visible"):(isNN4?"hide":"hidden")
	}
}

KLP.show=function(){
  this.setVisibility(true)
}

KLP.hide=function(){
  this.setVisibility(false)
}

KLP.isVisible=KLP.getVisibility=function(){
  return (this.css.visibility.toLowerCase().charAt(0)=='h')?false:true
}

KLP.setBgColor=function(c){
  if(isMSIE || isMozilla || isOpera7){
    this.css.backgroundColor=c
  }else if(isOpera){
    this.css.background=c
  }else if(isNN4){
    this.css.bgColor=c
  }
}


