/**
 * @title		yBox
 * @vesrion		0.0.1
 * @author		ylo
 */
// js class on html tag
document.getElementsByTagName("html")[0].className = "js";


/**
 * @section		png fix configuration
 */
pxPath = 'tpl/img/common/bg/px.gif';


// general inits
$(document).ready(function () {
	
	// init isIE
	manageIsIE.init();
	
	// png fix
	fixPng();
	
});


/**
 * @section		create global var ieIE 6, 7 & 8
 */
var isIE = false;
var manageIsIE = {
	init: function () {
		if (jQuery.browser.msie) {
			isIE = true;
			if(parseInt(jQuery.browser.version) == 6) {
				isIE = 6;
			} else if (parseInt(jQuery.browser.version) == 7) {
				isIE = 7;
			} else if (parseInt(jQuery.browser.version) == 8) {
				isIE = 8;
			}
		}
	}
};


/**
 * @section		fix png images
 * @affect		IE6
 */
function fixPng(elmt) {

	if(isIE == 6) {
		if(elmt) {
			var container = $(elmt);
		} else {
			var container = $('html');
		}
		var oImage = $('img', container);
		
		if(!oImage.length)  return;
		for(var i=0;i<oImage.length;i++) {
			if(oImage[i].src.indexOf('.png') > -1) {
				with(oImage[i].style) {
					background = 'none';
					filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + oImage[i].src + '", sizingMethod="image")';
				}
				oImage[i].src = pxPath;
			}
		}
	}
	
}

/**
 * @section		drop down menu (main menu)
 */
var manageSlideDownMenu = {
	config: {
		duration: 200
	},
	enter: function (obj) {
		// WARNING : soulever l'événement sur l'élément LI, pas sur le A
		$(obj).addClass('select');
		var $this = $('> ul', obj); 
		$this.css({display:'block'});/*.slideDown(manageSlideDownMenu.config.duration, function () {
			//$(this).removeAttr('style')
			manageFullscreenBg.update();
		});*/
		
	},
	leave: function (obj, config) {
		switch (config) {
			case 'slide' :
				$('> ul', obj).stop({clearQueue:true, gotoEnd:true}).slideUp(manageSlideDownMenu.config.duration, function () {
					//$(this).removeAttr('style')
					$(obj).removeClass('select');
					
				});
			break;
			default :
				//$('> ul', obj).stop({clearQueue:true, gotoEnd:true}).removeAttr('style');
				$('> ul', obj).stop({clearQueue:true, gotoEnd:true}).css({'display': 'none'});
				$(obj).removeClass('select');
		}
	}
};

