/* Javascript - Sport 2000 */

/***** Index *****/
// 00 - MSC - Rescue
// 10 - MSC - Events
// 20 - Navigations
// 99 - onLoad
/***************/

/***** 00 - MSC - Rescue *****/
function msc_rStart(){
	if(msc_nIe && !msc_nIe7){
		var parent = arguments[0].parentNode;
		var frame = document.createElement('iframe');
		var elem = parent.insertBefore(frame,arguments[0]);
		if(elem){
			elem.className = 'rescue';
			elem.style.position = 'absolute';
			elem.style.left = arguments[0].offsetLeft+'px';
			elem.style.top = arguments[0].offsetTop+'px';
			elem.style.width = arguments[0].offsetWidth+'px';
			elem.style.height = arguments[0].offsetHeight+'px';
			elem.style.filter = 'alpha(opacity=0);';
		}
	}
}
function msc_rEnd(){
	if(msc_nIe && !msc_nIe7){
		var parent = arguments[0].parentNode;
		var frame = msc_c('iframe','rescue',parent)[0];
		var elem = parent.removeChild(frame);
	}
}

/***** 10 - MSC - Events *****/
function msc_eAdd(o,e,f,p){
	var b = "f"+f; b = b.substring(b.indexOf(" "),b.indexOf("("));
	var a  = Array.prototype.splice.call(arguments,4,arguments.length);
	o[e+b] = function(e){ if(o.ev){ a.pop(); } else { o.ev = true; } a.push(e); f.apply(o,a); }
	if(o.attachEvent){ o.attachEvent("on"+e,o[e+b]); } else if(o.addEventListener){ o.addEventListener(e,o[e+b],p); }
}
function msc_eRemove(o,e,f,p){
	var b = "f"+f; b = b.substring(b.indexOf(" "),b.indexOf("("));
	if(o.detachEvent){ o.detachEvent("on"+e,o[e+b]); } else if(o.removeEventListener){ o.removeEventListener(e,o[e+b],p); }
	o.ev = undefined;
}

/***** 20 - Navigations *****/
function nHover(){
	msc_s('add',this,'hover');
}
function nOut(){
	msc_s('del',this,'hover');
}

/*** Permet de voir les png transparent sous ie6 ***/
function hackPng(){
  if (navigator.appVersion.indexOf("MSIE 6")!=-1)
    for (i = 0; i < document.images.length; i++)
      if (document.images[i].src.substring(document.images[i].src.length-3, document.images[i].src.length) == "png") 
      {
        document.images[i].style.height = document.images[i].height + "px";
        document.images[i].style.width = document.images[i].width + "px";
        document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + document.images[i].src + ",sizingMethod='scale')";
        document.images[i].src = "/S2K_Mountain_Root/Includes/Skins/Common/Css/Images/Dots/pix.gif";
      }
}

/***** 99 - onLoad *****/
function wLoad(){
	hackPng();
	
	// 20 - Navigations
	var n = msc_c('div','navigation',msc_o('header'));
	for(var i=0; i<n.length; i++){
		var li = n[i].getElementsByTagName("li");
		for(var j=0; j<li.length; j++){
			li[j].onmouseover = nHover;
			li[j].onmouseout = nOut;
		}
	}
	var l = msc_c('li','language',msc_o('toolbar'));
	for(var i=0; i<l.length; i++){
		l[i].onmouseover = nHover;
		l[i].onmouseout = nOut;
	}
	
}
msc_eAdd(window, "load", wLoad, false);

function afficheMaterielLayer(o) {
    o.id2 = "id" + o.title;
    document.getElementById(o.id2).style.display = "block";
}

function cacheMaterielLayer(o) {
    o.id2 = "id" + o.title;
    document.getElementById(o.id2).style.display = "none";
}

function ShowHideDetails(targetDiv, targetButton, sourceButton) {
    (document.getElementById(targetDiv).style.display == 'block') ? document.getElementById(targetDiv).style.display = 'none' : document.getElementById(targetDiv).style.display = 'block';
    document.getElementById(targetButton).style.display = '';
    document.getElementById(sourceButton).style.display = 'none' ;
}

function getID (id) {
	return document.getElementById(id);
}

function basketAddHide (id) {
	var time = setTimeout(function(){
		if (!getID(id)) {
			clearTimeout(time);
			return;	
		}
		var alpha = 100;
		var interval = setInterval(function(){
			if (alpha<=0||!getID(id)) clearInterval(interval);
			if (getID(id)) {
				getID(id).parentNode.style.filter = 'alpha(opacity='+alpha+')';
				getID(id).parentNode.style['-moz-opacity'] = alpha/100;
				getID(id).parentNode.style.opacity = alpha/100;
				alpha -= 10;
			}
		},15);
	},500);
}

var altInfosTime;
function altInfos (id,html) {
    var el, o, i, time;
    el = getID(id);
    if (!el) return;
    o = el.getElementsByTagName(html);
	for (i=0;i<o.length;i++) {
		o[i].onmousemove = function (e) {
			if(!e) e = window.event;
			if (altInfosTime) clearTimeout(altInfosTime);
			altInfosView(e,this);
		}
		o[i].onmouseout = function () {
			altInfosTime = setTimeout(function(){
				if (getID('altInfos')) {
					getID('altInfos').innerHTML = '';
					getID('altInfos').style.visibility = 'hidden';
				}
			},100);			
		}
	}
}

function altInfosView (e,o,test) {
    if (o.title != "") {
        o.rel = o.title;
		o.title = "";
    }

	var altInfos = getID('altInfos');
	if (!altInfos&&o.innerHTML!='') {
		var d = document.createElement("div");
		d.id = 'altInfos';
		document.body.appendChild(d);
		altInfos = getID('altInfos');
		altInfos.onmouseover = function (e) {
			if (altInfosTime) clearTimeout(altInfosTime);
		}
	}
	if (altInfos&&o.innerHTML=='') {
		altInfos.style.visibility = 'hidden';
		altInfos.innerHTML = '';
		return;	
	}

	if (altInfos) {
	    altInfos.innerHTML = '<span></span>' + o.rel;
		altInfos.style.left = (e.clientX-20)+'px';
		altInfos.style.top = (e.clientY-45)+'px';
		altInfos.style.visibility = 'visible';
    }

    getID('altInfos').onmouseout = function () {
        if (getID('altInfos')) {
            getID('altInfos').innerHTML = '';
            getID('altInfos').style.visibility = 'hidden';
        }
    }
	
}
















