// JavaScript Document
window.addEvent('domready', function() {
	var szNormal = 141, szSmall  = 82, szFull   = 498 ;

	var kwicks = $$("#kwicks .kwick");
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
	kwicks.each(function(kwick, i) {
		kwick.addEvent("mouseenter", function(event) {
			var o = {};
			o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("width").toInt();
					if(w != szSmall) o[j] = {width: [w, szSmall]};
				}
			});
			fx.start(o);
		});
	});

	$("kwicks").addEvent("mouseleave", function(event) {
		var o = {};
		kwicks.each(function(kwick, i) {
			o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
		});
		fx.start(o);
	})

	/**
	 * That CSS selector will find all <a> elements with the
	 * class boxed
	 *
	 * The example loads the options from the rel attribute
	 */
	SqueezeBox.assign($$('a.boxed'), {
		parse: 'rel'
	});

});

function showMyForm(tab,id_tab){
  // id formulaire
  var recherche_form = document.getElementById("recherche");
  var recherche_champs_form = document.getElementById("recherche_champs");
  // liste action et methode
  var liste_action = ["http://mikuru.haruhi.fr/post","http://yuki.haruhi.fr/index.php/Accueil/index.php/Special:Search","http://suzumiya.haruhi.fr/index.php?action=search2","http://kyon.haruhi.fr/recherche/"];
  var liste_method = ["get","","post","get"];
  var liste_recherche_champs_name = ["tags","search","search","search"];
  // liste des onglets
  var liste_buttons = document.getElementById("buttons").getElementsByTagName('LI');
  // onglet courant
  var tab_id = document.getElementById(tab_id);
  
  // choix du formulaire de recherche
  recherche_form.action =liste_action[id_tab];
  recherche_form.method =liste_method[id_tab];
  recherche_champs_form.name =liste_recherche_champs_name[id_tab];

  // gestion visuel des onglets
  for(var i=0;i<liste_buttons.length;i++){
    liste_buttons[i].style.backgroundPosition = "0 -36px";
    liste_buttons[i].style.color = "#FFF"
  }
  tab.style.backgroundPosition = "0 0";
  tab.style.color = "#D01F27"
}
