function tabsClickablePreview() {
	$(".block_with_tabs .tabs_buttons li").each(function(){
		$(this).click(function() {
			var curentImage = 0;
			$(".block_with_tabs .tabs_buttons .active").removeClass("active");
			curentImage = $(this).attr("id");
			$(".block_with_tabs .block_with_text .tabs_text").removeClass("active");
			$(".block_with_tabs .block_with_text ."+curentImage).addClass("active");
			$(this).addClass("active");
			return false;
		});
	});
}

function RecortTextInTabs () {
	$(".block_with_tabs_textfield .tabs_con").each(function(){
		var content_tabs = 0;
		var id_tabs = 0;
		var nextSpanHtml = 0;
		
		id_tabs = $(this).attr("id");
		content_tabs = $(this).html();
		nextSpanHtml = $(this).next().html();
		
		$(".block_with_tabs .tabs_buttons #"+id_tabs).html(content_tabs);
		$(".block_with_tabs .block_with_text ."+id_tabs).html(nextSpanHtml);			
		
		/*Приховуємо текстові блоки, коли ми не в адмінці*/
		$(".block_with_tabs_textfield").css({"display":"none"});
	});
}

function click_to_form_podpiski(){
	$(".submit_block_form_visittor_span").click(function(){
			var content_from_form =0;
			var content_from_form2 =0;
			
				$(".block_form_visitor1").wrapInner("<form style='display:none;' method='post' target='_blank' action='http://visitor.r20.constantcontact.com/d.jsp' name='ccoptin'></form>");
				$(".block_form_visitor2").wrapInner("<form name='ccoptin' action='http://visitor.r20.constantcontact.com/d.jsp' target='_blank' method='post' style='margin-bottom:2;'></form>");
				
				$(".submit_block_form_visittor").click();
				
				location.delay(500).reload();	
	});
}

/* select "support"*/
function selecter_select_support(){
	$(".supprot_form_page select option").each(function(){
		var value_option = 0;
		value_option = $(this).val();
		if(value_option == "1") {
			$(this).attr("selected","selected");
		}
	});
}
	
	
/* checking where we are situated. If now open cmsdesk , we start the function  */
function whoDisplayNoneContentTabsIfAdmin() {
var loc = 0;
	loc = document.location.href;
	loc=loc.indexOf("/cms/");
	if (loc == -1) {
		RecortTextInTabs ();
	}

}


$(document).ready(function(){ 
	tabsClickablePreview();
	whoDisplayNoneContentTabsIfAdmin();
	click_to_form_podpiski();
	selecter_select_support();
});
