var search_perfomer_interval;
var main_support_interval;
var interval;
var updatingNow = 0; //needed to do not show wait cursor during updating lists
var multi_model_id = 0;  // using on refresh
var blink_mail;
var blink_mail_t;
var chatBadWords = new Array(); var chatReplacements = new Array();

function badWordsFilter(msg) {
  var bwLen = chatBadWords.length;
  var gwLen = chatReplacements.length;
  var rand = new Date();
  var rEl=(rand.getSeconds())%gwLen;
  for (var i=0; i<bwLen; i++) {
    before = msg;
    after = msg.replace(chatBadWords[i]);
    if (before != after) {
      msg = chatReplacements[rEl];
      break;
    }
  }
  return msg;
}
function pushToFrame(msg, id) {
  var cpanel = parent.frames[id].document.getElementById('chat_panel');
  cpanel.innerHTML = msg + cpanel.innerHTML;
}

//function refresh_member_act(){
//  xajax_updateMemberActivity();
//}
function refresh(forcePerformerId) {
  updatingNow = 1;
  var flObject = window.document.getElementById('lSubscriber');
  if (null === flObject) flObject = window.document.getElementById('usersPerform_flex');
  if (null === flObject) flObject = window.document.getElementById('multistream'); 
  var tmpObject = window.document.getElementById('temp_value');
  //alert(flObject + "___" + tmpObject);
  if (null !== flObject && null !== tmpObject && (multi_model_id != 0 || Number(forcePerformerId) > 0)) {
    var performerId = multi_model_id;
    if (Number(forcePerformerId) > 0) performerId = Number(forcePerformerId);
    xajax_crefresh(performerId);
  } 
  updatingNow = 0;
  return false;
}

function generate(a){
  if (a!=0) xajax_generateProfile(a);
  else window.location="/";
  return false;
}
function pause(ifunc){
  setTimeout("startCheck('"+ifunc+"');",1000);
}
function startCheck(ifunc){
  interval = setInterval("top."+ifunc+"();",100);
}
function cwindow(cid) {
  frameid = 'chat_frame_'+cid;
  parent.frames[frameid].document.getElementById('chat_panel').innerHTML="";
}

function checkLogin(uid) {
  xajax_memberLogoutByAdmin(uid,0);
  setTimeout("checkLogin('"+uid+"');",60000);
}

function inprivate() {
  var checkbox = window.document.getElementById('mode');
  checkbox.checked = true;
  checkbox.disabled = "disabled";
  checkbox.type = 'hidden';
  var prv_text = window.document.getElementById('prv_text');
  prv_text.innerHTML = "";
  var btn_private = window.document.getElementById('btn_private');
  if (null !== btn_private) btn_private.style.display = 'none';
}
//**********************
function smile(template_url) {
  div = window.document.getElementById('smiles');
  if(div.style.display=='none') {
    if (div.innerHTML=='') xajax_addsmile();
    div.style.display='block';
    window.document.getElementById('smile_img').src = template_url + "/images/smiley-off.gif";
    window.document.getElementById('smile_img').alt="Hide smiles";
    window.document.getElementById('smile_img').title="Hide smiles"
  } else {
    //div.innerHTML='';
    div.style.display='none';
    window.document.getElementById('smile_img').src = template_url + "/images/smiley-on.gif";
    window.document.getElementById('smile_img').alt="Show smiles";
    window.document.getElementById('smile_img').title="Show smiles"
  }
}
//*********************
function showprofile(smid) {
  check = window.document.getElementById('check_profile');
  div = window.document.getElementById('gallery');
  if (check==null) xajax_generateModelProfile(smid);
  else div.innerHTML=null;
}


//**************
function schedule(day, hour) {
  select1 = window.document.getElementById('day_select');
  select2 = window.document.getElementById('hour_select');
  day = select1.value;
  hour = select2.value;
 //alert(day + '___' + hour);
  xajax_showSchedule(0, day, hour);
  window.document.getElementById('sel_model').value = "0";
}
//********************
function clearMail() {
  type = window.document.getElementById('mail_type_select_0');
  select = window.document.getElementById('model_select_0');
  subject = window.document.getElementById('subject_input');
  textarea = window.document.getElementById('message_area');
  //type.selected=true;
  if (select != null) select.selected=true;
  subject.value='';
  textarea.value='';
}
function sendMail(uid) {
  type = window.document.getElementById('mail_type_select');
  if (type.value == 0 || type.value == 2) select = window.document.getElementById('model_select').value;
  else select = 1;
  if (type.value == 4) {
    select = window.document.getElementById('email_address').value; 
  }

  subject = window.document.getElementById('subject_input');
  textarea = window.document.getElementById('message_area');
  button = window.document.getElementById('btn_send');
  if (select == 0) {
    alert("The recipient must be selected");
  } else {
    button.disabled=true;
    xajax_sendMail(uid, type.value, select, subject.value, textarea.value);
  }
}
function mark(what) {
  j=true;
  i=0;
  while(j==true) {
    checkbox = window.document.getElementById('check_'+i);
    if(checkbox) {
      if(what == 0) checkbox.checked = false;
      if(what == 1) checkbox.checked = true;
      i++;
    } else {
      j=false;
    }
  }
}
function deleteMessages(path) {
  j=true;
  i=0;
  var messages=new Array();
  while(j==true) {
    checkbox = window.document.getElementById('check_'+i);
    hidden = window.document.getElementById('hide_'+i);
    if(checkbox) {
      if(checkbox.checked==true) messages[i]=hidden.value;
      i++;
    } else {
      j=false;
    }
  }
  xajax_moveMail(messages, path, 0);
}
function usePromoCode() {
  input = window.document.getElementById('code_input').value;
  xajax_usePromoCode(input);
}
function freelogin() {
  chatname = window.document.getElementById('chat_name_txt').value;
  if (chatname == '') alert("Input name!");
  else xajax_loginForFree(chatname);
}

function clearSupport() {
  window.document.getElementById('text_mail').value = "";
  window.document.getElementById('text_phone').value = "";
  window.document.getElementById('text_name').value = "";
  window.document.getElementById('text_company').value = "";
  window.document.getElementById('text_question').value = "";
  window.document.getElementById('text_subject').value = "";
}
function sendSupport(uid) {
  mail = window.document.getElementById('text_mail').value;
  phone = window.document.getElementById('text_phone').value;
  name = window.document.getElementById('text_name').value;
  company = window.document.getElementById('text_company').value;
  subject = window.document.getElementById('text_subject').value;
  question = window.document.getElementById('text_question').value;
  if (mail == '') alert("Enter your e-mail address!");
  else {
    if (subject == '') alert("Enter subject!");
    else {
      if (question == '') alert("Enter your question!");
      else xajax_sendToSupport(uid, mail, phone, name, company, subject, question);
    }
  }
}
function vopen(imgf,name,imgW,imgH){
  var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
  var maxW = screen.availWidth;
  var maxH = screen.availHeight;

  centerW=(maxW-imgW)/2;
  centerH=(maxH-imgH)/2;
  if(isIE) centerH -=20;
  imgWindow=window.open(imgf, 'v', 'top='+centerH+',left='+centerW+',width='+imgW+',height='+imgH+',resizable=0');
  imgWindow.focus();
}
function iopen(imgf,name,imgW,imgH,next,prev,first,sshow){
  var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
  var maxW = screen.availWidth;
  var maxH = screen.availHeight;
  var pscroll='0';
  var centerW=(maxW-imgW)/2;
  var centerH=(maxH-imgH)/2;
  if(isIE) centerH -=20;
  ((imgW>maxW || imgH>maxH))? pscroll='1' : pscroll='0';
  imgWindow=window.open('/e/fimage.php?p='+imgf+'&n='+name+'&iw='+imgW+'&ih='+imgH+'&img_n='+next+'&img_p='+prev+'&img_f='+first+'&sshow='+sshow, 'i', 'top='+centerH+',left='+centerW+',width='+imgW+',height='+imgH+',resizable=1,scrollbars='+pscroll);
  imgWindow.focus();
}
function show_video(encodedId,encodedResourceId) {
  generate(encodedResourceId);
  show_video_pause(encodedId, encodedResourceId);
}
function show_video_pause(encodedId,encodedResourceId){
  setTimeout("top.xajax_preview('"+encodedId+"', '2', '"+encodedResourceId+"');",500);
}

  /**
   * Returns a list of elements on root which have a clsName class
   */
function getElementsByClassName ( root, clsName, clsIgnore )
  {
    var i, matches = new Array();
    var els = root.getElementsByTagName('*');
    var rx1 = new RegExp('.*'+clsName+'.*');
    var rx2 = new RegExp('.*'+clsIgnore+'.*');
    for(i=0; i<els.length; i++) {
      if(els.item(i).className.match(rx1) && (clsIgnore == '' || !els.item(i).className.match(rx2))) {
	      matches.push(els.item(i).id);
      }
    }
    return matches;
  }

function showClass(root, clsName, clsIgnore, show)
  {
    var elts = this.getElementsByClassName(root, clsName, clsIgnore);
    for(var i = 0; elts.length > i; i++) {
      //alert (elts[i]);
      if (null !== root.getElementById(elts[i])) {
        if (show) root.getElementById(elts[i]).style.display = "inline";
        else root.getElementById(elts[i]).style.display = "none";
      }
    }
  }

function showColor(root, clsName, clsIgnore, show)
  {
    //var id = 'chat_frame_'+window.document.getElementById('id_chat').value;
    var elts = this.getElementsByClassName(root, clsName, clsIgnore);
    for(var i = 0; elts.length > i; i++) {
      colorf = 'c'+elts[i];
      //alert('colorf: '+colorf);
      if (show) root.getElementById(elts[i]).style.color = root.getElementById(colorf).value;
      else root.getElementById(elts[i]).style.color = 'black';
    }
  }
function hidecolor(template_url) {
  var id = 'chat_frame_'+window.document.getElementById('id_chat').value;
  var cpanel = parent.frames[id].document;
  var status = window.document.getElementById('color_indicator').value;
  //alert (status);
  if (status == 1) {
    this.showColor(cpanel, 'nick_span', '', false);
    window.document.getElementById('color_indicator').value=0;
    window.document.getElementById('color_img').src= template_url+"/images/color-off.gif";
    window.document.getElementById('color_img').alt="Show nickname colors";
    window.document.getElementById('color_img').title="Show nickname colors";
  } else {
    this.showColor(cpanel, 'nick_span', '', true);
    window.document.getElementById('color_indicator').value=1;
    window.document.getElementById('color_img').src= template_url+"/images/color-on.gif";
    window.document.getElementById('color_img').alt="Hide nickname colors";
    window.document.getElementById('color_img').title="Hide nickname colors";
  }
}

function hidetime(template_url) {
  var id = 'chat_frame_'+window.document.getElementById('id_chat').value;
  var cpanel = parent.frames[id].document;
  var status = window.document.getElementById('time_indicator').value;
  //alert (status);
  if (status == 1) {
    this.showClass(cpanel, 'time_span', '', false);
    window.document.getElementById('time_indicator').value=0;
    window.document.getElementById('time_img').src= template_url+"/images/clock-off.gif";
    window.document.getElementById('time_img').alt="Show message time";
    window.document.getElementById('time_img').title="Show message time";
  } else {
    this.showClass(cpanel, 'time_span', '', true);
    window.document.getElementById('time_indicator').value=1;
    window.document.getElementById('time_img').src= template_url+"/images/clock-on.gif";
    window.document.getElementById('time_img').alt="Hide message time";
    window.document.getElementById('time_img').title="Hide message time";
  }
}

function switchsound(template_url) {
  ison = window.document.getElementById('sound_indicator').value;
  if (ison == 1) {
    document.getElementById('sound_container').innerHTML = '';
    window.document.getElementById('sound_indicator').value = 0;
    window.document.getElementById('sound_img').src = template_url + "/images/sound-off.gif";
    window.document.getElementById('sound_img').alt="Enable sound notifications";
    window.document.getElementById('sound_img').title="Enable sound notifications";
  } else {
    window.document.getElementById('sound_indicator').value = 1;
    window.document.getElementById('sound_img').src = template_url + "/images/sound-on.gif";
    window.document.getElementById('sound_img').alt="Disable sound notifications";
    window.document.getElementById('sound_img').title="Disable sound notifications";
  }
}
function playsound(template_url) {
      // plays the sound, if it's switched on
    var soundcontainer = document.getElementById('sound_container');
    var toplay = document.getElementById('sound_indicator').value;
    if (toplay == 1)
    {
      var flash = "<object style='visibility:hidden' classid='clsid:D27CDB6E-AE6D-11CF-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' width='0' height='0'>";
      flash += "<param name='movie' value='" + template_url+"/swf/sound.swf'>";
      flash += "<param name='quality' value='High'>";
      flash += "<embed style='visibility:hidden' src='"+template_url+"/swf/sound.swf' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='0' height='0' />";
      flash += "</object>";
      soundcontainer.innerHTML = flash;
    } else {
      soundcontainer.innerHTML = "";
    }
}
function checkChanges() {
  var online = window.document.getElementById('hidden_online');
  if (null === window.document.getElementById('hidden_online')) { clearInterval(refreshInt); return; }
  else xajax_checkChanges(online.value);
  //alert(online);
}

function createMail(a, b, c) {
  var subject = window.document.getElementById('subject_input').value;
  var body = window.document.getElementById('message_area').value;
  xajax_createMail(a, b, c, subject, body);
}
// Free chat
function showLoginOrChangeForm(type) {
  var free_chat_change = window.document.getElementById('free_chat_change');
  var free_chat_login = window.document.getElementById('free_chat_login');

  if(free_chat_change && free_chat_login) {
    if(type == 1) {
      // Login form
      free_chat_change.style.display='none';
      free_chat_login.style.display='';
    } else {
      // Change form
      free_chat_change.style.display='';
      free_chat_login.style.display='none';
    }
  }
}
function login_to_pay(max) {
  var email = window.document.getElementById('email_toPay').value;
  var pass = window.document.getElementById('pass_toPay').value;
  if (null !== window.document.getElementById('amountToPay') && window.document.getElementById('amountToPay').value != 0) {
    var amount = window.document.getElementById('amountToPay').value;
  } else {
    var amount = 0;
    for (var i=1; i<=max; i++) {
      //var checked = false;
      if (window.document.getElementById('amount_'+i).checked==true) amount = window.document.getElementById('amount_'+i).value;
    }
    var paymethod = 0;
  }
  if (null !== window.document.getElementById('payment_method')) paymethod = window.document.getElementById('payment_method').value;
  if (amount == 0) alert("You have to select amount.");
  else xajax_checkLoginForPay(email, pass, amount, paymethod);
}
function payLater() {
  var check = window.document.getElementById('pay_later_check').checked;
  for (var i=1; i<5; i++) {
    window.document.getElementById('amount_'+i).disabled = check;
  }
}

var initialTZShiftDone = 0;

function updateTime(suffix) {
  if (null !== document.getElementById('timeInput'+suffix)) {
    var ddate = document.getElementById('timeInput'+suffix).value;
    ddate = parseInt(ddate) + 1000;
    var adate = new Date("month day year hours:minutes:seconds");
    adate.setTime(ddate);
    var hhmmss = adate;
    document.getElementById('clock'+suffix).innerHTML = hhmmss;
    document.getElementById('timeInput'+suffix).value = ddate;
    if (suffix != "" && null !== document.getElementById('timeView'+suffix)) { //using in booking
      if (initialTZShiftDone == 0 ) {
        var tzOffsetInMinutes = adate.getTimezoneOffset() * -1;
        // alert("Set inital timezone offset in minutes: " + tzOffsetInMinutes);
        window.document.getElementById('timeDiff'+suffix).value = tzOffsetInMinutes;
        initialTZShiftDone = 1;
      }
      var month = adate.getMonth() + 1;
      var ddate = adate.getDate();
      var year = adate.getYear();

      var hh = adate.getHours();
      if (hh < 10) hh = "0" + hh;
      //window.document.getElementById('hh'+suffix).value = hh;
      var mm = adate.getMinutes();
      if (mm < 10) mm = "0" + mm;
      //window.document.getElementById('mm'+suffix).value = mm;
      var ss = adate.getSeconds();
      if (ss < 10) ss = "0" + ss;
      //window.document.getElementById('ss'+suffix).value = ss;
      window.document.getElementById('timeView'+suffix).innerHTML = ddate + "/" + month + "/" + (Number(year)+1900) + "  <b>" + hh + ":" + mm + "</b>:" + ss;
      if (null !== window.document.getElementById('bookingTimeControls')) {
        window.document.getElementById('bookingTimeControls').style.display = '';
      }
      //window.document.getElementById('timeView'+suffix).innerHTML = hhmmss;
    }
    var updateTimeInterval = setTimeout("updateTime('" + suffix + "');",1000);
  }
}
function changeTime(value, suffix) {
  if (null !== window.document.getElementById('timeInput' + suffix)) {
    var newTime = Number(window.document.getElementById('timeInput' + suffix).value) + Number(value * 60000);
    window.document.getElementById('timeInput' + suffix).value = newTime;
    var oldTimeDiff = window.document.getElementById('timeDiff'+suffix).value;
    if (null !== window.document.getElementById('timeDiff'+suffix)) {
      var timeDiff = Number(window.document.getElementById('timeDiff'+suffix).value) + Number(value);
      // alert("old diff: " + oldTimeDiff + ",timeDiff: " + timeDiff + ", adjust: " + value);
      window.document.getElementById('timeDiff'+suffix).value = Number(window.document.getElementById('timeDiff'+suffix).value) + Number(value);
    }
  }
}
function updateModels() {
  updatingNow = 1;
    if (null !== document.getElementById('invitations_result')) {
      invitation = 3;
    } else {
      invitation = 0;
    }
    xajax_checkNewInvitations();

  if ((null !== document.getElementById('update_filter'))&&(null !== document.getElementById('update_filter_s'))&&(null !== document.getElementById('update_filter_h'))&&(null !== document.getElementById('update_filter_r'))&&(null !== document.getElementById('update_filter_a'))&&(null !== document.getElementById('update_filter_height'))&&(null !== document.getElementById('update_filter_weight'))&&(null !== document.getElementById('update_filter_profession'))&&(null !== document.getElementById('update_filter_language'))&&(null !== document.getElementById('update_filter_h_cntry'))&&(null !== document.getElementById('update_filter_h_state'))&&(null !== document.getElementById('update_filter_cntry'))&&(null !== document.getElementById('update_filter_state'))&&(null !== document.getElementById('update_adv_search'))&&(null !== document.getElementById('update_page'))&&(null !== document.getElementById('update_filter_eye'))) {
    var to = document.getElementById('update_filter').value;
    var tos = document.getElementById('update_filter_s').value;
		var toh = document.getElementById('update_filter_h').value;
    var tor = document.getElementById('update_filter_r').value;
    var toa = document.getElementById('update_filter_a').value;

    var to_eye = document.getElementById('update_filter_eye').value;
    var to_he = document.getElementById('update_filter_height').value;
    var to_we = document.getElementById('update_filter_weight').value;
    var to_pr = document.getElementById('update_filter_profession').value;
    var to_lang = document.getElementById('update_filter_language').value;
    var to_hc = document.getElementById('update_filter_h_country').value;
    var to_hs = document.getElementById('update_filter_h_state').value;
    var to_c = document.getElementById('update_filter_country').value;
    var to_s = document.getElementById('update_filter_state').value;

    var to_adv = document.getElementById('update_adv_search').value;
    var to_pg = document.getElementById('update_page').value;
    if (to !== "false" && tos !== "false" && toh !== "false" && tor !== "false" && toa !== "false" && to_he !== "false" && to_we !== "false" && to_pr !== "false" && to_lang !== "false" && to_hc !== "false" && to_hs !== "false" && to_c !== "false" && to_s !== "false" && to_adv !== "false" && to_pg !== "false") {
    	xajax_checkChanges(to, tos, toh, tor, toa, invitation, to_adv, to_pg, to_eye, to_he, to_we, to_pr, to_lang, to_hc, to_hs, to_c, to_s);
    }
  } else {
    if (null !== document.getElementById('top_rating_table')) {
      xajax_checkChanges(0,0,0,0,0,1);
    }
    if (null !== document.getElementById('favorites_table')) {
      xajax_checkChanges(0,0,0,0,0,2);
    }
  }
  updatingNow = 0;
}
function countOnline() {
  updatingNow = 1;
  var browser=navigator.appName;
  var b_version=navigator.appVersion;
  var version=parseFloat(b_version);
  var forOldIE = 0;
  if (null !== window.document.getElementById('forOldIE')) forOldIE = window.document.getElementById('forOldIE').value;
  if (browser == "Microsoft Internet Explorer" && version == 4 && forOldIE == 1) {} //we are on profile/photo(video), so do nothing, IE 6.0 is a BigBug
  else {
    //alert("updating");
    xajax_countOnline();
  }
  //setTimeout("countOnline();", 3000);
  updatingNow = 0;
}
var insFlashTimeout = false; 
function createSwf(id, flashVars, resUrl, thW, thH, req0, req1, req2) {
  if (null !== window.document.getElementById('update_filter')) {
    var filter = window.document.getElementById('update_filter').value;
    if (filter != "false") {
      if (null !== window.document.getElementById('temp_value')) window.document.getElementById('temp_value').value = filter;
      if (null !== window.document.getElementById('update_filter')) window.document.getElementById('update_filter').value = "false";
    }
  }
  if (null !== window.document.getElementById("check_div_" + id)) {
    id='mdiv_' + id;
  }
  //var swf = new flash ();
  if (thW > 0) {} else thW = 100;
  if (thH > 0) {} else thH = 100;
  //insFlashTimeout = setTimeout("top.insertFlash('"+out+"', '"+id+"');", 1000);
  insFlashTimeout = setTimeout("checkVersion('"+req0+"', '"+req1+"', '"+req2+"', '"+id+"', '"+flashVars+"', 1, 'lSubscriber', '"+resUrl+"', '"+thW+"', '"+thH+"');", 1000);
}
function insertFlash(out, id) {
  var td = window.document.getElementById(id);
  td.innerHTML=out;
}
function fromFlashStreamThumb(id) {
}
function changeBack() {
  clearTimeout(insFlashTimeout);
  var filter = window.document.getElementById('temp_value').value;
  if (null !== window.document.getElementById('update_filter')) window.document.getElementById('update_filter').value = filter;
}
function createVideoThumb(id, resUrl, flashVars, width, height, thumb) {
  var swf = new flash ();
  if (Number(width) == 0) width = 100;
  if (Number(height) == 0) height = 100;
  if (Number(thumb) == 1) swf.setSWF (resUrl + '/thPlayer_vod.swf', width, height, 8);
  else swf.setSWF (resUrl + '/thPlayer_video.swf', width, height, 8);
  swf.setParam ('wmode', 'transparent');
  swf.setParam ('bgcolor', '#000000');
  swf.setParam ('quality', 'high');
  swf.setParam ('flashvars', flashVars);
  var out = swf.display ();
  var td = window.document.getElementById("tdv_"+id);
  if (null == td) td = window.document.getElementById(id);
  if (null !== td) td.innerHTML = out;
}
function fromFlashVideoThumb(id, resType, resId) {
  //alert(id + "_" + resId);
  xajax_preview(id, resType, resId);
}
function changeContent(id) {
  var src = window.document.getElementById("tdv_hidden_"+id);
  var destination = window.document.getElementById("tdv_"+id);
  destination.innerHTML = src.innerHTML;
}
//
// Creeping line functions
// --->
function scrollmarquee(){

  str = document.getElementById("creeping_line_span").innerHTML;
  if(str != "" && document.getElementById("creeping_line_span").offsetWidth) {

    if(!start) populate();
    actualwidth=document.all? creeping_line_span.offsetWidth : document.getElementById("creeping_line_span").offsetWidth
    if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8)) {
      cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
    } else {
      cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
      if(lefttime) {
        clearInterval(lefttime);
        lefttime=0;
      }
    }
  } else {
    start = 0;
    cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
    cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
  }
}

function populate(){
  if(!lefttime) {
    start = 1;
    str = document.getElementById("creeping_line_span").innerHTML;
    cross_marquee=document.getElementById("iemarquee");
    cross_marquee.innerHTML=str;
    cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
    if(window.navigator.userAgent.indexOf ("Gecko") >= 0 )  lefttime=setInterval("scrollmarquee()",40)
    else lefttime=setInterval("scrollmarquee()",20)
  }
}
// <---
// Creeping line functions
//
function setPaypalAmount(amount, credit, item_name) {
  form = document.getElementById("paypal_form");
  form.amount.value = amount;
  form.credit.value = credit;
  form.item_name.value = item_name;
  form.submit();
}

function addToFavorites (url, title) {
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	}
}
function checkMethod(frmId) {
  if (null !== window.document.getElementById('payment_method')) {
    window.document.getElementById('formName_' + frmId).value = window.document.getElementById('payment_method').value;
  }
}

function enableButtonFun(formId, buttonId, str){
  var btn=window.document.getElementById(formId).elements[buttonId];
  btn.disabled=false;
  btn.value=str;
}
function disableButtonFun(formId, buttonId, str){
  var btn=window.document.getElementById(formId).elements[buttonId];
  btn.disabled=true;
  btn.value=str;
}
function saveProfile(uid, obj, type) {
  var formId = obj.elements['formId'].value;
  disableButtonFun(formId, 'submitEditModel'+uid, "Processing...");
  xajax_saveProfile(uid, top.xajax.getFormValues(formId), type);
}

function inviteToPrivateFromMain(encUid){
  var formItem = "toprivate_" + encUid;
  var formToSubmit = window.document.forms["m_" + encUid];
  window.document.getElementById(formItem).value='1';
  formToSubmit.submit();
  return false;
}
function reloadPlayer(encId) {
  window.document.getElementById("player").style.height = 224;
  //window.document.getElementById("player").innerHTML = encId;
  xajax_reloadPlayer(encId);
}
function reloadThumb(encId) {
  xajax_reloadThumb(encId);
}
function addChatInfo(memb,data) {
  info = document.getElementById(memb+'_moneyinfo').innerHTML;
  if(null !== document.getElementById('stream_closed')) {
  document.getElementById('stream_closed').innerHTML = data;
  } else {
    document.getElementById(memb+'_moneyinfo').innerHTML = info+'<div id=\'stream_closed\'>'+data+'</div>';
  }
}
function checkPlaying() { //PPEV
  //alert(window.document.getElementById('showNow'));
  if (null !== window.document.getElementById('showNow')) {
    var playValue = window.document.getElementById('showNow').value;
    if (playValue != "") xajax_checkPPEVTime(playValue);
  }
}
var ppmInterval = 0;
function checkPPM(stop) {
  if (stop != 1) {
    if (null !== window.document.getElementById('showNow')) {
      var playValue = window.document.getElementById('showNow').value;
      if (playValue != "") xajax_checkPPM(playValue);
    }
  } else clearInterval(ppmInterval);
}

function getRegions(obj, s_mi_id){
	var root = window.document;
  if(obj.value=='-1'){
    root.getElementById('state_holder_id').style.display='none';
  } else {
    root.getElementById('state_holder_id').style.display='';
    xajax_getRegions(top.xajax.getFormValues('edit_model_rprof2_'+s_mi_id), 'edit_model_rprof2_'+s_mi_id);
  }

  //document.forms['std_register'].elements['state'].disabled=true;
  //xajax_getRegions(xajax.getFormValues('std_register'));
}
var overRate = 0;
var lines = 0;
var items = 0;
function rateOnMove(enc, line, num) {
  //alert(lines+"_"+items+"_"+line+"_"+num);
  //alert(overRate);
  if (overRate==1) {
    for (var ln=1;ln<=lines;ln++) {
      //for (var i=1;i<=num;i++) {
      for (var i=1;i<=items;i++) {
        //if (line == ln) {
        if (line == ln && i<=num) {
          window.document.getElementById(enc+'container_'+ln+'_'+i).style.display="none";
          window.document.getElementById(enc+'push_'+ln+'_'+i).style.display="";
        } else {
          window.document.getElementById(enc+'container_'+ln+'_'+i).style.display="";
          window.document.getElementById(enc+'push_'+ln+'_'+i).style.display="none";
        }
      }
    }
  } else {
    for (var i=1;i<=num;i++) {
      window.document.getElementById(enc+'container_'+line+'_'+i).style.display="";
      window.document.getElementById(enc+'push_'+line+'_'+i).style.display="none";
    }
  }
}
var speed = 0;
function textFormat(speed) {
  div = window.document.getElementById('textFormat');
  //alert('div :'+div.innerHTML);
  if(div.innerHTML == '') top.xajax_tFormatWww(speed);
  else div.innerHTML='';
}

var d=window.document;
var Columns=16;
function drawPalette(p){
	s=d.getElementById(p).value;
  a=s.match(/#(\w{6})/ig);    //for  hex- #CCCCCC,#999999,#666666,...
  j=0;s2='<table bgColor=black>';
  while(a[j]){
  	s2+='<tr>';
    for(i=0;i<Columns;i++)if(a[j])s2+='<td'
    	+'  style=\"font-size:4px;cursor:pointer;background-color:'+a[j++]+';\" width=\"4\" height=\"5\" onclick=\"selectColor(this);change_all();\"></td>';
      s2+='</tr>';
  }
  //d.body.innerHTML+=s2+'</table>';
   d.getElementById("palette").innerHTML += s2+'</table>';
}
// selectColor
function selectColor(div) {
	 var color = div.style.backgroundColor;
	 //alert("color: "+color+"div: "+div);
	 color = rgbNormal(color);
	 window.document.getElementById("font_color").value = color;
}
function rgbNormal(color) {
	 color = color.toString();
	 var re = /rgb\((.*?)\)/i;
	 if(re.test(color)) {
		 compose = RegExp.$1.split(",");
		 var hex = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];
		 var result = "#";
		 for (var i = 0; i < compose.length; i++) {
			 rgb = parseInt(compose[i]);
			 result += hex[parseInt(rgb / 16)] + hex[rgb % 16];
		 }
		 return result;
	 } else return color;
}
	function change_all()
{
	window.document.getElementById("text_example").innerHTML = '<span style=\"font-family:'+window.document.getElementById("font_face").value+';font-size:'+window.document.getElementById("font_size").value+'px; color:'+window.document.getElementById("font_color").value+';font-weight:normal; \">>>>Your text in chat<<<</span>';
}
function ssopen(ssf,name,imgW,imgH){
  var isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
  var maxW = screen.availWidth;
  var maxH = screen.availHeight;

  centerW=(maxW-imgW)/2;
  centerH=(maxH-imgH)/2;
  if(isIE) centerH -=20;
  imgWindow=window.open(ssf, name, 'top='+centerH+',left='+centerW+',width='+imgW+',height='+imgH+',resizable=1,scrollbars=1');
  imgWindow.focus();
}
//*************
function swapColor(id, bgcolor, color) {
if (bgcolor != '') { document.getElementById(id).style.backgroundColor = bgcolor; }
if (color != '') { document.getElementById(id).style.color = color; }
}
//*************
function addComment(encResId, comment, comm_type) {
 	xajax_addCommentHON(encResId, comment, comm_type);
}
//*************
function save_blog(modelId, post_id) {
  mood = window.document.getElementById('mood_other');
  preview = window.document.getElementById('mood_preview_td');
  music = window.document.getElementById('music_input');
  post = window.document.getElementById('post_body');
  subject = window.document.getElementById('subject_input');
  location1 = window.document.getElementById('location');
  access = window.document.getElementById('can_see').value;
  keys = window.document.getElementById('key_input').value;
  xajax_modelBlogSave(modelId, subject.value, mood.value, music.value, post.value, location1.value, post_id, access, keys);
}
//*************
function clear_blog() {
  mood = window.document.getElementById('mood_other');
  preview = window.document.getElementById('mood_preview_td');
  music = window.document.getElementById('music_input');
  post = window.document.getElementById('post_body');
  subject = window.document.getElementById('subject_input');
  location1 = window.document.getElementById('location');
  keys = window.document.getElementById('key_input');
  mood.value="";
  subject.value = "";
  music.value = "";
  post.value = "";
  keys.value = "";
  location1.value = "";
}
var descriptionTop = 80;
function showVideoDesc(id, encPic, from_prof){
	var coords = top.getCoords(window.document.getElementById(id));
	var div = window.document.getElementById('vd_top_div');
	var isMSIE = /*@cc_on!@*/false;

  if (from_prof) {
  	div.style.left = (coords['left']+25) + 'px';
  	if(isMSIE) div.style.top = (coords['top']+descriptionTop) +'px';
  	else div.style.top = (coords['top']+descriptionTop) +'px';
  } else {
  	div.style.left = (coords['left']+25) + 'px';
  	if(isMSIE) div.style.top = (coords['top']+descriptionTop) +'px';
  	else div.style.top = (coords['top']+descriptionTop) +'px';
  }
  xajax_showVideoDesc(encPic);
}
function showVideoDescAdv(id, id_img){
	var coords = top.getCoords(window.document.getElementById(id_img));
	var div = window.document.getElementById('vd_top_div');
	var desc = window.document.getElementById(id).value;

  div.style.left = (coords['left']+25) + 'px';
  div.style.top = (coords['top']+100) +'px';
  if(desc != '') window.document.getElementById('vd_body').innerHTML = desc;
  else window.document.getElementById('vd_body').innerHTML = 'This video has no description.';
	div.style.visibility = 'visible';
}
// Determine position & size of element
function getCoords(element) {
    var left = element.offsetLeft;
    var top = element.offsetTop;
    var i=2;
    for (var parent = element.offsetParent; parent; parent = parent.offsetParent) {
      left += parent.offsetLeft;
      top += parent.offsetTop;
    }
    return {
    	left: left,
    	top: top,
    	width: element.offsetWidth,
    	height: element.offsetHeight
    };
}
function blink_unread_mail(black, stop) {
	//alert(black);
	clearInterval(blink_mail);
	clearTimeout(blink_mail_t);
	if(stop == 1) {
		clearInterval(blink_mail);
		clearTimeout(blink_mail_t);
		blink_mail = 0;
		blink_mail_t = 0;
	} else {
		if(black == 0) {
			window.document.getElementById('mail_info_blink').style.color = "#FF0000";
			window.document.getElementById('mail_info_blink').style.fontWeight = "bold";
		}
		else {
			window.document.getElementById('mail_info_blink').style.color = "#000000";
			window.document.getElementById('mail_info_blink').style.fontWeight = "normal";
		}
		clearInterval(blink_mail);
		clearTimeout(blink_mail_t);
		if(black == 0) blink_mail_t = setTimeout("top.blink_unread_mail(1,0);", 500);
		else blink_mail_t = setTimeout("top.blink_unread_mail(0,0);", 500);
	}
	//alert("blink_mail: "+blink_mail+", blink_mail_t: "+blink_mail_t+", stop: "+stop);
}


function showPhotoFromMain(encUid){
  var formItem = "thAction_"+encUid;
  //alert("formItem: "+formItem);
  var formToSubmit = window.document.forms["m_" + encUid];
  window.document.getElementById(formItem).value = '7';
  //alert("window.document.getElementById(formItem).value: "+window.document.getElementById(formItem).value);
  formToSubmit.submit();
  return false;
}
function showVideoFromMain(encUid){
  var formItem = "thAction_"+encUid;
  //alert("formItem: "+formItem);
  var formToSubmit = window.document.forms["m_" + encUid];
  window.document.getElementById(formItem).value = '8';
  formToSubmit.submit();
  return false;
}
function sendModelMail(enc_id) {
  mail = window.document.getElementById('text_mail').value;
  phone = window.document.getElementById('text_phone').value;
  name = window.document.getElementById('text_name').value;
  company = window.document.getElementById('text_company').value;
  subject = window.document.getElementById('text_subject').value;
  question = window.document.getElementById('text_question').value;

  window.document.getElementById('bt_send').value = "...";
  window.document.getElementById('bt_send').disabled == true;
  if (mail == '') alert("Enter your e-mail address!");
  else {
    if (subject == '') alert("Enter subject!");
    else {
      if (question == '') alert("Enter your question!");
      //$enc_id, $action = 0, $aFormValues
      else xajax_sendModelMail(enc_id, 1, mail, phone, name, company, subject, question);
    }
  }
}
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
function getRateImg(imId, path) {
	//alert("getRateImg(imId, path)");
	imgDiv = window.document.getElementById('news_rate_img');
	//if(imgDiv.innerHTML == '&nbsp;') {
		imgDiv.innerHTML = "<img src='"+path+"/images/rate/line"+imId+".gif' border='0'>";
	//} else {
	//	imgDiv.innerHTML = "&nbsp;";
	//}
}
function setNewsRate(news_id, rating, path) {
	//alert("setNewsRate(news_id, rating, path)");
	imgDiv = window.document.getElementById('news_rate_img');
	imgDiv.innerHTML = "<img src='"+path+"/images/rate/line"+rating+".gif' border='0'>";
	xajax_catchRateNews(news_id, rating);
}
function setCompetRate(res_id, rate, if_voted, price, price_name) {
	var payed = "";
	var payed_check = "";
	for(var i=0; i<7; i++){
		payed_check = window.document.getElementById('payed_vote_'+i);
		if(payed_check.checked == true) payed = payed_check.value;
	}
	//alert(payed);
	if(if_voted == 0 && payed == 1) {
		xajax_catchRateComp(res_id, rate);
	} else {
		if(confirm('Are you realy want to buy x'+payed+' voting for '+(payed*price)+' '+price_name+'?')){
			xajax_catchRateComp(res_id, rate, payed);
		}
	}
}
function addModelToCompetition(uid, comp_id) {
  xajax_wwwAddToCompetition(comp_id);
}
function selectDate(){
	var d = window.document.getElementById('d_birth').value;
	var m = window.document.getElementById('m_birth').value;
	var y = window.document.getElementById('y_birth').value;
	var h = window.document.getElementById('news_h').value;
	var mi = window.document.getElementById('news_mi').value;

	window.document.getElementById('date_news').value = d+"."+m+"."+y+"."+h+"."+mi;
}
