/* -------------------------- */
/*   XMLHTTPRequest Enable    */
/* -------------------------- */
function ShowHide(el,tip)
{
 mn = document.getElementById(el);
 if (mn.style.display == "none")
  {
   mn.style.display = tip;
  }
   else
  {
   mn.style.display = "none";
  }
}

function Go(link)
{
 window.location=link;
}

/* Add to Favorite */
function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}

function bookmark(a){
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && 7 > b.version && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = url+','+title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}

function doRecControl()
{
 if (document.getElementById('mailto').value=="")
 {
  document.getElementById('mailto').value="заполнять обязательно";
  document.getElementById('mailto').style.color="#FF0000";
 }
 if (document.getElementById('mailfrom').value=="")
 {
  document.getElementById('mailfrom').value="заполнять обязательно";
  document.getElementById('mailfrom').style.color="#FF0000";
 }
 if (document.getElementById('txtmsg').value=="")
 {
  document.getElementById('txtmsg').value="заполнять обязательно";
  document.getElementById('txtmsg').style.color="#FF0000";
 }
}

function PlusKol(inputid,minkol)
{
  var kol = parseInt(document.getElementById(inputid).value);
  kol = kol+1;
  document.getElementById(inputid).value = kol;
}

function MinusKol(inputid,minkol)
{
  var kol = parseInt(document.getElementById(inputid).value);
  kol = kol-1;
  if (kol<minkol) { kol=minkol; }
  document.getElementById(inputid).value = kol;
}

function MinusKol(inputid,minkol)
{
  var kol = parseInt(document.getElementById(inputid).value);
  kol = kol-1;
  if (kol<minkol) { kol=minkol; }
  document.getElementById(inputid).value = kol;
}

function createObject()
{
 var request_type;
 var browser = navigator.appName;
 if(browser == "Microsoft Internet Explorer")
 {
  request_type = new ActiveXObject("Microsoft.XMLHTTP");
 } else
 {
  request_type = new XMLHttpRequest();
 }
 return request_type;
}

var http = null;
var rout_el_id = '';

function doAjRoute(file,el_id,parstr)
{
 rout_el_id = el_id ;
 if (http == null) http =createObject();
 // Set te random number to add to URL request
 nocache = Math.random();
 http.open('get', 'ajaxrout.php?file='+file+parstr+'&nocache='+nocache);
 http.onreadystatechange = AjReply;
 http.send(null);
}

function doAjRouteCahed(file,el_id,parstr)
{
 rout_el_id = el_id ;
 if (http == null) http =createObject();
 // Set te random number to add to URL request
 http.open('get', 'ajaxrout.php?file='+file+parstr);
 http.onreadystatechange = AjReply;
 http.send(null);
}

function AjReply()
{
 if(http.readyState == 4)
 {
  var response = http.responseText;
  document.getElementById(rout_el_id).innerHTML = response;
 }
}

function necessary_otziv_values()
{
   if (document.forms['vidguk'].SODERV.value=='') {alert("Заповнiть поле коментаря !!!");  return false;}
   if (document.forms['vidguk'].NAZ.value=='') {alert("Заповнiть поле Ім`я !!!");  return false;}
   if (document.forms['vidguk'].EMAIL.value=='') {alert("Заповнiть поле e-mail !!!");  return false;}

   var regexp=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/ //regular expression defining an email address
            if (document.forms['vidguk'].EMAIL.value.search(regexp)==-1)
            { //if match failed
              alert('Введiть вiрно Ваш e-mail !!!');
              document.forms['vidguk'].EMAIL.value='';
              document.forms['vidguk'].EMAIL.focus();
              return false;
            } else
            {
      if (confirm("Пiсля підтвердження, Ваша електронна адреса буде відображатись для відвідувачів сайту. Бажаєте продовжити?"))
       {return true;}
       else
       {return false;}
            }
 }

function focus_username( e )
{
if ( e.value == "логін" )
{
e.value = '';
return false;
}
}
function focus_password( e )
{
if ( e.value == "------" )
{
e.value = '';
return false;
}
}

function DoGolosovat()
{
  var v = getRadioGroupValue(document.OPROS.answerN);
  if(v==0) return false;
  document.OPROS.VALUE.value = v;
  document.OPROS.submit();
}

function getRadioGroupValue(radioGroupObj)
{
  for (var i=0; i < radioGroupObj.length; i++)
    if (radioGroupObj[i].checked) return radioGroupObj[i].value;

  return 0;
}


 function postTabber(id,page)
 {
  var old_tab = '1';
  var old_li = '';
  var new_li = '';
  var old_div = '';
  var new_div = '';

  old_tab = ''+document.getElementById('postTab_form_'+id+'_curtab').value;
  document.getElementById('postTab_form_'+id+'_curtab').value = page;

  old_li = document.getElementById('postTabs_li_'+id+'_'+old_tab);
  new_li = document.getElementById('postTabs_li_'+id+'_'+page);
  old_li.className='';
  new_li.className='postTabs_curr';

  old_div = document.getElementById('postTabs_div_'+id+'_'+old_tab);
  new_div = document.getElementById('postTabs_div_'+id+'_'+page);
  old_div.style.display = 'none';
  new_div.style.display = 'block';
}



