function setClass( hEl, sClass )
  {
    hEl.className = sClass
 }
 
function ChangeDiv ( div1, div2, link1 ) {
	var d1 = document.getElementById( div1 )
	var d2 = document.getElementById( div2 )
	var a1 = document.getElementById( link1 );
    
	if (d1.style.display == "block") {
		d1.style.display = "none";
		d2.style.display = "block";
		a1.innerHTML = 'Запрос';
		a1.className = '';
	} else {
		d1.style.display = "block";
		d2.style.display = "none";
		a1.innerHTML = 'Информация';
		a1.className = 'enlinkinfo';
	}
  	
   
}


function ShowElem(Elem,hide1){

  var FormElem = document.getElementById( Elem )
  var hideElem1 = document.getElementById( hide1 )  
  if(FormElem)
   if((FormElem.style.display == "none") || (FormElem.style.display == "")) {
    FormElem.style.display = "block";
	if (hideElem1)
	hideElem1.style.display = "none";
   }
  else    
    FormElem.style.display = "none";
}

function ShowHide(Elem){
	var FormElem = document.getElementById( Elem )
	if((FormElem.style.display == "none") || (FormElem.style.display == "")) {
    FormElem.style.display = "block";
	}
  else    
    FormElem.style.display = "none";
}


function StepByStep( Position, MaxCount, Container, Prefix, FirstElement){

    var SelectArray =  new Array();
    var PropertyContainer = document.getElementById( Container );


    for(cL = 0; cL < MaxCount; cL++)
     SelectArray[cL] = document.getElementById( Prefix+cL );

     if(SelectArray[Position].value == "" || !PropertyContainer ){

         for(cL = Position+1; cL < MaxCount; cL++)
           while(SelectArray[cL].options.length > 1)
             SelectArray[cL].options[SelectArray[cL].options.length - 1] = null;

     }else{

        for(cL = Position+1; cL < MaxCount; cL++){
         SelectArray[cL].options.length = null;
         SelectArray[cL].options[SelectArray[cL].options.length] = new Option(FirstElement,"")
         }


         var FoundNewItemKeys = new Array();

         var AvailArray = PropertyContainer.getElementsByTagName( 'a' );
          for(cA = 0; cA < AvailArray.length; cA++)

           if(AvailArray[cA].getAttribute('linkedid') == SelectArray[Position].value){

             SelectArray[Position+1].options[SelectArray[Position+1].options.length] = new Option(AvailArray[cA].getAttribute('name'), AvailArray[cA].getAttribute('itemid'))
          }


     }

}


function StepByStepUnique( Position, MaxCount, Container, Prefix, FirstElement){

 var SelectArray = new Array();
 var PropertyContainer = document.getElementById( Container );


 for(cL = 0; cL < MaxCount; cL++)
 SelectArray[cL] = document.getElementById( Prefix+cL );

if(SelectArray[Position].value == "" || !PropertyContainer ){

 for(cL = Position+1; cL < MaxCount; cL++)
 while(SelectArray[cL].options.length > 1)
 SelectArray[cL].options[SelectArray[cL].options.length - 1] = null;

 }else{

 for(cL = Position+1; cL < MaxCount; cL++){
 SelectArray[cL].options.length = null;
 SelectArray[cL].options[SelectArray[cL].options.length] = new Option(FirstElement,"")
 }


var FoundNewItemKeys = new Array();

 var AvailArray = PropertyContainer.getElementsByTagName( 'a' );
 for(cA = 0; cA < AvailArray.length; cA++)

 if(AvailArray[cA].getAttribute('linkedid') == SelectArray[Position].value){

 SelectArray[Position+1].options[SelectArray[Position+1].options.length] = new Option(AvailArray[cA].getAttribute('name'), AvailArray[cA].getAttribute('itemid'))
 }


 }

}
function StepByStep2( Position, MaxCount, Container, Prefix, FirstElement){

    var SelectArray =  new Array();
    var PropertyContainer = document.getElementById( Container );


    for(cL = 0; cL < MaxCount; cL++)
     SelectArray[cL] = document.getElementById( Prefix+cL );

     if(SelectArray[Position].value == "" || !PropertyContainer ){



         for(cL = Position+1; cL < MaxCount; cL++)
           while(SelectArray[cL].options.length > 1){
             SelectArray[cL].options[SelectArray[cL].options.length - 1] = null;
	     SelectArray[cL].style.display = "none";
	}     

     }else{

        for(cL = Position+1; cL < MaxCount; cL++){
         SelectArray[cL].options.length = null;
         SelectArray[cL].options[SelectArray[cL].options.length] = new Option(FirstElement,"")
         }


         var FoundNewItemKeys = new Array();

         var AvailArray = PropertyContainer.getElementsByTagName( 'a' );
          for(cA = 0; cA < AvailArray.length; cA++)

           if(AvailArray[cA].getAttribute('linkedid') == SelectArray[Position].value){
             SelectArray[Position+1].style.display = "inline";
             SelectArray[Position+1].options[SelectArray[Position+1].options.length] = new Option(AvailArray[cA].getAttribute('name'), AvailArray[cA].getAttribute('itemid'))
          }


     }




}

function CreateBookmarkLink(url, title) {
	
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { 
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) {
		return true; }
 }
 
 
 
 
 function disable()
 {
 var magazine = false;
 var other = false
  var exother = false
 
 if(document.form1.hear[0].checked == false)
    exother = true;
 
 if(document.form1.hear[1].checked == false)
    magazine = true;
    
    
 if(document.form1.hear[5].checked == false)
    other = true;    

  document.form1.exh_country.disabled = exother;
  document.form1.mag_name.disabled = magazine;
  document.form1.hearothertext.disabled = other;
 
 if (exother == true)
  document.form1.exh_other.disabled = true;  
  
 if (other == true)
  document.form1.mag_other.disabled = true; 
 }


function enableOther()
 {

 if((document.form1.hear[0].checked )&&(document.form1.exh_country.value == "Other"))
  document.form1.exh_other.disabled = false;
 else  
  document.form1.exh_other.disabled = true;
 
 if((document.form1.hear[1].checked )&&(document.form1.mag_name.value == "Other"))
  document.form1.mag_other.disabled = false;
 else  
    document.form1.mag_other.disabled = true;
 }


$(function() {
	$('a.bpic, a.simg').lightBox();
});