var tabFade = false;

/* main tabs functions */
function initMainTabs(){
	setTabsTargets();	
	$('.link a', '#asseco-tabs').bind('click', tabsTriger );
	$('.link a', '#asseco-tabs').bind('mouseenter', tabsLinkHover);
	$('.link a','#asseco-tabs').first().click();
}
function tabsTriger( event ){
	if(typeof event != 'undefined') event.preventDefault();

	if( $( $(this).attr('href').substr($(this).attr('href').indexOf('#') == -1 ? 0 : $(this).attr('href').indexOf('#')) ).length)
	{
		$('.link', '#asseco-tabs').removeClass('active');
		$(this).parent().addClass('active');
		$('.tab', '#asseco-tabs').removeClass('active');
		$( $(this).attr('href').substr($(this).attr('href').indexOf('#') == -1 ? 0 : $(this).attr('href').indexOf('#')) ).addClass('active');
		
	};
}
function tabsLinkHover( event ){
	
	if( $( $(this).attr('href').substr($(this).attr('href').indexOf('#') == -1 ? 0 : $(this).attr('href').indexOf('#')) ).length)
	{
		$('.link', '#asseco-tabs').removeClass('active');
		$(this).parent().addClass('active');
		$('.tab', '#asseco-tabs').removeClass('active');
		$( $(this).attr('href').substr($(this).attr('href').indexOf('#') == -1 ? 0 : $(this).attr('href').indexOf('#')) ).addClass('active');
		
		if(tabFade)
			$( $(this).attr('href')).hide(0, function(){
				$(this).fadeIn('slow');
			});
		
	};
}
function tabsLinkClear( event ){
	
}
function setTabsTargets(){
	var height = $('#asseco-tabs').height() - $('.tabs-footer','#asseco-tabs').height();			
	$('.tabs-targets', '#asseco-tabs').height( height );
	$('.tab', '#asseco-tabs').height( height );
	
}
/* main tabs functions */

/* popup tabs */

function initProductsTabs( startTab ){
	jQuery.noConflict();
	var tabsBox = $('#popup-tabs');
	$('.tabs-links a', tabsBox).unbind('click');
	$('.tabs-links a', tabsBox).bind('click', productsTabsTriger );
	productsTabSelect( startTab, tabsBox );
}
function productsTabsTriger( event ){
	jQuery.noConflict();
	if(typeof event != 'undefined') event.preventDefault();
	
	var tabsBox = $(this).parents('.tabs-box');
	

	if( $( $(this).attr('href').replace(/.*#/,'#tabs-tab-') ).length)
	{
		productsTabSelect( 	$(this).attr('href').replace(/.*#/,''), tabsBox );
	};
}
function  productsTabSelect( tabName , tabsBox ){
	jQuery.noConflict();	
	// clear //
	$('.link', tabsBox ).addClass('whitebg');
	$('.tab', tabsBox).removeClass('active').jScrollPaneRemove();;
	// set //
	$('#tabs-tab-' + tabName , tabsBox).addClass('active').jScrollPane({scrollbarWidth:5, scrollbarMargin:5});;
	$('.tabs-link-' + tabName, tabsBox).removeClass('whitebg');
	//$('#popupscroll .tab').jScrollPane({scrollbarWidth:5, scrollbarMargin:5});

}


