<!--
$(document).ready(function () {
	/* hide submenu */
	$("ul.cache").css("display","none");

/*  SEARCH  */
	$(".search").click(function(e) {  
/* 		e.preventDefault(); */
    $('#inprogress').fadeIn("fast");
    
    var type = $("input:checked").val()
  	var what = $("input#search_for").val();

		var dataString = 'what='+ what + '&type=' + type;
	//	alert (dataString);return false;
		
	$.ajax({
    type: "POST",
    url: "include/search.php",
    data: dataString,
    success: function(html) {
    	$('#inprogress').fadeOut("fast");
      $('#left').html(html);
    }, 
    error: function(html){
    	$('#left').html('<p class="error">Une erreur s\'est produit veuillez réessayer plus tard.<br /> An error occurred, please try later.</p>');
    }
  });
  return false;
  });  

	/* Menu */

	$("a.link").click(
		function(e){
			e.preventDefault();
			var a_view = this.href.split('view='); 
			var p = a_view[1].split('&lang=');
			var pid = a_view[1].split('&p=');

			switch(p[0]){
				case "nouvelles":
					callNews();
					break;

				case "contact":
					callTxt("contact", p[1]);
					break;

				case "catalogue":
					callCat(p[0],"", p[1]);
					break;
					
				case "fiche":
					callCat(p[0],pid, p[1]);
					break;
					
				case "gestion":
					callTxt("gestion", p[1]);
					break;

				case "cestqui":
					callTxt("cestqui", p[1]);
					break;

				case "licence-adaptation":
					callTxt('licence-adaptation', p[1]);
					callLicenceAdapt(p[1]);
					break;

				case "licence-mecanique":
					callTxt('licence-mecanique', p[1]);
					callLicenceMeca(p[1]);
					break;

				case "licence-synchro":
					callTxt('licence-synchro', p[1]);
					callLicenceSynchro(p[1]);
					break;

				case "licence-graphique":
					callTxt('licence-graphique', p[1]);
					callLicenceReproGraph(p[1]);
					break;
			}
	});

/// RollOver / RollOut 
	$("#nouvelles").hover(
		function(){hideOthers("all");} 
	);

// editions
	$("#editions").hover(
		function () {
			hideOthers("smenu1");
			$(".smenu1").fadeIn("fast");
			//
			$(".smenu1").hover(
			function () {
				$(".smenu1").fadeIn("fast");
			}, 
			function () {
				$(".smenu1").hide();
		});	
	});

//catalogue
	$("#catalogue").hover(
		function () {
			hideOthers("smenu2");
			$(".smenu2").fadeIn("fast");
			//
			$(".smenu2").hover(
				function () {
					$(".smenu2").fadeIn("fast");
				}, 
				function () {
					$(".smenu2").hide();
				});	
		});

//licence
	$("#licence").hover(
		function () {
			hideOthers("smenu3");
			$(".smenu3").fadeIn("fast");
			//
			$(".smenu3").hover(
				function () {
					$(".smenu3").fadeIn("fast");
				}, 
				function () {
					$(".smenu3").hide();
				});	
		});
	
	$("#menu").hover(
		function(){}, 
		function(){
			$(".smenu1").hide();
			$(".smenu2").hide();
			$(".smenu3").hide();
		});

});

function hideOthers(which){
	//alert(which);
	switch(which){
		case "all":
			$(".smenu1").hide();
			$(".smenu2").hide();
			$(".smenu3").hide();
			break;
			
		case "smenu1":
			$(".smenu2").hide();
			$(".smenu3").hide();
			break;
		
		case "smenu2":
			$(".smenu1").hide();
			$(".smenu3").hide();
			break;
			
		case "smenu3":
			$(".smenu1").hide();
			$(".smenu2").hide();
			break;
	}
}

/* AJAX call */
function callNews(){
	$.ajax({
	  url: "include/a_news.php",
	  cache: false,
	  success: function(html){
		  $("#right").show();
		  $("#search").hide();
	    $("#left").html(html);
	  }
	});
}

function callBreves(){
	$.ajax({
	  url: "include/a_breves.php",
	  cache: false,
	  success: function(html){
		  $("#right").show();
		  $("#search").hide();
	    $("#content-right").html(html);
	  }
	});
}

function callCat(t,p,l){
	$.ajax({
	  url: "include/a_catalogue.php?view="+t+"&pid="+p+"&lang="+l,
	  cache: false,
	  success: function(html){
		  $("#right").hide();
		  $("#search").show();
	    $("#left").html(html);
	  }
	});
}

function callLicenceAdapt(l){
	$.ajax({
	  url: "include/form_licence.php?lang="+l,
	  cache: false,
	  success: function(html){
 		  $("#right").show();
		  $("#search").hide();
	    $("#left").append(html);
	  }
	});
}

function callLicenceReproGraph(l){
	$.ajax({
	  url: "include/form_licencereprog.php?lang="+l,
	  cache: false,
	  success: function(html){
 		  $("#right").show();
		  $("#search").hide();
	    $("#left").append(html);
	  }
	});
}

function callLicenceMeca(l){
	$.ajax({
	  url: "include/form_licence_meca.php?lang="+l,
	  cache: false,
	  success: function(html){
 		  $("#right").show();
		  $("#search").hide();
	    $("#left").append(html);
	  }
	});
}

function callLicenceSynchro(l){
	$.ajax({
	  url: "include/form_licence_synchro.php?lang="+l,
	  cache: false,
	  success: function(html){
 		  $("#right").show();
		  $("#search").hide();
	    $("#left").append(html);
	  }
	});
}

function callTxt(v,lng){
	$.ajax({
	  url: "include/a_txt.php?view="+ v +"&lang="+lng,
	  cache: false,
	  success: function(html){
 		  $("#right").show();
		  $("#search").hide();
	    $("#left").html(html);
	  }
	});
}

function playExtrait(song, oeuvre, interprete){
	thisMovie("editions").playExtrait(song, oeuvre, interprete);
}

function thisMovie(movieName) {
  if (navigator.appName.indexOf("Microsoft") != -1) {
  	return window[movieName]
  }else if(document[movieName].length != undefined){
  	return document[movieName][1];
  }else{
	  return document[movieName]
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/*******************************/
/* FUNCTION confirm_del_link() */
/*******************************/
// Displays an confirmation box beforme to submit a "DELETE" query.
// receives:
//   the url (ex: www.molior.ca)
//   the language (1=French, 0=English)
//   a string identifying the data to delete (ex: 'Datadatadata...')
// returns:
//   true if the browser is Opera or the user cliked yes,
//   false otherwise

function confirm_del_link(the_url, lang, del_str)
{
  // Browser is Opera (crappy js implementation)
  if (typeof(window.opera) != 'undefined') {
    return true;
  }
  
  if (lang) {
    var confirm_del_msg = 'Voulez-vous vraiment supprimer cette entrée\n';
  } else {
    var confirm_del_msg = 'Do you really want to delete:\n';
  }
  
  var is_confirmed = confirm(confirm_del_msg); //+ del_str

  return is_confirmed;
} // --> end of the 'confirmLink()' function
