var imgpath = "/images/site";
function change_sign(l){
/*
	var id = l;
	document.getElementById(l).src= imgpath + "/_.gif";
	document.getElementById(l).name="open";
	if(id == 'img11'){
		if(document.getElementById('img12')){
			document.getElementById('img12').src = imgpath + "/+.gif";
			document.getElementById('img12').name="close";
		}
		if(document.getElementById('img13')){
			document.getElementById('img13').src = imgpath + "/+.gif";
			document.getElementById('img13').name="close";
		}
	}
	if(id == 'img12'){
		if(document.getElementById('img11')){
			document.getElementById('img11').src = imgpath + "/+.gif";
			document.getElementById('img11').name="close";
		}
		if(document.getElementById('img13')){
			document.getElementById('img13').src = imgpath + "/+.gif";
			document.getElementById('img13').name="close";
		}
	}
	if(id == 'img13'){
		if(document.getElementById('img11')){
			document.getElementById('img11').src = imgpath + "/+.gif";
			document.getElementById('img11').name="close";
		}
		if(document.getElementById('img12')){
			document.getElementById('img12').src = imgpath + "/+.gif";
			document.getElementById('img12').name="close";
		
		}
	}
	if(id == 'imgm'){
		if(document.getElementById('img11')){
			document.getElementById('img11').src = imgpath + "/+.gif";
			document.getElementById('img11').name="close";
		}
		if(document.getElementById('img12')){
			document.getElementById('img12').src = imgpath + "/+.gif";
			document.getElementById('img12').name="close";
		}
		if(document.getElementById('img13')){
	    	document.getElementById('img13').src = imgpath + "/+.gif";
	    	document.getElementById('img13').name="close";
	    }
	}   */
}

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
function rotate_img(img2){
	img1 = document.getElementById('imgObj').getElementsByTagName('img')[0];
	if (isDOM && isMSIE && img1.filters[0]){
		img1.filters[0].Apply();
	}
    img1.src = img2;
    if (isDOM && isMSIE && img1.filters[0]){
        img1.filters[0].play();
    }
}


function rotate_init(sign_id,main_src,img2,lnk){ 
	var links = document.getElementsByTagName("A");
	for(var i=0; i<links.length; i++){
		if(links[i].className=='fotosItemLnkSelect')  {links[i].className="fotosItemLnk"; links[i].name=""}
	}
	if(lnk.className=='fotosItemLnk'){ 
		lnk.className='fotosItemLnkSelect';	
		lnk.name="curlink"
	}
		change_sign(sign_id);
		rotate_img(img2);
		
		
	/*}else{ 
		rotate_img(main_src);
		if(document.getElementById(sign_id)){
			document.getElementById(sign_id).src = imgpath + "/+.gif";
			document.getElementById(sign_id).name="close";
		}
    }*/
}

function setSelClass(obj){
	if(obj.className=="fotosItemLnk"){
		obj.className="fotosItemLnkSelect"
	}
}
function restoreClass(obj){
	if(obj.className=="fotosItemLnkSelect" && obj.name!="curlink"){
		obj.className="fotosItemLnk"
	}

}

function openimg(url,w,h,scr,title){
    var x=(screen.width/2)-(w/2); var y=(screen.height/2)-(h/2);
    if(x==null || y==null) x=y=10;
    if(pup != null && !pup.closed) pup.close();
    if(scr == null) scr="no";
    
    options="height="+h+", width="+w+", left="+x+", top="+y+", scrollbars="+scr+", resizable=yes, align=center '";

    pup=window.open('','',options); 
    pup.document.open();
    pup.document.write("<html><head><title>Foto");
    

    
	pup.document.write("</title></head><body bgcolor=\"#E5ECFA\">");
	
	pup.document.write("<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");

	pup.document.write("<td style=\"border:1px solid #fff\" ><img height=\""+(h-20)+"\"  width=\""+(w-20)+"\"  onclick=\"window.close()\" src=\""+url+"\"/></td></TR></TABLE>");
	pup.document.write("</body></html>");
    pup.document.close();

    pup.focus();
}

	function selected_fon(td,id){
		td.className += "_select";
	}
	function restore_fon(td,id){
		td.className = td.className.substring(0,td.className.length-7);
	}

var pup = null;

function img_on(imgName,imgTarg) {
    document[imgTarg].src = imgName;
}

function make_obj(name){
   if(document.layers) return eval("document.layers['" + name + "']");
   else return document.getElementById(name);
}

function m_sel(name, mode){
   if(mode==1) make_obj(name).className='tops';
   else make_obj(name).className='top';
}

function openwin(url,w,h,scr,title){
    var x=(screen.width/2)-(w/2); var y=(screen.height/2)-(h/2);
    if(x==null || y==null) x=y=10;
    if(pup != null && !pup.closed) pup.close();
    if(scr == null) scr="no";

   options="height="+h+", width="+w+", left="+x+", top="+y+", scrollbars="+scr+", resizable='yes'";

    pup=window.open(url,title,options);
    pup.focus();
}

function openDocWindow(docName, section, baseUrl) {
    var url = baseUrl + "onlinedoc-view?name=" + docName + "&section=" + section;
    openwin(url, 720, 480, 'yes', 'onlinedoc');
}

function getCookie(Name) {   
  var search = Name + "="; 
  if (document.cookie.length > 0) { 
    offset = document.cookie.indexOf(search); 
    if (offset != -1) { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      return unescape(document.cookie.substring(offset, end));
   }    
  }
  return null;
}

function setCookie(Name,value) {   
  var data=escape(value);
  var search = Name + "="   
  document.cookie=search+data+';'+'path=/';
}

function add_points(path){
  var points=getCookie('sel_points');
  if(points==null) {
     alert('Ничего не выбрано');
     return;
  }
  window.location.href=path+'&points='+points;
  return;
}

function toggle_point(id) {   
  var res="";
  var find=false;
  if(getCookie("sel_points")){
   var points=getCookie("sel_points").split("-");
   for(i=0;i < points.length; i++){
    if(points[i]!=id) {
       if(res!="") res+="-";  
       res+=points[i];
       continue;
    }
    find=true;
   }
  }
  if(!find){
    if(res!="") res+="-";  
    res+=""+id;
  }
  setCookie("sel_points",res);  
}


function show_selections() {   

  if(getCookie("sel_points")){
   var points=getCookie("sel_points").split("-");
   for(i=0;i < points.length; i++){
    name="sel_"+points[i];
    el=document.getElementById(name);
    if(el){
        el.checked=true;
    }
   }
  }
}

function drop_selections() {   
  setCookie("sel_points","");
}

function set_selections(id) {   
  if(getCookie("sel_points")) res=getCookie("sel_points")+"-"+id;
  else res=""+id;
  setCookie("sel_points",res);
}

function refresh_changes() {
  window.location.reload(0);
}

function getRadioValue (radioButtonOrGroup) {
  var buttonsLength = radioButtonOrGroup.length;
  if (buttonsLength) { // group
    for (var b = 0; b < buttonsLength; b++)
      if (radioButtonOrGroup[b].checked)
        return radioButtonOrGroup[b].value;
  }
  else if (radioButtonOrGroup.checked)
    return radioButtonOrGroup.value;
  return null;
}

function uncheckRadioGroup (radioButtonOrGroup) {
  if (radioButtonOrGroup.length) { // we have a group
    for (var b = 0; b < radioButtonOrGroup.length; b++)
      if (radioButtonOrGroup[b].checked) {
        radioButtonOrGroup[b].checked = false;
        break;
      }
  }
  else 
    radioButtonOrGroup.checked = false;
}



function select_bush(select_mode,formname,fieldname,bush_id,page_id){
    var par=window.opener.parent;
    
    if(par){
        
        
        if(select_mode=="bush") par.document.forms[formname].elements[fieldname].value=bush_id;
        else  {
        	if(par.document.getElementById(fieldname)){
        		par.document.getElementById(fieldname).value=page_id;
        	}   else{
	        	par.document.forms[formname].elements[fieldname].value=page_id; 
	        }
        }

        var dom = document.getElementById("b"+bush_id);      
        if(par.document.getElementById(fieldname+"_title")){
        	par.document.getElementById(fieldname+"_title").value= dom.attributes["title"].value;
        }else{
	        par.document.forms[formname].elements[fieldname+"_title"].value=dom.attributes["title"].value;
	    }


    }
    window.close();

}

function select_doc_prm(formname,fieldname,title){
    var par=window.opener.parent;
    if(par) par.document.forms[formname].elements[fieldname].value=title;
    window.close();

}

var tmpImg = new Image();
tmpImg.src = '/images/sel-arrow-s.gif';
function switchDiv(divID,thisAnc) {
 if (document.getElementById(divID)) {
  if (!(document.getElementById(divID).style.display) || document.getElementById(divID).style.display == 'block') {
   document.getElementById(divID).style.display = 'none'
   thisAnc.className = 'divSelect';
   if (document.getElementById(divID + '-i')) document.getElementById(divID + '-i').src = '/images/sel-arrow.gif';
   } else {
     document.getElementById(divID).style.display = 'block';
     thisAnc.className = 'divSelectS';
     if (document.getElementById(divID + '-i')) document.getElementById(divID + '-i').src = '/images/sel-arrow-s.gif';
   }
 }
}
