
 // Разное

function set_bg(id, file){
		el = document.getElementById(id);
		el.style.backgroundImage = 'url(images/' + file +')';
}

function set_bg_color(id, col){
		el = document.getElementById(id);
		el.style.background = col;
}

function set_border(id, bordertype, width, type, col) { // Рисуем рамку вокруг объекта (ид объекта, с какой стороны рамка, толщина, тип, цвет)
	if (bordertype == 'none') {
		document.getElementById(id).style.border = "0px";
		document.getElementById(id).style.borderStyle = "none";
	} else { 
		if (bordertype == 'all') {
			document.getElementById(id).style.border = width;
			document.getElementById(id).style.borderStyle = type;
			document.getElementById(id).style.borderColor = col;
		} else {
			if (bordertype == 'top') {
				document.getElementById(id).style.borderTop = width;
				document.getElementById(id).style.borderTopStyle = type;
				document.getElementById(id).style.borderTopColor = col;
			} else {
				if (bordertype == 'bottom') {
					document.getElementById(id).style.borderBottom = width;
					document.getElementById(id).style.borderBottomStyle = type;
					document.getElementById(id).style.borderBottomColor = col;
				} else {
					if (bordertype == 'left') {
						document.getElementById(id).style.borderLeft = width;
						document.getElementById(id).style.borderLeftStyle = type;
						document.getElementById(id).style.borderLeftColor = col;
					} else {
						if (bordertype == 'right') {
							document.getElementById(id).style.borderRight = width;
							document.getElementById(id).style.borderRightStyle = type;
							document.getElementById(id).style.borderRightColor = col; }
					}
				}
			}		
		}
	}

}

function color_link(id, col){
  document.getElementById(id).style.color=col;
}

function line_link(id){
  document.getElementById(id).style.textDecoration='underline';
}

function unline_link(id){
  document.getElementById(id).style.textDecoration='none';
}

function clearText(id, def){
  if (id.value == def) id.value = '';
}

function writeText(id, def){
  if (id.value == '') id.value = def;
}

function openWindow(url, width, height){
  w = window.innerWidth ? window.innerWidth : document.body.clientWidth;
  h = window.innerHeight ? window.innerHeight : document.body.clientHeight;
  x = (w - width)/2;
  y = (h - height)/2;
  onlineWindow= window.open(url, "_blank", "left="+x+",top="+y+",height="+height+",width="+width+",height="+height+",status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
}

function checkForm(formName, fields, caps){
  var flag=true;
  cnt = fields.length;
  for (i = 0; i < cnt; i++){
    if (document['forms'][formName][fields[i]].value==''){
	  flag=false; window.alert('Не заполнено поле "'+caps[i]+'"');
	  return flag;
	}
  }
  return flag;
}

 // Работа с картинками

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null) {
      document.MM_sr[j++]=x; 
      if(!x.oSrc) x.oSrc=x.src; 
      x.src=a[i+2];}
}

 // Работа со слоями

function browser_init() {
	NC = (document.layers);
	IE = (document.all);
	Opera = (document.getElementById);
}

function hidelayer(n) {
	browser_init();
	if(IE) eval('document.all["layer'+n+'"].style.visibility = "hidden"'); 
	if(NC) eval('document.layers["layer'+n+'"].visibility = "hidden"');
	if(Opera) eval('document.getElementById("layer'+n+'").style.visibility = "hidden"');
}

function showlayer(n) {
	browser_init();
	if(IE) eval('document.all["layer'+n+'"].style.visibility = "visible"'); 
	if(NC) eval('document.layers["layer'+n+'"].visibility = "visible"');
	if(Opera) eval('document.getElementById("layer'+n+'").style.visibility = "visible"');
}



