$(function() {
    
    // Arrondis des box
	$('.contentouebcam').prepend('<div class="bl"></div><div class="br"></div>');
	$('#pano_meteo').prepend('<div class="bl"></div><div class="br"></div>');
	$('#historique').prepend('<div class="bl"></div><div class="br"></div>');
	
	$('#ctl00_cphContent_ulHistorique1 li').each(function callback(index, domElement) {
	$(this).addClass('clock times'+index);
	});
	
	$('#ctl00_cphContent_ulHistorique2 li').each(function callback(index, domElement) {
	$(this).addClass('clock times'+index);
	});
	
	$(".bloc_content:not(:first)").hide();
	$("#pano_meteo h4:first").addClass("active");
	
	$("#pano_meteo h4").click(function(){
		$("#pano_meteo h4").removeClass("active");
		$(".bloc_content").hide();
		$(this).next(".bloc_content").show();
		$(this).addClass("active");

	});
    
    // Webcam en Flash
    if ((webcamUrl != undefined) && (webcamUrl != ''))
    {
    
	    var flashvars = { 
			playlist: "<playlist><item type='video' source='" + webcamUrl + "'/></playlist>"
		};	
		var params = {
			allowScriptAccess : "sameDomain",
			movie: "http://java.viewsurf.com/cg85/Player.swf",
			quality: "high",
			scale: "noScale",
			wmode: "transparent",
			allowFullScreen: "true"
		};
		swfobject.embedSWF("http://java.viewsurf.com/cg85/Player.swf", "flashCam", webcamHeight, webcamWidth, "9.0.0", false, flashvars, params);
    
	}
	
	// Cas particulier pour la webcam de St Hilaire : position du scroll
	if (webcamUrl.indexOf('sthilaireriez2') > -1) $('#visuelPanoramique').scrollLeft(390);
    
});

var supersleightMeteo	= function() {
	
	var root = false;
	var applyPositioning = true;
	
	// Path to a transparent GIF image
	var shim			= '/global/img/x.gif';
	
	// RegExp to match above GIF image name
	var shim_pattern	= /x\.gif$/i;
	
	
	
	var fnLoadPngs = function() { 
		if (root) {
			root = document.getElementById(root);
		}else{
			root = document;
		}
		for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
			// background pngs
			//if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
			//	bg_fnFixPng(obj);
			//}
			// image elements
			if (obj.tagName=='IMG' && obj.src.match(/\.png$/i) !== null){
				el_fnFixPng(obj);
			}
			// apply position to 'active' elements
			if (applyPositioning && (obj.tagName=='A' || obj.tagName=='INPUT') && obj.style.position === ''){
				obj.style.position = 'relative';
			}
		}
	};

	var bg_fnFixPng = function(obj) {
		var mode = 'scale';
		var bg	= obj.currentStyle.backgroundImage;
		var src = bg.substring(5,bg.length-2);
		if (obj.currentStyle.backgroundRepeat == 'no-repeat') {
			mode = 'crop';
		}
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
		obj.style.backgroundImage = 'url('+shim+')';
	};

	var el_fnFixPng = function(img) {
		var src = img.src;
		img.style.width = img.width + "px";
		img.style.height = img.height + "px";
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		img.src = shim;
	};
	
	var addLoadEvent = function(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			};
		}
	};
	
	return {
		init: function() { 
			addLoadEvent(fnLoadPngs);
		},
		
		limitTo: function(el) {
			root = el;
		},
		
		run: function() {
			fnLoadPngs();
		}
	};
}();

supersleightMeteo.limitTo('meteorologie');
supersleightMeteo.init();





