/* parameters */
   minWidth = 1024;
   minHeight = 768;
   horizontalMargin = 0;
   verticalMargin = 25;
   /* end parameters */

function getCookie(cookie_id)
{
	var cookie = $.cookie(cookie_id);
	return cookie;
}
function handleChange(event)
{
	var url = event.path;
	if(url.indexOf('collection') > -1 && verticalMargin == 25)
	{
		//alert('visualizzo info');
		verticalMargin = 50;
		//resizeContent();
		$('#footer_info').fadeIn();
	}
	else if(url.indexOf('collection') == -1 && verticalMargin == 50)
	{
		//alert('nascondo info');
		verticalMargin = 25;
		//resizeContent();
		$('#footer_info').fadeOut();
	}
}
SWFAddress.addEventListener(SWFAddressEvent.CHANGE, handleChange);

function resizeContent()
{
   
   
   winHeight = $(window).height();
   winWidth = $(window).width();
   availableHeight = (winHeight - verticalMargin) > minHeight ? (winHeight - verticalMargin) : minHeight;
   availableWidth = (winWidth - horizontalMargin) > minWidth ? (winWidth - horizontalMargin) : minWidth;
   
   verticalPadding = availableHeight == minHeight ? verticalMargin : 0;
   
   $('#debug').html(availableHeight+' - '+availableWidth);
   $('#flash').css({'height':availableHeight, 'width':availableWidth, 'padding-bottom':verticalPadding}); 
}
function killSubFooter()
{
	/*$('#change_language').animate({
		height: 'slideUp',
		bottom: '0'
	});
	$('#store_locator').animate({
		height: 'slideUp',
		bottom: '0'
	});	*/
	$('#store_locator').fadeOut();
	$('#change_language').fadeOut();
}

function init()
{
	$('#store_locator').mousemove(function(){
		if(intval!=""){
          window.clearInterval(intval);
          intval="";
		}
		intval = setInterval("killSubFooter()",1000);
	});
	
	$('#change_language').mousemove(function(){
		if(intval!=""){
          window.clearInterval(intval);
          intval="";
		}
		intval = setInterval("killSubFooter()",1000);
	});
	
	$('#link_store_locator').mouseover(function(){
		$('#store_locator').fadeIn();
		$('#change_language').fadeOut();
	   if(intval!=""){
          window.clearInterval(intval);
          intval="";
		}
	});
	
	$('#link_store_locator').mouseout(function(){
		if(intval!=""){
          window.clearInterval(intval);
          intval="";
		}
		intval = setInterval("killSubFooter()",500);
	});
	
	$('#link_change_language').mouseover(function(){
		$('#store_locator').fadeOut();
		$('#change_language').fadeIn();
	   	if(intval!=""){
          window.clearInterval(intval);
          intval="";
		}
	});
	
	$('#link_change_language').mouseout(function(){
		if(intval!=""){
          window.clearInterval(intval);
          intval="";
		}
		intval = setInterval("killSubFooter()",500);
	});
	resizeContent();
		setTimeout(function(){
       resizeContent();
      },1000);
  $(window).resize(function() {
      resizeContent();
      setTimeout(function(){
       resizeContent();
      },1000);
    });
}
