var badges = '';
var profilesneeded = 15;
var profilesgot = 0;

function sortmyway()
{
    return 0.5 - Math.random(); //random gives us result 
}


$(document).ready(function(){
$('div#ContentBlock3').insertAfter('div#FooterContainer');

	$.ajax({
		type: "GET",
		url: PROFILE_XML_PATH,
		dataType: "xml",
		success: function(xml) {
		    var profiles = $(xml).find('profile');
			profiles.each(function(){
				if (sortmyway()+1 < 0.92)
				{
				    var photo = $(this).find('photo_url').text();
				    var name = $(this).find('screenname').text();
				    var age = $(this).find('age').text();
				    var city = $(this).find('city').text();
			        //alert(name);
                    
                    if (profilesgot < profilesneeded)
                    {
                    
                        badges += '<div class="wld_badge_item"><div class="wld_badge_item_photo">' + 
                            '<a href="#" onclick="alert(\'Please login or register to see more of ' + jQuery.trim(name) + '\');"><img src="' + photo + '" width="80" height="99" alt="See more of ' + jQuery.trim(name) + '" title="Want ' + jQuery.trim(name) + ' in your fuck book?" /></a></div>' + 
                            '<div class="wld_badge_item_detail"><span class="wld_badge_item_name">' + jQuery.trim(name) + '</span>, ' + 
                            '<span class="wld_badge_item_age">' + jQuery.trim(age) + '</span>,&nbsp;' + 
                            '<span class="wld_badge_item_region">' + city + '</span></div></div>';
			            profilesgot++;
			        }
			    }
			});
			// write out the HTML
			$('div#profileplaceholder').html(badges);
		}
	});
});
