<!--
var win;
var xmlHttp;
var chats = new Array();

timedouturl = "index";

String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}

function RTrim(str)
{
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
    {
        var i = s.length - 1;
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        {
            i--;
        }
        s = s.substring(0, i+1);
    }
    return s;
}

function SetNewMails(unread) {
    if (unread > 0) {
        var html = " (<font class='blue_star blue_star_custom'>" + unread + " new</font>)";
        jQuery('#newmailnumber').html(html);
    }
}
if (document.cookie.indexOf('session_id') != -1 && getCookie('session_id')) {
    jQuery(document).ready(function() {
        if (document.cookie.indexOf('WebMailNewMails_' + getCookie('session_id')) != -1) {
            SetNewMails(getCookie('WebMailNewMails_' + getCookie('session_id')));
        } else {
            try {
                jQuery.ajax({
                    type: "GET",
                    url: url_map_f('_get_webmail_new_mails_'),
                    cache: false,
                    dataType: "text",
                    success: function(unread) {
                        SetNewMails(unread);
                    }
                });
            } catch(e) {
            }
        }
    });
}

function send_email(p,new_win){
    if (new_win=='new'){
        window.open('send_email?'+p);
    }else{
        window.location.href='send_email?'+p;
    }
}

function clickOnce(){
    clickOnceForm(document.update.submitbut);
}

function clickOnceForm(f){
    f.value = 'Please wait...';
    f.disabled=true;
}

function changeSbGifToPleaseWait(){
    document.getElementById("pleaseWait").innerHTML = "<input type='button' value=\"Please wait...\" disabled>";
}

function checkPopup(){
    if (!(win && win.open && !win.closed)) {
        var text = "Please enable popups on our site!";
        var html = "<P align=justify class=main_text_l><b>" + text + "</b></p>";
        //if (document.all && document.all.warning)
           // document.all.warning.innerHTML = html;
        //else if (document.getElementById('warning'))
          //  document.getElementById('warning').innerHTML = html;
    }
}

function PopUpEx2(sendLink, name, width, height, scrollbars, top, left) {
    mm= "width=" + width + ",height=" + height + ",scrollbars=" + scrollbars + ",resizable=" + scrollbars;
    if (top) {
        mm += ", top=" + top;
    }
    if (left) {
        mm += ", left=" + left;
    }
    win = window.open(sendLink, name, mm);
    if (win && win.open && !win.closed)
        win.focus();
    return win;
}

function PopUpEx(sendLink, name, width, height, scrollbars) {
    mm= "width=" + width + ",height=" + height + ",scrollbars=" + scrollbars + ",resizable=" + scrollbars;
    win = window.open(sendLink, name, mm);
    if (win && win.open && !win.closed)
        win.focus();
    return win;
}

function PopUp(sendLink, name, width, height, scrollbars) {
    PopUpEx(sendLink, name, width, height, scrollbars);
}

function PopUp2(sendLink, name, width, height, scrollbars, top, left) {
    PopUpEx2(sendLink, name, width, height, scrollbars, top, left);
}

function newwindow(a,windowname, width, height, scrollbars, process_link){
    var mm= "width=" + width + ",height=" + height + ",scrollbars=" + scrollbars + ",resizable=" + scrollbars;
    var url = a.href;
    var win = window.open(a.href, windowname, mm);
    if (win && win.open && !win.closed){
        win.focus();
    }
    if(process_link == null){
        process_link = false;
    }
   return process_link;
}

function modelesswin(url,mwidth,mheight,winname){
    if (document.all&&window.print){ 
        eval('window.showModelessDialog(url,winname,"help:0;resizable:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")');
    }else{
        eval('window.open(url,winname,"width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")');
    }   
}

function fixForm(c)
{
  var i;
  var n = c.name;
  var l = c.form.elements.length;
  if (!c.checked) return;
  if (c.value == '0') {
    for (i = 0 ; i < l ; i++){
      var e = c.form.elements[i];
      if(e.name == n && e.value != c.value) e.checked=false;
    }
  } else {
    for (i = 0 ; i < l ; i++){
      var e = c.form.elements[i];
      if(e.name == n && e.value == '0') e.checked=false;
    }

  }
  return;
}

function CheckPassLenght(c,from)
{
    var i = 4;
    if (from && from == 'affiliate') {
        document.getElementById('view').style.color='#000000';
        i = 6;
    } else {
        document.getElementById('view').style.color='#000000';
    }
    if (from == 'ms') {
        document.getElementById('view').innerHTML = '';
    } else {
        if (i == 4) {
            document.getElementById('view').innerHTML = '(Minimum 4 characters for security reasons. No spaces or special characters.)';
        } else if (i == 6) {
            document.getElementById('view').innerHTML = '(Minimum 6 characters for security reasons. No spaces or special characters.)';
        } else {
            alert("Report translation bug!");
        }
    }
    document.getElementById('view').style.fontWeight = '';
    if ( (c.value.length < i) || (c.value.length > 12) ) {
        if (i == 4) {
            document.getElementById('view').innerHTML = '(Your password must contain between 4 and 12 characters. No spaces or special characters.)';
        } else if (i == 6) {
            document.getElementById('view').innerHTML = '(Your password must contain between 6 and 12 characters. No spaces or special characters.)';
        } else {
            alert("Report translation bug!");
        }
        document.getElementById('view').style.color = '#FF0000';
        c.value = '';
    } else if (c.value.match(/\W/)) {
        document.getElementById('view').innerHTML = 'Your password contains invalid characters! Please choose another password comprised only of letters and numbers with no spaces.';
        document.getElementById('view').style.color = '#FF0000';
        document.getElementById('view').style.fontWeight = 'bold';
        c.value = '';
    }
}
 
function popUpPayment() {
    window.open('/pay');
}

function im_guest_notice(fname){
    window.open('im_guest_notic.htm?fname='+fname);
}

function goldMemberOnly(message1,message2,message3)
{
   var mes;
   if ((message1==null) && (message2==null) && (message3==null)){
      mes = "This service is for gold members only. By becoming a gold member, you can access all services without restriction.";
   } else {
      if (message3!=""){
        mes=message3;
      }else{
        mes=message1;
        mes+= message2;
      }
   }
   modelesswin('goldMemberOnlyMessage_?message='+mes,440,486,'paymessage');
}

function goldMemberOnlyChat(party_id, party_name)
{
  goldMemberOnly(null,null,null);
}

function subscribe_today(message1,message2,message3)
{
   var mes;
   if ((message1==null) && (message2==null) && (message3==null)){
      mes = "This service is for gold members only. By becoming a gold member, you can access all services without restriction.";
   } else {
      if (message3!=""){
        mes=message3;
      }else{
        mes=message1;
        mes+= message2;
      }
   }
   modelesswin('_subscribe_today?message='+mes,420,486,'paymessage');
}

function RevealProfile(nextPage) {
    var newHref = "set_hidden?hide=0";
    if(nextPage!=null)
      newHref+="&next="+nextPage;
    window.location.href = newHref;
}


function profileIncomplete(){
     alert("Please complete your registration to use our services!");
     //window.location.href = "my_profile";
}

function countLineBreaks (string) {
    var re = /\r\n|\r|\n/g;
    var n = 0;
    while (re.exec(string))
        n++;
    return n;
}

/* if needed, tries to increase the number of rows of a textarea */
function growTAVert (textarea) {
    var lineBreaks = countLineBreaks(textarea.value);
    if (textarea.rows * textarea.cols < textarea.value.length) {
        var newRows = lineBreaks +
                      parseInt(textarea.value.length / textarea.cols) + 2;
        newRows = newRows <= 40 ? newRows : 40;
        textarea.rows = newRows;
    } else if (textarea.rows < lineBreaks) {
        textarea.rows = lineBreaks + 2;
    }
}

function mc (id) {
    var obj = eval("document.forms.accounts.changed_" + id);
    obj.value = 1;
}


function checklogin()
{
    var ret = true;
    jQuery.ajax({
        type: "GET",
        url: url_map_f('_check_authen'),
        async: false,
        cache: false,
        success: function( msg ){
            ret = jQuery.trim(msg) == '1';
        }
    });

    return ret;
}

function syncForm(){
    var result = checklogin();
    if (!result) {
        alert("Sorry, your session has expired. \nCopy your message into notepad, sign in again and paste your message from notepad!");
    }

    return result;
}

function setSelectValue(sel,val) {
    if (typeof(sel) != 'undefined') {
        var i;
        for (i = 0; i < sel.length; i++) {
            if (sel.options[i].value == val) {
                sel.selectedIndex = i;
            }
        }
    }
}

function FullSize(url,ix,iy) {
    if(ix>0) {
        PopUp(url,"fsphoto",ix+6,iy+6,"no");
    }
}



function getFormFieldValue(field) {
    switch (field.type) {

        case "button" :
        case "file" :
        case "hidden" :
        case "password" :
        case "reset" :
        case "submit" :
        case "text" :
        case "textarea" :
            return field.value;

        case "select-one" :
            var i = field.selectedIndex;
            if (i == -1)
                return "";
            else
                return (field.options[i].value == "") ? field.options[i].text : field.options[i].value;

        case "select-multiple" :
            var result = new Array();
            for (var i = 0; i < field.options.length; i++)
                if (field.options[i].selected)
                    result[result.length] = (field.options[i].value == "") ? field.options[i].text : field.options[i].value;
            return result;

        case "radio" :
        case "checkbox" :
            if (field.checked)
                return field.value;
            else
                return "";

        default :
            if (field[0].type == "radio") {
                for (i = 0; i < field.length; i++)
                    if (field[i].checked)
                        return field[i].value;

                return "";
            } else if (field[0].type == "checkbox") {
                var result = new Array();
                for (i = 0; i < field.length; i++)
                    if (field[i].checked)
                        result[result.length] = field[i].value;

                return result;
            } else {
                // unknown field type
            }
            break;
    }
   
    return "";
}

function fixPiclist(obj, usr_id, picno) {
    var form = obj.form;
    var npics = $("input[name=npics__" + usr_id +"]").val();
    var makemain = $("input[name=makemain__" + usr_id +"]");
    var picno_main = npics > 1 ? ($("input:radio[name=makemain__" + usr_id +"]:checked").val()) : 0;
    if (picno_main == undefined) picno_main = -1;
    // clear the other rank
    if (obj.name.substr(0, 6) == 'rank__' && obj.checked == true)
        $("input[name=rank4__" + usr_id +"]").attr('checked', '');
    if (obj.name.substr(0, 7) == 'rank4__' && obj.checked == true)
        $("input[name=rank__" + usr_id +"]").attr('checked', '');

    // undelete the main photo if setting a rank
    if ((obj.name.substr(0, 6) == 'rank__' ||
         obj.name.substr(0, 7) == 'rank4__') && obj.checked == true)
    {
        // if there is no main photo, then use first pic for main photo
        if (picno_main == -1) {
            picno_main = 0;
            if (npics > 1) {
                makemain.eq(0).attr('checked', 'checked');
            }
        }
        $("input[name=delp__" + usr_id + '_' + picno_main + "]").attr('checked', '');
        $("input[name=move2extra__" + usr_id + '_' + picno_main + "]").attr('checked', '');
        $("input[name=move2tatoo__" + usr_id + '_' + picno_main + "]").attr('checked', '');

    }

    // "undelete" the main photo
    if (obj.name.substr(0, 10) == 'makemain__' && picno == picno_main) {
        $("input[name=delp__" + usr_id + '_' + picno + "]").attr('checked', '');
        $("input[name=move2extra__" + usr_id + '_' + picno + "]").attr('checked', '');
        $("input[name=move2tatoo__" + usr_id + '_' + picno_main + "]").attr('checked', '');
    }

    if ((obj.name.substr(0, 6) == 'delp__' && obj.checked == true) || (obj.name.substr(0, 12) == 'move2extra__') || (obj.name.substr(0, 12) == 'move2tatoo__')) {
        if (obj.name.substr(0, 12) == 'move2extra__' || obj.name.substr(0, 12) == 'move2tatoo__')
        {
            $("input[name=delp__" + usr_id + '_' + picno + "]").attr('checked', '');
            if (obj.name.substr(0, 12) == 'move2extra__') {
                $("input[name=move2tatoo__" + usr_id + '_' + picno + "]").attr('checked', '');
            } else {
                $("input[name=move2extra__" + usr_id + '_' + picno + "]").attr('checked', '');
            }
        } else {
            $("input[name=move2extra__" + usr_id + '_' + picno + "]").attr('checked', '');
            $("input[name=move2tatoo__" + usr_id + '_' + picno + "]").attr('checked', '');
        }

        if (picno == 0 && npics == 1) {
            // set rank to 0
            $("input[name=rank__" + usr_id +"]").attr('checked', '');
            $("input[name=rank4__" + usr_id +"]").attr('checked', '');
        } else {
            // if pic to be deleted is the main photo,
            // then use the first not deleted pic for main photo
            if (picno == picno_main) {
                for (var i = 0; i < npics; i++) {
                     if (!($("input[name=delp__" + usr_id + '_' + i + "]").attr('checked')) && !$("input[name=move2extra__" + usr_id + '_' + picno + "]").attr('checked') && !$("input[name=move2tatoo__" + usr_id + '_' + picno + "]").attr('checked' )) {
                         makemain.eq(i).attr('checked', 'checked');
                         break;
                     }
                }
            } 

            // if all pics will be deleted, set rank to 0
            if (i == npics) {
                $("input[name=rank__" + usr_id +"]").attr('checked', '');
                $("input[name=rank4__" + usr_id +"]").attr('checked', '');
                makemain.eq(picno_main).attr('checked', '');
            }
        }
    }
}

function RotateImg(obj, usr_id, picno, nocensor) {
    var angle = 0;
    var uid = usr_id + '_' + picno;
    angle = parseInt(document.getElementById("rangle__"+uid).value) + parseInt(obj.name);
    var rotation = 0;
    if(Math.abs(angle) >= 360)
        if(angle > 0) angle -= 360;  
        else angle += 360;  
    document.getElementById("rangle__"+uid).value = angle;
    //only for IE v.5.5 and above 
    if(navigator.appName=="Microsoft Internet Explorer"){
        if(angle < 0) angle += 360;
        switch (angle){
            case  90 : rotation = 3; break;
            case 180 : rotation = 2; break;
            case 270 : rotation = 1; break;
        }
        document.getElementById("photo__"+uid).style.filter = "progid:DXImageTransform.Microsoft.BasicImage(rotation=" + rotation + ")";
        if ($("#pre"))
        {
            $("#pre").css("filter", "progid:DXImageTransform.Microsoft.BasicImage(rotation=" + rotation + ")");
        }
    } else {
        var url = "show_rotated_img_?usr_id=" + usr_id + "&picno=" + picno + "&angle=" + angle;
        if (nocensor) url += '&nocensor=1';
        document.getElementById("photo__" + uid).src = url;
        if ($("#pre"))
        {
            $("#pre").attr("src", url);
        }
    }
    if (document.getElementsByName('pic_id')[picno])
    {
        document.getElementsByName('pic_id')[picno].checked = true;
    }
}

function RotateImgWithoutDB(obj, usr_id, picno, item_id, rotate_and_save, is_extra_picture) {
    var angle = 0;
    is_extra_picture = is_extra_picture || 0;
    var uid = usr_id + '_' + picno + '_' + item_id;
    if (rotate_and_save) {
        angle = parseInt(obj.name);
    } else {
        rotate_and_save = 0;
        uid += '_edit';
        angle = parseInt(document.getElementById("rangle__" + uid).value) + parseInt(obj.name);
    }
    var rotation = 0;
    if(Math.abs(angle) >= 360)
        if(angle > 0) angle -= 360;  
        else angle += 360;  
    document.getElementById("rangle__"+uid).value = angle;
    //only for IE v.5.5 and above 
    if(navigator.appName == "Microsoft Internet Explorer" && rotate_and_save == 0){
        if(angle < 0) angle += 360;
        switch (angle){
            case  90 : rotation = 3; break;
            case 180 : rotation = 2; break;
            case 270 : rotation = 1; break;
        }
        document.getElementById("photo__"+uid).style.filter = "progid:DXImageTransform.Microsoft.BasicImage(rotation="+rotation+")";
    } else {
        var url = "show_rotated_img_without_db_?usr_id=" + usr_id + "&picno=" + picno + "&item_id=" + item_id + "&angle=" + angle + '&rotate_and_save=' + rotate_and_save + '&is_extra_picture=' + is_extra_picture;
        document.getElementById("photo__" + uid).src = url + "&rn=" + Math.random();
    }
}

function OnLoadPage(site) {
}

function clickSearchOnce(){
    var html="<center><br><input type='submit' value=\"Please wait...\" disabled></center>";
    if (document.getElementById('showsearch')) {
        document.getElementById('showsearch').innerHTML = html;
    } else if (document.all && document.all.showsearch) {
        document.all.showsearch.innerHTML = html;
    }
    return true;
}

function clickContinueOnce() {
    var html="<input type='submit' value=\"Please wait...\" disabled>";
    if (document.check.showcontinue){
            document.check.showcontinue.innerHTML = html;
    }else if (document.getElementById('showcontinue')){
            document.getElementById('showcontinue').innerHTML = html;
    }
    return true;
}

function setRadioValue(f, name, value){
  var i;
  var l = f.elements.length;
  for (i = 0 ; i < l ; i++){
      var e = f.elements[i];
      if(e.name == name){
            e.checked = (e.value == value? true: false);
      } 
  }
}
function show_hide_dist(r) {
    try{
        var r_value = r.value;
        if (r.name != 'is_distance'){
            if (r.name.indexOf('_cou')!= -1 || r.name.indexOf('state')!= -1){ // is country
                r_value = 0;
            }else{
                r_value = 1;
            }
            setRadioValue(r.form, 'is_distance', r_value);   
        }
    } catch (e) {}
}
function checkMessages(theBox,theArray) {
        if ( theBox.checked ) {
            for (i = 0; i < theArray.elements.length; i++) {
                try{
                    theArray.elements[i].checked = true ;
                }catch(e){}
            }
            theBox.form.checkall.checked = true;
        } else {
            for (i = 0; i < theArray.elements.length; i++) {
                try{
                    theArray.elements[i].checked = false ;
                }catch(e){}
            }
            theBox.form.checkall.checked = false;
        }
}

function uncheckAll(theBox) {
    try {
        if (!theBox.checked) {
            $("input[name='checkall']").each(function(){
                this.checked="";
            });
        }
    } catch(e) {}
}

function checkForm(frm){
    var sel = false;
    if(frm.del.length){
        for(var i=0;i<frm.del.length;i++){ 
            if(frm.del[i].checked){
                sel = true;
                break;
            }
        }
    }
    else{
        sel = frm.del.checked;
    }
    if(!sel){
        $("#error_div").show();
        $("#error_profile_not_select").show();
        document.location ='#top';
        return false;
    }
    return true;
}
function registerAlert() {
    alert('Please register to use the feature');
}


function createHiddenFormElement(inputForm, elementName, elementValue){
    var newElement = document.createElement("INPUT");
    newElement.type = "HIDDEN";
    newElement.name = elementName;
    newElement.value = elementValue;
    return inputForm.appendChild(newElement);
}

var submitForm, c_form_name, c_formtag, c_text, c_extra;

function check_spell_open(form_text_tag,form_name){
    if (!form_name) form_name ='update';
    var text = document.getElementById(form_text_tag).value;

    if(text.length < 1000) {
      return PopUpEx('/spell_checker_?form_name='+form_name+'&form_text_tag='+form_text_tag+'&text='+escape(text),'check_spell',500,400,'yes');
    } 

    PopUpEx('about:blank','check_spell',500,400,'yes');

    if(typeof(submitForm) == 'undefined') {
        submitForm = document.createElement("FORM");
        document.body.appendChild(submitForm);
        c_form_name = createHiddenFormElement(submitForm, "form_name", form_name);
        c_formtag = createHiddenFormElement(submitForm, "form_text_tag", form_text_tag);
        c_text=  createHiddenFormElement(submitForm, "text", text);
    } else {
        c_form_name.value = form_name;
        c_formtag.value = form_text_tag;
        c_text.value = text;
    }
    submitForm.method = "POST";
    submitForm.target = 'check_spell';
    submitForm.action= "/spell_checker_";
    submitForm.submit();
}

function check_spell(form_text_tag,form_name){
      if (!form_name) form_name ='update';
      var text = document.getElementById(form_text_tag).value;
      var reg = /\bblog\b|\bblogs\b|\bblogging\b|\bblogland\b|\bbloggers\b/gi;
      text = text.replace(reg,"")

      jQuery.ajax({
          type: "POST",
          url: url_map_f('_check_spell'),
          data: { 
              form_name: form_name, form_text_tag: form_text_tag, text: escape(text), ajaxRequestUncache: parseInt(Math.random() * 1000000) 
          },
          success: function(info){
             if(jQuery.trim(info)=='1'){
                alert("No misspelling found!");
             }else{
                check_spell_open(form_text_tag,form_name);
             }
          }
      });
}


// utility function to retrieve an expiration date in proper

// format; pass three integer parameters for the number of days, hours,

// and minutes from now you want the cookie to expire (or negative

// values for a past date); all three parameters are required,

// so use zeros where appropriate

function getExpDate(days, hours, minutes) {

    var expDate = new Date( );

    if (typeof days == "number" && typeof hours == "number" && 

        typeof hours == "number") {

        expDate.setDate(expDate.getDate( ) + parseInt(days));

        expDate.setHours(expDate.getHours( ) + parseInt(hours));

        expDate.setMinutes(expDate.getMinutes( ) + parseInt(minutes));

        return expDate.toGMTString( );

    }

}

// utility function called by getCookie( )

function getCookieVal(offset) {

    var endstr = document.cookie.indexOf (";", offset);

    if (endstr == -1) {

        endstr = document.cookie.length;

    }

    return unescape(document.cookie.substring(offset, endstr));

}

// primary function to retrieve cookie by name

function getCookie(name) {

    var arg = name + "=";

    var alen = arg.length;

    var clen = document.cookie.length;

    var i = 0;

    while (i < clen) {

        var j = i + alen;

        if (document.cookie.substring(i, j) == arg) {

            return getCookieVal(j);

        }

        i = document.cookie.indexOf(" ", i) + 1;

        if (i == 0) break; 

    }

    return "";

}

// store cookie value with optional details as needed

function setCookie(name, value, expires, path, domain, secure) {

    document.cookie = name + "=" + escape (value) +

        ((expires) ? "; expires=" + expires : "") +

        ((path) ? "; path=" + path : "") +

        ((domain) ? "; domain=" + domain : "") +

        ((secure) ? "; secure" : "");

}

// remove the cookie by setting ancient expiration date

function deleteCookie(name,path,domain) {

    if (getCookie(name)) {

        document.cookie = name + "=" +

            ((path) ? "; path=" + path : "") +

            ((domain) ? "; domain=" + domain : "") +

            "; expires=Thu, 01-Jan-70 00:00:01 GMT";

    }

}



//Instant Messenger functions

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var CommandBlocked = false;

function startIM (usr_id) {
   PopUp(_imurl,"im_" + usr_id,450,530,"yes");
}

function startPrivateChat(partyname, username) {
    var im_usersObj = isInternetExplorer ? document.all.im_users : document.im_users;
    var param = 'partyname=' + partyname;
    if((chats[partyname]==null) || (typeof(chats[partyname])=="undefined") || (chats[partyname].closed)) {
        try {
            chats[partyname] = PopUpEx(_privatechaturl + '?' + param, 'MIM_to_' + partyname, 600, 360, 'yes');
        } catch(e) { alert("error:" + e)};
        if(chats[partyname]==null || typeof(chats[partyname])=="undefined") {
//TODO: Possible, popups is blocked. Display notification.
            if(im_usersObj) {
                im_usersObj.TGotoLabel("/", "PopupBlocked");
            }
        }
    } else {
//TODO: Add blinking effect to window chats[partyname]. Don't know how to do it...
    }
}

function startPrivateChatForClone(partyname, username, hostname, session) {
    if((chats[partyname]==null) || (typeof(chats[partyname])=="undefined") || (chats[partyname].closed)) {
        try {
            chats[partyname] = PopUpEx('http://' + hostname + '/s' + session + '/im_private.htm?partyname=' + partyname, 'MIM_to_' + partyname, 600, 360, 'yes');
        } catch(e) {
            alert("error:" + e);
        }
    }
}

// add to bookmark
function addBookmark() 
{
    if (window.sidebar) 
    {
        window.sidebar.addPanel(document.title, document.location.href,"");
    } 
    else if(document.all) 
    {
        window.external.AddFavorite( document.location.href, document.title);
    } 
    else if( window.opera && window.print )
    {
    return true;
    }
} 

function getXMLHttpRequest()
{
    var http_request;
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }
        return http_request;

}

function popupMsg(id){
       document.getElementById(id).style.display='';
}

function HideandUNhideObj(i){
        nav=document.getElementById('div'+i).style;
        con=document.getElementById('ul'+i);
        if(nav.display=="none"){
                // set mouseout function here
                nav.display = 'block';
                con.onmouseout = function(evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display = 'none';
                    }
                }
        } else {
                nav.display='none';
                con.onmouseout = function (evt) {
                    if (checkMouseLeave(this, evt)) {
                        i = parseInt(this.id.substr(2));
                        nav=document.getElementById('div'+i).style;
                        nav.display= 'none';
                    }
                }
        }
}

function checkMouseLeave (element, evt) {

  evt = (evt) ? evt : ((window.event) ? window.event : "");
  window.status = evt;
  if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  } else {
        if (element.contains(evt.toElement)) {
                return(false);
        } else {
                return(true);
        }
  }
}

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

// for image show/hide

function getElementPosX(element) {
    var left = 0;
    if (element.offsetParent) {
        while (element.offsetParent) {
            left += element.offsetLeft;
            element = element.offsetParent;
        }
    } else if (element.x) {
        left += element.x;
    }
    return left;
}
function getElementPosY(element) {
    var top = 0;
    if (element.offsetParent) {
        while (element.offsetParent) {
            top += element.offsetTop;
            element = element.offsetParent;
        }
    } else if (element.y) {
        top += element.y;
    }
    return top;
}
function layoutImageBox(owner, box, offset) {
    try {
        if (typeof(offset) != 'undefined'){
            box.style.left = getElementPosX(owner) + offset + 'px';
        } else {
            box.style.left = getElementPosX(owner) + 'px';
        }
        box.style.top = getElementPosY(owner) + 'px';
        box.style.visibility = 'visible';
    } catch (e) {
//        alert(e);
    }
}
function showFullImage(owner, url, linkto, offset) {
    try{
        imageBox = document.getElementById('image_box');
        imageBoxUrl = document.getElementById('image_box_url');
        var img = new Image();
        img.onload = function() {
            imageBox.src = img.src;
            w = img.width;
            h = img.height;
            max = 300.0;
            if (img.width > max) {
                scale = max / img.width;
                w *= scale;
                h *= scale;
            } else if (img.height > max) {
                scale = max / img.height;
                w *= scale;
                h *= scale;
            }
            imageBox.width = w;
            imageBox.height = h;
            img = null;
            layoutImageBox(owner, imageBox, offset);
        }
        img.src = url;
        imageBoxUrl.href = linkto;
    } catch (e) {
//        alert(e);
    }
}

function show_full_img(owner, url, linkto, offset) {
    try{
        imageBox = $('#image_box');

        var img = new Image();
        img.onload = function() {
            w = img.width;
            h = img.height;
            max = 300.0;
            if (img.width > max) {
                scale = max / img.width;
                w *= scale;
                h *= scale;
            } else if (img.height > max) {
                scale = max / img.height;
                w *= scale;
                h *= scale;
            }
            imageBox.css({width: w, height: h, cursor: "pointer"});
            $(img).css({width: w, height: h});
            $(img).bind("click", function(){
               eval(linkto);
            });
            imageBox.empty();
            imageBox.append(img);
            img = null;
            layoutImageBox(owner, imageBox[0], offset);
        }
        $(img).attr("src", url);
    } catch (e) {
    //    alert(e);
    }
}

function hidden_full_img() {
    $('#image_box').css("visibility","hidden");
}

function text_change(object, resultFieldID, maxLength) {
    var ilen = maxLength - object.value.length;
    $('#' + resultFieldID).val(ilen > 0 ? ilen : 0);
    setMaxLength(object, maxLength);
}

function setMaxLength(object,length) {

    var tempString=object.value;

    if(tempString.length>length) {
        tempString=tempString.substr(0,length);
        object.value=tempString;    
    }
}


function check_Character(ta,len,text,length) {
    var ilen = ta.value.length;
    if (ilen < length) {
        document.getElementById(len).innerHTML = length - ilen;
    } else {
        document.getElementById(len).innerHTML = 0;
    }
    setCharacterText(ta,length);
}

function setCharacterText(object,length) {
    var tempString=object.value;
    if (tempString.length > length) {
        tempString=tempString.substr(0,length);
        object.value=tempString;
    }
}

function check_username_email(mark) {
    var username = $("#username").val().trim();
    if (!username) username = $("#username").html().trim();
    var email = document.update.email.value.trim();
    var email_repeat = document.update.email_repeat.value.trim();

    var emailname = email.substring(0, email.indexOf('@'));
    var pattern = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    var u_name_pattern = /^\w+$/;
    var msg = '<span style="font-size:10px; color: red;">Your username and email address name can not be the same.</span>';
    var msg_by_email = '<span style="font-size:10px; color: red;">Your email name should not be the same as your username.</span>';

    if (username.toLowerCase() == emailname.toLowerCase()) {
        $('#showalert').html(msg);
        $('#showalert_by_email').html(msg_by_email);
    } else if (!u_name_pattern.test(username) ) {
        msg = '<span style="font-size:10px; color: red;">Username can only contain a-z, A-Z, 0-9, and _.</span>';
        $('#showalert').html(msg);
    } else {
        $('#showalert').html('');
        $('#showalert_by_email').html('');
    }
    if (email.length > 0 && !(pattern.test(email))) {
        $('#show_invalid_email').html('<span style="font-size:10px;">Your email address is invaild. please choose a vaild one.</span>');
    } else {
        $('#show_invalid_email').html('');
    }
    if (email.length > 0 && email_repeat.length > 0 && email != email_repeat) {
        $('#show_diff_email').html('<span style="font-size:10px;">Your email address didn\'t match. Try again</span>');
    } else {
        $('#show_diff_email').html('');
    }
    if((username.length>0)&&(username == emailname)) { 
        if(Math.floor(Math.random() * 2)){
            document.update.username.focus();
        }else{
            document.update.email.focus();
        }
    }
    if (mark == 1) {
        if (username.length >= 6 && username.length <= 16) {
            $.ajax({
                type: "post",
                url: url_map_f("_check_username"),
                data: "username=" + username + "&ajaxRequestUncache=" + parseInt(Math.random() * 1000000),
                dataType: "xml",
                success: function(data) {
                    $("#username").val($(data).find("checkusername").find("username").text().trim());
                    $('#showalert').html('<span style="font-size:10px;">' + $(data).find("checkusername").find("description").text().trim() + "</span>");
                }
            });
        } else {
            $('#showalert').html('<span style="font-size:10px; color:red;"><b>Username should be 6-16 characters. No spaces or special characters.</b></span>');
        }
    }
}

function check_fname() {
    var fname = document.update.fname.value;
    if (fname.match(/^[a-zA-Z]*$/)) {
        $('#show_fname_alert').html('');
        $('#show_fname_alert').hide();
    } else {
        $('#show_fname_alert').html('<span style="font-size:10px; color: red;">First name may only contain letters.</span>');
        $('#show_fname_alert').show();
    }
}

function show_hide(obj_name){
    var obj = document.getElementById('s_h_'+obj_name);
    var div_link_obj = $("#div_s_h_t_" + obj_name);
    var link_text_obj = $("#s_h_t_" + obj_name);
    var showhide = document.getElementsByName(obj_name);
    var hideselect = document.getElementsByName(obj_name)[0];
    if(obj.style.display=='') {
        obj.style.display='none';
        div_link_obj.attr("class", "plus_arrow");
        link_text_obj.val();
        link_text_obj.html('Show');
        for (var i = 0;i < showhide.length;i++) {
            showhide[i].checked = false;
            if (showhide[i].value == "0") {
                showhide[i].checked = true;
            }
        }
        if (hideselect.options != undefined) {
            for (var i=0; i < hideselect.options.length; i++) {
                hideselect.options[i].selected = false;
                if (i == (hideselect.options.length - 1)) {
                    hideselect.options[i].selected = true;
                }
            }
        }
    } else {
        obj.style.display=''
        div_link_obj.attr("class", "minus_arrow_down");
        link_text_obj.html('Hide');
    }
 }                  

function show_hide_form() {
    try {
        var board = document.getElementById("past_board");
        if (board.style.display == 'none') {
               board.style.display = ''
        }else{
          board.style.display = 'none'
        }
    } catch(e) {
//        alert(e);
    }
}
// -->
function layoutImageBoxMenu(owner, box) {
    try {
        box.style.left = getElementPosX(owner) + owner.width + 'px';
        box.style.top  = getElementPosY(owner) + 'px';
        box.style.visibility = 'visible';
    } catch (e) {
//        alert(e);
    }
}
function showFullImageMenu(owner, url, height) {
    try{
        imageBox = document.getElementById('image_box');
//      imageBoxUrl = document.getElementById('image_box_url');
        var img = new Image();
        img.onload = function() {
            imageBox.src = img.src;
            w = img.width;
            h = img.height;
            max = 300.0;
            if (img.width > max) {
                scale = max / img.width;
                w *= scale;
                h *= scale;
            } else if (img.height > max) {
                scale = max / img.height;
                w *= scale;
                h *= scale;
            }
            imageBox.width = w;
            imageBox.height = h;
            img = null;
            layoutImageBoxMenu(owner, imageBox);
        }
        img.src = url;
//        imageBoxUrl.href = linkto;
    } catch (e) {
//        alert(e);
    }
}

function IsShowSelectProfileError(targetId,frm){
    if(IsSelectProfile(frm)){
        return true;
    } else {
            window.location.href="#";
        target = document.getElementById(targetId);
        target.style.display="";
        return false;
    }
}

function IsSelectProfile(frm){
    var format = /^mark_[0-9]{1,}$/i;
    var userlists="";
    for (i = 0; i < frm.elements.length; i++) {
        try{
           if(format.test(frm.elements[i].name)){
             if(!frm.elements[i].checked) {
                 continue;
             }
             var param=frm.elements[i].name.split("_");
             if(userlists!=""){
                userlists=userlists+"_";
             }
             userlists=userlists+param[1];
           }
        }catch(e){}
    }
    if(userlists=="") {
       return false;
    } else {
        return true;
    }
}

function deleteBatch(theBox,theArray) {
    var has_selected = 0;

    $('input[type="checkbox"][name^="email_"][value*="@"]').each(function() {
        if ($(this).attr('checked')) {
            has_selected = 1;
            return;
        }
    });

    if (has_selected == 0) {
        $('#invite_pending_error_msg').show();
        return;
    }

    $('#invite_pending_error_msg').hide();

    if(confirm('Are you sure you want to remove these emails from invite history?'))
    {
        theArray.delete_batch.value=1;
        theArray.submit();
    }
}

function jquery_show_search_omitted_profile (match_id){
    jQuery("#proflie_show_" + match_id).hide();
    jQuery("#space_" + match_id).hide();
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "action=search_user_show&match_id=" + match_id,
        success: function(){
        }
    });
}


function dd(show) {
   document.getElementById('min'+show).style.display=document.getElementById('min'+show).style.display?"":"none";
   document.getElementById('max'+show).style.display=document.getElementById('max'+show).style.display?"":"none";
}

var starCount = new Array();
var rateArr = new Array("Poor", "Nothing Special", "Worth Watching", "Pretty Cool", "Awesome!");
var isRated = false;
var rateScore;
function showStars(id) {
    if(isRated)
        return false;

    for (var i = 0,j = 1; i < id ; i++,j++)
    {
        starCount[i] = document.getElementById("star_" + j);
        starCount[i].src = "http://images.LargeFriends.com/stars/red_star.gif";
    }
    for(var i = id,j = id+1; i < 5 ; i++,j++)
    {
        starCount[i] = document.getElementById("star_" + j);
        starCount[i].src = "http://images.LargeFriends.com/stars/gray_star.gif";
    }

    showRates(id);
}

function showRates(id){
    var msg = document.getElementById("message");
    var msg_content = '';
    if (id > 0) {
        msg_content = rateArr[id-1];
    }
    msg.innerHTML = msg_content;
    rateScore = id;
}

function add_rate_count(video) {
    if(isRated == true) return false;
    
    var http_request;
    http_request=getXMLHttpRequest();
    http_request.open('GET', '/add_rate_count_?video='+video+'&score='+rateScore+'&ajaxRequestUncache='+parseInt(Math.random() * 1000000), true);
    for(var i=1;i<6;i++){
        if(i <= rateScore) {
            document.getElementById("a" + i).innerHTML = "<img border='0' src='http://images.LargeFriends.com/stars/red_star.gif'>";
         } else {
             document.getElementById("a" + i).innerHTML = "<img border='0' src='http://images.LargeFriends.com/stars/gray_star.gif'>";
          }
     }
        http_request.onreadystatechange =  function(){
            if (http_request.readyState == 4) {
                if (http_request.status == 200) {
                    var info = http_request.responseText;
                    if(info.trim()=='1'){
                        document.getElementById("thanks").style.display = "block";
                        document.getElementById("message").style.display = "none";
                        document.getElementById("rate").style.display = "none";                  
                    }
                } else {
                    alert('There was a problem with the request.');
            }
       }
    }
    http_request.send(null);
    isRated = true;
}

function highlightStatus(status) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('highlight_status_'),
        data: "status=" + status,
        success: function( msg ){
            window.location='/get_highlight_and_featured?status='+msg;
        }
    });
}

function email_replies(status) {
    var http_request;
    http_request=getXMLHttpRequest();
    http_request.open('GET', '/email_replies_status_?status='+status+'&ajaxRequestUncache='+parseInt(Math.random() * 1000000), true);
        http_request.onreadystatechange =  function(){
            if (http_request.readyState == 4) {
                if (http_request.status == 200) {
                    var info = http_request.responseText;
                    if(jQuery.trim(info)=='1'){
                        window.location.reload();                
                    }
                } else {
                    alert('There was a problem with the request.');
            }
       }
    }
   http_request.send(null);
}

function deleteConfirm()
{
    var count=0;
    var obj = document.forms.del_form.del;
    if (obj == null)
        return false;
    
    if (obj.length == null)//only one
    {
        if( obj.checked)
            count=1;
    }else {
        for(i = 0; i < obj.length; i++)
            if ( obj[i].checked )
                count++;
    }        
    if (count==0)
    {
        alert("Note:Please select the topics first!");
        return false;
    }
    else
        return confirm("Are you sure you want to remove the checked topics?");
}


function dyniframesize(iframename) {
  var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
  var FFVersion = getFFVersion.substr(0,2)
  //extra height in px to add to iframe in FireFox 1.0+ browsers
  var FFextraHeight=FFVersion>=0.1? 30 : 0 

  var pTar = null;
  if (document.getElementById){
    pTar = document.getElementById(iframename);
  }
  else{
    eval('pTar = ' + iframename + ';');
  }
  if (pTar && !window.opera){
    //begin resizing iframe
    pTar.style.display="block";
    
    if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
      //ns6 syntax
      pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight; 
      pTar.width = pTar.contentDocument.body.scrollWidth;
    }
    else if (pTar.Document && pTar.Document.body.scrollHeight){
      //ie5+ syntax
      pTar.height = pTar.Document.body.scrollHeight;
      pTar.width = pTar.Document.body.scrollWidth;
    }
  }
}

function dont_allow_newuser_add_favorites (id) {
    jQuery('span#addFavoritesInfo'+id).html('<font color="blue">We are sorry, but you may add to favorites only after your profile has been approved by our staff</font>');
}

function jquery_add_to_favoriate (match_id, username, type) {
    if (username) {
        jQuery("#favoriate_add_comment_" + match_id).html("<b>saving...</b>");
    } else {
        jQuery("#favoriate_add_" + match_id).html("<b>saving...</b>");
        jQuery("input[name='fav_button']").each(function(){
            jQuery(this).val("saving");
        });
    }

    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "action=favoriate_add&match_id=" + match_id,
        success: function(){
            if (username) {
                jQuery("#favoriate_add_comment_" + match_id).html('Already in <a href="http://www.largefriendfinder.net/favorites" target="_blank">favorites</a>');
                jQuery('#fav_comment_title_' + match_id).show();
                jQuery('#favorite_rank_' + match_id).load('/favorite_rank_?prof_id=' + match_id + '&title=1');
            } else {
                if (type == 1) {
                    jQuery("#favoriate_add_comment_" + match_id).html('Already in <a href="http://www.largefriendfinder.net/favorites" target="_blank">favorites</a>');
                }
                jQuery("#favoriate_add_" + match_id).show();
            }
            jQuery("#favoriate_add_" + match_id).html('Already in <a href="http://www.largefriendfinder.net/favorites" target="_blank">favorites</a>');

            jQuery("input[name='fav_button']").each(function(){
                jQuery(this).val("Already in favorites");
                jQuery(this).show();
                var obj = jQuery(this)[0];
                obj.onclick = new Function("window.open('favorites','','')");
            });
        }
    });
}

function jquery_add_profiles_to_favoriate (){
    var match_id;
    var count = 0;
    var del = document.getElementsByName('del');
    for (var i = 0; i < del.length; i++) {
        if( del[i].checked ) {
            match_id = del[i].value;
            jquery_add_to_favoriate( match_id, null, 1 );
            count ++;
        }
    }
    if ( count ==0 ){
        alert("You did not select profiles to add to your favorite profile list.")
    }
}

function jquery_hide_search_profile ( match_id ) {
    jQuery("#proflie_show_" + match_id).hide();
    //jQuery("#proflie_show_" + match_id).html("<b>loading...</b>");

    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "action=search_user_hide&match_id=" + match_id,
        success: function(){
            jQuery("#proflie_hide_" + match_id).show();
            jQuery("#proflie_hide_" + match_id).css({border: "1px solid rgb(221, 221, 221)"});
            jQuery("input[name='mark_" + match_id + "']").attr("disabled", "true");
        }
    });
}

function jquery_show_search_profile ( match_id ) {
    jQuery("#proflie_hide_" + match_id).hide();
    //jQuery("#proflie_show_" + match_id).html("<b>loading...</b>");

    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "action=search_user_show&match_id=" + match_id,
        success: function(){
            jQuery("#proflie_show_" + match_id).show();
            jQuery("input[name='mark_" + match_id + "']").attr("disabled", "");
        }
    });
}

function add_video_to_favorite(video) {
    var favorite = document.getElementById("is_in_favorite_"+video);
    var favorite_num = document.getElementById("favorite_num");
    jQuery.ajax({
          type: "POST",
          url: url_map_f('add_video_to_favorite_'),
          data: "frompage=videos&video_to_favorite=" + video,
          success: function(info){
                favorite.innerHTML = "already in <a href=\"\&quot;/videos?my_favorite=1\&quot;\">favorites</a>";
                favorite_num.innerHTML = "(" + info + ")";
          }
      });
}

function jquery_add_forum_to_favoriate (topic_id) {
    jQuery("#save_topic").html("<b><label>saving...</label></b>");

    jQuery.ajax({
        type: "POST",
        url: url_map_f('_forum_by_jquery'),
        data: "id=" + topic_id,
        success: function(){
            var htmlText = '<label>Already in</label><a href="http://www.largefriendfinder.net/forum_saved_topics">favorite topics</a>';
            jQuery("#save_topic").html(htmlText);
            jQuery("#save_topic").show();
        }
    });
}

function on_search_focus(obj) {
    obj.style.color = '#000000';
    obj.value = '';
}

function on_search_blur(obj) {
  if (obj.value == '') {
        obj.style.color='#818181';
        obj.value = "username or title";
  }
}

function show_whole_comments(obj) {
    $(obj).parent("span").css('display', 'none');
    $(obj).parent("span").next().css('display', 'block');
}


function escapeHTML(str) {
    return str.replace(/&/g, "&amp;")
    .replace(/</g, "&lt;")
    .replace(/>/g, "&gt;")
    .replace(/"/g, "&quot;");
}

function ChangeColor(obj){
    document.getElementById("show_color").value=obj.options[obj.selectedIndex].value;
    obj.options[obj.selectedIndex].selected=true;
    document.getElementsByName("c_color").item(0).style.color = obj.options[obj.selectedIndex].value;
    $('#text').css({'color': obj.value});
    obj.style.background = obj.value;
}

function on_maillist_focus(obj) {
    if(obj.value == 'You can copy and paste the email addresses, separated by space, newline, comma or semicolon. ex:lily@yahoo.com, Joe@gmail.com, bill@hotmail.com,tim@aol.com') {
        obj.value='';
        obj.style.color='#000000';
    }
}

function on_maillist_blur(obj) {
    if (obj.value == '') {
        obj.value = 'You can copy and paste the email addresses, separated by space, newline, comma or semicolon. ex:lily@yahoo.com, Joe@gmail.com, bill@hotmail.com,tim@aol.com';
        obj.style.color='#818181';
    }
}

function checkImgType(fileURL, allow_pdf, allow_txt_type){
    if (allow_pdf){
        var right_type=new Array(".gif",".jpg",".jpeg",".png",".bmp", ".pdf")
    } else if (allow_txt_type) {
        var right_type=new Array(".doc",".txt", ".pdf")
    } else {
        var right_type=new Array(".gif",".jpg",".jpeg",".png",".bmp")
    }
    var right_typeLen=right_type.length;
    var imgUrl=fileURL.toLowerCase();
    var postfixLen=imgUrl.length;
    var len4=imgUrl.substring(postfixLen-4,postfixLen);
    var len5=imgUrl.substring(postfixLen-5,postfixLen);
    for (i=0;i<right_typeLen;i++) {
        if((len4==right_type[i])||(len5==right_type[i])) {
            return 1;
        }
    }
    return 0;
}

function selectall (name, value) {
    if(value==1){
        $('input[name='+ name + ']').attr('checked',true);
    } else {
        $('input[name=' + name + ']').attr('checked',false);
    }
}

function check_all (name, tag) {
    if(tag==1){
        $('input[name='+ name + ']').each(function() {
            if ($(this).val() != 0) {
                $(this).attr("checked", true);
            } else {
                $(this).attr("checked", false);
            }
        });
    } else {
        $('input[name='+ name + ']').each(function() {
            if ($(this).val() != 0) {
                $(this).attr("checked", false);
            } else {
                $(this).attr("checked", true);
            }
        });
    }
}

function invite_as_affiliate(id) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_affiliate_by_jquery'),
        data: {prof_id:id, action:'invite_as_aff'},
        success: function( msg ){
           if (jQuery.trim(msg) == '1') {
               $("#invite_aff_link_" + id).html("Sent successfully!");
           } else {
               $("#invite_aff_link_" + id).html("Sent failed!");
           }
        }
    });
}


function saveCallData(usr_id, val, phone_location){
    if(val==1){
        PopUp('/de/censor_call_log_?prof_id=' + usr_id + '&phone_location=' + phone_location, 'user_call_log', 600, 400, 'yes');
    }
}

function sendCallRemind(prof_id, username) {
    if (confirm("Are you sure you want to send this user a chargeback email?")) {
        jQuery.ajax({
            type: "GET",
            url: url_map_f('censor_send_call_remind_?prof_id=' + prof_id + '&username=' + username),
            success: function( msg ) {
               if (jQuery.trim(msg) == '1') {
                   window.location.reload();
               }
            }
        });
    }
}

function send_verification_request(usr_id, to_email) {
    if (usr_id == '' || usr_id <= 1)
        return;

    $.getJSON(
        url_map_f("censor_send_verification_request_"), 
        { prof_id: usr_id, to_email: to_email, random: Math.random() },
        function(info) {
            if (info.ret == 1) {
                $('#verification_request_' + usr_id).html('<b>Sent out successfully!</b>');
            } else {
                alert(info.error);
            }
    });
}

function visible_quote(item) {
    $("#quote_" + item).toggle();
    if ($("#quote_title_" + item).text() == "- Hide quoted text -") {
        $("#quote_title_" + item).html("- Show quoted text -");
    } else {
        $("#quote_title_" + item).html("- Hide quoted text -");
    }
}
// ######################invite page, check email begin#####################
function error_show(msg) {
    $("#error").show();
    $("#error_msg").html(msg);
    return false;
}

function checkaddress(f) {
    var mailError = 0;
    var mailList = $("#mail_list").val();
    if (mailList == "" || mailList == "You can copy and paste the email addresses, separated by space, newline, comma or semicolon. ex:lily@yahoo.com, Joe@gmail.com, bill@hotmail.com,tim@aol.com") {
        mailError = 1;
    }
    if (mailError) {
        return error_show("A valid email address is required!");
    }

    var emails1 = "";
    var email1;
    var noValidAddress = true;
    var maillistarray, maillist;
    var obj = f.elements['mail_list'];
    var text = obj.value.trim();
    if (text == 'You can copy and paste the email addresses, separated by space, newline, comma or semicolon. ex:lily@yahoo.com, Joe@gmail.com, bill@hotmail.com,tim@aol.com') {
        text = '';
    }
    maillistarray = text.split(/[,;\n\s]\s*/);
    var wrong_email = '';
    for (maillist in maillistarray) {
        email1 = maillistarray[maillist];
        if (checkemail(email1)) {
            noValidAddress = false;
        } else {
            if (email1.length > 0) {
                wrong_email += email1 + ","
            }
        }
        if (email1.length > 0 && emails1.indexOf(email1 + ",") != -1) {
            return error_show("You have inputted duplicated email address!");
        }
        emails1 += email1 + ",";
    }
    if (noValidAddress) {
        return error_show("You haven't inputted any valid email address!");
    }
    if (wrong_email) {
        return error_show("The following email address is not valid: " + wrong_email.substring(0, wrong_email.length - 1));
    }
    return true;
}

function checkemail(str) {
    if (str.length < 1 || str.length > 100) return false;
    if (str.indexOf('@', 0) == -1 || str == "" || str.indexOf('.', 0) == -1) return false;
    thePos = str.indexOf('@', 0) + 1
    if (str.indexOf('@', thePos) != -1 || str.indexOf(';', thePos) != -1 || str.indexOf(',', thePos) != -1 || str.indexOf(' ', thePos) != -1) return false;
    return true;
}

function ChangeImportType(targ, selectObj) {
    var v = selectObj.options[selectObj.selectedIndex].value;
    if (v == '--select--') {
        return;
    } else {
        PopUp('friend_import_in_pp_?skip_member=0&type=' + v, 'import', '560', '600', 'yes');
        var obj = document.getElementById('past_board');
        if (obj) {
            obj.style.display = '';
        }
    }
}
// ######################invite page, check email end#####################

function flash_element(element_id) {
    var obj = document.getElementById(element_id);
    obj.style.visibility = obj.style.visibility == "hidden" ? "visible" : "hidden";
    setTimeout("flash_element('" + element_id + "')", 500);
}

function YYDD(year,month,day){

    MonHead = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    var day_value = day.options[day.selectedIndex].value;
    var year_value = year.options[year.selectedIndex].value;
    var n = MonHead[month.selectedIndex];

    if (month.selectedIndex == 1 && IsPinYear(year_value)){
        n++;
    }

    if (day_value > n) {
        day_value = n;
    }

    writeDay(n, day);
    day.value = day_value;
}

function MMDD(year,month,day){

    MonHead = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

    var day_value = day.options[day.selectedIndex].value;
    var year_value = year.options[year.selectedIndex].value;
    var n = MonHead[month.selectedIndex];

    if (month.selectedIndex == 1 && IsPinYear(year_value)){
        n++;
    }
    if (day_value > n) {
        day_value = n;
    }

    writeDay(n, day);
    day.value = day_value;

}

function writeDay(n, day){
    var e = day;
    optionsClear(e);
    for (var i=1; i<(n+1); i++){
        e.options.add(new Option(i,i));
    }
}

function IsPinYear(year){
    return(0 == year%4 && (year%100 !=0 || year%400 == 0));
}

function optionsClear(e){
    for (var i=e.options.length; i>=0; i--)
    e.remove(i);
}

function UpdateCountryInfoByJSON() {
    cou_id = $('select[name=country]').val();
    $.getJSON(
        "js_fill_states.xml",
        {country: cou_id, type: 'json'},
        function(json){
            cLeng = json.countries.length;
            options = '';
            for(var i=1; i < cLeng; i++){
                options += '<option value="' + json.countries[i].value + '">' + json.countries[i].text + '</option>';
            }
            $("select[name=state_id]").empty();
            $("select[name=state_id]").html(options);
        }
    );
}

function jquery_request_photo(pic_num, isguest, usr_id, about_id, user_name, img) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_request_photo'),
        data: "usr_id=" + usr_id + "&about_id=" + about_id,
        success: function(){
            $('#request_photo_' + about_id).html('Request sent');
            $('#request_photo_' + about_id).parent().css("cursor", "default");
            $('#request_photo_' + about_id).parent().removeAttr("onclick");
            $('#request_photo_' + about_id).parent().css("background-image", "url('" + img +" ')");
        }
    });
}

function jquery_vote_blog_topic (blog_id, vote) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_vote_by_jquery'),
        data: "vote=" + vote + "&blog_id=" + blog_id,
        success: function(data){
            if (vote == 1) {
                jQuery("#vote_" + vote).html(data + ' up');
            } else {
                jQuery("#vote_" + vote).html(data + ' down');
            }
        }
    });
}

/**
 * 
 * 
 * @author User (2009-10-19)
 * 
 * @param msg_id : Blog post message id
 * @param vote : deside whether up or down when user vote
 */
function jquery_vote_blog_msg(msg_id, vote) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_vote_by_jquery'),
        data: "vote=" + vote + "&msg_id=" + msg_id,
        success: function(data){
            if (vote == 1) {
                jQuery("#msg_" + msg_id).html(data + ' up');
            } else {
                jQuery("#msg_" + msg_id).html(data + ' down');
            }
        }
    });
}

function on_element_blur(obj, default_val) {
    if (obj.value == '') {
        obj.value = default_val;
        obj.style.color='#818181';
    }
}

function on_element_focus(obj, default_val) {
    if (obj.value == default_val) {
        obj.value = '';
        obj.style.color='#000000';
    }
}

// Photo upload pop on user_details page
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup() {
    //loads popup only if it is disabled
    if (popupStatus == 0) {
        $("#backgroundPopup").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup").fadeIn("slow");
        $("#popupContact").fadeIn("slow");
        popupStatus = 1;
    }
}

function disablePopup() {
    //disables popup only if it is enabled
    if (popupStatus == 1) {
        $("#backgroundPopup").fadeOut("slow");
        $("#popupContact").fadeOut("slow");
        popupStatus = 0;
    }
}

function checkUserID () {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_check_authen'),
        success: function(){}
    }); 
}

function update_blog_submit() {
    clickOnce();
    document.update.action='blog_post';
    document.update.target='';
    document.update.submit();
}

function add_or_replace_str(source, oldstr, newstr) {
    if (source.indexOf(oldstr) >= 0) {
        source = source.replace(oldstr, newstr);
    } else {
        source = source + newstr;
    }

    return source;
}

function jquery_save_mail_to_draft (obj, to, subject, text, del_draft_msg_id) {
    $(obj).attr('disabled', 'disabled');
    jQuery.ajax({
        type: "GET",
        url: url_map_f('_save_mail_to_draft'),
        data: "to=" +  to+ "&subject=" + subject + "&text=" + text +"&del_draft_msg_id=" + del_draft_msg_id,
        success: function(data) {
            $('#del_draft_msg_id').val(data);
            $(obj).val('Saved to draft');
        }
    });
}
function jquery_delete_draft(del_draft_msg_id) {
    jQuery.ajax({
        type: "GET",
        url: url_map_f('_save_mail_to_draft'),
        data: "only_delete_draft=1&del_draft_msg_id=" + del_draft_msg_id,
        success: function() {}
    });
}
function add_card_to_favorite(card) {
    var favorite = document.getElementById("favorite_" + card);
    jQuery.ajax({
        type: "POST",
        url: url_map_f('add_card_to_favorite_'),
        data: "card_id=" + card,
        success: function() {
            favorite.innerHTML = "already in <a href=\"/customize_greeting_cards?favorite=1\">favorites</a>";
        }
    });
}

function add_cards_to_favorite() {
    var checkboxes = $("input[name='cards']");
    var params = '';
    var values = [];
    for (var i = 0; i < checkboxes.length; i++) {
        if (checkboxes[i].checked) {
            params += '&cards_id=' + checkboxes[i].value;
            values.push(checkboxes[i].value);
        }
    }
    jQuery("input[type='checkbox']").attr("checked", false);
    jQuery.ajax({
        type: "POST",
        url: url_map_f('add_card_to_favorite_'),
        data: "favorite=0" + params,
        success: function() {
            show_tip();
        }
    });
    var show_tip = function() {
        for (var i = 0; i < values.length; i++) {
            document.getElementById("favorite_" + values[i]).innerHTML = "already in <a href=\"/customize_greeting_cards?favorite=1\">favorites</a>";
        }
    }
}

function dele_card_from_favorite(card) {
    if (confirm("Are you sure you want to remove the card from your favorites?")) {
        jQuery.ajax({
            type: "POST",
            url: url_map_f('customize_greeting_cards'),
            data: "favorite=1&delete_from_favorite=" + card,
            success: function(){
                window.location.reload();
            }
        });
    }
}

function show_hide_group(div_id, icon_id) {
    var div_obj  = $("#" + div_id);
    var icon_obj = $("#" + icon_id);
    if (div_obj.is(":hidden")) {
        div_obj.show();
        icon_obj.attr("class", "minus"); 
    } else {
        div_obj.hide();
        icon_obj.attr("class", "plus"); 
    }
}

function show_hide_profile(tr_id, icon_id, a_id) {
    var tr_obj_one;
    var tr_obj_two;
    if (tr_id == 'profile_my_video') {
        tr_obj_one = $("#" + tr_id + '_url');
        show_hide_profile_special(tr_id + '_url', tr_id + '_description', icon_id);
    } else if (tr_id == 'profile_customized') {
        tr_obj_one = $("#" + tr_id + '_title');
        show_hide_profile_special(tr_id + '_title', tr_id + '_content', icon_id);
    } else {
        tr_obj_one = $("#" + tr_id);
        show_hide_group_arrow(tr_id, icon_id);
    }
    if (tr_obj_one.is(":hidden")) {
        $("#" + a_id).html('Show');
    } else {
        $("#" + a_id).html('Hide');
    }
}

function show_hide_group_arrow(div_id, icon_id) {
    var div_obj  = $("#" + div_id);
    var icon_obj = $("#" + icon_id);
    if (div_obj.is(":hidden")) {
        div_obj.show();
        icon_obj.attr("class", "minus_arrow_down"); 
    } else {
        div_obj.hide();
        icon_obj.attr("class", "plus_arrow"); 
    }
}

function show_hide_profile_special(tr_id_1, tr_id_2, icon_id) {
    var tr_id_1_obj  = $("#" + tr_id_1);
    var tr_id_2_obj  = $("#" + tr_id_2);
    var icon_obj = $("#" + icon_id);
    if (tr_id_1_obj.is(":hidden")) {
        tr_id_1_obj.show();
        tr_id_2_obj.show();
        icon_obj.attr("class", "minus_arrow_down"); 
    } else {
        tr_id_1_obj.hide();
        tr_id_2_obj.hide();
        icon_obj.attr("class", "plus_arrow"); 
    }
}

var more_text_id = '';
function more_or_less(a) {
    if (more_text_id && more_text_id != a) {
        var prev_obj = $("#" + more_text_id);
        if (prev_obj.html() != 'More') {
            prev_obj.html('More');
        }
    }
    var a_obj = $("#" + a);
    if (a_obj.html() == 'More') {
        a_obj.html('Less');
    } else {
        a_obj.html('More');
    }
    more_text_id = a;
}

function jquery_unblock(unblock_id) {
    jQuery.ajax({
        type: "get",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "action=un_block&match_id=" + unblock_id,
        success: function() {
            window.location.reload();
        }
    });
}

function jquery_block_member(block_id,comments) {
    jQuery.ajax({
        type: "get",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "action=block&match_id=" + block_id + "&extra_data=" + comments,
        success: function() {
            window.location.reload();
        }
    });
}

function doprint() {
    var bdhtml = window.document.body.innerHTML;
    var sprnstr = "<!--startprint-->";
    var eprnstr = "<!--endprint-->";
    var prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
    var prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
    window.document.body.innerHTML = prnhtml;
    window.print();
    window.location.reload();
}

function IsShowSelectCardsError(targetId, frm) {
    if (IsSelectCards(frm)) {
        target = document.getElementById(targetId);
        target.style.display = "none";
        return true;
    } else {
        window.location.href = "#";
        target = document.getElementById(targetId);
        target.style.display = "";
        return false;
    }
}

function IsSelectCards(frm) {
    var flag = 0;
    for (i = 0; i < frm.elements.length; i++) {
        if (!frm.elements[i].checked) {
            continue;
        } else {
            flag = 1;
            break;
        }
    }
    if (flag == 1) {
        return true;
    } else {
        return false;
    }
}

function SendToFriends(frm, from_page) {
    var text = '';
    if (frm.del.length) {
        for (var i = 0; i < frm.del.length; i++) {
            if (frm.del[i].checked) {
                text = text + frm.del[i].value + '_';
            }
        }
    } else {
        if (frm.del.checked) {
            text = frm.del.value;
        }
    }
    if (text == '') {
        document.getElementById("error_profile_not_select").style.display = 'block';
        document.location = '#';
    } else {
        window.open('send_friends?from_page=' + from_page + '&user_list=' + text);
    }
}

function IsNum(s)
{
    if( s!=null ){
        var r,re;
        re = /[\d|.]*/i;
        r = s.match(re);
        return (r==s)?true:false;
    }
    return false;
}
var comment_usr_id;
function show_hide_comment (usr_id, username, fav_comment, type) {
    if (comment_usr_id != usr_id) {
        jQuery('#pic_td_' + comment_usr_id).removeAttr('vAlign').removeAttr('style');
        jQuery('#ckbox_td_' + comment_usr_id).removeAttr('vAlign').removeAttr('style');
        jQuery('#comment_td_' + comment_usr_id).hide();
        jQuery('#commend_frame_' + comment_usr_id).attr('src', '');
    }
    if (jQuery('#comment_td_' + usr_id).is(":hidden")) {
        fav_comment = fav_comment ? fav_comment : 0;
        var src = 'favorites_comments_?active=editcomments&prof_id=' + usr_id + '&username=' + username + '&edit=1&iframe=1&fav_comment=' + fav_comment;
        if (type == 'block') {
            src = 'blocked_?active=editreason&prof_id=' + usr_id + '&username=' + username + '&iframe=1&frompage=who_blocked&blocked_comment=' + fav_comment;
        } else if (type == 'friends') {
            src = 'friends_comments_?active=editcomments&prof_id=' + usr_id + '&username=' + username;
        } else if (type == 'chat_comments') {
            src = 'whom_had_chat_comments_?active=editcomments&prof_id=' + usr_id + '&username=' + username;
        } else if (type == 'photo_album') {
            src = 'favorites_comments_?active=editcomments&prof_id=' + usr_id + '&username=' + username + '&edit=1&iframe=1&from_page=photo_album&fav_comment=' + fav_comment;
        } else if (type == 'match_comments') {
            src = 'compatible_matches_comments_?active=editcomments&prof_id=' + usr_id + '&username=' + username;
        }
        jQuery('#pic_td_' + usr_id).attr('vAlign', 'top').css('padding-top', '15px');
        jQuery('#ckbox_td_' + usr_id).attr('vAlign', 'top').css('padding-top', '92px');
        jQuery('#commend_frame_' + usr_id).attr('src', src);
        if (type == 'photo_album') {
            jQuery('#comment_td_' + usr_id).show();
        } else {
            jQuery.facebox({ div: '#comment_td_' + usr_id });
        }
        comment_usr_id = usr_id;
    } else {
        jQuery('#pic_td_' + usr_id).removeAttr('vAlign').removeAttr('style');
        jQuery('#ckbox_td_' + usr_id).removeAttr('vAlign').removeAttr('style');
        jQuery('#comment_td_' + usr_id).hide();
        jQuery('#commend_frame_' + usr_id).attr('src', '');
    }
}

var hidden_div_id = 0, hidden_icon_id = 0, hidden_level = 0;
function fold_group(div_id, icon_id, level) {
    if (!level) {
        level = 1;
    }
    if (hidden_div_id && hidden_div_id != div_id && hidden_icon_id && hidden_icon_id != icon_id && hidden_level) {
        if (hidden_level > level) {
            var rel_id = $("#" + hidden_div_id).attr("rel");
            var rel_icon_id = "";
            if (rel_id == "earn_gold_ways") {
                rel_icon_id = "earn_gold_icon";
            }
            if (rel_id && rel_icon_id && rel_id != div_id) {
                $("#" + rel_id).hide();
                $("#" + rel_icon_id).attr("class", "plus");
            }
        }
        if (hidden_level >= level) {
            $("#" + hidden_div_id).hide();
            $("#" + hidden_icon_id).attr("class", "plus"); 
        }
    }
    hidden_div_id = div_id;
    hidden_icon_id = icon_id;
    hidden_level = level;
    show_hide_group(div_id, icon_id);
}

// censor telphone number lengh check.
function censor_check_tel_lengh() {
    var sel_value = $("select[name='type'] option[selected]").val();
    if (sel_value == "telphone") {
        var lengh = $("#arg").val().length;
        if (lengh < 4) {
            $("#telphone_info").html("telphone number should at least 4 symbols/digits");
            return false;
        }
    }
    return true;
}

var writing_ideas_div = "";
var writing_ideas_icon = "";
function show_writing_ideas (div_id, icon_id, url) {
    if (writing_ideas_div && writing_ideas_div != div_id && writing_ideas_icon && writing_ideas_icon != icon_id) {
        $("#" + writing_ideas_div).hide();
        $("#" + writing_ideas_icon).attr("class", "plus"); 
    }
    var div_obj  = $("#" + div_id);
    var icon_obj = $("#" + icon_id);
    if (div_obj.is(":hidden")) {
        div_obj.load(url);
        div_obj.show();
        icon_obj.attr("class", "minus"); 
        writing_ideas_div = div_id;
        writing_ideas_icon = icon_id;
    } else {
        div_obj.html('');
        div_obj.hide();
        icon_obj.attr("class", "plus"); 
    }

}

function remove_travelling(about_id) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_remove_travelling'),
        data: "&about_id=" + about_id,
        success: function(data) {
            $('#show_travelling').hide();
        }
    });
}

function on_card_msg_focus(obj) {
    if(obj.value == 'Write down your best wishes. They will be shown on the card directly.') {
        obj.value = '';
        obj.style.color = '#000000';
    }
}

function on_card_msg_blur(obj) {
    if (obj.value == '') {
        obj.value = 'Write down your best wishes. They will be shown on the card directly.';
        obj.style.color = '#818181';
    }
}

function load_from_user_json(element, pkg) {
    var name = element.attr("name");
    // $("#" + name + "_save").text("loading");
    $.ajax({
        url: "/_user_json?method=load",
        data: {"package": pkg, "key": name},
        success: function(value) {
            value = value.replace(/^\s+|\s+$/g, "");
            if (value && value != element.val()) {
                element.val(value);
                element.css("color", "#000");
            }
            $("#" + name + "_save").text("save now");
        }
    });
}

function save_to_user_json(element, pkg) {
    var name = element.attr("name");
    var value = element.val();
    $("#" + name + "_save").text("saving");
    $.ajax({
        url: "/_user_json?method=save",
        data: {"package": pkg, "key": name, "value": value},
        success: function() {
            $("#" + name + "_save").text("saved");
            fields_changed --;
            $("#" + name + "").attr("change_flag", "");
        }
    });
    var on_change = function() {
        var button = $("#" + name + "_save");
        if (button.text() == "saved") button.text("save now");
    };
    element.change(on_change);
    element.keypress(on_change);
}

// initial online saveable elements
function initial_online_saveable_elements(pkg) {
    $(".online_saveable").each(function() {
        // initial datas, if there was "save now".
        if ($('#' + $(this).attr("name") + "_save").size() > 0) {
            return;
        }
        load_from_user_json($(this), pkg);

        // add control elements
        var element = "$('.online_saveable[name=" + $(this).attr("name") + "]')";
        $(this).next().children().eq(0).after("<div style=\"float:right; margin-left:1em;\"><a href=\"javascript:;\" id=\""
            + $(this).attr("name") + "_save\" onclick=\"save_to_user_json("
            + element + ", '" + pkg + "'); save_now_tip()\">save now</a></div>");
    });
}

function send_password_to_user(email) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('do_remind'),
        data: "from_page=censor&usr_email=" + email,
        success: function(data) {
            if (data.indexOf('###OK###') != -1) {
                alert('Send successfully!');
            } else {
                alert('Send Unsuccessfully!');
            }
        }
    });
}

function show_long_text(more_link, sub_text_id, full_text_id) {
    var sub_t  = $('#' + sub_text_id);
    var full_t = $('#' + full_text_id);
    if (full_t) {
        full_t.show();
        if (sub_t) {
            sub_t.hide();
        }
    }
}

function submit_to_rating(usr_id) {
    jQuery.ajax({
        type: "post",
        url: url_map_f('_add_in_rating_by_jquery'),
        data: "usr_id=" + usr_id,
        success: function(data) {
            window.location.reload();
        }
    });
}

function jquery_user_view(about_id) {
    if (!about_id) return;
    jQuery.ajax({
        type: "post",
        url: url_map_f('_view_user'),
        data: "about_id=" + about_id
    });
}
/**
 * view picture with fullscreen mode
 * u : image's url
 * w : image's width
 * h : image's height
 */
function view_bigger_picture(u, w, h, decription_div, story_pic_p1, story_pic_p2, like_usr_id, liked, only_show_one){
    w = 0;
    h = 0;
    var mask = $(document.createElement('div'));
    mask.css({ 'background': 'none repeat scroll 0 0 #000000', 'position': 'absolute', 'z-index': '2000', 'left': '0px', 'top': '0px', 'display': 'none', 'width': '100%', 'height': '100%', 'opacity': '0.2' });
    $(document.body).append(mask);
    if (like_usr_id) jquery_user_view(like_usr_id);
    var box = $(document.createElement('div'));
    box.css({ 'padding': '0px', 'margin': '0px', 'z-index': '2500', 'position': 'absolute', 'display': 'none', 'width': '48px', 'height': 'auto' });
    box.attr('id', 'pop_up_box');
    box.bind('contextmenu', function(e) {
        return false;
    });

    var header = $(document.createElement('div'));
    header.addClass('header');
    header.append('<div class="tl"></div><div class="bg"></div><div class="tr"></div>');

    box.append(header);

    var close = $(document.createElement('a'));
    close.html('<img src="http://images.LargeFriends.com/common-de/box_close_square_btn.png" width="27" height="27" border="0" />');
    close.attr('href','javascript: void(0);');
    close.attr('id', 'box_close_link');
    close.click(function() {
        current_story_pic_desc = '';
        box.fadeOut("fast", function() {
            box.replaceWith('');
            mask.fadeOut("fast", function() {
                mask.replaceWith('');
            });
        });
    });
    close.css({ 'right': '15px', 'top': '5px', 'position': 'absolute', 'width': '27px', 'height': '27px' });

    var like_btn;
    var content = $(document.createElement('div'));
    content.addClass('content');

    var top_link = $("#top_link").html();
    if (top_link) {
        content.append('<div align="center" style="font-weight: bold; margin: 0px 10px 0px; background-color: #ffffff; font-size: 13px;">' + top_link + '</div>');
    }

    var loading = $(document.createElement('div'));
    loading.addClass('loading');
    content.append(loading);

    var img = $(document.createElement('img'));
    var show_num = $(document.createElement('div'));
    show_num.css({'height': '18px', 'text-align': 'left', 'background-color': '#fff', 'margin': '0px 10px', 'padding': '13px 5px 0px', 'font-size': '14px'});
    if (window.max_code && !only_show_one || (story_pic_p1 && story_pic_p2 > 1)) {
        var show_img = function() {
            if (w && h) {
                changeBoxSize(cur_img_original_width, cur_img_original_height);
            }
            if ($('#poplink').length) {
                if ($('#poplink').attr('href').slice(-3) == 'pay') {
                    window.open($('#poplink').attr('href'), $('#poplink').attr('target'));
                } else {
                    if ($('#poplink img:first').attr('original_pic')) {
                        img.attr('src', $('#poplink img:first').attr('original_pic'));
                    } else {
                        img.attr('src', $('#poplink img:first').attr('src'));
                    }
                }
            } else {
                if ($('#GetInfo').length) {
                    if ($('#GetInfo a:first').attr('href').slice(-3) == 'pay') {
                        img.attr('src', $('#GetInfo img:first').attr('src'));
                        window.open($('#GetInfo a:first').attr('href'), $('#GetInfo a:first').attr('target'));
                    } else {
                        if ($('#GetInfo img:first').attr('original_pic')) {
                            img.attr('src', $('#GetInfo img:first').attr('original_pic'));
                        } else {
                            img.attr('src', $('#GetInfo img:first').attr('src'));
                        }
                    }
                } else {
                    if (story_pic_p1 && story_pic_p2) {
                        setMaskSize();
                        img.attr('src', $('#' + current_story_pic_code + ' img').attr('src'));
                        var image = new Image();
                        image.src = img.attr('src');
                        changeImgSize(image.width, image.height);
                    }
                }
            }
        };

        var arrow_left = $(document.createElement('a'));
        var arrow_right = $(document.createElement('a'));
        arrow_left.html('<img src="http://images.LargeFriends.com/common-de/photo-arrow-left.gif" border="0" />');
        arrow_left.attr('href','javascript: void(0);');
        arrow_left.css({'margin-right': '5px'});
        arrow_right.html('<img src="http://images.LargeFriends.com/common-de/photo-arrow-right.gif" border="0" />');
        arrow_right.attr('href','javascript: void(0);');
        arrow_right.css({'margin-left': '5px'});
        if (window.max_code) {
            show_num.html('Photo <span id="show_now_pic_num">' + (current_code + 1) + '</span> of <span>' + (max_code + 1) + '</span>');
        } else if (story_pic_p1 && story_pic_p2 > 1) {
            var tmp = decription_div.split(story_pic_p1 + '_');
            var now_pic = parseInt(tmp[tmp.length - 1]);
            show_num.html('(<span id="show_now_pic_num">' + now_pic + '</span> / <span>' + story_pic_p2 + '</span>)');
        }
        arrow_left.click(function() {
            $("#picture_decription").html('');
            img.attr('src', '');
            img.css('visibility', 'hidden');
            if (story_pic_p1 && story_pic_p2) {
                GetStoryShowPic(0, story_pic_p1, story_pic_p2);
            } else {
                GetShow(current_code - 1);
            }
            show_img();
        });
        arrow_right.click(function() {
            $("#picture_decription").html('');
            img.attr('src', '');
            img.css('visibility', 'hidden');
            if (story_pic_p1 && story_pic_p2) {
                GetStoryShowPic(1, story_pic_p1, story_pic_p2);
            } else {
                GetShow(current_code + 1);
            }
            show_img();
        });
        show_num.prepend(arrow_left);
        show_num.append(arrow_right);
        content.prepend(show_num);

        img.mousemove(function(e) {
            var e = e || window.event;
            var mousePosX = parseInt(e.pageX ? e.pageX : (e.clientX + document.body.scrollLeft - document.body.clientLeft));
            if (parseInt(mousePosX - img.offset().left) < parseInt(img.width()/2)) {
                img.css('cursor', 'url("http://images.LargeFriends.com/common-de/pic_viewer_left.cur"), auto');
            } else {
                img.css('cursor', 'url("http://images.LargeFriends.com/common-de/pic_viewer_right.cur"), auto');
            }
        });
        img.click(function(e) {
            var e = e || window.event;
            var mousePosX = parseInt(e.pageX ? e.pageX : (e.clientX + document.body.scrollLeft - document.body.clientLeft));
            $("#picture_decription").html('');
            img.attr('src', '');
            img.css('visibility', 'hidden');
            if (parseInt(mousePosX - img.offset().left) < parseInt(img.width()/2)) {
                if (story_pic_p1 && story_pic_p2) {
                    GetStoryShowPic(0, story_pic_p1, story_pic_p2);
                } else {
                    GetShow(current_code - 1);
                }
            } else {
                if (story_pic_p1 && story_pic_p2) {
                    GetStoryShowPic(1, story_pic_p1, story_pic_p2);
                } else {
                    GetShow(current_code + 1);
                }
            }
            show_img();
        });
    }
    img.css('border', '5px solid #ffffff');
    loading.append(img);

    content.append('<div id="picture_decription" align="center" style="font-weight: bold; margin: 0px 10px 0px; background-color: #ffffff;"></div>');
    content.append(close);
    if (like_btn) {
        content.append(like_btn);
    }
    box.append(content);

    var footer = $(document.createElement('div'));
    footer.addClass('footer');
    footer.append('<div class="bl"></div><div class="bg"></div><div class="br"></div>');
    box.append(footer);

    $(document.body).append(box);

    if (!w) {
        img.load(function() {
            img.css("width","");
            img.css("height","");
            changeImgSize(img.get(0).width, img.get(0).height);
            var cur_decription_content = current_story_pic_desc ? $("#" + current_story_pic_desc).html() : decription_div ? $("#" + decription_div).html() : $("#about_info").html();
            $('#picture_decription').html(cur_decription_content);
            box.css('visibility', 'visible');
            img.css('visibility', 'visible');
        });
        initBoxSize();
    } else {
        img.load(function() {
            var cur_decription_content = current_story_pic_desc ? $("#" + current_story_pic_desc).html() : decription_div ? $("#" + decription_div).html() : $("#about_info").html();
            $('#picture_decription').html(cur_decription_content);
            img.css('visibility', 'visible');
        });
        changeBoxSize(w, h);
    }
    mask.css('opacity','0');
    mask.fadeTo("slow", 0.2, function() {
        box.show();
        img.attr('src', u);
    });
    mask.click(function() {close.click();});
    function changeImgSize(w, h) {
        w = parseInt(w);
        h = parseInt(h);
        var k = h/w;
        if (w > 640) {
            w = 640;
            h = w*k;
        }
        if (w < 120) {
            w = 120;
            h = w*k;
        }
        var left = parseInt(($(window).width() - (w + 30))/2) > 0 ? parseInt(($(window).width() - (w + 30))/2) : 100;
        var top = parseInt(($(window).height() - (h + 30))/2) > 0 ? parseInt(($(window).height() - (h + 30))/2) : 100;
        box.css('left', ($(document).scrollLeft() + left) + 'px');
        box.css('top', ($(document).scrollTop() + top) +'px');
        box.css('width', parseInt(w + 30) + 'px');
        box.find(".bg").css('width', parseInt(w + 10) + 'px');
        img.width(w);
        img.height(h);
        $(window).resize(function(){changeBoxSize(w, h);});
    }
    function setMaskSize() {
        mask.css('width', $(document).width() + 'px');
        mask.css('height', $(document).height() + 'px');
    }
    function changeBoxSize(w, h) {
        setMaskSize();
        changeImgSize(w, h);
    }
    function initBoxSize() {
        setMaskSize();
        box.css('visibility', 'hidden');
        box.css('left', $(document).scrollLeft() + 'px');
        box.css('top', $(document).scrollTop() + 'px');
        box.css('width', '30px');
        box.find(".bg").css('width', '10px');
    }
}

function format_positive_number_to_money(number) {
    number += '';

    var pos = number.indexOf('.');
    var suffix = '';
    if (pos > -1) {
        suffix = number.substring(pos);
        number = number.substring(0, pos);
    }

    if (number.length > 3) {
        number = number.split('').reverse().join('');
        number = number.replace(/(\d{3})\B/g, '$1,');
        number = number.split('').reverse().join('');
    }

    return number + suffix;
}

function SetIframeHeight(obj) {
    var cwin = obj;
    if (document.getElementById) {
        if (cwin && !window.opera) {
            if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight)
                cwin.height = cwin.contentDocument.body.offsetHeight + 20; //FF NS
            else if(cwin.Document && cwin.Document.body.scrollHeight)
                cwin.height = cwin.Document.body.scrollHeight + 10;//IE
        } else {
            if(cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight)
                cwin.height = cwin.contentWindow.document.body.scrollHeight;//Opera
        }
    }
}

function jquery_vote_std_story (story_id, vote) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_vote_by_jquery'),
        data: "vote=" + vote + "&story_id=" + story_id,
        success: function(data){
            jQuery("#msg_" + story_id).html(data + ' up');
        }
    });
}

function jquery_vote_std_treatment_story (story_id, vote) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_vote_by_jquery'),
        data: "vote=" + vote + "&std_treatment_story_id=" + story_id,
        success: function(data){
            jQuery("#msg_" + story_id).html(data + ' up');
        }
    });
}

function remove_profiles_confirm(tip_text) {
    if(!$("input:checked").length) {
        $("#error_profile_not_select").show();
        $(document.body).scrollTop(0);
        return false;
    }
    $("error_profile_not_select").hide();

    tip_text = tip_text || 'Are you sure you want to remove it?';
    jQuery.facebox('<div id="pop_container" align="center"><div>' + tip_text +'<br /> <br /><div><div><input value="OK" style="height:25px; margin:5px 10px; width:80px;" type="button" onclick="remove_profiles();"  /><input value="Cancel" style="height:25px; margin:5px 10px; width:80px;" type="button" onclick="jQuery(document).trigger(\'close.facebox\')" /></div></div>');
}

function remove_profiles() {
    jQuery("input[name=btnDelSel]").val("1");
    $("form:first").submit();
}

function isDigit(s) { 
    var patrn = /^[0-9]{1,64}$/;
    if (!patrn.exec(s)) return false;
    return true;
} 

/* {{{ NOTE: DO NOT ADD ANY NONE OF JQUERY PLUGINS RELATED CODES BELOW */

/**
 * jQuery plugins
 *
 * See how to write jQuery plugins: http://docs.jquery.com/Plugins/Authoring
 */
(function($) {

    /**
     * Add picture tips.
     */

    $.fn.add_pic_tips = function(options) {
        var opts = $.extend({}, $.fn.add_pic_tips.defaults, options);
        var img_box = $("#show_big_photo");
        if (img_box.length == 0)
            $('<img id="show_big_photo" style="display: none;" />').appendTo("body"); 
        $(this).live(
            "mouseover mouseout",
            function (event) {
                if (event.type == 'mouseover') {
                    $("#show_big_photo")
                        .attr({src: $(this).attr("src")})
                        .css({position: "absolute", left: $(this).offset().left + opts.left, top: $(this).offset().top + opts.top})
                        .show();
                } else {
                    $("#show_big_photo").hide();
                }
            }
        );
    };

    $.fn.add_pic_tips.defaults = {left: 50, top: 20};

})(jQuery);

/* NOTE: DO NOT ADD ANY NONE OF JQUERY PLUGINS RELATED CODES ABOVE }} */

function delete_blog_confirm(del_message, blog_id, deltopic) {
    var alert_text = deltopic ? 'Are you sure you want to remove all comments and the blog?' : 'Are you sure you want to remove the comment?';
    $.facebox('<div align="center">' + alert_text + '<br /><br /><br /><input type="button" onclick="location.href=\'/blogs/blog_delete?del_message=' + del_message + '&blog_id=' + blog_id + '&deltopic=' + deltopic + '&delete=1\'" value="Yes" style="margin-right: 50px; width: 70px;" /><input type="button" onclick="$(document).trigger(\'close.facebox\');" class="close" value="Cancel" style="width: 70px;" /></div>');
}

function delete_forum_confirm(message_id, topic_id, author_post, from_page, topic_author) {
    var alert_text = author_post ? 'Are you sure you want to delete the post?' : 'Are you sure you want to delete the comment?';
    $.facebox('<div align="center">' + alert_text + '<br /><br /><br /><input type="button" onclick="location.href=\'/forum_delete_post?message_id=' + message_id + '&topic_id=' + topic_id + '&author_post=' + author_post + '&from_page=' + from_page + '&topic_author=' + topic_author + '&delete=1\'" value="Yes" style="margin-right: 50px; width: 70px;" /><input type="button" onclick="$(document).trigger(\'close.facebox\');" class="close" value="Cancel" style="width: 70px;" /></div>');
}

function delete_photo_confirm(pic_url, picno, x, photo_is_verify) {
    $.facebox.settings.closeImage_type = 'top';
    var alert_text = '<div align="center" style="width: 640px;">        <div><img src="' + pic_url + '" width="' + (x > 360 ? 360 : x) + '" border="0" /></div><br />        <div style="border: 1px solid #ff9a00; width: 95%; margin: 10xp 0px; padding: 10px; text-align: left; background-color: #f6f0f0;">Remember, you can get 20x more interest and responses with photos on your profile. The more photos you have, the more attention you will get.</div><br />        <div style="color: red; text-align: center; height: 30px; font-weight: bold;">It can not be retrieved after deleting it. ' + (photo_is_verify ? "Your verified logo will disappear if all photos are removed." : "Are you sure you want to delete this photo?") + '</div>        <div><input onclick="$(document).trigger(\'close.facebox\');" type="button" value="No, I want to keep it" class="buttont_details" style="margin-right: 20px;" /><input onclick="window.location.href=\'' + url_map_f("/picture_delete_confirm?picno=" + picno + "&clear=1") + '\';" type="button" value="Yes, delete the photo" class="buttont_details" /></div>    </div>';
    $.facebox(alert_text);
}

function delete_extra_photo_confirm(manage_link, pic_url, delete_id, album_type, x) {
    $.facebox.settings.closeImage_type = 'top';
    var alert_text = '<div align="center" style="width: 640px;">        <div><img src="' + pic_url + '" width="' + (x > 360 ? 360 : x) + '" border="0" /></div><br />        <div style="color: red; text-align: center; height: 30px; font-weight: bold;">' + "Are you sure you want to delete this photo?" + '</div>        <div><input onclick="$(document).trigger(\'close.facebox\');" type="button" value="No, I want to keep it" class="buttont_details" style="margin-right: 20px;" /><input onclick="window.location.href=\'' + url_map_f("/" + manage_link + "?delete_id=" + delete_id + "&album_type=" + album_type) + '\';" type="button" value="Yes, delete the photo" class="buttont_details" /></div>    </div>';
    $.facebox(alert_text);
}

function delete_profile_comment_confirm(about_id, del_id) {
    var alert_text = '<div align="center">Are you sure you want to remove the comment?<br /><br /><br /><input type="button" onclick="location.href=\'/perboard?update=1&active=2&about_id=' + about_id + '&update_usr_id=' + del_id + '\'" value="Yes" style="margin-right: 50px; width: 70px;" /><input type="button" onclick="$(document).trigger(\'close.facebox\');" class="close" value="Cancel" style="width: 70px;" /></div>';
    $.facebox(alert_text);
}

function propose_date(usr_id) {
    $.ajax({
        type: "POST",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "match_id=" + usr_id + "&action=propose_date",
        success: function(data) {
            $("#propose_date_" + usr_id).html("Date proposed");
        }
    });
}

function jquery_date_likes(usr_id) {
    $("#like_date_link_" + usr_id).unbind();
    $.getJSON(
        url_map_f("_process_date_likes"), 
        { match_id: usr_id },
        function(info) {
            if ($("#like_date_" + usr_id).hasClass('n-like-button2')) {
                $("#like_date_" + usr_id).removeClass('n-like-button2');
            }
            $("#like_date_" + usr_id).addClass('n-unlike-button2');
            $("#like_date_link_" + usr_id).show();
            if (info.is_like) {
                $("#like_button_" + usr_id).html("Dislike the idea");
            } else {
                $("#like_button_" + usr_id).html("Like this idea");
            }
            $("#likes_count_" + usr_id).html('<a href="http://www.largefriendfinder.net/who_like_date_ideas?prof_id=' + usr_id + '">' + info.likes_count + ' likes</a>');
            $(".n-like-num2").show();
        }
    );
}

function request_photo_note(isguest, usr_id, usr_name) {
    usr_name = usr_name ? ' of <b>' + usr_name + '</b>' : '' ;
    if (isguest) {
        jQuery.facebox('<span style="width: 400px;">We have sent a notice to this member asking him / her to post photos. Please check again a few days later.<br /><br />This member might be more interested in showing photos privately.<a href="http://www.largefriendfinder.net/send_email?prof_id=' + usr_id + '">Send an email</a> to show your interest now!<br /><br /><a href="http://www.largefriendfinder.net/my_profile?profile_group=photo" target="_blank" onclick="jQuery(document).trigger(\'close.facebox\')">Click here to post your photos now</a>');
    } else {
        jQuery.facebox('<span style="width: 400px;">You have successfully requested the photo ' + usr_name + '.</span><br /><br />We have sent a notice to this member asking him / her to post photos. Please check again a few days later.<br /><br /><a href="http://www.largefriendfinder.net/my_profile?profile_group=photo" target="_blank" onclick="jQuery(document).trigger(\'close.facebox\')">Click here to post your photos now</a>');
    }
}

function show_hide_wink_pop(usr_id, is_show) {
    if (is_show == 'show') {
        $("#wink_pop_div" + usr_id).show();
    } else {
        $("#wink_pop_div" + usr_id).hide();
    }
}

function add_serial_number () {
    var serial_number = 1;
    $(".serial_id").each(function(){
        $(this).html(serial_number  + ".");
        serial_number ++;
    });
}

function show_facebox_photo(pic_url, msg) {
    $.facebox.settings.closeImage_type = 'top';
    var content = '<div align="center" style="width: 500px;">        <div><img src="' + pic_url + '" border="0" width="500" /></div><br />';
    if (typeof(msg) != 'undefined')
    {
        content += '<div>' + msg + '</div>';
    }
    content += '</div>';
    $.facebox(content);
}

function show_facebox_content(content, add_link_href, add_link_target, add_link_text) {
    $.facebox.settings.closeImage_type = 'top';
    if (add_link_href && add_link_text) {
        content += '<div align="center" style="margin-top: 20px; margin-bottom: 10px;">                        <div><a href="' + add_link_href + '"';
        if (add_link_target) {
            content += ' target="' + add_link_target + '"';
        }
        content += ' >' + add_link_text + '</a></div>                    </div>';
    }
    $.facebox(content);
}

function ask_first_date_idea_tips() {
    $.facebox.settings.closeImage_type = 'top';
    jQuery.facebox({ div: '#perfect_date_popup' });
    jQuery("#facebox").css('bottom', "300px");
}

var current_story_pic_code;
var current_story_pic_desc;

function GetStoryShowPic(code,usr_id,max) {
    var now_pic_id;
    if (code>0) {
        if (max==3) {
            if (current_story_pic_code == 'photo_show_'+usr_id+'_2') {
                $('#photo_'+usr_id+'_1').hide();
                $('#photo_'+usr_id+'_2').hide();
                $('#photo_'+usr_id+'_3').show();
                current_story_pic_code = 'photo_show_'+usr_id+'_3';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_3';
                now_pic_id = 3;
            } else if (current_story_pic_code == 'photo_show_'+usr_id+'_3') {
                $('#photo_'+usr_id+'_1').show();
                $('#photo_'+usr_id+'_2').hide();
                $('#photo_'+usr_id+'_3').hide();
                current_story_pic_code = 'photo_show_'+usr_id+'_1';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_1';
                now_pic_id = 1;
            } else {
                $('#photo_'+usr_id+'_1').hide();
                $('#photo_'+usr_id+'_2').show();
                $('#photo_'+usr_id+'_3').hide();
                current_story_pic_code = 'photo_show_'+usr_id+'_2';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_2';
                now_pic_id = 2;
            }
        } else if (max==2) {
            if (current_story_pic_code == 'photo_show_'+usr_id+'_2') {
                $('#photo_'+usr_id+'_2').hide();
                $('#photo_'+usr_id+'_3').show();
                current_story_pic_code = 'photo_show_'+usr_id+'_3';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_3';
            } else {
                $('#photo_'+usr_id+'_2').show();
                $('#photo_'+usr_id+'_3').hide();
                current_story_pic_code = 'photo_show_'+usr_id+'_2';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_2';
                now_pic_id = 2;
            }
        }
    } else {
        if (max==3) {
            if (current_story_pic_code == 'photo_show_'+usr_id+'_3') {
                $('#photo_'+usr_id+'_1').hide();
                $('#photo_'+usr_id+'_2').show();
                $('#photo_'+usr_id+'_3').hide();
                current_story_pic_code = 'photo_show_'+usr_id+'_2';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_2';
                now_pic_id = 2;
            } else if (current_story_pic_code == 'photo_show_'+usr_id+'_2') {
                $('#photo_'+usr_id+'_1').show();
                $('#photo_'+usr_id+'_2').hide();
                $('#photo_'+usr_id+'_3').hide();
                current_story_pic_code = 'photo_show_'+usr_id+'_1';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_1';
                now_pic_id = 1;
            } else {
                $('#photo_'+usr_id+'_1').hide();
                $('#photo_'+usr_id+'_2').hide();
                $('#photo_'+usr_id+'_3').show();
                current_story_pic_code = 'photo_show_'+usr_id+'_3';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_3';
                now_pic_id = 3;
            }
        } else if (max==2) {
            if (current_story_pic_code == 'photo_show_'+usr_id+'_2') {
                $('#photo_'+usr_id+'_2').hide();
                $('#photo_'+usr_id+'_3').show();
                current_story_pic_code = 'photo_show_'+usr_id+'_3';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_3';
                now_pic_id = 3;
            } else {
                $('#photo_'+usr_id+'_2').show();
                $('#photo_'+usr_id+'_3').hide();
                current_story_pic_code = 'photo_show_'+usr_id+'_2';
                current_story_pic_desc = 'pic_desc_'+usr_id+'_2';
                now_pic_id = 3;
            }
        }
    }
    $("#show_now_pic_num").html(now_pic_id);
}

function featured_member(prof_id, featured_action) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('censor_minor_operation_'),
        data: {prof_id:prof_id, action:featured_action},
        success: function(data){
            if (featured_action == 'featured_member') {
                if (data == 1) {
                    $("#feature_member_" + prof_id).html("Already a homepage featured member (<a href=\"javascript: featured_member(" + prof_id + ", 'cancel_featured_member')\">Cancel it</a>)");
                } else {
                    alert('The ratio of photo is wrong!');
                }
            } else if (featured_action == 'cancel_featured_member') {
                $("#feature_member_" + prof_id).html("<a href=\"javascript:featured_member(" + prof_id + ", 'featured_member')\">Select this as homepage featured member</a><span style=\"color: blue\">(Only if the main photo is a full photo of userself, the ratio is 4:3, or it's CS mistake) <a href=\"javascript:void(0)\" onclick=\"PopUp('/modules/featured_member_example_', '', 420, 300)\">example</a></span>");
            }
        }
    });
}

function save_private_note(prof_id, tips) {
    var val = jQuery.private_notes[prof_id].find('#comments_private_note_' + prof_id).eq(0).val();
    if (val == tips) {
        val = '';
        jQuery.private_notes[prof_id].find('#comments_private_note_' + prof_id).eq(0).val('');
    }
    if (val.length > 2000) {
        jQuery.private_notes[prof_id].find('#comments_private_note_error' + prof_id).eq(0).show();
        return;
    }
    jQuery.private_notes[prof_id].find('#comments_private_note_error' + prof_id).eq(0).hide();

    $('#searchresults_private_comment_' + prof_id).html(val);
    $('#searchresults_private_comment_' + prof_id).show();
    $.ajax({
        type: "POST",
        url: url_map_f('json/update_private_note_'),
        data: { prof_id: prof_id, note: val },
        dataType: "json",
        success: function(data){
            private_note_toggle(prof_id);
            if (val) {
                $('#add_edit_' + prof_id).html('edit');
            } else {
                $('#add_edit_' + prof_id).html('add');
            }
        }
    });


}

function private_note_toggle(prof_id) {
    if ($('#facebox').is(":visible")) {
        $(document).trigger('close.facebox');
        $("#searchresults_private_comment_" + prof_id).show();
    } else {
        $.facebox(jQuery.private_notes[prof_id]);
        $('#facebox .close').click(function(){
            $("#searchresults_private_comment_" + prof_id).show();
            $.facebox.close();
        })
        $("#searchresults_private_comment_" + prof_id).hide();
    }
}

function remove_video_url_confirm(usr_id) {
    jQuery.facebox('<div id="pop_container" align="center"><div style="color: red;">Are you sure you want to delete this video?<br /> <br /><div><div><input value="Yes" style="height:25px; margin:5px 10px; width:80px;" type="button" onclick="jQuery(\'input[name=my_video_url_' + usr_id + ']\').val(\'\'); jQuery(\'#delete_video_' + usr_id + '\').toggle(); jQuery(document).trigger(\'close.facebox\');" /><input value="No" style="height:25px; margin:5px 10px; width:80px;" type="button" onclick="jQuery(document).trigger(\'close.facebox\')" /></div></div>');
}


function request_photo_confirm(pic_num, isguest, usr_id, about_id, user_name, img) {
    $.facebox.settings.closeImage_type = 'top';
    var alert_text = '<div align="center" style="width: 450px;">        <div style="color: blue; text-align: center; height: 30px; font-weight: bold;">Are you sure you want to send photo request to this member?</div>        <div><input onclick="jquery_request_photo(' + pic_num + ', '+ isguest + ', ' + usr_id + ', ' + about_id + ', \'' + user_name + '\', \'' + img + '\'); $(document).trigger(\'close.facebox\');" type="button" value="Yes, send it" class="buttont_details" style="margin-right: 50px;" /><input onclick="$(document).trigger(\'close.facebox\');" type="button" value="No, cancel it" class="buttont_details" /></div>    </div>';
    if (pic_num == 0) {
        alert_text = '<p style="color: blue;">Before sending photo request to this member, you need to first upload your photo.</p><p align="center"><a href="http://www.largefriendfinder.net/my_profile?profile_group=photo" target="_blank" onclick="jQuery(document).trigger(\'close.facebox\')">Upload a photo now</a></p>';
    }
    $.facebox(alert_text);
}

function show_hide_featured_members() {
    if ($("#featured_members").is(":hidden")) {
        $("#featured_members").css("display", "block");
        $("#show_hide_featured_members").attr("class", "minus"); 
    } else {
        $("#show_hide_featured_members").attr("class", "plus"); 
        $("#featured_members").css("display", "none");
    }
}

function jquery_photo_likes(usr_id, hide_reason) {
    var reason = $.trim($('#like_photo_reason').val());
    if (hide_reason) {
        $("#like_photo").hide();
        $("#like_photo_tip").html('Sent...');
        $("#like_photo_tip").show();
    }
    $.getJSON(
        url_map_f("_process_photo_likes"), 
        { about_id: usr_id, reason: reason, change_reason: hide_reason, random: Math.random() },
        function(data) {
            if (data == 1) {
                if (hide_reason) {
                    $("#like_photo_tip").html('<span class="font_blue">Sent successfully</span>');
                } else {
                    $("#like_user_photo").html('<span class="font_blue">You liked this photo!</span>');
                    $("#like_btn" + usr_id).html('<img src="http://images.LargeFriends.com/common/liked_btn.png" height="23" width="128" border="0" />');
                }
            } else {
                if (hide_reason) {
                    $("#like_photo_tip").html('<font color="red">Sent failed, you can try it again.</font>');
                    $("#like_photo").show();
                }
            }
        }
    );

}

function jquery_photo_unlikes(usr_id) {
    $.getJSON(
        url_map_f("_process_photo_likes"), 
        { about_id: usr_id, action: 'unlike', random: Math.random() },
        function(data) {
            if (data == 1) {
                $("#unlike_user_photo").html('<span class="font_blue">You unliked this photo!</span>');
            }
        }
    );
}

function switch_tab(selected_tab, tab_content_id, tab_on_css) {
    if (!tab_on_css) {
        tab_on_css = 'active title title_border';
    }
    $("#selects .active").removeClass(tab_on_css);
    $(selected_tab).addClass(tab_on_css);
    $(".selecte_content").hide();
    $("#" + tab_content_id).show();
}

function show_response_status() {
    jQuery(document).ready(function() {
        $(".user_response_status").each(function() {
            jQuery(this).show();
        });
    });

    $(".navigation_links_class a").each(function() {
        var link = $(this).attr('href');
        if ( !link.match(/show_responce_active_status/) ) {
            link = link + '&show_responce_active_status=1';
            $(this).attr('href', link);
        }
    });
}

function show_fisrt_date_idea(idea, category, location) {
    $.facebox.settings.closeImage_type = 'top';
    var content = '<b>My first date idea: </b>' + idea;
    content += '<div style="margin-top: 10px; margin-bottom: 10px;">';
    if (category) {
        content += '<b>Category: </b>' + category;
    }
    if (location) {
        content += '&nbsp;&nbsp;&nbsp;&nbsp;<b>Location: </b>' + location + '</div>';
    }
    $.facebox(content);
}

function show_jquery_confirm_box(msg, func, btn_position) {
    if (btn_position) {
        $.facebox.settings.closeImage_type = btn_position;
    }
    var alert_text = '<div align="center" style="width: 350px;">        <div style="text-align: center; margin-top: 5px; margin-bottom: 20px;">' + msg + '</div>        <div><input onclick="$(document).trigger(\'close.facebox\'); ' + func + ';" type="button" value="OK" style="margin-right: 50px; width: 70px" /><input onclick="$(document).trigger(\'close.facebox\');" type="button" value="Cancel" style="width: 70px;" /></div>    </div>';
    $.facebox(alert_text);
}

function add_favoriate_for_gallery(match_id) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "action=favoriate_add&match_id=" + match_id,
        success: function(data){
            if (data == 1) {
                $("#add_favorite_" + match_id).hide();
                $("#in_favorites_" + match_id).show();
            }
        }
    });
}

function delete_question(question_id) {
    $(document).trigger('close.facebox');
    jQuery.ajax({
        type: "POST",
        url: url_map_f('_process_user_info_by_jquery'),
        data: "action=delete_question&question_id=" + question_id,
        success: function(data){
            if (data == 1) {
                $("#question_" + question_id).hide();
            }
        }
    });
}

function delete_question_confirm(question_id) {
    var alert_text = 'Are you sure you want to remove it?';
    $.facebox('<div align="center">' + alert_text + '<br /><br /><br /><input type="button" onclick="delete_question(\'' + question_id + '\')" value="Ok" style="margin-right: 50px; width: 70px;" /><input type="button" onclick="$(document).trigger(\'close.facebox\');" class="close" value="Cancel" style="width: 70px;" /></div>');
}

function replace_unwanted_comment(target_textarea_id, replaced_textarea_id) {
    $("#" + target_textarea_id).val($("#" + replaced_textarea_id).val());
}

function ajax_block_ip(usr_id, block_ip) {
    jQuery.ajax({
        type: "POST",
        url: url_map_f('censor_minor_operation_'),
        data: "action=block_one_ip&block_ip=" + block_ip,
        success: function(){
            $('#ip_' + usr_id).text('Blocked');
        }
    });
}

function show_edit_module(edit_div_id, show_div_id, item_name) {
    $('#' + edit_div_id).show();
    $('#' + show_div_id).hide();
    $('#' + edit_div_id).load('edit_my_profile_?profile_item=' + item_name + '&edit_div_id=' + edit_div_id + '&show_div_id=' + show_div_id + '&ajaxRequestUncache=' + parseInt(Math.random() * 1000000));
}

function hide_edit_module(edit_div_id, show_div_id) {
    $('#' + edit_div_id).hide();
    $('#' + show_div_id).show();
	$('#' + edit_div_id).html('');
}


