/**********************************************
* Browser definition                          *
**********************************************/
if (navigator.userAgent.toLowerCase().indexOf('msie') != -1 && navigator.userAgent.toLowerCase().indexOf('opera') == -1) {
	var isIE = true;
	//get IE version
	if (navigator.userAgent.toLowerCase().indexOf("msie 5.5") != -1) {
		var isIE55 = true;
	} else if (navigator.userAgent.toLowerCase().indexOf("msie 6") != -1)  {
		var isIE6 = true;
	} else if (navigator.userAgent.toLowerCase().indexOf("msie 7") != -1)  {
		var isIE7 = true;
	}
} else if (navigator.userAgent.toLowerCase().indexOf('opera') != -1) {
	var isOp = true;
} else if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1 || 
		  (navigator.userAgent.toLowerCase().indexOf('mozilla') != -1 && (navigator.userAgent.toLowerCase().indexOf('rv:1.7') != -1 || navigator.userAgent.toLowerCase().indexOf('rv:1.8') != -1))) {
	var isMoz = true;
}


/**
  * Add an event on a given object
  * @param html object obj, the object to add event on
  * @param string evType, the event type to add (click, mouseover, blur, etc.)
  * @param string fcn, the function name to call on event
  * @return boolean true on success, false on failure
  */
function WG_addEvent(obj, evType, fcn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fcn, true);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on"+evType, fcn);
		return r;
	} else {
		return false;
	}
	return true;
}

/**
  * Stop event on a given object
  * @param html object e, the object to stop event on (if none (IE case mostfully), get it from window.event) 
  * @return void
  */
function WG_cancelEvent(e) {
    var e = e || window.event;
	
    e.cancelBubble = true; // for IE
    if (typeof e.stopPropagation == 'function')
        e.stopPropagation();

    e.returnValue = false; // for IE
    if (typeof e.preventDefault == 'function')
        e.preventDefault();
}

/**
  * Get element by id
  * @param string id, the element id to get
  * @return wanted element or false if not founded
  */
function WG_getE(id) {
	if (e = document.getElementById(id)) { 
		return e;
	} else {
		return false;
	}
}

//FO_openPopupImage
//IN: le chemin d'une image
//OUT : -
//Description : ouvre une popup et la resize à la taille de l'image
function FO_openPopupImage(vSrc){
	var str_url = 'popup.html';
	var str_name = 'Agrandissement';
	var str_args = 'width=10,height=10,toolbar=no,scrollbars=no,resizable=yes';
	//ouvre la fenetre
	w = window.open (str_url, str_name, str_args);
	w.document.writeln('<html><head><title>BaseballShop</title>');
	w.document.writeln('<script language="javascript">');
	w.document.writeln('function checksize()  {  '); 
	w.document.writeln('var w = document.images[0].width; ');
	w.document.writeln('var h = document.images[0].height; ');
	w.document.writeln('window.resizeTo(w+10, h+50); ');
	w.document.writeln('window.focus(); ');
	w.document.writeln('}');
	w.document.writeln('</script>');
	w.document.writeln('</head>');
	w.document.writeln('<body onload="javascript:checksize();" leftMargin="0" topMargin="0">');
	w.document.writeln('<div align="center"><a href="#" onClick="javascript:window.close();"><img src="'+vSrc+'" border="0"></a></div>');
	w.document.writeln('</body></html>');
	w.document.close();
}

//FO_openPopup
//IN: -
//OUT : -
//Description : ouvre la popup produits
function FO_openPopup(){
	var str_url = 'popup.php'
	var str_name = 'Agrandissement';
	var str_args = 'width=583,  height=500, scrollbars=yes,resizable=yes';
	//ouvre la fenetre
	window.open (str_url, str_name, str_args);
}
//FO_openPopup
//IN: -
//OUT : -
//Description : ouvre la popup conditions
function FO_openPopupConditions(){
	var str_url = 'conditions.php'
	var str_name = 'Agrandissement';
	var str_args = 'width=583,  height=500, scrollbars=yes,resizable=yes';
	//ouvre la fenetre
	window.open (str_url, str_name, str_args);
}
