// jquery.generalSite.js Dynamat
// www.numerique.ca

$(function(){
		
		$(document).pngFix();
		
		/* liens externes */
		$("a[href^='http:']").not("[href*=" + location.hostname + "]").attr('target','_blank').not(":has(img)").not("[id]").after('<img src="/images/icones/icone_externe.gif" alt="lien externe" style="margin-left:3px;"/>');    
		/* ajout de la fonction print */
		
        
		$("#btnPrint").show().click(function(){window.print();});
        $("#btnEnvoyer").show();
        $.nyroModalSettings({
            processHandler: function(settings){
                var scaleRatio = 1;
                var from = settings.from;
                if (from && from.href && from.href.indexOf('http://www.youtube.com/watch?v=') == 0)
				{
                    $.nyroModalSettings({
                        type: 'swf',
                        width: (640 * scaleRatio),
                        height: (370 * scaleRatio),
                        url: from.href.replace(new RegExp("watch\\?v=", "i"), 'v/')
                    });
                }
                else {
                    if (from.href.indexOf('tableauDimensions.php') >= 0){
                        $.nyroModalSettings({
                        width: (700),
                        height: (100),
                        url: from.href 
                        });
                    }
                    else {
                        if (from.href.indexOf('tableauDimensions_ang.php') >= 0){
                            $.nyroModalSettings({
                            width: (700),
                            height: (100),
                            url: from.href 
                            });
                        }
                        else{
                            $.nyroModalSettings({
                            width: (500),
                            height: (650),
                            url: from.href 
                            });
                        }
                    }
                }
            }
        });
            
		$("p[class^='numeroDeTelephone']").formaterTelIPhone();
});

/*
  Ajout du protocol tel: sur les numéros de téléphone, pour iPhone OS
  Abel Laflamme - 8 juin 2010
*/
jQuery.fn.formaterTelIPhone = function () {
  if (navigator.userAgent.match(/iPhone/i)) {
   	 $(this).wrapInner('<a href="tel:'+$(this).text().replace(/[^0-9]+/g,'')+'"></a>');
  }
}
