/* Javascript - Touvet */

/***** Review *****/
// 00 - autoRoll
// 05 - Popup
// 99 - onLoad / onUnLoad
/*****************/

/***** 00 - autoRoll *****/
var onAdd = '-on';
var activeAdd = '-active';
function autoRoll(Img,Event){
	if(!Img.onmouseout && Event == true) Img.onmouseout = function(){ autoRoll(Img) };
	imgExt = Img.src.substring(Img.src.lastIndexOf("."));
	imgName = Img.src.substring(0,Img.src.lastIndexOf("."));
	imgOn = imgName+onAdd+imgExt;
	if(imgName.indexOf(onAdd) != -1) imgName = imgName.substring(0,imgName.length-onAdd.length);
	imgOff = imgName+imgExt;
	if(Img.src.indexOf(onAdd) != -1) Img.src = imgOff;
	else Img.src = imgOn;
}

function autoRollEvents(){
	var imgTable = arguments[0].getElementsByTagName('img');
	for(var i=0; i<imgTable.length; i++){
		if(imgTable[i].src.indexOf(onAdd) == -1 && imgTable[i].src.indexOf(activeAdd) == -1) imgTable[i].onmouseover = function(){autoRoll(this,true)};
	}
}

/***** 05 - Popup *****/
function popThis(url,nom,isCenter,w,h,o){
	if(isCenter){
		var popHPos = (screen.availWidth/2)-(w/2);
		var popVPos = (screen.availHeight/2)-(h/2);
		pop = window.open(url,nom,'width='+w+',height='+h+',top='+popVPos+',left='+popHPos+','+o);
	} else {
		pop = window.open(url,nom,'width='+w+',height='+h+','+o);
	}
	pop.focus();
}

/***** 99 - onLoad / onUnLoad *****/
window.onload = function(){
	
	// 00 - autoRoll
	if(_('navigation')){
		autoRollEvents(_('navigation'));
	}
	if(_('homeLinks')){
		autoRollEvents(_('homeLinks'));
	}
	
}

window.onunload = function(){

}
