// functions to make things easier... :-)
  
  function status_clear(a) {
    self.status=a;
  }
  
  function get_object(name) {
    if (document.getElementById) {
      return document.getElementById(name);
    } else if (document.all) {
      return document.all[name];
    } else if (document.layers) {
      return document.layers[name];
    }
  }

  function logout() {
    window.location.href="/logout.php";
    return false;
  }

  function createXmlHttpRequestObject() {
    var xmlHttp;
    try {
      xmlHttp = new XMLHttpRequest();
      //if (xmlHttp.overrideMimeType) xmlHttp.overrideMimeType('text/html');
    } catch(e) {
      var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
      for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) {
        try { 
          xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
        } catch (e) {}
      }
    }
    if (!xmlHttp) alert("Your browser doesn't support Ajax.");
    else return xmlHttp;
  }

  function xml_value_return(xml_obj,xml_tag) {
    if (xml_obj) {
      if (xml_obj.getElementsByTagName(xml_tag)) {
        xml_obj=xml_obj.getElementsByTagName(xml_tag);
        if (xml_obj[0]) {
          if (xml_obj[0].firstChild) {
            if (xml_obj[0].firstChild.nodeValue) return xml_obj[0].firstChild.nodeValue; else return null;
          } else return null;
        } else return null;
      } else return null;
    } else return null;
  }

  function set_style(id, style, value) {
    if (typeof(id)=="string") if (get_object(id).style) eval("get_object(id).style."+style+"=value;");
    else if (typeof(id)=="object") if (id.style) eval("id.style."+style+"=value;");
  }
  function set_class(id, class_name) {
    if (typeof(id)=="string") get_object(id).className=class_name;
    else if (typeof(id)=="object") id.className=class_name;
  }
  
  function trim(text) {
  	return String(text).replace(/^\s+|\s+$/g,"");
  }
  
  function visibility_change(element) {
    if (!get_object(element).style.visibility || get_object(element).style.visibility=="hidden") get_object(element).style.visibility="visible";
    else get_object(element).style.visibility="hidden";
  }

  function element_content(element, content) {
    var xml_http_content_object=createXmlHttpRequestObject();
    if (xml_http_content_object) {
      xml_http_content_object.onreadystatechange=function() {
        if (xml_http_content_object.readyState==4) {
          if (xml_http_content_object.status==200) {
            get_object(element).innerHTML="";
            if (xml_http_content_object.responseText!="") get_object(element).innerHTML=xml_http_content_object.responseText;
          }
        }
      }
      xml_http_content_object.open("GET",content,true);
      xml_http_content_object.send(null);
    }
  }

  function overdiv_black_resize() {
    if (get_object("main_div").offsetHeight>document.body.offsetHeight) get_object("overdiv_black").style.height=get_object("main_div").offsetHeight+"px";
    else get_object("overdiv_black").style.height=document.body.offsetHeight+"px";
    if (document.body.offsetWidth<1000) get_object("overdiv_black").style.width="1000px";
    else get_object("overdiv_black").style.width=document.body.offsetWidth+"px";
    setTimeout("overdiv_black_resize()",200);
  }

// tabs
  var tab_switcher_tabs=new Array();
  var tab_switcher_active=new Array();

  function tab_switcher_over(name,i,o) {
    if (o==1 && tab_switcher_active[name]!=i) {
      set_class("tab_switcher_left['"+name+"']["+i+"]","tab_switcher_left_over");
      set_class("tab_switcher_middle['"+name+"']["+i+"]","tab_switcher_middle_over");
      set_class("tab_switcher_right['"+name+"']["+i+"]","tab_switcher_right_over");
    }
    else if (o==0 && tab_switcher_active[name]!=i) {
      set_class("tab_switcher_left['"+name+"']["+i+"]","tab_switcher_left");
      set_class("tab_switcher_middle['"+name+"']["+i+"]","tab_switcher_middle");
      set_class("tab_switcher_right['"+name+"']["+i+"]","tab_switcher_right");
    }
  }

// country language change
  function clch(id_language) {
    get_object("id_new_id_language["+document.country_language_form["new_id_language"].value+"]").style.fontWeight="";
    get_object("id_new_id_language["+id_language+"]").style.fontWeight="bold";
    document.country_language_form["new_id_language"].value=id_language;
  }

  var country_languages_options_opened=-1;
  function country_language_options(id_country,id_language,language_only) {
    if (language_only!=-1 && country_languages_options_opened!=language_only) {
      element_content('top_ext_content', '/ajax/country_languages.php?id_country='+id_country+'&id_language='+id_language+'&language_only='+language_only);
      get_object('top_ext').style.visibility="visible";
      get_object('top_ext_content').style.visibility="visible";
      country_languages_options_opened=language_only;
    } else {
      get_object('top_ext_content').style.visibility="hidden";
      get_object('top_ext').style.visibility="hidden";
      country_languages_options_opened=-1;
    }
  }

// paging
  function paging_set_style(sn,i,class_add) {
    set_class('paging_left['+sn+']['+i+']','paging_left_'+class_add);
    set_class('paging_number['+sn+']['+i+']','paging_number_'+class_add);
    set_class('paging_right['+sn+']['+i+']','paging_right_'+class_add);
  }

// log in / sign up / forgot password boxes

  function log_in_sign_up_menu_hover(id,oo) {
    var new_class="active";
    if (oo==0 && id==log_in_sign_up_menu_hover_active) new_class="active";
    else if (oo==0 && id!=log_in_sign_up_menu_hover_active) new_class="inactive";
    set_class("right_box_orange_sel_left["+id+"]","left_"+new_class);
    set_class("right_box_orange_sel_middle["+id+"]","middle_"+new_class);
    set_class("right_box_orange_sel_right["+id+"]","right_"+new_class);
  }

  function log_in_box_open() {
    sign_up_box_close();
    forgot_password_box_close();
    log_in_sign_up_menu_hover_active=1;
    set_class("right_box_orange_sel_left[1]","left_active");
    set_class("right_box_orange_sel_middle[1]","middle_active");
    set_class("right_box_orange_sel_right[1]","right_active");
    get_object("log_in_opener").href="javascript: void(0);";
    get_object("right_box_orange_sel_left[1]").onclick="";
    get_object("right_box_orange_sel_middle[1]").onclick="";
    get_object("right_box_orange_sel_right[1]").onclick="";
    set_style("log_in_box_div","display","block");
    set_style("log_in_box_div","visibility","visible");
    document.log_in_form["email"].focus();
  }
  function log_in_box_close() {
    log_in_sign_up_menu_hover_active=0;
    set_class("right_box_orange_sel_left[1]","left_inactive");
    set_class("right_box_orange_sel_middle[1]","middle_inactive");
    set_class("right_box_orange_sel_right[1]","right_inactive");
    get_object("log_in_opener").href="javascript: log_in_box_open();";
    get_object("right_box_orange_sel_left[1]").onclick=log_in_box_open;
    get_object("right_box_orange_sel_middle[1]").onclick=log_in_box_open;
    get_object("right_box_orange_sel_right[1]").onclick=log_in_box_open;
    set_style("log_in_box_div","visibility","hidden");
    set_style("log_in_box_div","display","none");
    get_object("log_in_td_error").innerHTML="";
    document.log_in_form["email"].value="@";
    document.log_in_form["password"].value="";
    document.log_in_form["remember_me"].checked=false;
    document.log_in_form["email"].disabled=false;
    document.log_in_form["password"].disabled=false;
    document.log_in_form["remember_me"].disabled=false;
    document.log_in_form["submit"].disabled=false;
  }

  function sign_up_box_open() {
    log_in_box_close();
    forgot_password_box_close();
    generate_security_code(2);
    log_in_sign_up_menu_hover_active=2;
    set_class("right_box_orange_sel_left[2]","left_active");
    set_class("right_box_orange_sel_middle[2]","middle_active");
    set_class("right_box_orange_sel_right[2]","right_active");
    get_object("sign_up_opener").href="javascript: void(0);";
    get_object("right_box_orange_sel_left[2]").onclick="";
    get_object("right_box_orange_sel_middle[2]").onclick="";
    get_object("right_box_orange_sel_right[2]").onclick="";
    set_style("sign_up_box_div","display","block");
    set_style("sign_up_box_div","visibility","visible");
    document.sign_up_form["first_name"].focus();
  }
  function sign_up_box_close() {
    log_in_sign_up_menu_hover_active=0;
    set_class("right_box_orange_sel_left[2]","left_inactive");
    set_class("right_box_orange_sel_middle[2]","middle_inactive");
    set_class("right_box_orange_sel_right[2]","right_inactive");
    get_object("sign_up_opener").href="javascript: sign_up_box_open();";
    get_object("right_box_orange_sel_left[2]").onclick=sign_up_box_open;
    get_object("right_box_orange_sel_middle[2]").onclick=sign_up_box_open;
    get_object("right_box_orange_sel_right[2]").onclick=sign_up_box_open;
    set_style("sign_up_box_div","visibility","hidden");
    set_style("sign_up_box_div","display","none");
    get_object("sign_up_td_error").innerHTML="";
    document.sign_up_form["id_invitation"].value="";
    document.sign_up_form["invitation_code"].value="";
    document.sign_up_form["first_name"].value="";
    document.sign_up_form["last_name"].value="";
    document.sign_up_form["email"].value="@";
    document.sign_up_form["password"].value="";
    document.sign_up_form["confirm_password"].value="";
    get_object("sign_up_security_image").src="/ajax/form_check_code.php?id_form=2&ri=0&id_language=<?php echo $id_language; ?>";
    document.sign_up_form["security_code"].value="";
    document.sign_up_form["remember_me"].checked=false;
    document.sign_up_form["accept_terms"].checked=false;
    document.sign_up_form["first_name"].disabled=false;
    document.sign_up_form["last_name"].disabled=false;
    document.sign_up_form["email"].disabled=false;
    document.sign_up_form["password"].disabled=false;
    document.sign_up_form["confirm_password"].disabled=false;
    document.sign_up_form["security_code"].disabled=false;
    document.sign_up_form["remember_me"].disabled=false;
    document.sign_up_form["accept_terms"].disabled=false;
    document.sign_up_form["submit"].disabled=false;
    document.sign_up_form["pseudonym_type"][0].checked=true;
    for (i=0; i<5; i++) document.sign_up_form["pseudonym_type"][i].disabled=false;
    document.sign_up_form["pseudonym"].value=dict_other;
    set_style("pseudonym_textinput","color","#aaaaaa");
    document.sign_up_form["pseudonym"].disabled=false;
    set_style("pseudonym_table","visibility","hidden");
    set_style("pseudonym_table","display","none");
  }

  function pseudonym_generate() {
    if (document.sign_up_form["first_name"].value!=trim(document.sign_up_form["first_name"].value).toUpperCase().substr(0,1)+trim(document.sign_up_form["first_name"].value).substr(1)) document.sign_up_form["first_name"].value=trim(document.sign_up_form["first_name"].value).toUpperCase().substr(0,1)+trim(document.sign_up_form["first_name"].value).substr(1);
    if (document.sign_up_form["last_name"].value!=trim(document.sign_up_form["last_name"].value).toUpperCase().substr(0,1)+trim(document.sign_up_form["last_name"].value).substr(1)) document.sign_up_form["last_name"].value=trim(document.sign_up_form["last_name"].value).toUpperCase().substr(0,1)+trim(document.sign_up_form["last_name"].value).substr(1);
    if (document.sign_up_form["pseudonym"].value!=trim(document.sign_up_form["pseudonym"].value).toUpperCase().substr(0,1)+trim(document.sign_up_form["pseudonym"].value).substr(1)) document.sign_up_form["pseudonym"].value=trim(document.sign_up_form["pseudonym"].value).toUpperCase().substr(0,1)+trim(document.sign_up_form["pseudonym"].value).substr(1);
    if (trim(document.sign_up_form["first_name"].value)!="" && trim(document.sign_up_form["last_name"].value)!="") {
      get_object("pseudonym_type_text[1]").innerHTML=trim(document.sign_up_form["first_name"].value)+" "+trim(document.sign_up_form["last_name"].value);
      get_object("pseudonym_type_text[2]").innerHTML=trim(document.sign_up_form["first_name"].value)+" "+trim(document.sign_up_form["last_name"].value).substring(0,1);
      get_object("pseudonym_type_text[3]").innerHTML=trim(document.sign_up_form["first_name"].value);
      get_object("pseudonym_type_text[4]").innerHTML=trim(document.sign_up_form["last_name"].value);
      set_style("pseudonym_table","visibility","visible");
      set_style("pseudonym_table","display","block");
    } else {
      set_style("pseudonym_table","visibility","hidden");
      set_style("pseudonym_table","display","none");
    }
  }
  function pseudonym_clear() {
    if (document.sign_up_form["pseudonym"].value==dict_other) document.sign_up_form["pseudonym"].value='';
    set_style("pseudonym_textinput","color","#000000");
    document.sign_up_form["pseudonym_type"][4].checked=true;
  }

  function forgot_password_box_open() {
    sign_up_box_close();
    log_in_box_close();
    generate_security_code(1);
    set_style("forgot_password_box_div","display","block");
    set_style("forgot_password_box_div","visibility","visible");
    document.forgot_password_form["email"].focus();
  }
  function forgot_password_box_close() {
    set_style("forgot_password_box_div","visibility","hidden");
    set_style("forgot_password_box_div","display","none");
    get_object("forgot_password_td_error").innerHTML="";
    document.forgot_password_form["email"].value="@";
    get_object("forgot_password_security_image").src="/ajax/form_check_code.php?id_form=1&ri=0&id_language=<?php echo $id_language; ?>";
    document.forgot_password_form["security_code"].value="";
    document.forgot_password_form["email"].disabled=false;
    document.forgot_password_form["security_code"].disabled=false;
    document.forgot_password_form["submit"].disabled=false;
  }

  function generate_security_code(id_form) {
    var xml_http_security_code=createXmlHttpRequestObject();
    if (xml_http_security_code) {
      xml_http_security_code.open("GET","/ajax/form_check_code.php?id_form="+id_form+"&ri=-1&id_language="+id_interface_language,true);
      xml_http_security_code.onreadystatechange=function() {
        if (xml_http_security_code.readyState==4 && xml_http_security_code.status==200) {
          var response=xml_http_security_code.responseText;
          if (response!="") {
            if (id_form==1) {
              document.forgot_password_form["requested_index"].value=parseInt(response);
              get_object("forgot_password_security_image").src="/ajax/form_check_code.php?id_form=1&ri="+parseInt(response)+"&id_language="+id_interface_language;
            } else if (id_form==2) {
              document.sign_up_form["requested_index"].value=parseInt(response);
              get_object("sign_up_security_image").src="/ajax/form_check_code.php?id_form=2&ri="+parseInt(response)+"&id_language="+id_interface_language;
            }
          }
        }
      }
      xml_http_security_code.send(null);
    }
  }

// this keeps me online if I have browser open but make no click + updates count of new messages in main menu

  number_regexp=/^[1-9][0-9]*$/;
  ids_list_regexp=/^[1-9][0-9]*([,][1-9][0-9]*)*$/;

  function keep_me_online(id_users_refresh_msg_cnt,function_run_count) {
    var xml_http_keep_me_online=createXmlHttpRequestObject(), parameters="", update_users_msg_cnt=0, time_next=10000;
    if (xml_http_keep_me_online) {
      if (id_users_refresh_msg_cnt && ids_list_regexp.test(id_users_refresh_msg_cnt)==true) {
        parameters="?id_users_refresh_msg_cnt="+id_users_refresh_msg_cnt;
        update_users_msg_cnt=1;
      }
      xml_http_keep_me_online.open("GET","/ajax/keep_me_online.php"+parameters,true);
      xml_http_keep_me_online.onreadystatechange=function() {
        if (xml_http_keep_me_online.readyState==4 && xml_http_keep_me_online.status==200) {
          var response=xml_http_keep_me_online.responseText;
          //alert(response);
          if (response!="") {
            var response_array=response.split(";");
            update_main_msg_cnt(response_array[0],response_array[1]);
            for (var i=2; i<response_array.length; i++) {
              temp=response_array[i].split(",");
              update_user_msg_cnt(temp[0],temp[1],temp[2]);
            }
          }
        }
      }
      xml_http_keep_me_online.send(null);
    }
    function_run_count++;
    if (function_run_count<6) time_next=10000;
    else if (function_run_count<9) time_next=20000;
    else if (function_run_count<11) time_next=30000;
    else time_next=60000;
    setTimeout("keep_me_online('"+id_users_refresh_msg_cnt+"',"+function_run_count+");",time_next);
  }

  function main_menu_hover(id,oo,id_s) {
    var new_class="over";
    if (oo==0 && id_s==id) new_class="active";
    if (oo==0 && id_s!=id) new_class="inactive";
    set_class("main_menu_td_left["+id+"]","left_"+new_class);
    set_class("main_menu_td_middle["+id+"]","middle_"+new_class);
    if (id==4) {
      if (parseInt(get_object("main_menu_messages_count").innerHTML)==0) envelope_class="envelope0"; else envelope_class="envelope";
      set_class("main_menu_td_middle2[4]","middle_"+new_class+" "+envelope_class);
    }
    set_class("main_menu_td_right["+id+"]","right_"+new_class);
  }

  function update_main_msg_cnt(count,id_user_latest_message) {
    if (parseInt(count)>0) {
      set_style("main_menu_td_middle2[4]","backgroundImage","url('"+images_files_dir+"envelope.gif')");
      if (beta1_config==0 && parseInt(count)>parseInt(new_messages_count) && chat_window_play_new_msg_sound==1) {
        if (chat_window==null || ( (chat_window.open) && chat_window.open==false ) || ( (chat_window.closed) && chat_window.closed==true ) ) {
          soundManager.play('new_message');
          chat_window_play_new_msg_sound=0;
          open_chat_window(id_user_latest_message);
        }
      }
    } else {
      set_style("main_menu_td_middle2[4]","backgroundImage","url('"+images_files_dir+"envelope0.gif')");
    }
    get_object("main_menu_messages_count").innerHTML=parseInt(count);
    new_messages_count=parseInt(count);
  }

  function update_user_msg_cnt(id_user,count,count_new) {
    if (typeof(user_list_item_id_user)!="undefined" && ids_list_regexp.test(id_user)==true) {
      id_user_array=id_user.split(",");
      for (var j=0; j<id_user_array.length; j++) {
        for (var i=0; i<user_list_item_id_user.length; i++) {
          if (user_list_item_id_user[i]==id_user_array[j]) {
            var all_messages_count_old=parseInt(get_object("span_messages_count["+i+"]").innerHTML);
            if (count.charAt(0)=="+") {
              get_object("span_messages_count["+i+"]").innerHTML=parseInt(get_object("span_messages_count["+i+"]").innerHTML)+parseInt(count.substr(1));
              var all_messages_count_new=all_messages_count_old+parseInt(count.substr(1));
            } else {
              get_object("span_messages_count["+i+"]").innerHTML=count;
              var all_messages_count_new=count;
            }
            if (count_new!="x" && count_new>0) {
              get_object("span_new_messages_count["+i+"]").innerHTML=count_new;
              set_class("span_new_messages_count["+i+"]","user_profile_card_messages_new");
              set_class("span_messages_count["+i+"]","user_profile_card_messages_all");
              try {
                set_style("user_list_last_message_text["+i+"]","width","360px");
                set_style("user_list_last_message_answer_button["+i+"]","visibility","visible");
                if (all_messages_count_new>all_messages_count_old) update_last_sent_message(id_user,i);
              } catch(e) { }
            } else if (count_new!="x") {
              get_object("span_new_messages_count["+i+"]").innerHTML="";
              set_class("span_new_messages_count["+i+"]","user_profile_card_messages_new_no_new");
              set_class("span_messages_count["+i+"]","user_profile_card_messages_all_no_new");
              try {
                set_style("user_list_last_message_answer_button["+i+"]","visibility","hidden");
                set_style("user_list_last_message_text["+i+"]","width","auto");
                if (all_messages_count_new>all_messages_count_old) update_last_sent_message(id_user,i);
              } catch(e) { }
            }
          }
        }
      }
    }
  }

// quick search in main menu

  function quick_search_form_keyword_clear(keyword) {
    if (document.quick_search_form["filter_keyword"].value==keyword) document.quick_search_form["filter_keyword"].value='';
    set_style("quick_search_form_keyword","color","#000000");
  }
    
  function quick_search_form_check(keyword,alert_text) {
    if (document.quick_search_form["filter_keyword"].value==keyword || trim(document.quick_search_form["filter_keyword"].value)=='') {
      alert(alert_text);
      set_style("quick_search_form_keyword","color","#000000");
      document.quick_search_form["filter_keyword"].focus();
      return false;
    }
  }

// main menu - submenu opener

  function main_submenu_open(id,i) {
    if (i==1) {
      set_style("main_submenu["+id+"]","display","block");
      set_style("main_submenu["+id+"]","visibility","visible");
      set_style("main_menu_item["+id+"]","background","url('"+images_files_dir+"back_main_menu.gif') 0px -26px repeat-x");
    } else {
      set_style("main_submenu["+id+"]","visibility","hidden");
      set_style("main_submenu["+id+"]","display","none");
      set_style("main_menu_item["+id+"]","background","url('"+images_files_dir+"back_main_menu.gif') 0px 0px repeat-x");
    }
  }

// user photos
  
  function enlarge_photo(id_s,id_user,file) {
    var screen_w=640, screen_h=480;
    if (parseInt(navigator.appVersion)>3) {
      screen_w=screen.width;
      screen_h=screen.height;
    }
    window.open("/user_photo.php?id_s="+id_s+"&id_user="+id_user+"&file="+file,"user_photo","status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,top="+parseInt((screen_h-250)/2)+",left="+parseInt((screen_w-250)/2)+",height=250,width=250");
  }

// user chat

  var chat_window=null;
  var chat_window_is_focused=0;
  var chat_window_play_new_msg_sound=1;
  function open_chat_window(id_chat_partner,send_as_sms,id_list) {
    var width=610, height=600;
    var screen_w=800, screen_h=600;
    if (parseInt(navigator.appVersion)>3) {
      screen_w=screen.width;
      screen_h=screen.height;
    }
    if (!send_as_sms) send_as_sms=0;
    if (!id_list) id_list=0;
    chat_window=window.open("/messenger.php?id_chat_partner="+id_chat_partner+"&send_as_sms="+send_as_sms+"&id_list="+id_list,"chat_window","status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,top="+parseInt((screen_h-height)/2)+",left="+parseInt((screen_w-width)/2)+",height="+height+",width="+width);
    if (chat_window && chat_window.open==true && ( !chat_window.closed || chat_window.closed==false)) {
      chat_window.focus();
      chat_window_is_focused=1;
      chat_window_play_new_msg_sound=1;
    }
  }

// user notes
  
  function open_user_notes_window(id_user) {
    var width=700, height=500;
    var screen_w=800, screen_h=600;
    if (parseInt(navigator.appVersion)>3) {
      screen_w=screen.width;
      screen_h=screen.height;
    }
    user_notes_window=window.open("/user_notes.php?id_user="+id_user,"user_notes_window_"+id_user,"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,top="+parseInt((screen_h-height)/2)+",left="+parseInt((screen_w-width)/2)+",height="+height+",width="+width);
    user_notes_window.focus();
  }

// send user profile to friend
  
  function open_send_to_friend_window(id_user) {
    var width=700, height=360;
    var screen_w=800, screen_h=600;
    if (parseInt(navigator.appVersion)>3) {
      screen_w=screen.width;
      screen_h=screen.height;
    }
    send_to_friend_window=window.open("/send_to_friend.php?id_user="+id_user,"send_to_friend_window_"+id_user,"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,top="+parseInt((screen_h-height)/2)+",left="+parseInt((screen_w-width)/2)+",height="+height+",width="+width);
    send_to_friend_window.focus();
  }

// print profile
  
  function open_print_profile_window(id_user,id_language) {
    var width=710, height=480;
    var screen_w=800, screen_h=600;
    if (parseInt(navigator.appVersion)>3) {
      screen_w=screen.width;
      screen_h=screen.height;
    }
    user_print_profile_window=window.open("/print_profile.php?id_user="+id_user+"&id_language="+id_language,"print_profile_window_"+id_user,"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,top="+parseInt((screen_h-height)/2)+",left="+parseInt((screen_w-width)/2)+",height="+height+",width="+width);
    user_print_profile_window.focus();
  }

// pdf export profile
  
  function open_pdf_export_profile_window(id_user,id_language) {
    var width=710, height=480;
    var screen_w=800, screen_h=600;
    if (parseInt(navigator.appVersion)>3) {
      screen_w=screen.width;
      screen_h=screen.height;
    }
    user_pdf_export_profile_window=window.open("/pdf_profile.php?id_user="+id_user+"&id_resume_language="+id_language,"pdf_export_profile_window_"+id_user,"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=0,top="+parseInt((screen_h-height)/2)+",left="+parseInt((screen_w-width)/2)+",height="+height+",width="+width);
    //user_pdf_export_profile_window.focus();
  }

// send a job to friend
  
  function open_send_to_friend_job_window(id_job) {
    var width=700, height=257;
    var screen_w=800, screen_h=600;
    if (parseInt(navigator.appVersion)>3) {
      screen_w=screen.width;
      screen_h=screen.height;
    }
    send_to_friend_job_window=window.open("/send_to_friend_job.php?id_job="+id_job,"send_to_friend_job_window_"+id_job,"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,top="+parseInt((screen_h-height)/2)+",left="+parseInt((screen_w-width)/2)+",height="+height+",width="+width);
    send_to_friend_job_window.focus();
  }

// apply for a job
  
  function open_apply_for_job_window(id_job) {
    var width=700, height=400;
    var screen_w=800, screen_h=600;
    if (parseInt(navigator.appVersion)>3) {
      screen_w=screen.width;
      screen_h=screen.height;
    }
    apply_for_job_window=window.open("/apply_for_job.php?id_job="+id_job,"apply_for_job_window_"+id_job,"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,top="+parseInt((screen_h-height)/2)+",left="+parseInt((screen_w-width)/2)+",height="+height+",width="+width);
    apply_for_job_window.focus();
  }

// user lists
  
  function user_menu_open(id_user) {
    set_style("user_profile_card_"+id_user,"zIndex","1");
    set_style("user_menu_"+id_user,"display","block");
    var obj=get_object("user_menu_opener_"+id_user);
    var user_menu_left=0, user_menu_top=0, window_width=0, window_height=0, window_scroll_left=0, window_scroll_top=0;
    if (obj.offsetParent) {
      do {
  			user_menu_left+=obj.offsetLeft;
  			user_menu_top+=obj.offsetTop;
  	  }
      while (obj=obj.offsetParent);
  	}
    if (typeof(window.innerWidth)=='number' ) { //Non-IE
      window_width=window.innerWidth-20;
      window_height=window.innerHeight-20;
    } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) { //IE 6+ in 'standards compliant mode'
      window_width=document.documentElement.clientWidth;
      window_height=document.documentElement.clientHeight;
    } else if(document.body && (document.body.clientWidth || document.body.clientHeight) ) { //IE 4 compatible
      window_width=document.body.clientWidth;
      window_height=document.body.clientHeight;
    }
    if (typeof(window.pageYOffset)=='number') { //Netscape compliant
      window_scroll_top=window.pageYOffset;
      window_scroll_left=window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { //DOM compliant
      window_scroll_top=document.body.scrollTop;
      window_scroll_left=document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { //IE6 standards compliant mode
      window_scroll_top=document.documentElement.scrollTop;
      window_scroll_left=document.documentElement.scrollLeft;
    }
    if (window_height-(user_menu_top-window_scroll_top)-22<get_object("user_menu_"+id_user).offsetHeight) {
      if (window_width-(user_menu_left-window_scroll_left)<get_object("user_menu_"+id_user).offsetWidth) {
        set_class("user_menu_"+id_user,"user_menu user_menu_top_left");
      } else {
        set_class("user_menu_"+id_user,"user_menu user_menu_top_right");
      }
    } else {
      if (window_width-(user_menu_left-window_scroll_left)<get_object("user_menu_"+id_user).offsetWidth) {
        set_class("user_menu_"+id_user,"user_menu user_menu_bottom_left");
      } else {
        set_class("user_menu_"+id_user,"user_menu user_menu_bottom_right");
      }
    }
    set_class("user_menu_opener_"+id_user,"user_menu_link");
    set_style("user_menu_"+id_user,"visibility","visible");
  }
  
  function user_menu_close(id_user) {
    set_style("user_profile_card_"+id_user,"zIndex","0");
    set_class("user_menu_opener_"+id_user,"user_menu_link_mouseout");
    set_style("user_menu_"+id_user,"visibility","hidden");
    set_style("user_menu_"+id_user,"display","none");
    set_class("user_menu_"+id_user,"user_menu user_menu_bottom_right");
  }

// contacts

  function remove_from_contacts(id_menu,id_user) {
    user_menu_close(id_menu);
    if (window.confirm(dict_really_want_to_remove_from_contacts)) {
      var xml_http_remove_from_contacts=createXmlHttpRequestObject();
      if (xml_http_remove_from_contacts) {
        xml_http_remove_from_contacts.open("GET","/ajax/remove_from_contacts.php?id_user="+id_user,true);
        xml_http_remove_from_contacts.onreadystatechange=function() {
          if (xml_http_remove_from_contacts.readyState==4 && xml_http_remove_from_contacts.status==200) {
            var response_remove_from_contacts=xml_http_remove_from_contacts.responseText;
            if (response_remove_from_contacts!="" && response_remove_from_contacts.charAt(0)=="1") window.location.reload();
          }
        }
        xml_http_remove_from_contacts.send(null);  
      }
    }
  }

// connections

  var temp_sent_connection_requests=new Array();
  function add_to_connections(id_menu,id_user,user_name,id_link,already_sent) {
    user_menu_close(id_menu);
    if ((already_sent==0 || already_sent==2) && !temp_sent_connection_requests[id_user]) {
      var window_scroll_top=0, window_height=0;
      if (typeof(window.pageYOffset)=='number') { //Netscape compliant
        window_scroll_top=window.pageYOffset;
      } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { //DOM compliant
        window_scroll_top=document.body.scrollTop;
      } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { //IE6 standards compliant mode
        window_scroll_top=document.documentElement.scrollTop;
      }
      if (typeof(window.innerWidth)=='number' ) { //Non-IE
        window_height=window.innerHeight-20;
      } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) { //IE 6+ in 'standards compliant mode'
        window_height=document.documentElement.clientHeight;
      } else if(document.body && (document.body.clientWidth || document.body.clientHeight) ) { //IE 4 compatible
        window_height=document.body.clientHeight;
      }
      document.add_to_connections_form["id_user"].value=id_user;
      document.add_to_connections_form["id_link"].value=id_link;
      if (already_sent!=2) {
        get_object("add_to_connections_div").style.marginTop=(window_scroll_top+Math.round(window_height/4))+"px";
      	get_object("add_to_connections_username").innerHTML=user_name;
      	get_object("add_to_connections_box_foto").innerHTML=get_object("user_profile_card_photo_image["+id_menu+"]").innerHTML;
        get_object("overdiv_popup").innerHTML=get_object("add_to_connections_div_holder").innerHTML;
        get_object("add_to_connections_div_holder").innerHTML="";
        visibility_change("overdiv_black");
        visibility_change("overdiv_popup");
      } else {
        add_to_connections_form_check();
      }
    } else {
      alert(dict_connection_request_already_sent);
    }
  }

  function add_to_connections_close() {
    visibility_change("overdiv_black");
    visibility_change("overdiv_popup");
    document.add_to_connections_form["message"].disabled=false;
    document.add_to_connections_form["submit"].disabled=false;
    document.add_to_connections_form["message"].value=dict_click_to_type_note_send_along_with_connection_request;
    document.add_to_connections_form["message"].style.color="#999999";
    document.add_to_connections_form["send_message"].value=0;
    get_object("add_to_connections_div_holder").innerHTML=get_object("overdiv_popup").innerHTML;
    get_object("overdiv_popup").innerHTML="";
  }
  
  function add_to_connections_message(i) {
    if (i==1) {
      if (document.add_to_connections_form["send_message"].value==0) {
        document.add_to_connections_form["send_message"].value=1;
        document.add_to_connections_form["message"].value="";
        document.add_to_connections_form["message"].style.color="#000000";
      }
    } else {
      if (trim(document.add_to_connections_form["message"].value)=="") {
        document.add_to_connections_form["send_message"].value=0;
        document.add_to_connections_form["message"].value=dict_click_to_type_note_send_along_with_connection_request;
        document.add_to_connections_form["message"].style.color="#999999";
      }
    }
  }

  function add_to_connections_form_check() {
    var url_add_to_connections="/ajax/add_to_connections.php";
    var params_add_to_connections="id_user="+document.add_to_connections_form["id_user"].value+"&send_message="+document.add_to_connections_form["send_message"].value+"&message="+document.add_to_connections_form["message"].value;
    var xml_http_add_to_connections=createXmlHttpRequestObject();
    if (xml_http_add_to_connections) {
      document.add_to_connections_form["message"].disabled=true;
      document.add_to_connections_form["submit"].disabled=true;
      xml_http_add_to_connections.open("POST",url_add_to_connections,true);
      xml_http_add_to_connections.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xml_http_add_to_connections.setRequestHeader("Content-length", params_add_to_connections.length);
      xml_http_add_to_connections.setRequestHeader("Connection", "close");
      xml_http_add_to_connections.onreadystatechange=function() {
        if (xml_http_add_to_connections.readyState==4) {
          if (xml_http_add_to_connections.status==200) {
            var response_add_to_connections=xml_http_add_to_connections.responseText;
            if (response_add_to_connections!="") {
              if (response_add_to_connections.charAt(0)=="1") {
                alert(dict_error_while_sending_connection_request);
                add_to_connections_close();
              }
              if (response_add_to_connections.charAt(0)=="2") {
                alert(dict_user_is_already_in_connections);
                add_to_connections_close();
              }
              if (response_add_to_connections.charAt(0)=="3") {
                alert(dict_connection_request_already_sent);
                add_to_connections_close();
              }
              if (response_add_to_connections.charAt(0)=="4") {
                temp_sent_connection_requests[document.add_to_connections_form["id_user"].value]=1;
                alert(dict_connection_request_was_sent);
                add_to_connections_close();
              }
              if (response_add_to_connections.charAt(0)=="5") {
                var response_add_to_connections_array=response_add_to_connections.split(";;;;;");
                get_object("connections_count").innerHTML=response_add_to_connections_array[1];
                if (get_object("subscriptions_count")) get_object("subscriptions_count").innerHTML=response_add_to_connections_array[2];
                get_object("my_rank").innerHTML=response_add_to_connections_array[3];
                for (i=0; i<user_list_item_id_user.length; i++) {
                  if (user_list_item_id_user[i]==document.add_to_connections_form["id_user"].value) {
                    get_object("user_menu_item_link["+i+"_"+document.add_to_connections_form["id_link"].value+"]").style.visibility="hidden";
                    get_object("user_menu_item_link["+i+"_"+document.add_to_connections_form["id_link"].value+"]").style.display="none";
                  }
                }
                temp_sent_connection_requests[document.add_to_connections_form["id_user"].value]=1;
                alert(dict_user_was_added_to_connections);
              }
            } else {
              document.add_to_connections_form["message"].disabled=false;
              document.add_to_connections_form["submit"].disabled=false;
            }
          } else if (xml_http_add_to_connections.status==12029 || xml_http_add_to_connections.status==12030 || xml_http_add_to_connections.status==12031 || xml_http_add_to_connections.status==12152 || xml_http_add_to_connections.status==12159) add_to_connections_form_check();
        }
      }
      xml_http_add_to_connections.send(params_add_to_connections);  
    }
    return false;
  }

  function remove_from_connections(id_menu,id_user) {
    user_menu_close(id_menu);
    if (window.confirm(dict_really_want_to_remove_from_connections)) {
      var xml_http_remove_from_connections=createXmlHttpRequestObject();
      if (xml_http_remove_from_connections) {
        xml_http_remove_from_connections.open("GET","/ajax/remove_from_connections.php?id_user="+id_user,true);
        xml_http_remove_from_connections.onreadystatechange=function() {
          if (xml_http_remove_from_connections.readyState==4 && xml_http_remove_from_connections.status==200) {
            var response_remove_from_connections=xml_http_remove_from_connections.responseText;
            if (response_remove_from_connections!="" && response_remove_from_connections.charAt(0)=="1") window.location.reload();
          }
        }
        xml_http_remove_from_connections.send(null);  
      }
    }
  }

// blacklist

  function add_to_blacklist(id_menu,id_user,user_name,id_link,reload) {
    user_menu_close(id_menu);
    var window_scroll_top=0, window_height=0;
    if (typeof(window.pageYOffset)=='number') { //Netscape compliant
      window_scroll_top=window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { //DOM compliant
      window_scroll_top=document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { //IE6 standards compliant mode
      window_scroll_top=document.documentElement.scrollTop;
    }
    if (typeof(window.innerWidth)=='number' ) { //Non-IE
      window_height=window.innerHeight-20;
    } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) { //IE 6+ in 'standards compliant mode'
      window_height=document.documentElement.clientHeight;
    } else if(document.body && (document.body.clientWidth || document.body.clientHeight) ) { //IE 4 compatible
      window_height=document.body.clientHeight;
    }
    document.add_to_blacklist_form["id_user"].value=id_user;
    document.add_to_blacklist_form["id_link"].value=id_link;
    document.add_to_blacklist_form["reload"].value=reload;
    get_object("add_to_blacklist_div").style.marginTop=(window_scroll_top+Math.round(window_height/4))+"px";
  	get_object("add_to_blacklist_username").innerHTML=user_name;
    get_object("overdiv_popup").innerHTML=get_object("add_to_blacklist_div_holder").innerHTML;
    get_object("add_to_blacklist_div_holder").innerHTML="";
    visibility_change("overdiv_black");
    visibility_change("overdiv_popup");
  }
  
  function add_to_blacklist_close() {
    visibility_change("overdiv_black");
    visibility_change("overdiv_popup");
    get_object("add_to_blacklist_ra_r").style.visibility="hidden";
    get_object("add_to_blacklist_ra_r").style.display="none";
    get_object("add_to_blacklist_ra_rd").style.visibility="hidden";
    get_object("add_to_blacklist_ra_rd").style.display="none";
    document.add_to_blacklist_form["report_abuse"].disabled=false;
    document.add_to_blacklist_form["report_abuse_reason"].disabled=false;
    document.add_to_blacklist_form["report_abuse_reason_description"].disabled=false;
    document.add_to_blacklist_form["submit"].disabled=false;
    document.add_to_blacklist_form["report_abuse"].checked=false;
    document.add_to_blacklist_form["report_abuse_reason"].value=1;
    document.add_to_blacklist_form["report_abuse_reason_description"].value="";
    get_object("add_to_blacklist_div_holder").innerHTML=get_object("overdiv_popup").innerHTML;
    get_object("overdiv_popup").innerHTML="";
  }

  function add_to_blacklist_ra() {
    if (document.add_to_blacklist_form["report_abuse"].checked==true) {
      get_object("add_to_blacklist_ra_r").style.visibility="visible";
      get_object("add_to_blacklist_ra_r").style.display="block";
    } else {
      get_object("add_to_blacklist_ra_rd").style.visibility="hidden";
      get_object("add_to_blacklist_ra_rd").style.display="none";
      document.add_to_blacklist_form["report_abuse_reason_description"].value="";
      get_object("add_to_blacklist_ra_r").style.visibility="hidden";
      get_object("add_to_blacklist_ra_r").style.display="none";
      document.add_to_blacklist_form["report_abuse_reason"].value=1;
    }
  }

  function add_to_blacklist_ra_r(i) {
    if (i==6) {
      get_object("add_to_blacklist_ra_rd").style.visibility="visible";
      get_object("add_to_blacklist_ra_rd").style.display="block";
    } else {
      get_object("add_to_blacklist_ra_rd").style.visibility="hidden";
      get_object("add_to_blacklist_ra_rd").style.display="none";
      document.add_to_blacklist_form["report_abuse_reason_description"].value="";
    }
  }

  function add_to_blacklist_form_check() {
    var url_add_to_blacklist="/ajax/add_to_blacklist.php";
    if (document.add_to_blacklist_form["report_abuse"].checked==true) report_abuse_param=1; else report_abuse_param=0;
    var params_add_to_blacklist="id_user="+document.add_to_blacklist_form["id_user"].value+"&report_abuse="+report_abuse_param+"&report_abuse_reason="+document.add_to_blacklist_form["report_abuse_reason"].value+"&report_abuse_reason_description="+document.add_to_blacklist_form["report_abuse_reason_description"].value;
    var xml_http_add_to_blacklist=createXmlHttpRequestObject();
    if (xml_http_add_to_blacklist) {
      document.add_to_blacklist_form["report_abuse"].disabled=true;
      document.add_to_blacklist_form["report_abuse_reason"].disabled=true;
      document.add_to_blacklist_form["report_abuse_reason_description"].disabled=true;
      document.add_to_blacklist_form["submit"].disabled=true;
      xml_http_add_to_blacklist.open("POST",url_add_to_blacklist,true);
      xml_http_add_to_blacklist.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xml_http_add_to_blacklist.setRequestHeader("Content-length", params_add_to_blacklist.length);
      xml_http_add_to_blacklist.setRequestHeader("Connection", "close");
      xml_http_add_to_blacklist.onreadystatechange=function() {
        if (xml_http_add_to_blacklist.readyState==4) {
          if (xml_http_add_to_blacklist.status==200) {
            var response_add_to_blacklist=xml_http_add_to_blacklist.responseText;
            if (response_add_to_blacklist!="" && response_add_to_blacklist.charAt(0)!="-") {
              response_add_to_blacklist_array=response_add_to_blacklist.split(";;;;;");
              get_object("blacklist_count").innerHTML=response_add_to_blacklist_array[0];
              get_object("connections_count").innerHTML=response_add_to_blacklist_array[1];
              if (get_object("subscriptions_count")) get_object("subscriptions_count").innerHTML=response_add_to_blacklist_array[2];
              get_object("my_rank").innerHTML=response_add_to_blacklist_array[3];
              alert(dict_user_was_added_to_blacklist);
              add_to_blacklist_close();
              for (i=0; i<user_list_item_id_user.length; i++) {
                if (user_list_item_id_user[i]==document.add_to_blacklist_form["id_user"].value) {
                  get_object("user_menu_item_link["+i+"_"+document.add_to_blacklist_form["id_link"].value+"]").style.visibility="hidden";
                  get_object("user_menu_item_link["+i+"_"+document.add_to_blacklist_form["id_link"].value+"]").style.display="none";
                }
              }
              if (document.add_to_blacklist_form["reload"].value==1) window.location.reload();
            } else {
              document.add_to_blacklist_form["report_abuse"].disabled=false;
              document.add_to_blacklist_form["report_abuse_reason"].disabled=false;
              document.add_to_blacklist_form["report_abuse_reason_description"].disabled=false;
              document.add_to_blacklist_form["submit"].disabled=false;
            }
          } else if (xml_http_add_to_blacklist.status==12029 || xml_http_add_to_blacklist.status==12030 || xml_http_add_to_blacklist.status==12031 || xml_http_add_to_blacklist.status==12152 || xml_http_add_to_blacklist.status==12159) add_to_blacklist_form_check();
        }
      }
      xml_http_add_to_blacklist.send(params_add_to_blacklist);  
    }
    return false;
  }

  function remove_from_blacklist(id_menu, id_user) {
    user_menu_close(id_menu);
    if (window.confirm(dict_really_want_to_remove_from_blacklist)) {
      var xml_http_remove_from_blacklist=createXmlHttpRequestObject();
      if (xml_http_remove_from_blacklist) {
        xml_http_remove_from_blacklist.open("GET","/ajax/remove_from_blacklist.php?id_user="+id_user,true);
        xml_http_remove_from_blacklist.onreadystatechange=function() {
          if (xml_http_remove_from_blacklist.readyState==4 && xml_http_remove_from_blacklist.status==200) {
            var response_remove_from_blacklist=xml_http_remove_from_blacklist.responseText;
            if (response_remove_from_blacklist!="" && response_remove_from_blacklist.charAt(0)=="1") window.location.reload();
          }
        }
        xml_http_remove_from_blacklist.send(null);  
      }
    }
  }

// subscriptions
  
  function add_to_subscriptions(id_menu,id_user,id_link) {
    user_menu_close(id_menu);
    var xml_http_add_to_subscriptions=createXmlHttpRequestObject();
    if (xml_http_add_to_subscriptions) {
      xml_http_add_to_subscriptions.open("GET","/ajax/add_to_subscriptions.php?id_user="+id_user,true);
      xml_http_add_to_subscriptions.onreadystatechange=function() {
        if (xml_http_add_to_subscriptions.readyState==4 && xml_http_add_to_subscriptions.status==200) {
          var response_add_to_subscriptions=xml_http_add_to_subscriptions.responseText;
          if (response_add_to_subscriptions!="") {
            if (response_add_to_subscriptions.charAt(0)!="-") {
              get_object("subscriptions_count").innerHTML=response_add_to_subscriptions;
              for (i=0; i<user_list_item_id_user.length; i++) {
                if (user_list_item_id_user[i]==id_user) {
                  get_object("user_menu_item_link["+i+"_"+id_link+"]").style.visibility="hidden";
                  get_object("user_menu_item_link["+i+"_"+id_link+"]").style.display="none";
                }
              }
              alert(dict_user_was_added_to_subscriptions);
            }
          }
        }
      }
      xml_http_add_to_subscriptions.send(null);  
    }
  }
  
  function remove_from_subscriptions(id_menu,id_user) {
    user_menu_close(id_menu);
    if (window.confirm(dict_really_want_to_remove_from_subscriptions)) {
      var xml_http_remove_from_subscriptions=createXmlHttpRequestObject();
      if (xml_http_remove_from_subscriptions) {
        xml_http_remove_from_subscriptions.open("GET","/ajax/remove_from_subscriptions.php?id_user="+id_user,true);
        xml_http_remove_from_subscriptions.onreadystatechange=function() {
          if (xml_http_remove_from_subscriptions.readyState==4 && xml_http_remove_from_subscriptions.status==200) {
            var response_remove_from_subscriptions=xml_http_remove_from_subscriptions.responseText;
            if (response_remove_from_subscriptions!="" && response_remove_from_subscriptions.charAt(0)=="1") window.location.reload();
          }
        }
        xml_http_remove_from_subscriptions.send(null);  
      }
    }
  }

// my lists
  
/*  var dict_add_new_list="";
  var dict_my_lists="";
  var dict_please_select_list="";
  var dict_user_is_already_in_this_list="";
  var dict_user_was_added_to_list="";
  var dict_please_fill_in_list_name="";
  var dict_list_with_this_name_already_exists="";
  var dict_new_list_was_created_and_user_was_added_to_list="";
  var dict_really_want_to_remove_from_this_list="";*/
  
  function add_to_list(id_menu,id_user) {
    user_list_id_user=id_user;
    user_menu_close(id_menu);
    add_to_list_generate_lists();
    var window_scroll_top=0, window_height=0;
    if (typeof(window.pageYOffset)=='number') { //Netscape compliant
      window_scroll_top=window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { //DOM compliant
      window_scroll_top=document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { //IE6 standards compliant mode
      window_scroll_top=document.documentElement.scrollTop;
    }
    if (typeof(window.innerWidth)=='number' ) { //Non-IE
      window_height=window.innerHeight-20;
    } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight) ) { //IE 6+ in 'standards compliant mode'
      window_height=document.documentElement.clientHeight;
    } else if(document.body && (document.body.clientWidth || document.body.clientHeight) ) { //IE 4 compatible
      window_height=document.body.clientHeight;
    }
    get_object("add_to_list_div").style.marginTop=(window_scroll_top+Math.round(window_height/4))+"px";
    get_object("overdiv_popup").innerHTML=get_object("add_to_list_div_holder").innerHTML;
    get_object("add_to_list_div_holder").innerHTML="";
    visibility_change("overdiv_black");
    visibility_change("overdiv_popup");
  }
  
  function add_to_list_close() {
    visibility_change("overdiv_black");
    visibility_change("overdiv_popup");
    get_object("add_to_list_name_td").innerHTML="";
    get_object("add_to_list_value_td").innerHTML="";
    get_object("add_to_list_div_holder").innerHTML=get_object("overdiv_popup").innerHTML;
    get_object("overdiv_popup").innerHTML="";
  }
  
  function add_to_list_generate_lists() {
    document.add_to_list_form["submit"].disabled=false;
    document.add_to_list_form["cancel"].disabled=false;
    if (get_object("add_to_list_td_error").innerHTML!="") get_object("add_to_list_td_error").innerHTML="";
    if (user_list_names.length>0) {
      var select_options="";
      select_options+="<select style=\"width: 140px;\" name=\"id_user_list\" onchange=\"javascript: add_to_list_new_list();\">";
      select_options+="<option value=\"0\" class=\"nothing\">---------------------------&gt;</option>";
      for (i=0; i<user_list_names.length; i++) {
        select_options+="<option value=\""+user_list_ids[i]+"\">"+user_list_names[i]+"</option>"
      }
      select_options+="<option value=\"-1\" style=\"color: #ff0000;\">"+dict_add_new_list+"</option>";
      select_options+="</select>";
      get_object("add_to_list_name_td").innerHTML=dict_my_lists;
      get_object("add_to_list_value_td").innerHTML=select_options;
      document.add_to_list_form["adding_new_list"].value=0;
    } else {
      get_object("add_to_list_name_td").innerHTML=dict_add_new_list;
      get_object("add_to_list_value_td").innerHTML="<input type=\"text\" class=\"textinput\" style=\"width: 136px;\" name=\"new_list_name\" value=\"\" maxlength=\"100\" tabindex=\"1\">";;
      document.add_to_list_form["adding_new_list"].value=1;
    }
  }
  
  function add_to_list_new_list() {
    if (document.add_to_list_form["id_user_list"].value=="-1") {
      get_object("add_to_list_td_error").innerHTML="";
      get_object("add_to_list_name_td").innerHTML=dict_add_new_list;
      get_object("add_to_list_value_td").innerHTML="<input type=\"text\" class=\"textinput\" style=\"width: 121px; vertical-align: middle;\" name=\"new_list_name\" value=\"\" maxlength=\"100\" tabindex=\"1\"><img src=\""+images_files_dir+"select_opener.gif\" style=\"vertical-align: middle;\" onclick=\"javascript: add_to_list_generate_lists();\">";
      document.add_to_list_form["adding_new_list"].value=1;
      setTimeout("document.add_to_list_form[\"new_list_name\"].focus()",100);
    }
  }
  
  function add_to_list_form_check() {
    if (document.add_to_list_form["adding_new_list"].value==0) {
      var id_user_list=document.add_to_list_form["id_user_list"].value;
      if (id_user_list==0) {
        get_object("add_to_list_td_error").innerHTML=dict_please_select_list;
        document.add_to_list_form["id_user_list"].focus();
      } else {
        var xml_http_add_to_list=createXmlHttpRequestObject();
        if (xml_http_add_to_list) {
          document.add_to_list_form["id_user_list"].disabled=true;
          document.add_to_list_form["submit"].disabled=true;
          xml_http_add_to_list.open("GET","/ajax/add_to_my_list.php?id_user="+user_list_id_user+"&id_user_list="+id_user_list,true);
          xml_http_add_to_list.onreadystatechange=function() {
            if (xml_http_add_to_list.readyState==4 && xml_http_add_to_list.status==200) {
              var response_add_to_list=xml_http_add_to_list.responseText;
              if (response_add_to_list!="") {
                if (response_add_to_list.charAt(0)=="-" && response_add_to_list.charAt(1)=="1") {
                  alert(dict_user_is_already_in_this_list);
                  document.add_to_list_form["id_user_list"].disabled=false;
                  document.add_to_list_form["submit"].disabled=false;
                  document.add_to_list_form["id_user_list"].focus();
                }
                else {
                  get_object("my_list_count_"+id_user_list).innerHTML=response_add_to_list;
                  alert(dict_user_was_added_to_list);
                  add_to_list_close();
                }
              } else {
                document.add_to_list_form["id_user_list"].disabled=false;
                document.add_to_list_form["submit"].disabled=false;
                document.add_to_list_form["id_user_list"].focus();
              }
            }
          }
          xml_http_add_to_list.send(null);  
        }
      }
    } else {
      var user_list_name=trim(document.add_to_list_form["new_list_name"].value);
      if (user_list_name=="") {
        get_object("add_to_list_td_error").innerHTML=dict_please_fill_in_list_name;
        document.add_to_list_form["new_list_name"].focus();
      } else {
        var xml_http_add_to_list=createXmlHttpRequestObject();
        if (xml_http_add_to_list) {
          document.add_to_list_form["new_list_name"].disabled=true;
          document.add_to_list_form["submit"].disabled=true;
          var url_add_to_list="/ajax/add_to_my_list.php";
          var params_add_to_list="id_user="+user_list_id_user+"&new_list_name="+encodeURIComponent(user_list_name);
          xml_http_add_to_list.open("POST",url_add_to_list,true);
          xml_http_add_to_list.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          xml_http_add_to_list.setRequestHeader("Content-length", params_add_to_list.length);
          xml_http_add_to_list.setRequestHeader("Connection", "close");
          xml_http_add_to_list.onreadystatechange=function() {
            if (xml_http_add_to_list.readyState==4) {
              if (xml_http_add_to_list.status==200) {
                var response_add_to_list=xml_http_add_to_list.responseText;
                if (response_add_to_list!="") {
                  if (response_add_to_list.charAt(0)=="-" && response_add_to_list.charAt(1)=="1") {
                    alert(dict_list_with_this_name_already_exists);
                    document.add_to_list_form["new_list_name"].disabled=false;
                    document.add_to_list_form["submit"].disabled=false;
                    document.add_to_list_form["new_list_name"].focus();
                  }
                  else {
                    if (user_list_ids.length==0) get_object("my_lists_list").innerHTML="";
                    get_object("my_lists_list").innerHTML+="<div class=\"left_menu_item_my_list\">&bull;&nbsp; <a href=\"/?id_s=16&id_user_list="+parseInt(response_add_to_list)+"\">"+user_list_name+":</a> <span id=\"my_list_count_"+parseInt(response_add_to_list)+"\">1</span></div>";
                    user_list_names[user_list_names.length]=user_list_name;
                    user_list_ids[user_list_ids.length]=parseInt(response_add_to_list);
                    alert(dict_new_list_was_created_and_user_was_added_to_list);
                    add_to_list_close();
                  }
                } else {
                  document.add_to_list_form["new_list_name"].disabled=false;
                  document.add_to_list_form["submit"].disabled=false;
                  document.add_to_list_form["new_list_name"].focus();
                }
              } else if (xml_http_add_to_list.status==12029 || xml_http_add_to_list.status==12030 || xml_http_add_to_list.status==12031 || xml_http_add_to_list.status==12152 || xml_http_add_to_list.status==12159) add_to_list_form_check();
            }
          }
          xml_http_add_to_list.send(params_add_to_list);
        }
      }
    }
    return false;
  }
  
  function remove_from_list(id_menu, id_user, id_user_list) {
    user_menu_close(id_menu);
    if (window.confirm(dict_really_want_to_remove_from_this_list)) {
      var xml_http_remove_from_list=createXmlHttpRequestObject();
      if (xml_http_remove_from_list) {
        xml_http_remove_from_list.open("GET","/ajax/remove_from_my_list.php?id_user="+id_user+"&id_user_list="+id_user_list,true);
        xml_http_remove_from_list.onreadystatechange=function() {
          if (xml_http_remove_from_list.readyState==4 && xml_http_remove_from_list.status==200) {
            var response_remove_from_list=xml_http_remove_from_list.responseText;
            if (response_remove_from_list!="" && response_remove_from_list.charAt(0)=="1") window.location.reload();
          }
        }
        xml_http_remove_from_list.send(null);  
      }
    }
  }

// RSS

  function rss_open(type,id,language) {
    window.open("/rss/?type="+type+"&id="+id+"&language="+language,"");
  }

// to be done...

  function tbd() {
    //user_menu_close(id_user);
    alert("To be done ...");
  }

