jQuery(document).ready(function(){
	$("a.login_link").click(function() {
            var id = $(this).parent().parent().attr("id");
            if ( id == "" ) {
                var id = $(this).parent().parent().parent().attr("id");
            }
            var url = window.location.href;
            
            $.ajax({
                type: "POST",
                url: "/setsession",
                data:{url: url, id: id},
                async: false,
                dataType: "json",
                success: function(resp) {
                    if ( resp.good == 1 ) {
                        document.location.replace = "/";
		  	window.location.href = "/";
                    }
                }
            });
            return false;
        });
        try{
            if ( ( undefined != div_modal_show_after_login ) ) {
                if ( div_modal_show_after_login != "" ) {
                    if ( "join_meet_me" == div_modal_show_after_login ) {
                        if ($("#mmtab4").length) {
                            changeMMtabs("attendingmembersmeetme");
                        }
                        $("#joinmeetmeTrigger").click();
                    } else {
                        if ($("#mmtab3").length) {
                            changeMMtabs("messageboardmeetme");
                        }
                        $("#" + div_modal_show_after_login).jqmShow();
                    }
                }
            }
        } catch(e){

        }
	if ( $("#error_space_size_message").html() != "" ) {
//		$("#error_space_size").show();
//		hideErrorSpace();
                $("#size_error_message_a").click();
	}
	
	$('.activebanner').click(bCl);
	$('.topBanner img.hiddenbannermask').click(bCl);
	btabSetEvent();
	//$("a[id^='aorder_']").live('click', filterBy);
	//$("a[id^='aorder_']").live('click', filterBy);
//	$("#gotoadminpart").live('click', function() {
//		$.ajax({
//				type: "POST",
//				url:  "/admin/users/changeusersession",
//				data: {sign: 2},
//				async: false,
//				dataType: "json",
//				success: function(resp) {
//					if ( resp.link != "" ) {
//						document.location.href = resp.link;
//					}
//				},
//				error: function(resp) {
//					alert('some error occure');
//				}
//		})
//	});
	
	// setbuddiesrefreshinterval();	
	keyboard_init();
	
	$.ajaxSetup({
		  dataFilter: function(data, type) {
		  	if ( data.indexOf("[[error_99999]]") != -1 ) {
		  		document.location.replace = "/";
		  		window.location.href = "/";

		  	}
		  	return data;
		  }
	});

        $("a#preview").live("click", function () {
        	var seldiv = $('#visited_countries_info div.sel');
            id = seldiv.attr('id');
            if ( id != undefined ) {
                a = new String(id.toString());
                a = a.substring("c_".length, a.length);
				var titlecountry = $(seldiv).find('span#country').html();
//            $.ajax({
//                    type: "POST",
//                    url:  "/world/spot/getxmlgallery/",
//                    data: 'country_id='+ a,
//                    async: false,
//                    success: function(resp) {
//                       console.log(resp);
//                    },
//                    error: function(data) {
//                        alert("Some error occure");
//                    }
//             });
				$('#window_preview_gallery .jqmCloseLine span.title').html(titlecountry);
				
				
				
				$('#window_preview_gallery').jqmShow();
                getFlashGallery("/getxmlgallery/country_id/" + a);
                $("#preview_picture_gallery").click();
                
                /* ff2 fix */
                //$('#flash_div').hide();
                $('.jqmOverlay').css('z-index', '-1');
                $('#flash_div').css('position', 'absolute');
                $('#flash_div').css('top', '0px');
                $('#flash_div').css('left', '0px');
                setTimeout("brb()", 1000);
                /**/
                
                
                //$('.jqmOverlay').css('z-index', '1');
                
                $("#picture_gallery_desc").html("");
                $("#picture_gallery_title").html('');

            }
        });

        workWithCheckbox("visited_countries_invite", "input.visited_country_invite");
        workWithCheckbox("meet_me_invite", "input.meet_me_invite");
        workWithCheckbox("blogs_invite", "input.blog_invite");
        workWithCheckbox("chats_invite", "input.chat_invite");
        
       view_profile_reg_window_init();
       view_profile_buddy_window_init();
        
});
var pending_requests = new Array();

function brb() {
	
	$('.jqmOverlay').css('z-index', '2999');
	
	$('#flash_div').show();
}


function workWithCheckbox(id, el) {
    $("#" + id).click(function(){
        var sign = $(this).attr("checked");
        $(el).attr("checked", sign);
    });

    $(el).click(function(){
        if ( $(this).attr("checked") ) {
            if ( !$("#" + id).attr("checked") ) {
                $("#" + id).attr("checked", true);
            }
        } else {
            var s = true;
            $(this).parent().find(el).each(function(){
                if ($(this).attr("checked")) {
                    s = false;
                }
            });
            if ( s ) {
                $("#" + id).attr("checked", false);
            }
        }
    });
}

function getImageID(id, desc, title){
    if ( (undefined != desc) && (desc != "") && (desc != "null") ) {
        $("#picture_gallery_desc").show();
        $("#picture_gallery_desc").html(desc);
    } else {
        $("#picture_gallery_desc").hide();
        $("#picture_gallery_desc").html("");
    }
    if ( (undefined != title) && (title != "") && (title != "null") ) {
        $("#picture_gallery_title").show();
        $("#picture_gallery_title").html(title);
    } else {
        $("#picture_gallery_title").hide();
        $("#picture_gallery_title").html('');
    }
}

function getFlashGallery(url) {
    if ( "" != url ) {
//        var so = new SWFObject("/flash/polaroid/polaroid.swf", "polaroid", "950px", "560px", "8", "#FFFFFF");
//        so.addVariable("xmlURL", url);
//        so.write("div_preview");


//        var flashvars = {
//            xmlURL: url
//        };
//        var params = {};
//        var attributes = {
//            id: "polariod",
//            name: "polaroid"
//        };
//
//        swfobject.embedSWF("/flash/polaroid/polaroid.swf", "div_preview", "950", "560", "9.0.0","/flash/polaroid/expressInstall.swf", flashvars, params, attributes);
//alert(url);
        $('#div_preview').html('');
        $('#div_preview').flash({
            src: '/flash/polaroid/polaroid.swf',
            width: 800,
            height: 600,
            flashvars: {
            	xmlURL: url
            }
        }, {expressInstall: true});

    }
//    setPhotosURL(url);
}

//function thisMovie(movieName) {
//         if (navigator.appName.indexOf("Microsoft") != -1) {
//             return window[movieName];
//         } else {
//             return document[movieName];
//         }
//     }
//     function setPhotosURL(url) {
//  	thisMovie("polaroid").setPhotosURL(url);
//    }

var regex_alpha = (/^[a-zA-Z ]*$/);
var regex_alpha_digits = (/^[a-zA-Z0-9]*$/);
var regex_title = (/^[a-zA-Z0-9 \-\_]*$/);
var regex_title1 = (/^[a-zA-Z0-9\-\_]*$/);


var regex_url = (/^[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_%&?\/.=]+$/i);
var regex_url_without_protocol = (/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_%&?\/.=]+$/i);
var regex_text_only = (/^[a-zA-Z0-9 \.\,\!\?\-\+\=\(\)\[\]\*\`\$\%\#\&\<\>]*$/);
var regex_text = (/^[a-zA-Z0-9 \.\,\!\?\-\+\=\(\)\[\]\*\`\$\%\#\&\<\>\r\n]*$/);
var regex_email = (/^\w*@(((([a-z0-9]{1,})|([a-z0-9][-][a-z0-9]+))[\.][a-z0-9])|([a-z0-9]+[-]?))*[a-z0-9]+\.([a-z])+$/i);
var regex_email_with_protocol = (/^[A-Za-z]+:\w*@(((([a-z0-9]{1,})|([a-z0-9][-][a-z0-9]+))[\.][a-z0-9])|([a-z0-9]+[-]?))*[a-z0-9]+\.([a-z])+$/i);
var digits_only = (/^[0-9]*$/);
var regex_price = (/^[0-9\.]*$/);


jQuery.fn.maxlength = function(options) {
  var settings = jQuery.extend({
    maxChars: 10,
    maxenter: 0,
    text_element: 'maxlength',
    leftChars: "character left"
  }, options);

  if (settings.text_element.length) {
  	$("#"+settings.text_element).val(settings.maxChars - $(this).val().length);
  }
    
  return this.each(function() {
    var me = $(this);
    var l = settings.maxChars;
    var maxenter = parseInt(settings.maxenter);
    me.bind('keydown keypress keyup',function(e) {
		var str = me.val();
    	if (maxenter) {
    		
			var temparr = me.val().split('\n');
			if ((temparr.length>maxenter) && (e.keyCode==13)) {
				
				return false;
			}
    	}
		
      if(me.val().length>settings.maxChars) me.val(me.val().substr(0,settings.maxChars));
      l = settings.maxChars - me.val().length;
      if (settings.text_element.length) {$("#"+settings.text_element).val(l);}
    });
  });
};

function textValidateLength(id, min, max, errmessage) {
    var me = $("#" + id);
    if ((me.val().length>min) && (me.val().length<max)) {
        return true;
    } else {
    	if (errmessage!=undefined) 
        	$('.error_validate_' + id).html(errmessage);
        else 
        	$('.error_validate_' + id).html(error.text.length);
    }
    return false;
}

function selectValidateNumberPositiveValue(selelement) {
	var value = selelement.val();
	if (!isNaN(value) && (value>0)) return true;
	return false;
}

function selectValidateSelect(id, ind) {
	var el;
	$("#"+id).each(function() {
		el = this;
	});
	
	
	if ( undefined == ind ) { 
	    if ((el != undefined) && (el.selectedIndex>0)) {
	        return true;
	    }
	} else {
	    if ((el != undefined) && (el.selectedIndex>=0)) {
			return true;
	    }
	}
	return false;
	
}


function datetimesCompareValidate(hourfrom_id, hourto_id, monthfrom_id, monthto_id,  
						dayfrom_id, dayto_id, yearfrom_id, yearto_id) 
{
	// return false, if second datetime<=first datetime
    var secfrom = parseInt($('#'+hourfrom_id).val())*3600;
    var secto = parseInt($('#'+hourto_id).val())*3600;
    if (isNaN(secfrom) || isNaN(secto)) {
    	return -1;
    }
    var from = new Date($('#'+yearfrom_id).val(), $('#'+monthfrom_id).val()-1, $('#'+dayfrom_id).val()); 
    var from_without_hoursandseconds = from;   
    var from = Math.round(from.getTime()/1000)+secfrom;
    var to = new Date($('#'+yearto_id).val(), $('#'+monthto_id).val()-1, $('#'+dayto_id).val());    
    var to_without_hoursandseconds = to; 
    var to = Math.round(to.getTime()/1000)+secto;
    
	if (from<to) {
		return true;
	} else {
    	if (from_without_hoursandseconds.getTime()==to_without_hoursandseconds.getTime()) {
    		return -2;
    	}		
	}
	return false;
}
function datetimeGreaterThanNowValidate(hour_id, month_id, day_id, year_id, isGMT) 
{
	var nowdate = new Date();
	var offset = 0;
	if ( isGMT != true ) {
		isGMT = false;
	} else {
		offset = nowdate.getTimezoneOffset()*60;
	}
	// return false, -1 or -2, if selected datetime less than now datetime
	
	var nowdate_without_hoursandseconds = new Date(nowdate.getFullYear(), nowdate.getMonth(), nowdate.getDate());
	
	
	var datetimenow = Math.round(nowdate.getTime()/1000);
    var sec = parseInt($('#'+hour_id).val())*3600;
    if (isNaN(sec)) {
    	return -1;
    }
    var datetime = new Date($('#'+year_id).val(), $('#'+month_id).val()-1, $('#'+day_id).val());    
    var datetime_without_hoursandseconds = datetime;
    var datetime = Math.round(datetime.getTime()/1000)+sec;
	
    if ((datetime-offset)>=datetimenow) {
    	return true;
    } else { 
    	if (nowdate_without_hoursandseconds.getTime()==(datetime_without_hoursandseconds.getTime())) {
    		return -2;
    	}
    }
    return false;
}
function textValidateNotEmpty(element) {
	var res = trim(element.val());
	if (res.length>0) {
		return true;
	}
	return false;
}

function textValidate(id, regex) {
    if ( regex == undefined ) {
        regex = regex_alpha;
    }
	var me = $("#" + id);
	return regex.test(me.val());
}

jQuery.fn.textValidate = function(options) {
    var settings = jQuery.extend({
        regex: regex_alpha,
        errorClass: '.error_validate_',
        errorMessage: error.text.symbols
    }, options);
    
    return this.each(function(){
        $(this).bind('keydown keypress keyup',function() {
            result = textValidate($(this).attr('id'), settings.regex)
            if (!result) {
                $(settings.errorClass + $(this).attr('id')).html(settings.errorMessage);
            } else {
                $(settings.errorClass + $(this).attr('id')).html("");
            }
        });
    });
};

function trim (str, charlist) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: mdsjack (http://www.mdsjack.bo.it)
    // +   improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev)
    // +      input by: Erkekjetter
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: DxGx
    // +   improved by: Steven Levithan (http://blog.stevenlevithan.com)
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // *     example 1: trim('    Kevin van Zonneveld    ');
    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: trim('Hello World', 'Hdle');
    // *     returns 2: 'o Wor'
    // *     example 3: trim(16, 1);
    // *     returns 3: 6
 
    var whitespace, l = 0, i = 0;
    str += '';
    
    if (!charlist) {
        // default list
        whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";
    } else {
        // preg_quote custom list
        charlist += '';
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
    }
    
    l = str.length;
    for (i = 0; i < l; i++) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(i);
            break;
        }
    }
    
    l = str.length;
    for (i = l - 1; i >= 0; i--) {
        if (whitespace.indexOf(str.charAt(i)) === -1) {
            str = str.substring(0, i + 1);
            break;
        }
    }
    
    return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}
function strip_tags(str, allowed_tags) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Luke Godfrey
    // +      input by: Pul
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +      input by: Alex
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Marc Palau
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strip_tags('<p>Kevin</p> <br /><b>van</b> <i>Zonneveld</i>', '<i><b>');
    // *     returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
    // *     example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
    // *     returns 2: '<p>Kevin van Zonneveld</p>'
    // *     example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
    // *     returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>'

    var key = '', tag = '', allowed = false;
    var matches = allowed_array = [];

    var replacer = function(search, replace, str) {
        return str.split(search).join(replace);
    };

    // Build allowes tags associative array
    if (allowed_tags) {
        allowed_array = allowed_tags.match(/([a-zA-Z]+)/gi);
    }

    str += '';

    // Match tags
    matches = str.match(/(<\/?[^>]+>)/gi);

    // Go through all HTML tags
    for (key in matches) {
        if (isNaN(key)) {
            // IE7 Hack
            continue;
        }

        // Save HTML tag
        html = matches[key].toString();

        // Is tag not in allowed list? Remove from str!
        allowed = false;

        // Go through all allowed tags
        for (k in allowed_array) {
            // Init
            allowed_tag = allowed_array[k];
            i = -1;

            if (i != 0) {i = html.toLowerCase().indexOf('<'+allowed_tag+'>');}
            if (i != 0) {i = html.toLowerCase().indexOf('<'+allowed_tag+' ');}
            if (i != 0) {i = html.toLowerCase().indexOf('</'+allowed_tag)   ;}

            // Determine
            if (i == 0) {
                allowed = true;
                break;
            }
        }

        if (!allowed) {
            str = replacer(html, "", str); // Custom replace. No regexing
        }
    }

    return str;
}
function cleanMediaTags(m) {
    //img, embed, object
    m = m.replace(/<img[^>]+>/gi, '');
    m = m.replace(/<object[^>]+>.*<\/object>/gi, '');
    m = m.replace(/<object[^>]+>/gi, '');
    m = m.replace(/<param[^>]+>/gi, '');
    m = m.replace(/<\/param>/gi, '');
    m = m.replace(/<\/object>/gi, '');
    m = m.replace(/<embed[^>]+>/gi, '');
    return m;    
}
function paginator(action) {
    $(".pager").click(function () {
        var page = $(this).attr('title');
        
        $.ajax({
				type: "POST",
				url:  action,
				data: 'data='+page,
				async: false,
				success: function (data) {
                    document.location.href = "";
				},
				error: function (data) {
                    //alert("Trubls");
				}
	     });
    });
}

function paginator_bloglist(action) {
    $(".pager").click(function () {
        var page = $(this).attr('title');

        $.ajax({
				type: "POST",
				url:  action,
				data: 'data='+page,
				async: false,
				success: function (data) {
                    $("#blog_list").empty();
                    $("#blog_list").html(data);
//                    document.location.href = "";
				},
				error: function (data) {
                    //alert("Trubls");
				}
	     });
    });
}

function paginator_blogmessages(action) {
    $(".pager").live('click', function () {
        var page = $(this).attr('title');

        $.ajax({
				type: "POST",
				url:  action,
				data: 'data='+page,
				async: false,
				success: function (data) {
                    $("#blog_message").empty();
                    $("#blog_message").html(data);
//                    document.location.href = "";
				},
				error: function (data) {
                    //alert("Trubls");
				}
	     });
    });
}

var _show = function (hash){
//	hash.w.css('top', '').css('left', '').css('width', '').css('height', '');
    docw = getDocumentWidth();
    doch = getDocumentHeight();
    divw = hash.w.width();
    divh = hash.w.height();

    if ( (docw - divw) < 0 ) {
        divw = docw;
    }
    if ( (doch - divh) < 0 ) {
        divh = doch;
    }

    var left    = ( docw - divw ) / 2;
    var top     = ( doch - divh ) / 2;

//    hash.w.css('top', top+'px').css('left', left+'px').css('width', divw+'px').css('height', divh+'px').show();
    hash.w.css('top', top+'px').css('left', left+'px').show();
    setHWModal(hash);
//    hash.w.css('top', top+'px').css('left', left+'px');
}

function setHWModal(hash) {
    var block = hash.w;
    var id = block.attr('id');
    var content = $("#" + id + " div:nth-child(3)");
    var element_id = content.attr("id");
    var cur_width = content.width();
    var cur_height = content.height();
//    alert(cur_width);
    if ($.browser.msie && $.browser.version == 6) {
        block.css('width', cur_width + 40);
        /*block.css('height', cur_height + 140);*/
    } else {
        block.css('width', cur_width + 40);
//        block.css('height', cur_height + 170);
        if ( "quickme_window_area" != element_id ) {
            //block.css('height', cur_height + 90); //128
            block.css('height', 'auto'); 
        } else {
            //block.css('height', cur_height + 20); //58
            block.css('height', 'auto');
        }
    }

    $("#" + id + " > div").each( function() {
        if ( $(this)[0] != content[0] ) {
            $(this).css('width', cur_width + 40);
        } else {
            $(this).css('width', cur_width);
        }
    });
//	content.css('margin', '0 auto');
//	content.css('margin-left', 'auto');
//	content.css('margin-right', 'auto');
//    alert(content.width());
//    alert(content.height());
//    console.log(content);
}

function getDocumentWidth() {
    var myWidth = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
    }
    return myWidth;
}
function getDocumentHeight(){
    var myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
    }
    return myHeight;
}

function getSelectedBuddies(area) {
    var buddies = [];
	$('#'+area).find('input:checked').each(function(){
        id = $(this).attr('id');
		buddies.push(id.slice('buddy_'.length, id.length));
	});

    return buddies;
}

function fieldValidateBetween(id, min, max) { 
    var me = $("#" + id);
    if (!textValidate(id, digits_only)) return false;
    if ((me.val()>=min) && (me.val()<=max)) {
        return true;
    } else {
        return false;
    }
    return false;
}

// marker icons for google map
function getBallonIcon(country_name) {
    var icon = new GIcon(G_DEFAULT_ICON);
    icon.image = "/images/internal/ballons/countries/"+country_name+".png";
    icon.iconAnchor = new GPoint(16, 32);
    icon.infoWindowAnchor = new GPoint(16, 5);
    icon.iconSize = new GSize(32, 32);
    return icon;
}

function getPinIcon(country_name) {
    var icon = new GIcon(G_DEFAULT_ICON);
    icon.image = "/images/internal/pins/countries/"+country_name+".png";
    icon.iconAnchor = new GPoint(12, 32);
    icon.infoWindowAnchor = new GPoint(16, 0);
    icon.iconSize = new GSize(32, 32);
    return icon;
}

function getBoundsZoomLevel(extendedData) {

    var bounds = extendedData ? extendedData.LatLonBox : undefined;
    var zoom = 4;
    if (bounds) {
        var llbounds = new GLatLngBounds(
            new GLatLng(bounds.south, bounds.west),
            new GLatLng(bounds.north, bounds.east)
        );
        zoom = map.getBoundsZoomLevel(llbounds);
    }
    return zoom;
}

function centerMapPoint(address, markerPoint, zoomonclick) {
    map.clearOverlays();
    geocoder.getLocations(address, function(response){
        // addAddressToMap() is called when the geocoder returns an
        // answer. It adds a marker to the map with an open info window.
        if (!response || response.Status.code != 200) {
            //alert("Sorry, we were unable to geocode that address");
        } else {
            // get address point
            place = response.Placemark[0];
            point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
            // set map center to the point
	        zoom = getBoundsZoomLevel(place.ExtendedData); 
	        map.setCenter(markerPoint, zoom);
	        if (undefined!=window.countryzoom) {
	        	window.countryzoom = zoom;
	        }
	        
			if ((undefined!=zoomonclick) && (zoomonclick==true) && (undefined!=tempto)) {
				tempto.zoom[0] = zoom;
				
				createMarker(markerPoint, true);
			} else {
	            // place marker
	            createMarker(markerPoint);
			}
        }
    });
}

function convertObjectToString(obj, rem) {
    var str = '';
    for(prop in obj) {
        str+= rem + prop + " value :" ;
        if ( typeof obj[prop] == "object" ) {
            str+=convertObjectToString(obj[prop], "\t");
        } else {
            str+= obj[prop];//Concate prop and its value from object
        }
        str+= "\n";
    }
    return str;
}

function str_replace(search, replace, subject) {
    // Replaces all occurrences of search in haystack with replace  
    // 
    // version: 903.3016
    // discuss at: http://phpjs.org/functions/str_replace
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
    var s = subject;
    var ra = r instanceof Array, sa = s instanceof Array;
    var f = [].concat(search);
    var r = [].concat(replace);
    var i = (s = [].concat(s)).length;
    var j = 0;
    
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    }

    return sa ? s : s[0];
}

function html_entity_decode( string, quote_style ) {
    // Convert all HTML entities to their applicable characters  
    // 
    // version: 901.714
    // discuss at: http://phpjs.org/functions/html_entity_decode
    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: marc andreu
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
    // *     example 2: html_entity_decode('&amp;lt;');
    // *     returns 2: '&lt;'
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }

    // &amp; must be the last character when decoding!
    delete(histogram['&']);
    histogram['&'] = '&amp;';

    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }
    
    return tmp_str;
}

function get_html_translation_table(table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 903.1614
    // discuss at: http://phpjs.org/functions/get_html_translation_table
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco
    // +   bugfixed by: madipta
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // %          note: Table from http://www.the-art-of-web.com/html/character-codes/
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    useTable      = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS');
    useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT');
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
    
    // Map numbers to strings for compatibilty with PHP constants
    if (!isNaN(useTable)) {
        useTable = constMappingTable[useTable];
    }
    if (!isNaN(useQuoteStyle)) {
        useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
    }

    if (useTable == 'HTML_SPECIALCHARS') {
        // ascii decimals for better compatibility
        entities['38'] = '&amp;';
        if (useQuoteStyle != 'ENT_NOQUOTES') {
            entities['34'] = '&quot;';
        }
        if (useQuoteStyle == 'ENT_QUOTES') {
            entities['39'] = '&#039;';
        }
        entities['60'] = '&lt;';
        entities['62'] = '&gt;';
    } else if (useTable == 'HTML_ENTITIES') {
        // ascii decimals for better compatibility
	    entities['38']  = '&amp;';
        if (useQuoteStyle != 'ENT_NOQUOTES') {
            entities['34'] = '&quot;';
        }
        if (useQuoteStyle == 'ENT_QUOTES') {
            entities['39'] = '&#039;';
        }
	    entities['60']  = '&lt;';
	    entities['62']  = '&gt;';
	    entities['160'] = '&nbsp;';
	    entities['161'] = '&iexcl;';
	    entities['162'] = '&cent;';
	    entities['163'] = '&pound;';
	    entities['164'] = '&curren;';
	    entities['165'] = '&yen;';
	    entities['166'] = '&brvbar;';
	    entities['167'] = '&sect;';
	    entities['168'] = '&uml;';
	    entities['169'] = '&copy;';
	    entities['170'] = '&ordf;';
	    entities['171'] = '&laquo;';
	    entities['172'] = '&not;';
	    entities['173'] = '&shy;';
	    entities['174'] = '&reg;';
	    entities['175'] = '&macr;';
	    entities['176'] = '&deg;';
	    entities['177'] = '&plusmn;';
	    entities['178'] = '&sup2;';
	    entities['179'] = '&sup3;';
	    entities['180'] = '&acute;';
	    entities['181'] = '&micro;';
	    entities['182'] = '&para;';
	    entities['183'] = '&middot;';
	    entities['184'] = '&cedil;';
	    entities['185'] = '&sup1;';
	    entities['186'] = '&ordm;';
	    entities['187'] = '&raquo;';
	    entities['188'] = '&frac14;';
	    entities['189'] = '&frac12;';
	    entities['190'] = '&frac34;';
	    entities['191'] = '&iquest;';
	    entities['192'] = '&Agrave;';
	    entities['193'] = '&Aacute;';
	    entities['194'] = '&Acirc;';
	    entities['195'] = '&Atilde;';
	    entities['196'] = '&Auml;';
	    entities['197'] = '&Aring;';
	    entities['198'] = '&AElig;';
	    entities['199'] = '&Ccedil;';
	    entities['200'] = '&Egrave;';
	    entities['201'] = '&Eacute;';
	    entities['202'] = '&Ecirc;';
	    entities['203'] = '&Euml;';
	    entities['204'] = '&Igrave;';
	    entities['205'] = '&Iacute;';
	    entities['206'] = '&Icirc;';
	    entities['207'] = '&Iuml;';
	    entities['208'] = '&ETH;';
	    entities['209'] = '&Ntilde;';
	    entities['210'] = '&Ograve;';
	    entities['211'] = '&Oacute;';
	    entities['212'] = '&Ocirc;';
	    entities['213'] = '&Otilde;';
	    entities['214'] = '&Ouml;';
	    entities['215'] = '&times;';
	    entities['216'] = '&Oslash;';
	    entities['217'] = '&Ugrave;';
	    entities['218'] = '&Uacute;';
	    entities['219'] = '&Ucirc;';
	    entities['220'] = '&Uuml;';
	    entities['221'] = '&Yacute;';
	    entities['222'] = '&THORN;';
	    entities['223'] = '&szlig;';
	    entities['224'] = '&agrave;';
	    entities['225'] = '&aacute;';
	    entities['226'] = '&acirc;';
	    entities['227'] = '&atilde;';
	    entities['228'] = '&auml;';
	    entities['229'] = '&aring;';
	    entities['230'] = '&aelig;';
	    entities['231'] = '&ccedil;';
	    entities['232'] = '&egrave;';
	    entities['233'] = '&eacute;';
	    entities['234'] = '&ecirc;';
	    entities['235'] = '&euml;';
	    entities['236'] = '&igrave;';
	    entities['237'] = '&iacute;';
	    entities['238'] = '&icirc;';
	    entities['239'] = '&iuml;';
	    entities['240'] = '&eth;';
	    entities['241'] = '&ntilde;';
	    entities['242'] = '&ograve;';
	    entities['243'] = '&oacute;';
	    entities['244'] = '&ocirc;';
	    entities['245'] = '&otilde;';
	    entities['246'] = '&ouml;';
	    entities['247'] = '&divide;';
	    entities['248'] = '&oslash;';
	    entities['249'] = '&ugrave;';
	    entities['250'] = '&uacute;';
	    entities['251'] = '&ucirc;';
	    entities['252'] = '&uuml;';
	    entities['253'] = '&yacute;';
	    entities['254'] = '&thorn;';
	    entities['255'] = '&yuml;';
    } else {
        throw Error("Table: "+useTable+' not supported');
        return false;
    }
    
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}
 /* b */
function bCl() {
	
	function gotobannerpage() {
		var temp = topbannerlink.split(':');
		if (temp.length && (temp[0]=='mailto')) {
			window.location.href = topbannerlink;
		} else {
			var wi = window.open("");
			wi.location.href = topbannerlink;
		}
		return false;
	}
	var parnt = null;
	if ($(this).parent()[0].tagName.toLowerCase()=='a') parnt = $(this).parent().parent();
		else parnt = $(this).parent();
	var topbannerpad = parseInt(parnt.find('.topbannerpad').html());
	var topbannerlink = parnt.find('.topbannerlink').html(); 
	if (topbannerlink.length==0) {
		return true;
	}
	if (isNaN(topbannerpad)) {
		
		gotobannerpage(topbannerlink);
		
		return false;
	}
	$.ajax({
			type: "POST",
			url:  "/click",
			data: "topbannerpad="+topbannerpad,
			async: false,
			//dataType: "json",
			success: function(data) {
			},
			error: function(data) {
			}
	}); 	
	
	gotobannerpage(topbannerlink);
	return false;
}

function in_array(needle, haystack, argStrict) {
    var found = false, key, strict = !!argStrict;

    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }

    return found;
}
/* <keyboard> */
function viewKeyboard(e) {
   if (!e) e = event;	
   
	/* frame */	
	//virkDialogShow();
	/* div */
	var posx = e.clientX+getScrollXY().scrOfX;
	var posy = e.clientY+getScrollXY().scrOfY;
	
	if ((undefined!=window.keyboard_params) && (undefined!=window.keyboard_params.topcorrect)) {
		posy += keyboard_params.topcorrect;
	}
	if ((undefined!=window.keyboard_params) && (undefined!=window.keyboard_params.leftcorrect)) {
		posx += keyboard_params.leftcorrect;
	}
	$('#virk').css('left', posx+'px');
	$('#virk').css('top', (posy-100)+'px');
	
	$('.virkedible').each(function() {
		attachinput(this);
	});	
	virkshow();
	reinitKeyboard();
	return false;
}

function reinitKeyboard() {
	var layout = virkCtrl.getLayout();
	virkCtrl.kbd = new Keyboard (virkCtrl, layout, VIRK_NOKBD);
	
}
function attachinput(el) {
	try {
		var newattacher = new VirkAttacher();
		newattacher.onCtrl(el, document);
	} catch(e) {}
}
function detachinput(el) {
	try {
		var newdetacher = new VirkDetacher();
		newdetacher.onCtrl(el, document);
	} catch(e) {}
}
function keyboard_init() {
	
	if ($('#virk').attr('id')==undefined) {
		return false;
	}
	$('#virkclose').live('click', hideKeyboard);
	window.onblur = function() {
		 hideKeyboard();
	}
	
	$("#virk").draggable({ 
		handle: '#virkhandler',
		start: function() {
			$(document).disableSelection();			
		},
		stop: function() {
			reinitKeyboard();
			$(document).enableSelection();
		}
		
	});

	$("a.keyboard").live('click', viewKeyboard);

}
function f_hidekeyboard(res) {
	    res.live('click', function(){
	    	if (this.id=='layouts') return true;
			else hideKeyboard();
	    });
}

function hideKeyboard() {
	$('.virkedible').each(function() {
		detachinput(this);
	});		
	virkclose();
	return false;	
}
function virkclose() {
	$('#virk').hide();
	return false;
}
function virkshow() {
	$('#virk').show();
	return false;
}
/* </keyboard> */

function slideErrorSpace() {
	$("#error_space_size").slideUp('slow');
}
function hideErrorSpace() {
	setTimeout('slideErrorSpace()', 3000);
}
function setErrorSpace(error){
    $("#size_error_message_a").click();
//	$("#error_space_size").show();
//	$("#error_space_size_message").html(error);
//	hideErrorSpace();
}
function getBoundsZoomLevelForMap(extendedData, formap) {

    var bounds = extendedData ? extendedData.LatLonBox : undefined;
    var zoom = 4;
    if (bounds) {
        var llbounds = new GLatLngBounds(
            new GLatLng(bounds.south, bounds.west),
            new GLatLng(bounds.north, bounds.east)
        );
        zoom = formap.getBoundsZoomLevel(llbounds);
    }
    return zoom;
}
function wordwrap( str, int_width, str_break, cut ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Nick Callen
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Sakimori
    // +   bugfixed by: Michael Grier
    // *     example 1: wordwrap('Kevin van Zonneveld', 6, '|', true);
    // *     returns 1: 'Kevin |van |Zonnev|eld'
    // *     example 2: wordwrap('The quick brown fox jumped over the lazy dog.', 20, '<br />\n');
    // *     returns 2: 'The quick brown fox <br />\njumped over the lazy<br />\n dog.'
    // *     example 3: wordwrap('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.');
    // *     returns 3: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod \ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim \nveniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea \ncommodo consequat.'

    // PHP Defaults
    var m = ((arguments.length >= 2) ? arguments[1] : 75   );
    var b = ((arguments.length >= 3) ? arguments[2] : "\n" );
    var c = ((arguments.length >= 4) ? arguments[3] : false);

    var i, j, l, s, r;

    str += '';

    if (m < 1) {
        return str;
    }

    for (i = -1, l = (r = str.split(/\r\n|\n|\r/)).length; ++i < l; r[i] += s) {
        for(s = r[i], r[i] = ""; s.length > m; r[i] += s.slice(0, j) + ((s = s.slice(j)).length ? b : "")){
            j = c == 2 || (j = s.slice(0, m + 1).match(/\S*(\s)?$/))[1] ? m : j.input.length - j[0].length || c == 1 && m || j.input.length + (j = s.slice(m).match(/^\S*/)).input.length;
        }
    }

    return r.join("\n");
}

function urlencode( str ) {
    var ret = str;
    ret = ret.toString();
    ret = encodeURIComponent(ret);
    ret = ret.replace(/%20/g, '+');
    return ret;
}


function btabEvent() {
	var el = this;
	var classes = $(el).attr('class').split(' ');
	var btabname = '';
	var temp = '';
	
	for (var i=0;i<classes.length;i++) {
		temp = classes[i].split('_');
		if (temp[0]=='btab') {
			btabname = classes[i].substr(temp[0].length+1);
		}
	}
	changebtab(btabname);
    return true;
}
function btabSetEvent() {
	$('.btabset').live('click', btabEvent);
	return true;
}
function changebtab(btabname) {
	if (btabname.length && ($('.'+'banner_'+btabname).css('display')=='none')) {
		$('.adBanner').find("div").each( function() {
			$(this).hide();
		});
		$('.'+'banner_'+btabname).show();
	}
	return true;
}
function getcrossclearurl() {
	var tmp = location.href.substr(0, location.href.length-location.search.length-location.hash.length);
	if (tmp.substr(tmp.length-1, 1)=='#') tmp = tmp.substr(0, tmp.length-1);
	return tmp;
}
function crossclearreload() {
	location.href = getcrossclearurl();
}
function cycle(val, max, def, delta) {
	if (def==undefined) def=0;
	if (max==undefined) max=1; 
	if (delta==undefined) delta=1;
	val += delta;
	if (val>max) {
		val = def;
	}
	return val;
}
function spotheight(bestbuddies) {
    //bestbuddies caused that bestbuddies block is situated at the bottom of the page above bottom menu
	$("body").css("height", "auto");
	$('body').hide();$('body').show(); //ie8 fix
	//alert($(window).height()+';'+$(document.body).height());
    if ($(window).height()<$(document.body).height()) {
    	$("body").css("height", "auto");
    } else {
    	$("body").css("height", "100%");
    	if (undefined!==bestbuddies) {
    		$(".bestbuddies").css('visibility', 'hidden'); // for ie6
	    	$(".bestbuddies").css('position', 'absolute');
	    	var cor = $(document.body).height()-$('#wrapper').height();
	    	$(".bestbuddies").css('bottom', (cor+5)+'px');
	    	$(".bestbuddies").css('visibility', 'visible'); // for ie6
    	}
    }
    //alert($("body").css("height"));
}
function SpotOnResize() {
	$("#fon_body").height($("#wrapper").height() /*+20*/ );
	spotheight(true);
}
function correctPosition(oElement,oPos,oWhich) {
      while( oElement.offsetParent ) {
        oPos -= oElement['offset'+oWhich];
        oElement = oElement.offsetParent;
      }
      oPos += document.documentElement['scroll'+oWhich] ? document.documentElement['scroll'+oWhich] : document.body['scroll'+oWhich];
      return oPos;
}
function spotaboutcorrect() {
	/*
    $('#about_myself').css('position', 'relative');
    $('#about_myself').css('width', '980px');
    $('#about_myself').css('overflow', 'auto');
    */
	$('#about_myself').css('visibility', 'hidden'); // for ie6
    var amh = $('#about_myself').height();
    var cort = 40;
    var maxt = amh;
    
    var wraph = $('.wrap').height();
    var wrapperh = $('#wrapper').height();
    //alert(maxt);
    if (wraph<wrapperh) {
    	maxt = amh+(wrapperh-wraph-42);
    }
    //alert(maxt);
	$("#about_myself div").each(function() {
		if (this.style.position=='absolute') {
			var t = parseInt($(this).css('top').split('px')[0]);
			var h = parseInt($(this).css('height').split('px')[0]);
			if ((t+h)>maxt) maxt = t+h;
		}
	});    
    $('#about_myself').css('height', parseInt(maxt+cort)+'px');
    //alert(maxt);
    $('#about_myself').css('visibility', 'visible'); // for ie6
}


function addEditorPanel(elements_id, video, blockquote, add_event) {
	var editor = tinyMCE.get(elements_id);
	if (undefined!=editor) return false;
	var plugins = "paste,bbcode";
	var buttons = "bold,italic,underline,forecolor,link,unlink,image";
	if (video) {
		plugins += ',media';
		buttons += ',media';
	}
	if (blockquote) {
	    buttons += ',blockquote';
	}
	var event = '';
	if (add_event) {
	    event = "ed.onInit.add("+add_event+")";
	}
	
	tinyMCEParams = {
	  mode : "exact",
	  theme : "advanced",
	  editor_selector : "mceEditor",
	  plugins : plugins, //,preview
	  paste_auto_cleanup_on_paste : true,
	  elements : elements_id,
	  theme_advanced_toolbar_location : "top",
	  theme_advanced_toolbar_align : "left",
	  theme_advanced_buttons1: buttons, //,|,preview
	  theme_advanced_buttons2: "",
	  theme_advanced_buttons3: "",
	  theme_advanced_buttons4: "",
	  inline_styles : false,
	  convert_fonts_to_spans : false,
	  remove_linebreaks : false,
	  add_unload_trigger : false,
	  entity_encoding : "raw",
	  content_css : "/css/default/tinymce.css",
      setup: function(ed){eval(event);}
      
	};
	
	tinyMCE.init(tinyMCEParams);
}

function view_profile_reg_window_init() {
	if ($('#view_profile_reg').length) { 
		$('#view_profile_reg').jqm({
	        overlay: 30,
	        overlayClass: 'jqmOverlay',
	        onShow: function(hash) {
	        	_show(hash);
	        	$('#blog_message').find('embed').css('visibility', 'hidden');
	        	$('#about_myself').find('embed').css('visibility', 'hidden');
	        },
	        onHide: function(hash){
	            hash.w.hide();
	            hash.o.remove();
	            $('#blog_message').find('embed').css('visibility', 'visible');
	            $('#about_myself').find('embed').css('visibility', 'visible');
	        }
		});	
	}
}
function view_profile_buddy_window_init() {
	if ($('#view_profile_buddy').length) { 
		$('#view_profile_buddy').jqm({
	        overlay: 30,
	        overlayClass: 'jqmOverlay',
	        onShow: function(hash) {
	        	_show(hash);
	        	$('#blog_message').find('embed').css('visibility', 'hidden');
	        	$('#about_myself').find('embed').css('visibility', 'hidden');
	        },
	        onHide: function(hash){
	        	//alert('asdf');
	            hash.w.hide();
	            hash.o.remove();
	            $('#blog_message').find('embed').css('visibility', 'visible');
	            $('#about_myself').find('embed').css('visibility', 'visible');
	        }
		});	
	}
}

function needRegistration() {
	$('#view_profile_reg').jqmShow();
	return false;
}
function needToBeBuddy(bfrom, bto, status) {
	var pending_message = waiting_buddies_pending_message;
	if (!bfrom || !bto) return false;
	if (undefined!=pending_requests[bto]) status = 1;
	if ((undefined!==status) && (status)) {
		try {
			$('#view_profile_buddy_buddieslink').hide();
			$('#view_profile_buddy_waitingbuddieslink').show();
			if (status==2) pending_message = waiting_buddies_declined_message;
		} catch(e) {}
	} else {
		try {
			$('#view_profile_buddy_waitingbuddieslink').hide();
			$('#view_profile_buddy_buddieslink').show();
		} catch(e) {}
	}
	try {
		$('#view_profile_buddy_waitingbuddieslink').unbind('click');
		$('#view_profile_buddy_waitingbuddieslink').bind('click', function() {
			alert(pending_message);	
			return false;
		});	
		$('#view_profile_buddy_buddieslink').unbind('click');
		$('#view_profile_buddy_buddieslink').bind('click', function() {
			tryaddbuddy(bfrom, bto);
			return false;
		});	
		$('#view_profile_buddy_spotmyworldlink').unbind('click');
		$('#view_profile_buddy_spotmyworldlink').bind('click', function() {
			tryspotinvite(bfrom, bto);
			return false;
		});	
	} catch(e) {}
	
	$('#view_profile_buddy').jqmShow();
	return false;
}
function tryaddbuddy(bfrom, bto) {
	//alert(bfrom+';'+bto);
	$.ajax({
        type: "POST",
        data: {bfrom: bfrom, bto: bto},
        url:  "/default/users/addbuddyrequest",
        async: false,
        dataType: "json",
        success: function(resp) {
			$('#view_profile_buddy_buddieslink').hide();
			$('#view_profile_buddy_waitingbuddieslink').show();
			pending_requests[bto] = 1;
			$('#view_profile_buddy').jqmHide();
        },
        error: function(resp) {
        }
    });
	return false;
}
function tryspotinvite(bfrom, bto) {
	//alert(bfrom+';'+bto);
	$.ajax({
		type: "POST",
		data: {bfrom: bfrom, bto: bto},
		url:  "/default/users/buddyspotrequest",
		async: false,
		dataType: "json",
		success: function(resp) {
			$('#view_profile_buddy').jqmHide();
		},
        error: function(resp) {
        }		
	});		
	return false;
}
	


