$j = jQuery.noConflict();

$j('html').addClass('JS');

$j(document).ready(function(){

    $j('a.lstyle').each(function(){
        $j(this).attr({'href': $j(this).attr('rev') + $j(this).attr('rel')});
        $j(this).removeAttr('name');
        $j(this).removeAttr('rel');
        $j(this).removeAttr('rev');
    });

    $j('.fav_container_disabled').each(function(){
        $j(this).find('.profile_header_title').css({'opacity': 0.2});
        $j(this).find('.fav_item').css({'opacity': 0.2});
    })


    $j('#city_select > ul').mouseover(function() {
        $j(this).css({
            'background-color': 'white',
            'border': 'solid 1px #ccc'
        });
        $j('#city_select .arrow').hide();
        $j('#city_select li').show();
        return false;
    });

    $j('#city_select > ul').mouseout(function() {
        $j(this).css({
            'background-color': 'transparent',
            'border': 'none'
        });
        $j('#city_select li').hide();
        $j('#city_select li.city_selected').show();
        $j('#city_select .arrow').show();
        return false;
    });

    $j('#phone_show_link').click(function() {
        $j('#phone_placeholder').load($j(this).attr('rev'));
        return false;
    });

/*    if ($j('#rating').length>0){
        var cur_val =  $j('#rating').attr('cur_value');
        $j('#rating').rating({maxvalue:5, increment: 0.5, curvalue:0});
        $j('.disable').click(function(){
            $('#rating').removeClass('rating_enabled');
        })
        $j('.enable').click(function(){
            $('#rating').addClass('rating_enabled');
        });
    };
*/
     $j('.rating').each(function(){
        //if ($j(this).attr('id')!='rating'){
            var cur_val = $j(this).attr('cur_value')/2;
            $j(this).rating({maxvalue:5, increment: 0.5, curvalue: cur_val, disabled: false});
        //}
     });

     $j('#rating_reset').each(function(n,e){
        e.onclick = function() {
            $j('.rating').rating({maxvalue:5, increment: 0.5, curvalue: 0, disabled: false});
            $j('#e_class').attr({value:0});
            $j(this).css({visibility:'hidden'});
        }
     });

     $j('.link_to_dialog').each(function(n,e){
        e.onclick = function() {
            return show_dialog();
        };
     });

     $j('.link_to_close_dialog').each(function(n,e){
        e.onclick = function() {
            return hide_dialog();
        };
     });

     $j('.expandlink').each(function(n,e){
         $j(e).bind('click', function() { $j('#'+this.rel).css({'display':'block'}) });
     });
});

function is_parent(child_obj,parent_obj){
    if(!child_obj)return false;
    if(child_obj==parent_obj)return true;
    return is_parent(child_obj.parentNode,parent_obj);
}

function show_age(obj){
    $j(obj).append($j('#findblock_age'));
    return false;
}

function show_shadow(){
    $j('#shadow').css({'display':'block', 'opacity': 0.7, 'height': $j(document).height()});
    return false;
}

function hide_shadow(){
    $j('#shadow').css({'display':'none'});
    return false;
}

function hide_dialog(){
    var dialog = $j('#dialog');
    dialog.css({'display':'none'});
    hide_shadow();
    return false();
}

function show_dialog(){
    var dialog = $j('#dialog'),
        myWidth = 0, myHeight = 0;
    if (typeof(window.innerWidth) == 'number') {
      myWidth = window.innerWidth;
      myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
      myWidth = document.documentElement.clientWidth;
      myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
      myWidth = document.body.clientWidth;
      myHeight = document.body.clientHeight;
    }
    show_shadow();
    dialog.css({'display':'block'});    
    dialog.css({'top':  myHeight/2 - dialog.height()/2, 'left':  myWidth/2 - dialog.width()/2});
    return false;
}
