$j(document).ready(function(){	

$j("img[src='/Utilities/ShowThumbnail.aspx?USM=1&W=80&H=80&R=1&Img='],img[src='?action=thumbnail&width=150&height=200'],img[src='?action=thumbnail&width=150&height=150'],img[src='?action=thumbnail&width=100&height=100']").remove();

/*Swap out 'share with a friend' text with image */
$j("a:contains('Share With a Friend')").html("<img src='/images/share.jpg' width='144' height='44' alt='Share with a friend' />");

if($j('#Price').length != 0){	
	$j('#Price').attr("disabled", true);
}
			
//Sort the results
function defineMembershipLevel(val){
	switch(val)
	{
		case "fb_box low":
			val="3";
			return(val);
			break;
		case "fb_box medium":
			val="2";
			return(val);
			break;
		case "fb_box high":
			val="1";
			return(val);
			break
		case "fb_box":
			val="3";
			return(val);
			break
		default:
		break;
	}
}

	//Remove high listings from sortable box
	 $j('#sortme .high').remove();
	 
	//Sort the membership items
	var mylist = $j('#sortme');

	//Disabled sortingU
	if(mylist.length != 0){ 
		var listitems = mylist.children('.fb_box').get();
		listitems.sort(function(a, b) {	
		   var valA = $j(a).attr('class');
		   var valB = $j(b).attr('class');
		   return (defineMembershipLevel(valA) < defineMembershipLevel(valB)) ? -1 : (defineMembershipLevel(valA) > defineMembershipLevel(valB)) ? 1 : 0;
		})
		$j.each(listitems, function(idx, itm) { mylist.append(itm); });
	}
	
	//Remove boxes from listings
	if($j("div.featured_business").length != 0){
		$j("div.featured_business.low").remove();
		$j("div.featured_business.medium").remove();
		$j("div.fb_box.high").remove();
	}
	
			
		//Change visibility of elements depending on membership level
	
		if($j("#businessDetailView").length != 0){
			if(membershipLevel=="low"){
				$j("div.featured_business").remove();
			}
		}

	//make it so people can only have one listing
	if($j("div#existing-listings .fb_box").length != 0){
		$j("div#existing-listings").css("display", "block");
		$j("div#create-a-listing").remove();
	}else{
		$j("div#existing-listings").remove();
		$j("div#create-a-listing").css("display", "block");
	}
	
	//*Ad rotator*//

   $j('.adRotator').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		timeout: 7000,
		random: '1',
		cleartype: true, 
		cleartypeNoBg: true
	});
	
	/** Rounded corners on ads **/
	$j('.sidebox.adRotator img').after("<img src='/images/ad-corners.png' width='165' height='165' alt='Image Thumbnail' class='roundCorners' />");
	
	/** Conditional Hiding **/
	/*$j('.mustExist:empty').closest('.conditional').remove();*/
});


