/* ---------------------------- */
 function _if_cursor_pos(_p_input)
 {
  _p_input.focus();
 
  if(_p_input.selectionStart) return _p_input.selectionStart; //Gecko
  else if(document.selection)  //IE
  {
    var _v_range=_p_input.createTextRange();
    _v_range.setEndPoint("EndToStart", document.selection.createRange());
    return _v_range.text.length;
  }
  return 0;
 }
/* ---------------------------- */
function _if_get_rating(_p_name)
{ _v_klc_rating=0;
 for(_v_counter=1;_v_counter<11 && _v_klc_rating==0;_v_counter++)
 {
  var _v_obj_rating=document.getElementById(_p_name+_v_counter);
  if(_v_obj_rating.checked) _v_klc_rating=_v_obj_rating.value;
 }
 if(_v_klc_rating==0) alert("Пожалуйста выберите оценку!");
 return _v_klc_rating;
}
/* ---------------------------- */
function _if_x_submit_rating(_p_num_lnk,_p_type_doc,_p_name_div,_p_style,_p_klc_rating)
{
// _v_klc_rating=_if_get_rating('_fv_rating'+_p_name_div+'_');
  
 if(_p_klc_rating>=1 && _p_klc_rating<=10)
  xajax__if_x_rating(_p_num_lnk,_p_type_doc,_p_klc_rating,_p_name_div,_p_style);

 return false;
}
/* ---------------------------- */
function _if_x_submit_gallery_rating(_p_num_aim)
{ _v_klc_rating=_if_get_rating('_fv_rating_'); if(_v_klc_rating>=1 && _v_klc_rating<=10)
  xajax__if_x_gallery_rating(_p_num_aim,_v_klc_rating);

 return false;
}
/* ---------------------------- */
function _if_x_submit_article_rating(_p_num_art)
{
 _v_klc_rating=_if_get_rating('_fv_rating_');
 if(_v_klc_rating>=1 && _v_klc_rating<=10)
  xajax__if_x_article_rating(_p_num_art,_v_klc_rating);

 return false;
}
/* ---------------------------- */
 function _if_tr_color(_p_id)
 {
  _v_tr=document.getElementById(_p_id);
  if(_v_tr.old_class==null)
  {
   if(_v_tr.className==null) _v_tr.old_class='';
   else _v_tr.old_class=_v_tr.className;
  }
  if(_v_tr.className=='dict_trd')
   _v_tr.className=_v_tr.old_class;
  else _v_tr.className='dict_trd';
 }
/* ---------------------------- */
 function _if_set_value(_p_element,_p_value)
 {
  if(_p_element!='')
  {
   _v_element=document.getElementById(_p_element);
   _v_element.value=_p_value;
  }
 }
/* ---------------------------- */
 function _if_form_action(_p_form,_p_url,_p_element,_p_value)
 {
  _v_form=document.getElementById(_p_form);
  _if_set_value(_p_element,_p_value);
  if(_p_url!='') _v_form.action=_p_url;
  _v_form.submit();
  return false;
 }
/* ---------------------------- */
function _if_create_popup(_p_wrapper_id,_p_id,_p_body_id,_p_width,_p_height,_p_html)
{
 var _v_body=document.getElementsByTagName("body").item(0);

 var _v_popup_wrapper=document.createElement("div");
 _v_popup_wrapper.setAttribute('id',_p_wrapper_id);
 _v_popup_wrapper.onclick=function() {_if_close_popup(_p_wrapper_id,_p_id);}
 _v_popup_wrapper.style.display='none';
 _v_popup_wrapper.style.position='absolute';
 _v_popup_wrapper.style.top='0px';
 _v_popup_wrapper.style.left='0px';
 _v_popup_wrapper.style.zIndex='1000';
 _v_popup_wrapper.style.width='100%';
 _v_popup_wrapper.style.height='100%';
 _v_popup_wrapper.style.background="#000000";
 _v_body.insertBefore(_v_popup_wrapper,_v_body.firstChild);

 var _v_popup=document.createElement("div");
 _v_popup.setAttribute('id',_p_id);
 _v_popup.style.display='none';
 _v_popup.style.position='absolute';
 _v_popup.style.zIndex='1001';
 _v_popup.style.top='0px';
 _v_popup.style.left='0px';
 _v_popup.style.border="solid 2px black";
 _v_popup.style.padding="10px";
 _v_popup.style.width=_p_width+'px';
 _v_popup.style.height=_p_height+'px'; 
 _v_popup.style.background="#909090";
 _v_popup_wrapper.appendChild(_v_popup);
// _v_popup_wrapper.insertBefore(_v_popup,_v_popup_wrapper.nextSibling);

 var _v_href=document.createElement("a");
 _v_href.setAttribute('href','#');
 _v_href.setAttribute('title','Чтобы закрыть, кликните!');
 _v_href.onclick=function(){_if_close_popup(_p_wrapper_id,_p_id); return false;}
 _v_popup.appendChild(_v_href);

 var _v_popup_body=document.createElement("div");
 _v_popup_body.setAttribute('id',_p_body_id);
 _v_popup_body.style.textAlign='center';
 _v_popup_body.style.width=_p_width+'px';
 _v_popup_body.innerHTML=_p_html+'<p>Кликните, чтобы закрыть</p><div style="clear:both;"></div>';
 _v_popup.appendChild(_v_popup_body);

 return false;

}
/* ---------------------------- */
function _if_show_popup(_p_wrapper_id,_p_id,_p_body_id,_p_width,_p_height)
{
 _v_popup_wrapper=document.getElementById(_p_wrapper_id);
 _v_popup=document.getElementById(_p_id);

 var _v_body={};  
 if(window.innerWidth){// Все браузеры кроме IE  
  _v_body.width=window.innerWidth;  
  _v_body.height=window.innerHeight;  
 } else if (document.documentElement && document.documentElement.clientWidth){  
 // Эти ф-ции для IE6 и документов с объявлением DOCTYPE  
  _v_body.width=document.documentElement.clientWidth;  
  _v_body.height=document.documentElement.clientHeight+document.documentElement.scrollTop;
 } else if (document.body.clientWidth){  
 // Эти ф-ции для IE4, IE5 и IE6 без объявления DOCTYPE  
 _v_body.width=document.body.clientWidth;  
 _v_body.height=document.body.clientHeight+document.body.scrollTop;  
 } 

 _v_popup.style.top=(document.documentElement.scrollTop+
   (_v_body.height-_p_height)/2)+'px';
 _v_popup.style.left=(_v_body.width-_p_width)/2+'px';

 _v_popup_wrapper.style.width=_v_body.width+'px';
 if(document.documentElement.offsetHeight>_v_body.height+document.documentElement.scrollTop)
  _v_popup_wrapper.style.height=document.documentElement.offsetHeight+'px';
 else
  _v_popup_wrapper.style.height=(_v_body.height+document.documentElement.scrollTop)+'px';

 _v_popup_wrapper.style.display = 'block';
 _v_popup.style.display = 'block';

 return false;
}
/* ---------------------------- */
function _if_close_popup(_p_wrapper_id,_p_id)
{
 _v_popup_wrapper=document.getElementById(_p_wrapper_id);
 _v_popup=document.getElementById(_p_id);

 _v_popup_wrapper.style.display = 'none';
 _v_popup.style.display = 'none';

 return false;
}
/* ---------------------------- */
//Размер документа по вертикали
function _if_get_document_height()
{
 return (document.body.scrollHeight>document.body.offsetHeight)?
   document.body.scrollHeight:document.body.offsetHeight;
}
/* ---------------------------- */
//Размер документа по горизонтали
function _if_get_document_width()
{
 return (document.body.scrollWidth>document.body.offsetWidth)?
   document.body.scrollWidth:document.body.offsetWidth;
}
/* ---------------------------- */
 function _if_show_hide_thumbs(_p_id)
 {
  _if_show_hide_div(_p_id);
  var _v_div=document.getElementById('bimage_similar');
  if(_v_div==null) return;
  var _v_div_bottom=document.getElementById('bimage_bottom2');
  if(_v_div_bottom==null) return;
  var _v_div_comment=document.getElementById('bimage_comment');
  if(_v_div_comment==null) return;
  if(_v_div.style.display!='block') 
  {
   _v_div_bottom.className='bimage_bottom2_tr';
   _v_div_comment.style.marginTop='90px';
  }
  else 
  {
   _v_div_bottom.className='bimage_bottom2';
   _v_div_comment.style.marginTop='0px';
  }
 }
/* ---------------------------- */
 function _if_show_hide_div(_p_id)
 {
  var _v_div=document.getElementById(_p_id);
  if(_v_div==null) return;
  if(_v_div.style.display!='block') _v_div.style.display='block';
  else _v_div.style.display='none';
 }
/* ---------------------------- */
 function _if_show_big_image(_p_num_aim,_p_num_art,_p_width,_p_height)
 {
   var _v_div=document.getElementById('bimage_overlay');
   if(_v_div==null) return;
   _v_body=_if_body_measure();
   if(_p_width<_p_height)
    setTimeout('_if_show_hide_thumbs(\'bimage_similar\')',1500);

   xajax__if_x_create_image(_p_num_aim,_p_num_art,_v_body.width,_v_body.height,'true');
 }
/* ---------------------------- */
/* ---------------------------- */
 function _if_body_measure()
 {
  var _v_body={};  
  if(window.innerWidth)
  {// Все браузеры кроме IE  
   _v_body.width=window.innerWidth;  
   _v_body.height=window.innerHeight;  
  } 
  else if (document.documentElement && document.documentElement.clientWidth)
  {  
 // Эти ф-ции для IE6 и документов с объявлением DOCTYPE  
   _v_body.width=document.documentElement.clientWidth;  
   _v_body.height=document.documentElement.clientHeight+document.documentElement.scrollTop;
  } 
  else if (document.body.clientWidth)
  {  
 // Эти ф-ции для IE4, IE5 и IE6 без объявления DOCTYPE  
   _v_body.width=document.body.clientWidth;  
   _v_body.height=document.body.clientHeight+document.body.scrollTop;  
  } 
  return _v_body;
 }
/* ---------------------------- */
function _if_radio_button_change(_p_name_div)
{
 for(_v_counter=1;_v_counter<11;_v_counter++)
 {
  var _v_obj_rating=document.getElementById(_p_name_div+_v_counter);
  var _v_div_rating=document.getElementById(_p_name_div+'div'+_v_counter);
  if(_v_obj_rating.checked)
    _v_div_rating.className='radio_button_selected';
  else
    _v_div_rating.className='radio_button';
 }
}
/* ---------------------------- */

