

function get_GET(key)
{
 get = new String(window.location);
 x = get.indexOf('?');
 if(x == -1) return "";

 l = get.length;
 get = get.substr(x+1, l-x);
 l = get.split('&');

    for(i=0; i<l.length; i++)
    {
     get = l[i].split('=');
     if(get[0] == key)
     return get[1];
    }

 return "";
}






function set_picture()
{
 var pic_arr = new Array();

 for(i=1; i<12; i++)
 pic_arr[pic_arr.length] = '/img/gallery/'+i+'.jpg';

 document.img_pic.src = pic_arr[getrandom(pic_arr.length-1)];
}






function set_left_form()
{
 document.main_find.city.value = get_GET('city');
 document.main_find.metro.value = get_GET('metro');

 document.main_find.bust_from.value = get_GET('bust_from');
 document.main_find.bust_to.value = get_GET('bust_to');

 document.main_find.age_from.value = get_GET('age_from');
 document.main_find.age_to.value = get_GET('age_to');

 document.main_find.height_from.value = get_GET('height_from');
 document.main_find.height_to.value = get_GET('height_to');

 document.main_find.price_from.value = get_GET('price_from');
 document.main_find.price_to.value = get_GET('price_to');
}






function set_left_anket()
{
 var left_an_arr = ta.concat(fa);
 var left_an_index = getrandom(left_an_arr.length-1);

 document.img_left.src = left_an_arr[left_an_index][1];
 document.all.href_1_left.href = '/details.php?id='+left_an_arr[left_an_index][0];
 document.all.href_2_left.href = '/details.php?id='+left_an_arr[left_an_index][0];
}







function getrandom(max_random)
{
 var min_random = 0;

 max_random++;

 var range = max_random - min_random;
 var n=Math.floor(Math.random()*range) + min_random;

 return n;
} 







function reset_del()
{
  if(!confirm('Удалить ?'))
  {
   event.returnValue=false;
   event.cancelBubble=true;
  }
}







function getElementNum(form, obj)
{
 var i = 0;

  while(form.elements[i])
  {
   if (form.elements[i] == obj ) return i;
   i++;
  }

 return 0;
}







function check_traffic()
{
  if( !/^\d+$/.test(document.main.traffic.value) )
  {
   alert('в графе <предполагаемое количество переходов> должно быть число');
   return false;
  }

  if( document.main.login.value=="" || document.main.password.value=="" )
  {
   alert('поля <логин> и <пароль> не должны быть пустыми');
   return false;
  }

}







var Detail_Hwnd;

function Open_Detail_Hwnd(url, width, height)
{
if(Detail_Hwnd) Detail_Hwnd.close();

SepWin=window.open (url, 'Detail_Hwnd', 'width='+width+',height='+height+',resizable=1');
//SepWin.document.open();
//SepWin.document.writeln('<HTML><HEAD><TITLE>детальная информация</TITLE><LINK rel=stylesheet type=text/css href=/css/style.css><LINK rel=stylesheet type=text/css href=/css/css.css></HEAD><BODY leftmargin=0 topmargin=0>'+url+'</BODY></HTML>');
//SepWin.document.close();
SepWin.focus();
}







function video(id)
{
 SepWin = window.showModalDialog('/video.php?id='+id, 'BE-MINE.RU - видео', 'dialogWidth:400px;dialogHeight:320px;center:1;scroll:0;help:0;status:0');

   if(event)
   {
    event.returnValue=false;
    event.cancelBubble=true;
   }
}

