$(document).ready(function(){
	$(".box").each(function(cnt,eli){
		var rightInfo = $(eli).find(".boxContent.hasRightInfo");
		if(rightInfo && $(rightInfo).find(".icon.indent:contains('Direktlink')")[0] && $(rightInfo).find(".icon.indent:contains('HTML')")[0]){
			var adm = $(eli).find("div[id]");
			var bottomInfo = $(eli).find(".bottomInfo input[id]");
			
			if(adm && bottomInfo && $(adm).attr("id").search(/adm_.+/) != -1 && bottomInfo.attr("id").search(/admCode_.+/) != -1){
				var admLinkValue = bottomInfo.val();
				var admLinkSrc = admLinkValue.substring(admLinkValue.indexOf("src=")+5,admLinkValue.indexOf("\"",admLinkValue.indexOf("src=")+5));
				var admHTML = $(adm.find("div div").children());
				var admHTMLtext = $.trim(admHTML.parent().html().replace(/\[link\]/g,admLinkSrc).replace(/admGetCode/g,"admPartnerdoor"));
				var admCodeHTML = $("<textarea onfocus='this.select()' class='text code' style='height:150px'>"+admHTMLtext+"</textarea>");
				
				admHTML.html(admHTMLtext);
				$(bottomInfo).before($(admCodeHTML));
				admCodeHTML.css({
					"background":"#E8EDC2",
					"border":"1px solid #A1D21E"
				});
				
				bottomInfo.remove();
			}
		}
	});
});

