
function AddFavorite() {
  if(/MSIE/.test(navigator.userAgent)) {
    window.external.AddFavorite(document.location.href,document.title);
    return false;
  }
  else if(/Mozilla/.test(navigator.userAgent)){
    if (typeof window.sidebar == "object")
      window.sidebar.addPanel (document.title, document.location.href, "");
    return false;
  }
  else if(/Opera/.test(navigator.userAgent)) {
    var a = document.createElement('A');
    if (!a) return false;
    a.setAttribute('rel','sidebar');
    a.setAttribute('href',document.location.href);
    a.setAttribute('title',document.title);
    a.click();
    return true;
  }
  else
    return false;
}

function SetHome(o) {
  o.style.behavior='url(#default#homepage)';
  o.setHomePage('http://uapoisk.net/');
  return false;
}


function change_region(form_name,select_name) 
{
//alert ( 'form_name=[' + form_name + '], select_name=[' + select_name +']');

    var CurList = document.forms[form_name].elements[select_name];
    var id = CurList.options[CurList.selectedIndex].value;

    if(select_name=='input_country_id')   // Украина
    {
        next_select_name = 'input_state_id';
        var str1=loadHTML("http://bdsmpeople.ru/getstates.php?id="+id);
  
        city_select_name = 'input_city_id';
        var CityList = document.forms[form_name].elements[city_select_name];
        CityList.length = 0;
    }

    if(select_name=='input_state_id')     // Виницкая обл.
    {
        next_select_name = 'input_city_id';
        var str1=loadHTML("http://bdsmpeople.ru/getcities.php?id="+id);
    }     

    var NextList = document.forms[form_name].elements[next_select_name];
    NextList.length = 0;

    var regionlist=str1.split(";");
    var cnt = regionlist[0]*2;

//    alert('cnt=['+cnt+']');



    if(form_name=='form_search')
    {
        if (document.createElement)
        {
            var newNextListOption = document.createElement("OPTION");
            newNextListOption.value = "0";
            newNextListOption.text  = "Любой регион";
            (NextList.options.add) ? NextList.options.add(newNextListOption) : NextList.add(newNextListOption, null);
        }
        else
        {
            NextList.options[i] = new Option('Любой регион', '0', false, false);
        }
    }

    for(var i=1;i<cnt;i=i+2) 
    {
        if (document.createElement)
        {
            var newNextListOption = document.createElement("OPTION");
            newNextListOption.value = regionlist[i];
            newNextListOption.text  = regionlist[i+1];
            (NextList.options.add) ? NextList.options.add(newNextListOption) : NextList.add(newNextListOption, null);
            //alert('1');
        }
        else
        {
            NextList.options[i] = new Option(regionlist[i+1], regionlist[i], false, false);
           // alert('2');
        }
    }

if(select_name=='input_country_id')  
{
    change_region(form_name,'input_state_id');
}

}


function getXmlHttp()
{
var xmlhttp;
try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

function loadHTML(sURL){
var request = getXmlHttp();
if(!request)  return "";

request.open('GET', sURL, false);
request.send(null);
return request.responseText;
}

function wopen(url,name,w,h)
{
    var w=window.open(url,name,"width="+w+",height="+h+",resizable=1,toolbar=0,location=0,status=0,menubar=0,directories=0,scrollbars=no,top=50,left=50");
    w.focus();
}
