var relPathToRoot = '/vestakuechen/';
relPathToRoot = '';
$(document).ready(function() {
    //toggleStorePromo();
	storeIndicator();
	fullClickPromo();
});

function storeIndicator() 
{
	if( !$( '.promo-filiale' ) ) return;
	
	var stores = $( '.promo-filiale ul a[id]' );
	
	if( !stores.length ) return;
	
	var store     = null;
	var id        = null;
	var imgString = '<img src="' + relPathToRoot + 'fileadmin/templates/default/images/stores/fil00.png" alt="" class="store-indicator" id="store_indicator_20" />';
	
	for( var i = 0; i < stores.length; i++ )
	{
		store     = stores[i];
		
		$( store ).bind( 'mouseover mouseleave', toggleStoreImage );
		
		id         = $( store ).attr( 'id' ).substring( 3 );
		imgString += '<img src="' + relPathToRoot + 'fileadmin/templates/default/images/stores/' + $( store ).attr( 'id' ) + '.png" alt="" class="store-indicator hide" id="store_indicator_' + id + '" />';
	}
	$( '.promo-filiale .padding' ).append( imgString );
}

function toggleStoreImage( evt )
{
	var id = $( this ).attr( 'id' ).substring( 3 );
	$( '#store_indicator_' + id ).toggleClass( 'hide' );
}

function toggleStorePromo()
{
	if( !$( '.promo-filiale' ) ) return;
	$( '.promo-filiale img.small' ).bind( 'mouseenter', function() { $( '.promo-filiale img.large' ).css( 'display', 'block' ); } );
	$( '.promo-filiale img.large' ).bind( 'mouseout', function() { $( '.promo-filiale img.large' ).css( 'display', 'none' ); } );
}

function fullClickPromo()
{
	var selectors = ['.promotions .col-1', '.promotions .col-2', '.promotions .col-3' ];
	var block     = null;
	var links     = null;
	
	for( var i = 0; i < selectors.length; i ++ )
	{
		links = $( selectors[i] + ' a' );
		
		if( links.length != 1 ) continue;
		
		$( selectors[i] ).bind( 'click', function() { document.location.href = $( this ).find( 'a' ).attr( 'href' ); } ).css( 'cursor', 'pointer' )
	}
}
