var ident_ws = $('#ident_ws').val();

$.fn.qtip.styles.tabtip = {
	width: 180,
	background: '#E21917',
	color: '#FFFFFF',
	textAlign: 'center',
	border: {
		width: 1,
		radius: 3,
		color: '#E21917'
	},
	tip: 'bottomMiddle',
	name: 'light'
}

function bar_click_counter(co) {
	$.ajax({
		url: "https://www.sva-onlinezulassung.de/tab_bar/bar_click_counter.php",
		data: "ws="+ident_ws+"&co="+co,
		type: "GET"
	});
}

var stateArrowButton = 1;
function switchArrowButton() {
	if (stateArrowButton == 1) {
		$('#xs_tab_bar_button').css({ "background-image": "url(https://www.sva-onlinezulassung.de/tab_bar/button_produkte_links.png)" });
		stateArrowButton = 0;
		bar_click_counter("PRODUKTE_OUT");
	} else {
		$('#xs_tab_bar_button').css({ "background-image": "url(https://www.sva-onlinezulassung.de/tab_bar/button_produkte_rechts.png)" });
		stateArrowButton = 1;
		bar_click_counter("PRODUKTE_IN");
	}
}
function jtipRun() {
	$('#xs_tab_bar_content img').each(function() {
		var thisid = $(this).attr("id");
		$(this).qtip({
			content: '<span style="font-size:11px;">' + $('#text_' + thisid).val() + '</span>',
			position: { corner: { target: 'topMiddle', tooltip: 'bottomMiddle' } },
			style: { name: 'tabtip' },
			show: { solo: true, when: { event: 'mouseover' }, effect: { type: "fade", length: 200} },
			hide: { when: { event: 'mouseout' } }
		});
	});
}

$(document).ready(function() {

	$('#xs_tab_bar_content').css({
		"margin-left": -$('#xs_tab_bar_content').outerWidth(),
		"visibility": "visible"
	});

	$('#xs_tab_bar_button').click(function() {
		var $marginLefty = $('#xs_tab_bar_content');
		$marginLefty.animate({
			marginLeft: parseInt($marginLefty.css('marginLeft'),10) == 0 ? -$marginLefty.outerWidth() : 0
		});
		switchArrowButton();
		// setTimeout("jtipRun()", 1000);
		jtipRun();
	});

});

