<!--//
//set up layer call
var isIE, isNS, isNS6, isDOM, lR, sR, vis, invis, myTimeOut, goName;
	if (document.all) {isIE= true;lR="document.all.";rR="";sR=".style";vis="visible";invis="hidden";}
	if (document.layers){isNS = true;lR="document.layers.";rR="";sR="";vis="show";invis="hide";}
	if (document.getElementById &&!isIE) {isDOM=true;lR = "document.getElementById('";rR="')";sR = "').style";invis ="hidden";vis = "visible"}
	if (isDOM == true && navigator.appName =="Netscape") isNS6 = true;

function display(nam,val)
{
if (val>0) {eval(""+lR+nam+sR+".visibility='"+vis+"';");} else {eval(""+lR+nam+sR+".visibility='"+invis+"';");}
if (!isNS) if (val>0) {eval(""+lR+nam+sR+".display='block';");} else {eval(""+lR+nam+sR+".display='none';");}
return;
}
	
function checkform()
{
if (arguments.length>0)
{
if (arguments.length>1)
 { 
 for (var i=1;i<arguments.length;i++)
  {
  if (document.forms[arguments[0]].elements[arguments[i]].value=="") 
     {
	 alert("Вы не заполнили обязательное поле!");
	 document.forms[arguments[0]].elements[arguments[i]].focus();
	 return false;
	 }
  }
 } else 
 {
 for (var i=0;i<document.forms[arguments[0]].elements.length;i++)
  {
  if (document.forms[arguments[0]].elements[i].value=="") 
     {
	 alert("Вы не заполнили обязательное поле!");
	 document.forms[arguments[0]].elements[i].focus();
	 return false;
	 }
   } 
 }//>1
}//>0
return true;
}

function popup(url,w,h,params)
{
open(url, "win","width="+w+",height="+h+",status=no,toolbar=no,menubar=no"+params);
}

function showpic(nam,w,h,alt,val)
{
var rand=Math.floor(Math.random()*1000);
if (nam!="")
 {
myWin= open("", "win"+rand,"width="+w+",height="+h+",status=no,toolbar=no,menubar=no");

  // открыть объект document для последующей печати 
  myWin.document.open();
  
  // генерировать новый документ 
  myWin.document.write("<html><head><title>"+alt+"</title></head>");
  myWin.document.write("<body bgcolor=#FFFFFF text=#000000 leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>");
  if (val>=4) {
  myWin.document.write("<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" WIDTH=\""+w+"\" HEIGHT=\""+h+"\" id=\"fla"+rand+"\" ALIGN=\"\">");
  myWin.document.write("<PARAM NAME=movie VALUE=\""+nam+"\">"); 
  myWin.document.write("<PARAM NAME=quality VALUE=high>");
  myWin.document.write("<PARAM NAME=bgcolor VALUE=#FFFFFF>");
  myWin.document.write("<EMBED src=\""+nam+"\" quality=high bgcolor=#FFFFFF  WIDTH=\""+w+"\" HEIGHT=\""+h+"\" NAME=\"fla"+rand+"\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>");
  } else
  {
  myWin.document.write("<img src='"+nam+"' width='"+w+"' height='"+h+"' alt='"+alt+"'>");
  }
  myWin.document.write("</body></html>");
  // закрыть документ - (но не окно!)
  myWin.document.close();
 
 }
}

function q(txt)
{
if (!txt) txt="Вы действительно хотите удалить данную запись?";
return confirm(txt);
}

var focus_element="";
function add_text(form,element,left,right)
{
if (element=='') element=focus_element;
if (element=='') return;
document.forms[form].elements[element].focus();
sel=document.selection.createRange();
sel.text=""+left+sel.text+right;
return;
}

function add_obj_text(obj,nam,left,right)
{
if (!obj) return;
obj.all[nam].focus();
sel=obj.selection.createRange();
sel.text=""+left+sel.text+right;
return;
}

function set_focus_element(value)
{
focus_element=value;
}

function set_form_element_value(form,el,val)
{
if (document.forms[form]) if (document.forms[form].elements[el])
document.forms[form].elements[el].value=""+val;
return;
}

function showselect()
{
if (document.forms[arguments[0]].elements[arguments[1]].length>0)
{
uniqueid=document.forms[arguments[0]].elements[arguments[1]].options[document.forms[arguments[0]].elements[arguments[1]].selectedIndex].value;
} else 
{
uniqueid=0;
}
if (uniqueid=='') uniqueid=0;
		datalist=document.forms[arguments[0]].elements[arguments[3]];
		document.forms[arguments[0]].elements[arguments[2]].length=0;
	  if (arguments[4]) {var txt=arguments[4];} else {var txt="";}
	   if (txt) document.forms[arguments[0]].elements[arguments[2]].options[document.forms[arguments[0]].elements[arguments[2]].options.length]=new Option(''+txt,'');
		for (posindex=0;posindex<datalist.length;posindex++)
		{
			parentid=datalist[posindex].value.substr(0,datalist[posindex].value.indexOf(','));
			if (parentid==uniqueid)
			{
				parentid=datalist[posindex].value.substr(datalist[posindex].value.indexOf(',')+1,datalist[posindex].value.length-datalist[posindex].value.indexOf(','));
				dataname=datalist[posindex].text;

				document.forms[arguments[0]].elements[arguments[2]].options[document.forms[arguments[0]].elements[arguments[2]].options.length]=new Option(dataname,parentid);
				if (arguments[5]) if (document.forms[arguments[0]].elements[arguments[2]].options.length>0) document.forms[arguments[0]].elements[arguments[2]].options[document.forms[arguments[0]].elements[arguments[2]].options.length-1].selected=true;
			}
		}
return;
}


function showselected()
{
for (var i=1;i<document.forms[arguments[0]].elements[arguments[1]].length;i++)
 {
 if (document.forms[arguments[0]].elements[arguments[1]].options[i].value==arguments[2]) 
   {
   document.forms[arguments[0]].elements[arguments[1]].options[i].selected=true;
   break;
   }
 }
return; 
}


function setcolor(obj)
{
var col1=arguments[1];
var col2=arguments[2];
if (col1==null) {col1="#FF0000";}
if (col2==null) {col2="#000000";}
if (obj.style) 
 {
 obj.style.color=""+col1;
 var nam=obj.name;
 } else
 {
var nam=obj;
 }

for (var i=0;i<document.anchors.length;i++)
{
if (document.anchors[i].name==nam) {document.anchors[i].style.color=""+col1;} else {document.anchors[i].style.color=""+col2;}
}
return;
}
/////////////////SET COLOR OF FIELDS///////////////////////
var marked_row = new Array;

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function
//-->
