var Cookie = {
  set: function(name, value, daysToExpire) {
    var expire = '';
    if (daysToExpire != undefined) {
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      expire = '; expires=' + d.toGMTString();
    }
    return (document.cookie = escape(name) + '=' + escape(value || '') + expire + '; path=/');
  },
  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  erase: function(name) {
    var cookie = Cookie.get(name) || true;
    Cookie.set(name, '', -1);
    return cookie;
  },
  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookie.set('_test', '1');
    return (Cookie.erase('_test') === '1');
  }
};

function hideByCookie(name)
{
    if(Cookie.accept()) 
    {
       var d=Cookie.get(name);
       if(d == null)
       {
           if($(name)){
           $(name).hide();
           return true;
           }
       }        
    }
    return false;
}

function toggleWithCookie(name)
{
    if(Cookie.accept())
    {
        var d=Cookie.get(name);
        if(d == null)
        {
            if($(name))
            {
                $(name).show();
                Cookie.set(name, '1', undefined);
                return true;
            }
        }
        else
        {
            if($(name))
            {
                $(name).hide();
                Cookie.erase(name);
            }
        }
    }
    return false;
}
function highlightTab(tabs, toShow)
{
     $$('#' + tabs + ' dt a').each(function(e){  e.removeClassName('active');  });
     $$('#' + tabs + ' dd').each(function(e){e.hide(); });
     $('tab_' + toShow).addClassName('active');
     $(toShow).show();     
}
function tabsHighlightWithCookie(tabs, toShow)
{
    
       if(Cookie.accept())
       {
           var d=Cookie.get(toShow);
           if(d == null)
           {

                highlightTab(tabs, toShow);
                $$('#' + tabs + ' dd').each(function(e){ Cookie.erase(e.id); });
                Cookie.set(toShow, '1', undefined);
           }
           else
           {
                highlightTab(tabs, toShow);             
           }
           
       }
};
function tabsWakeup(tabs, alt)
{
    var found_sth=false;
    if(Cookie.accept())
    {
        $$('#' + tabs + ' dd' ).each(
        function(e){
            var d=Cookie.get(e.id);
            if( d ) {
                highlightTab(tabs, e.id);
                found_sth=true;
            }
        }
        
        );
        
    }
    if(found_sth==false)
    {
        highlightTab(tabs, alt);
    }
}
function expand(name)
{
    if(Cookie.accept())
    {
        var d=Cookie.get(name);
        if(d == null)
        {
            if($(name))
            {
                $(name).show();
                Cookie.set(name, '1', undefined);
            }
        }
    }    
}

function collapse(name)
{
    if(Cookie.accept())
    {
        var d=Cookie.get(name);
        if(d != null)
        {
            if($(name)) {
            $(name).hide();
            Cookie.erase(name);}
        }
    }   
}

Effect.Scroll = Class.create();
Object.extend(Object.extend(Effect.Scroll.prototype, Effect.Base.prototype), {
    initialize: function(element) {
        this.element = $(element);
        if(!this.element) throw(Effect._elementDoesNotExistError);
        this.start(Object.extend({x: 0, y: 0}, arguments[1] || {}));
    },
    setup: function() {
        var scrollOffsets = (this.element == window)
        ? document.viewport.getScrollOffsets()
        : Element._returnOffset(this.element.scrollLeft, this.element.scrollTop) ;
        this.originalScrollLeft = scrollOffsets.left;
        this.originalScrollTop  = scrollOffsets.top;
    },
    update: function(pos) {
        this.element.scrollTo(Math.round(this.options.x * pos + this.originalScrollLeft), Math.round(this.options.y * pos + this.originalScrollTop));
    }
});

Element.addMethods({
    scrollTo: function(element, left, top){
        var element = $(element);
        if (arguments.length == 1){
            var pos = element.cumulativeOffset();
            window.scrollTo(pos[0], pos[1]);
        } else {
            element.scrollLeft = left;
            element.scrollTop  = top;
        }
        return element;
    }
});


var message_select_toggle=0;
/*
* this function handels the tabulator in the profile page
*/

function handleaboutme_subTab(elm1, elm2)
{
    $$('dt.tabbox-headme a').each( function(e) {e.removeClassName('activeone highlight'); }  ); $(elm1).addClassName('activeone highlight');
    $$('div.show_hide_aboutme').each(function(e){e.hide();}); $(elm2).show();
}

//for moreaboutme sub iterm
function handlemoreaboutme_subTab(elm1, elm2)
{
    $$('dt.tabbox-headmore a').each( function(e) {e.removeClassName('activeone highlight'); }  ); $(elm1).addClassName('activeone highlight');
    $$('div.show_hide_moraboutme').each(function(e){e.hide();}); $(elm2).show();
}

/*
* handle foot tad in the profile page
*/
function handlefootTab(elm1,elm2)
{
    $$('dt.tabbox-head a').each( function(e) {e.removeClassName('activeone highlight'); }  ); $(elm1).addClassName('activeone highlight');
    $$('div.show_hide').each(function(e){e.hide();}); $(elm2).show();
}

/*gallery part*/
function handle_accordion(elm1,elm2)
{
    $$('dl.gallery-left dt').each( function(e) {e.removeClassName('activeone'); }  ); $(elm1).addClassName('activeone');
    $$('dd.show_hide').each(function(e){e.hide();}); $(elm2).show();
}

function handle_subaccordion(elm1,elm2)
{
    $$('dl.gallery-left dt.subpager').each( function(e) {e.removeClassName(''); }  ); $(elm1).addClassName('');
    $$('dd.show_hide .gallery-list').each(function(e){e.hide();}); $(elm2).show();
}

/*rating part*/
function setRating(num, userid, fromwhom, galleryid, checkwhich)
{
    var n=1;
    var checkwhich =checkwhich;
    for(n=1;n< (num+1);n++)
    {
        $('rating-' + n).setStyle({backgroundImage :  'url(/images/onestar-g.png)'});
    }
    if(checkwhich=='usergallery')
    {
        var url='/ajax/user-gallery/vote/';
    }
    else if(checkwhich=='eventgallery')
    {
        //var url='/eventgallery/voting/userid/'+userid+'/points/'+num+'/fromwhom/'+fromwhom+'/pictureid/'+galleryid;
        var url='/ajax/event-picture-vote/';
    }
    else if(checkwhich=='userprofile')
    {
        var url='/edit-profile/vote';
    }

    new Ajax.Updater('gallery_voting',url,{ parameters: { userid: userid,  points: num, fromwhom: fromwhom, pictureid: galleryid } });

}

function editRating(num,elem2,strname)
{
    var n=1;
    var m=1;
    $$('dl.b-box dd.tabbox-content .rating li .rating-star li').each(
    function(e) {
        e.setStyle({backgroundImage :  'url()'});
    }
    );
    for(n=1;n< (num+1);n++)
    {
        m = n+strname;
        $('rating-' + m).setStyle({backgroundImage :  'url(/images/onestar.png)'});
    }
    $(elem2).value = num;
}

function changetheval(num,vv)
{
    $(vv).value=num;
}

/*message part*/
function message_operate(elm1,elm2)
{
    $$('.message-list li.messageone .aktionen li a').each( function(e) {e.removeClassName('highlight'); }  ); $(elm1).addClassName('highlight');
    $$('.message-list li.messageone .relpy-con').each(function(e){e.hide();}); $(elm2).show();
}

function message_select(elm)
{
    var toggle = $(elm).checked;
    $$('.message-con input[type=checkbox]').each(function(check) {
        check.checked = toggle;
    });

}

var upload_picture;
//var requester=new Hash();

function showUploadPicture(url,height,width)
{
    //upload_picture = new Window({className:'alphacube', closable:false, height:600, resizable: false, maximizable:false, minimizable:false, title:'', url:'http://192.168.1.184/userprofile/uploadPicture', width:720});
    upload_picture = new Window({className:'alphacube', closable:true, height: height, resizable: false, maximizable:false, minimizable:false, title:'', url: url, width: width});
    upload_picture.showCenter();
    upload_picture.setDestroyOnClose();
    return false;
}

function resizeUploadPicture(height, width)
{
    upload_picture.setSize(height, width, true);
    
}

function closeUploadPicture()
{
    upload_picture.close();
}
function closeUploadPictureAndEffect(elm,elm2)
{
    upload_picture.close();
    if(elm=='Success')
    {
        $(elm2).hide();
        showRequester('/requester/thanksmsgfordo');
    }

}


function showRequester(url)
{
    var a=new Dialog.alert({url: url, options: {method: 'get'}}, {className: "alphacube", width: 430, okLabel: "OK"});
}

function showConfirmMessage(url,msgid,newreqesturl,redirecturl)
{
    var a=new Dialog.confirm(
                                                {url: url, options: {method: 'get'}},
                                                {className: "alphacube", width: 430,  okLabel: "OK",
                                                    onOk: function(val){
                                                        val.close();
                                                        _newRequestWithOneParam(newreqesturl,msgid,redirecturl);
                                                    }
                                                }
                                            );

}
function  _newRequestWithOneParam(newreqesturl,msgid,redirecturl)
{
    new Ajax.Request(newreqesturl,
                                   {method: 'post', 
                                       onSuccess:function(transport){
                                           window.location.href=redirecturl;
                                       },
                                       onFailure: function(transport) {
                                            _newRequestWithOneParam(newreqesturl,msgid,redirecturl);
                                        },
                                        parameters: {msgid: msgid}
                                   } );
}
//delete several messages
function operateOneMoreMessages(url,newreqesturl,redirecturl,what)
{
    var msgids = new Array();
    var i=0;
    $$('.message-con  input[type=checkbox]').each(function(check)
    {
        if(check.checked)
        {
            msgids[i++]=check.value;

        }
    });
    if(msgids.size()==0) return;
    var str=msgids.toString();    
    var a=new Dialog.confirm({url: url, options: {method: 'get'}},
    {
        className: "alphacube", width: 430,
        okLabel: "OK",
        onOk: function(val)
        {
                val.close();
                _updateMessageSystem(newreqesturl, str, what, redirecturl);
                
    }
    });

}
function _updateMessageSystem(newreqesturl, str, what, redirecturl)
{
                new Ajax.Request(newreqesturl, {method: 'post',
                    onSuccess: function(transport) {
                        window.location.href=redirecturl;
                    },
                    onFailure: function(transport) {
                        _updateMessageSystem(newreqesturl,str, what );
                    },
                    parameters: {msgids: str, what: what } } );
}
function redirectToURL(redirecturl)
{
    window.location.href=redirecturl;
    return false;
}



function getImageWidth()
{
    return $('file').width;
}


/*

goole map api code

*/


var map;
var gdir;
var geocoder = null;
var addressMarker;
var staticToAddress;
function initialize(adr1, adr2, locale)
{
    staticToAddress=adr2;
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);

        setDirections(adr1, adr2, locale);
    }
}

function setDirections(fromAddress, toAddress, locale) {
    gdir.load("from: " + fromAddress + " to: " + toAddress,
    { "locale": locale });
}

function handleErrors(){
    if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
    alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
    else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
    alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);

    else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
    alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

    //   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
    //     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);

    else if (gdir.getStatus().code == G_GEO_BAD_KEY)
    alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

    else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
    alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);

    else alert("An unknown error occurred.");

}

function onGDirectionsLoad(){
    // Use this function to access information about the latest load()
    // results.

    // e.g.
    // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
    // and yada yada yada...
}



function location_images(elm1,elm2,elm3)
{
    $$('.loca-top .loca-dg .loca-r .loca-g-list li span').each( function(e) {e.removeClassName('displaynone'); }  ); $(elm1).addClassName('displaynone');
    $$('.loca-top .loca-dg .loca-r .b-user-image span').each(function(e){e.hide();}); $(elm2).show();
    $$('.loca-top .loca-dg .loca-l dd').each(function(e){e.hide();}); $(elm3).show();
}

function event_images(elm1,elm2,elm3)
{
    $$('.loca-bottom .event-g li span').each( function(e) {e.removeClassName('displaynone'); }  ); $(elm1).addClassName('displaynone');
    $$('.loca-bottom .b-user-image span').each(function(e){e.hide();}); $(elm2).show();
    $$('.loca-bottom .loca-dg .loca-r dd').each(function(e){e.hide();}); $(elm3).show();
}

function setUlwidth()
{
    var onewidth=0;
    $('eventlist').childElements().each(function(oneli){onewidth +=oneli.getWidth()+4;});
    $('eventlist').setStyle({width:onewidth +'px'});
}

function setFlyerwidth()
{
    var onewidth=0;
    $('flyerlist').childElements().each(function(oneli){onewidth +=oneli.getWidth()+5;});
    $('flyerlist').setStyle({width:onewidth +'px'});
}

function setToupdateOnemsgMenue(dowhat,updatezone,msgid,ivalue)
{
    if(dowhat=='readmsg')
    {
        //var url='/messages/readOneMessage/msgid/'+msgid;
        var url='/messages/onemessageread';
    }
    else if(dowhat=='setreadstatus')
    {
        //var url='/messages/toggleOneMessageReadStatus/msgid/'+msgid+'/ivalue/'+ivalue;
        var url='/messages/msgstatustoggle';
    }
    else if(dowhat=='updateLeftMenu')
    {
        var url='/messages/left-menu-update';
    }

    new Ajax.Updater(updatezone,url,{ parameters: { msgid: msgid, ivalue: ivalue } });
}

// the next two function is used in message response
function setCompleteEffect(elem)
{
    if($(elem).value != '')
    return 1;
    return 0;
}
function sethasreplytextcontentAttr(p,frt,updatezone,rmhiglihtelem,styleElem,whichmethod,leftmenuezone,msgid,ivalue)
{
    //var url ='/messages/setReplytextAttr/p/'+p;
    var submitdo = '';
    var submitnotdo='';
    var upz=updatezone;
    var rmhl=rmhiglihtelem;
    var styelm =styleElem;
    var singled='\'';
    var dotd   =',';
    if(p==1)
    {
        //submitdo +='new Ajax.Updater('+singled+upz+singled+dotd+singled+ '/frontend_dev.php/messages/'+whichmethod+singled+dotd+' {asynchronous:true, evalScripts:false, onComplete:function(request, json){showRequester('+singled+'/requester/showRemindMessage'+singled+');$('+singled+styelm+singled+').setStyle({display: \'none\'});$('+singled+rmhl+singled+').removeClassName('+singled+'highlight'+singled+');}, parameters:Form.serialize(this)}); return false;';
        submitdo +='new Ajax.Updater('+singled+upz+singled+dotd+singled+ '/messages/'+whichmethod+singled+dotd+' {asynchronous:true, evalScripts:false, onComplete:function(request, json){showRequester('+singled+'/requester/ishavesendmsg'+singled+');getfriendtotransmsg(3,'+singled+leftmenuezone+singled+dotd+msgid+dotd+ivalue+');$('+singled+styelm+singled+').setStyle({display: \'none\'});$('+singled+rmhl+singled+').removeClassName('+singled+'highlight'+singled+');}, parameters:Form.serialize(this)}); return false;';
    }
    else
    {
        submitdo +='new Ajax.Updater('+singled+upz+singled+dotd+singled+ '/messages/'+whichmethod+singled+dotd+' {asynchronous:true, evalScripts:false, parameters:Form.serialize(this)}); return false;';
    }

    $(frt).writeAttribute('onsubmit',submitdo);
}
//function getfriendtotransmsg() use in message page for transmitte msg
function getfriendtotransmsg(ch,updatezone,whichone,ivalue)
{
    if(ch==0)
    {
        //onclick the one_message right menue item 'transmitted'
        //@messages_getfriendtoforward
        //var url='/messages/getMyFrienListForTransMsg/whichone/'+whichone;
        new Ajax.Updater(updatezone,'/messages/getfriendsforward',{ parameters: { whichone: whichone } });

    }
    else if(ch==1)
    {
        //when onclick one Item from select list the selected user's username show
        //@messages_putUsernameIntoPlace
        //var url='/messages/putUsernameIntoPlace/whichone/'+whichone;
        new Ajax.Updater(updatezone,'/messages/putusername',{ parameters: { whichone: whichone } });
    }
    else if(ch==2)
    {
        //when onclick one Item from select list the selected user's info show
        // var url='/messages/showSelectedIntoPlace/whichone/'+whichone+'/ivalue/'+ivalue;
        new Ajax.Updater(updatezone,'/messages/showselecteduser',{ parameters: { whichone: whichone, ivalue: ivalue } });
    }
    else if(ch=='3')
    {
        //var url='/messages/updateLeftMenue/whichone/'+whichone+'/ivalue/'+ivalue;
        new Ajax.Updater(updatezone,'/messages/refereshleftmen',{ parameters: { whichone: whichone, ivalue: ivalue } });
    }
    else
    {
        //when the GuarUser input friend's part of name
        var inputvalue = $(whichone).value;
        //var url='/messages/autoComplete/partname/'+inputvalue+'/ivalue/'+ivalue;
        new Ajax.Updater(updatezone,'/messages/autosearchuser',{ parameters: { partname: inputvalue, ivalue: ivalue } });
    }

}

/*member search detial*/
function membersearch(elm1,elm2)
{
    $$('.msearch-nav li a').each( function(e) {e.removeClassName('highlight'); }  ); $(elm1).addClassName('highlight');
    $$('div.member-showhide').each(function(e){e.hide();}); $(elm2).show();
}
/* picture deleted confirm*/
function deleteOneObject(url,newreqesturl,redirecturl,parameter1)
{
    var msgids = new Array();
    var a=new Dialog.confirm({url: url, options: {method: 'get'}},
    {className: "alphacube", width: 430,
    okLabel: "OK",
    onOk: function(val)
    {
        val.close();
        new Ajax.Request(newreqesturl, {method: 'post', parameters: { parameter1: parameter1} } );
        window.location.href=redirecturl;
    }
    });

}


function setOnlineStatus(status)
{
    $('online_status_up').innerHTML='[' + tOnStat[status] +']';
    $('online_status_down').innerHTML='[' + tOnStat[status] +']';
    $('dede').toggle();
    $('show2_detial').toggle();
    $('hide2_detial').toggle();
    new Ajax.Updater(
    'online_status', '/setOnlineStatus/'+ status, {evalScripts: true}
    );
}

function setThatme(eve,pictureid,newRequest)
{
    var a,b,c,d;
    a=$('thatme_box').offsetLeft;
    b=$('thatme_box').offsetTop;
    c=$('wrapper').offsetLeft;
    d=$('wrapper').offsetTop;
    xx=document.documentElement.scrollLeft+eve.clientX - a - c - 237;
    yy=document.documentElement.scrollTop+eve.clientY - b -d-215;//before is 190, paul change to 215
    new Ajax.Updater('thats_me', newRequest, { parameters: { x: xx, y: yy, pictureId:  pictureid } });
}

function addIWantYouInputTag(eve,userid,pictureid,eventid,newRequest)
{
   var a,b,c,d;
    a=$('needYou_box').offsetLeft;
    b=$('needYou_box').offsetTop;
    c=$('wrapper').offsetLeft;
    d=$('wrapper').offsetTop;
    xx=document.documentElement.scrollLeft+eve.clientX - a - c - 237;
    yy=document.documentElement.scrollTop+eve.clientY - b -d - 215;//before is 190, paul change to 215
    var inputId = 'input_'+userid;
    var divId ='div_'+userid;
    if($(divId)){ $(divId).remove(); }
    
    var html = "<div class=\"inydiv\" id=\""+divId+"\" style=\"position: absolute; top: "+yy+"px; left: "+xx+"px;\">";
        html += "<input class=\"inytextinput\" type=\"text\" id=\""+inputId+"\" name=\"input_id\" value=\"say something..\" onblur=\"if($(this).value==''){$(this).value=='say something..';};return false;\" onclick=\"$(this).value='';return false;\"/>";
        html +="<input class=\"button-style\" type=\"button\" name=\"cancel\" value=\"Cancel\" onclick=\"$('"+divId+"').remove();return false;\"/>";
        html +="<input class=\"button-style\" type=\"submit\" name=\"cancel\" value=\"Send\" onclick=\"setNeedYou("+userid+","+pictureid+","+eventid+",'"+newRequest+"');return false;\"/>";
        html +="</div>";
    $('INeedYou').insert(html);
}

function setNeedYou(userid,pictureid,eventid,newRequest)
{
    var inputId='input_'+userid;
    var divId = 'div_'+userid;
    var x = $(divId).getStyle('left');
    var y = $(divId).getStyle('top');
    var shortMsg = $(inputId).value;
    new Ajax.Updater('INeedYou', newRequest, { parameters: { x: x, y: y, pictureId:  pictureid, msg: shortMsg, eventId: eventid } });
}



function ratingSet(elm1)
{
    $$('.myprofile .rating li.ratingone .rating-star a').each( function(e) {e.removeClassName('active-rating'); }  ); $(elm1).addClassName('active-rating');
    $('noedit').show();$('editclean').hide();
}

function GalleryratingSet(elm1)
{
    $$('.gallery-main-foot.bigfoot .links .rating-star a').each( function(e) {e.removeClassName('active-rating'); }  ); $(elm1).addClassName('active-rating');
}

/*block one user from friendship request response*/
function newRequest(url,objid,newreqesturl)
{
    var a=new Dialog.confirm({url: url, options: {method: 'get'}}, {className: "alphacube", width: 430,  okLabel: "Yes", cancelLabel: "No", onOk: function(val){val.close();new Ajax.Request(newreqesturl, {method: 'post', parameters: {parameter1: objid}, evalScripts:true } ); }});

}
/*setting start in moreAboutme*/
function settingAndUpdate(updatezone,newRequest,param1,param2)
{
    new Ajax.Updater(updatezone,newRequest,{ parameters: { param1: param1, param2: param2 } });
}
/*delete and update part zone*/
function deleteAndUpdate(updatezone,newRequest,param1,param2,url)
{
    var a=new Dialog.confirm({url: url, options: {method: 'get'}},
    {className: "alphacube", width: 430,
    okLabel: "OK",
    onOk: function(val)
    {
        val.close();
        new Ajax.Updater(updatezone,newRequest,{ parameters: { param1: param1, param2: param2 } });
    }
    });
}
/*move one address book to another group*/
function moveAddressBook(updatezone,newRequest,param1,param2,url)
{
    var a=new Dialog.confirm({url: url, options: {method: 'get'}},
    {className: "alphacube", width: 430,
    okLabel: "OK",
    onOk: function(val)
    {
        val.close();
        var idstr = param1+param2;
        var input_div = 'create_'+idstr;
        var move_to_group='';
        if($(input_div).visible())
        {
            var inputId = 'input_'+idstr;
            move_to_group = $(inputId).value;
            var newGroupId = 'addressBook_'+move_to_group
            if(!$(newGroupId))
            {
                var dl = new Element('dl', { id: newGroupId });
                $('group_list').insert(dl);
                $(newGroupId).innerHTML='new group here it is!';
            }
        }
        else
        {
            move_to_group = $(idstr).value;
        }
        var updatezone2 = 'addressBook_'+move_to_group;
        new Ajax.Updater(updatezone,newRequest,{ parameters: { param1: param1, param2: param2, param3: move_to_group } });
        new Ajax.Updater(updatezone2,'/ajax/get-one-group-addressbook/',{ parameters: { param1: param1, param3: move_to_group } });
    }
    });
}

function refreshGroupName(param1,param2)
{
   var updatezone = param1;
   new Ajax.Updater(updatezone,'/ajax/refresh-group-options-name/',{ parameters: { param1: param1, param2: param2 } });

}

function memberSize(elm1)
{
    $$('.member-list .friend-top .m-listsize a').each( function(e) {e.removeClassName('active'); }  ); $(elm1).addClassName('active');
}

function miniList()
{
    $$('.member-list .friend-list li').each( function(e) {e.addClassName('small-list'); e.removeClassName('middle-list'); e.removeClassName('large-list');}  );
    $$('.member-list .friend-list li .user-text').each( function(e) { e.setStyle({display: 'none'}); }  );
    $$('.member-list .friend-list li .friend-relative').each( function(e) {e.setStyle({display: 'none'}); }  );
    $$('.member-list .friend-top .pager').each( function(e) {e.addClassName('s-m-pager'); e.removeClassName('l-m-pager'); }  ); 
}

function middleList()
{
    $$('.member-list .friend-list li').each( function(e) {e.addClassName('middle-list');e.removeClassName('large-list'); }  );
    $$('.member-list .friend-list li .user-text').each( function(e) { e.setStyle({display: 'block'}); }  );
    $$('.member-list .friend-list li .friend-relative').each( function(e) {e.setStyle({display: 'none'}); }  );
    $$('.member-list .friend-top .pager').each( function(e) {e.removeClassName('s-m-pager'); e.removeClassName('l-m-pager'); }  ); 
}

function largeList()
{
    $$('.member-list .friend-list li').each( function(e) {e.addClassName('large-list'); }  );
    $$('.member-list .friend-list li .user-text').each( function(e) { e.setStyle({display: 'block'}); }  );
    $$('.member-list .friend-list li .friend-relative').each( function(e) {e.setStyle({display: 'block'}); }  );
    $$('.member-list .friend-top .pager').each( function(e) {e.addClassName('l-m-pager'); e.removeClassName('s-m-pager'); }  );
}

function PPSize(elm1)
{
    $$('.pplist .m-listsize a').each( function(e) {e.removeClassName('active'); }  ); $(elm1).addClassName('active');
}

function PPminiList()
{
    $$('.events-list li.eventone').each( function(e) {e.addClassName('small-list'); e.removeClassName('middle-list'); e.removeClassName('large-list');}  );
    $$('.events-list li.eventone .comment-right').each( function(e) { e.setStyle({display: 'none'}); }  );
    $$('.events-list li.eventone .pplinks').each( function(e) {e.setStyle({display: 'none'}); }  );
    $('pplist').addClassName('noborder'); $('pplist').removeClassName('pplargemargin');
    $$('.events-list li.eventone .friendname').each( function(e) {e.setStyle({display: 'block'}); }  );
    $$('.pplist .pplist-lefttop').each( function(e) {e.addClassName('s-pptop'); e.removeClassName('m-pptop'); }  );
}

function PPmiddleList()
{
    $$('.events-list li.eventone').each( function(e) {e.addClassName('middle-list');e.removeClassName('large-list'); }  );
    $$('.events-list li.eventone .comment-right').each( function(e) { e.setStyle({display: 'block'}); }  );
    $$('.events-list li.eventone .pplinks').each( function(e) {e.setStyle({display: 'none'}); }  );
    $('pplist').addClassName('noborder'); $('pplist').removeClassName('pplargemargin');
    $$('.events-list li.eventone .friendname').each( function(e) {e.setStyle({display: 'none'}); }  );
    $$('.pplist .pplist-lefttop').each( function(e) {e.removeClassName('s-pptop'); e.addClassName('m-pptop'); }  );
}

function PPlargeList()
{
    $$('.events-list li.eventone').each( function(e) {e.removeClassName('small-list'); e.removeClassName('middle-list'); }  );
    $$('.events-list li.eventone .comment-right').each( function(e) { e.setStyle({display: 'block'}); }  );
    $$('.events-list li.eventone .pplinks').each( function(e) {e.setStyle({display: 'block'}); }  );
    $('pplist').removeClassName('noborder'); $('pplist').addClassName('pplargemargin');
    $$('.events-list li.eventone .friendname').each( function(e) {e.setStyle({display: 'none'}); }  );
    $$('.pplist .pplist-lefttop').each( function(e) {e.removeClassName('s-pptop'); e.removeClassName('m-pptop'); }  );
}


function executeWhenFinish(elem1, elem2,i,msgid)
{
    if($('text_errorline'))
    { 
        
    }
    else if($('NotHasSelectedFriend'))
    {
    }
    else
    {
         $(elem1).setStyle({ display: 'none'});
        $(elem2).removeClassName('highlight');
        setToupdateOnemsgMenue('updateLeftMenu','onemessageleftmenue'+i,msgid,i);
        showRequester('/requester/ishavesendmsg');
    }
}

function executeAfterWriteMessage()
{
    if($('text_errorline'))
    {

    }
    else if($('NotHasSelectedFriend'))
    {
    }
    else
    {
        showRequester('/requester/ishavesendmsg');
    }
}


function MusicTypeSelect(elem)
{
    var ch = $(elem).checked;
    $$('#event_musicType input[type="checkbox"]').each(function(e) {
        e.checked = ch;
    });
    return ch;

}

/*location info*/
function handleLocationTab(elm1,elm2)
{
    $$('dt.tabbox-head a').each( function(e) {e.removeClassName('activeone highlight'); }  ); $(elm1).addClassName('activeone highlight');
    $$('div.friend-main').each(function(e){e.hide();}); $(elm2).show();
}

function bannerTab(elm1,elm2)
{
    $$('.bannertemplate .boxsubmenu2 a').each( function(e) {e.removeClassName('highlight'); }  ); $(elm1).addClassName('highlight');
    $$('div.show_hide').each(function(e){e.hide();}); $(elm2).show();
}

function charCounter(id, maxlimit, limited, counter_id){

    if($F(id).length >= maxlimit){
        if(limited){	$(id).value = $F(id).substring(0, maxlimit); }
        $(counter_id).addClassName('charcount-limit');
        $(counter_id).removeClassName('charcount-safe');
    } else {
        $(counter_id).removeClassName('charcount-limit');
        $(counter_id).addClassName('charcount-safe');
    }
    $(counter_id).update( $F(id).length + '/' + maxlimit );
}

function makeItCount(id, maxsize, limited, counter_id){
    if(limited == null) limited = true;
    if ($(id)){
        Event.observe($(id), 'keyup', function(){charCounter(id, maxsize, limited, counter_id);}, false);
        Event.observe($(id), 'keydown', function(){charCounter(id, maxsize, limited, counter_id);}, false);
       charCounter(id,maxsize,limited,counter_id);
    }
}