/**
 * Prototype des fonctions générales pour tout le site valable sur toutes les pages
 */
var oProtoGeneral = {


	/**
	 * Initialisation de la page
	 */
	init: function () {

		// Initialise l'autocomplétion de la recherche
		if ($("#oACmot").length) {
			$("#oACmot").autocomplete('/include_/quicksearch.ajax.php', {
                    minChars: 1,
                    selectFirst: true,
                    width:200,
                    max:50 });
		}

		// Initialise les boutons rollover <- leftcol.js
        /*bouton1 = new Image; bouton1.src = "/images/boutphonefinder_f2.png";
		bouton2 = new Image; bouton2.src = "/images/boutcomparerprix_f2.png";
		bouton3 = new Image; bouton3.src = "/images/boutdeblocage_f2.png";*/

		// Initialise la rotation des news sur la homepage <- ui.tabs.function.js
		if ($("#rotate").length) {
			$("#rotate ul").tabs({ fxFade: true }).tabsRotate(7000);
			$("#rotate ul").tabs({ event: 'mouseover' });
		}

        // Initialise la liste des urls <- jumpmenu.js
        $("select[name='ListeUrl']").change(function() {
			location.href = $("select[name='ListeUrl']").val();
        });

		// Initialise le diaporama des photos
		if ($("#diapoTelephone").length) {
			$("#diapoTelephone a").lightBox({
				imageBlank: '/images/lightbox-blank.gif',
				imageLoading: '/images/lightbox-ico-loading.gif',
				imageBtnClose: '/images/lightbox-btn-close.gif',
				imageBtnPrev: '/images/lightbox-btn-prev.gif',
				imageBtnNext: '/images/lightbox-btn-next.gif'
			});
		}

        if ($.browser.msie && $.browser.version < 7) pngFix();

	},

	changeUrl: function(url) {
		location.href = url;
  }

};


/**
 * Prototype pour le comparateur de téléphone
 */
var oProtoCompare = {

	clickTel : function (checkbox) {
		nombre = $("#formComparateur :checkbox:checked").length;
		if (nombre > 3) {
			alert('Vous ne pouvez comparer que 3 téléphones maximum');
			checkbox.checked = false;
		}
	},

	submitForm : function () {
		nombre = $("#formComparateur :checkbox:checked").length;
		if (nombre > 3) {
			alert('Vous ne pouvez pas comparer plus de 3 téléphones');
			return false;
		} else if (nombre <= 1) {
			alert('Vous devez séléctionner au moins 2 téléphones pour comparer');
			return false;
		} else
			return true;
	}

};


// PNG transparency in Win IE 5.5 & 6
/*Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="/scripts_/pngfix.js"></script>
<![endif]-->*/
function pngFix() {

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) 
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}

}