(function($){
 profile_plug = function(marketprofile) {
 
//eg marketprofile might be 'trendy' etc set in status.xml;
//default if no marketprofile in status 
if (marketprofile == '') {
	marketprofile = 'home';
}

	$.ajax({
                 type: "GET",
                 url: "plugmarket.xml",
                 dataType: "xml",
                 cache: false,
                 success: function(xml) {

	$(xml).find('plugs').each(function() {
	var getmarket = $(this).attr('marketid');
	 if(getmarket==marketprofile) {
	 	var pplugtext1 = $(this).find('plugbox1').children('ptext:first').text();
	 	var pplughead1 = $(this).find('plugbox1').children('phead:first').text();
		var pplugpict1 = $(this).find('plugbox1').children('pimage:first').text();
		var pplugurl1 = $(this).find('plugbox1').children('purl:first').text();
		var pplugtype1 = $(this).find('plugbox1').children('plugtype:first').text();
		
		var pplugtext2 = $(this).find('plugbox2').children('ptext:first').text();
	 	var pplughead2 = $(this).find('plugbox2').children('phead:first').text();		
	 	var pplugpict2 = $(this).find('plugbox2').children('pimage:first').text();
	 	var pplugurl2 = $(this).find('plugbox2').children('purl:first').text();
	 	var pplugtype2 = $(this).find('plugbox2').children('plugtype:first').text();

	 	
	 	if(pplugtype1=="image"){

	 	$('#plug1Box #plug1Image').html('<img src="plug/'+pplugpict1+'" width="316px"  height="250px" />');
	 	} else { 	
	 	$('#plug1Head').html(pplughead1);
	 	$('#plug1Pict').html('<img src="plug/'+pplugpict1+'" width="140px" />');
		 pplugtext1 = '<div style="margin-top:8px">'+pplugtext1+'<\/div>' ; 	
		$('#plug1Text').html(pplugtext1);	
		}
		$('#plug1Url').attr("href", pplugurl1);

		if (pplugurl1.toLowerCase().indexOf("boyz.co.uk") >= 0){$('#plug1Url').attr("target", "_self")};

	 	if(pplugtype2=="image"){
	 	$('#plug2Box #plug2Image').html('<img src="plug/'+pplugpict2+'" width="316px"  height="250px" />');
	 	} else {			 	
	 	$('#plug2Head').html(pplughead2);
	 	$('#plug2Pict').html('<img src="plug/'+pplugpict2+'" width="140px" />');
		 pplugtext2 = '<div style="margin-top:8px">'+pplugtext2+'<\/div>' ; 
		$('#plug2Text').html(pplugtext2);
		}
		$('#plug2Url').attr("href", pplugurl2);

		if (pplugurl2.toLowerCase().indexOf("boyz.co.uk") >= 0){$('#plug2Url').attr("target", "_self")};
		
		//need to jump out here using return false to exit???
	 }
	});

			
		}
       	});


return false;
          }           
})(jQuery);













