function loadPolice(crea)
{
  if (typeof sIFR == "function")
  {
      if (crea!=1)
      {
      	sIFR.replaceElement('.corpo_normal', named({sFlashSrc: "inc/siFR/corpoA_normal.swf", sColor: "#6d6d6d", sLinkColor:"#6d6d6d", sWmode: "transparent"}));
      	sIFR.replaceElement('.corpo_italic', named({sFlashSrc: "inc/siFR/corpoA_italic.swf", sColor: "#dd0505", sWmode: "transparent"}));
      	sIFR.replaceElement('.corpo_red', named({sFlashSrc: "inc/siFR/corpoA_normal.swf", sColor: "#dd0505", sWmode: "transparent"}));
      	sIFR.replaceElement('.conduit', named({sFlashSrc: "inc/siFR/conduit.swf", sFlashVars:"textalign=center", sColor: "#5f5e5e", sWmode: "transparent"}));
      	sIFR.replaceElement('.conduit_right', named({sFlashSrc: "inc/siFR/conduit.swf", sFlashVars:"textalign=right", sColor: "#5f5e5e", sWmode: "transparent"}));
      }
    	sIFR.replaceElement('.conduit_right_14', named({sFlashSrc: "inc/siFR/conduit.swf", sFlashVars:"textalign=right", sColor: "#5f5e5e", sWmode: "transparent"}));
      sIFR.replaceElement('.conduit_right_16', named({sFlashSrc: "inc/siFR/conduit.swf", sFlashVars:"textalign=right", sColor: "#5f5e5e", sWmode: "transparent"}));
      sIFR.replaceElement('.conduit_right_24', named({sFlashSrc: "inc/siFR/conduit.swf", sFlashVars:"textalign=right", sColor: "#5f5e5e", sWmode: "transparent"}));
  };
}

function loadGallery(div)
{
  if (div.indexOf('div_crea', 0)>0)
    $('#gallery_crea'+div.substring(9, div.indexOf(' ', 0))).boxplusGallery();	
}

function load(id_page, div, nom)
{
  $.ajax({
    url: 'ajax/page.php',
    data: 'id_page='+id_page+'&nom='+nom,
    success: function(data) {
      if (data!='') 
      {
        $(div).html(data);
        loadPolice(1);
        loadGallery(div);
      }
    }
  });
}


function sizeinit(){
	var wrapper_width = $(window).width();
	var wrapper_height = $(window).height();
	var header_height = $('#nav').height();
	pos = (wrapper_width-$('#header').width())/2;
	$('#header').css ('left', pos+'px');
	if (wrapper_height > 636)
		article_height = wrapper_height;
	else
		article_height = 636;	  
    if (wrapper_width > 1800)
		article_width = wrapper_width;
	else
		if(wrapper_width == 1280)
			article_width = 1280;
	else
		article_width = 1800;
	total_width = 0;
	$('.content').each(function(){
		$(this).css ('width', article_width+'px');
		total_width += $(this).width ();
	});
	total_width += 1000;
	$('#wrapper').css ('width', total_width+'px');	
	$('.article').css ('height', article_height+'px');	
	$('.inner').css ('width', wrapper_width+'px');	
	
    $.localScroll.hash({ axis: 'yx', lazy: true, easing: 'easeInOutExpo', hash: true, onBefore: function( e, anchor, $target ) { navig($(anchor).attr('id')); } });
}

jQuery.fn.hint=function(blurClass){if(!blurClass){blurClass='blur';}
return this.each(function(){var $input=jQuery(this),title=$input.attr('title'),$form=jQuery(this.form),$win=jQuery(window);function remove(){if($input.val()===title&&$input.hasClass(blurClass)){$input.val('').removeClass(blurClass);}}
if(title){$input.blur(function(){if(this.value===''){$input.val(title).addClass(blurClass);}}).focus(remove).blur();$form.submit(remove);$win.unload(remove);}});};

jQuery.extend( jQuery.easing, {
  def: 'easeInOutExpo',
  easeInOutExpo: function (x, t, b, c, d) {
    if (t==0) return b;
    if (t==d) return b+c;
    if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
    return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  }
});
function navig(id) {
    if (id=='') id='home1';
    $('a.activ').removeClass('activ');
    $('#goto'+id).addClass('activ');
    document.title = 'Hors Norme - ' + $('#'+id).attr('name');
  }
  
/*
$(window).resize(function(){
  sizeinit();
  $.localScroll.hash();
});
*/

var resizeTimer = null;
$(window).bind('resize', function() {
    if (resizeTimer) clearTimeout(resizeTimer);
    resizeTimer = setTimeout(sizeinit, 500);
})

$(function(){
  sizeinit();
  $("body").ezBgResize({img : "images/background.jpg"});
  var inithash = location.hash.slice(1);
  var mprev = '';
  var mnext = '';
  var msecid = '';


  if (inithash == '' && window.location.href.search('.*/creations\.php.*')==-1)
    document.location.href="index.php#home1";
  else  if (inithash == '' && window.location.href.search('.*/creations\.php.*')!=-1)
    document.location.href="creations.php#home1";

  
  navig(inithash);
  $.localScroll.defaults.axis = 'yx';
  $.localScroll({axis: 'yx', lazy: true, easing: 'easeInOutExpo', reset: false, lock: true, hash: true, onBefore: function( e, anchor, $target ) { navig($(anchor).attr('id')); } });

  
  
});

