function change_tab(element) {
	var tab_name = element.attr('id').replace('_tab','');

	var div_name = '';

	$("#content_divs .body_div").each( function(i) {
		var div_name = this.id.replace('_div','');

		if (div_name == tab_name) {
			$('#' + this.id).css('display','block');
			$('#' + div_name + '_tab').css('backgroundColor','#fff');
		} else {
			$('#' + this.id).css('display','none');
			$('#' + div_name + '_tab').css('backgroundColor','#eee');
		}
	});
}

function trim(str) {
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}


function setURL(headline,url_id) {
	var tempURL = trim(headline).replace(/ /g,"-");
	tempURL = tempURL.replace(/[^a-zA-Z0-9\-]/g,"");
	tempURL = encodeURI(tempURL);
	document.getElementById(url_id).value = tempURL.toLowerCase() ;
}

function getHtmlForLeftItem(item_id, div_to_add){
		var link = "/segment_lead_form/left_item_html/" + item_id;
		
		$.get(link, function(data){
			$(data).appendTo("#" + div_to_add);
		});
	 
}
