cyrilleinvalides/choupas/www/admin/libs/scripts/collapsemenu.js

340 lines
7.8 KiB
JavaScript
Executable File

//<!--
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("windows")!=-1) );
var is_mac = (agt.indexOf("mac")!=-1);
var isNav4, isNav6, isIE4;
function setBrowser()
{
if (is_ie)
{
isIE4 = true;
}
else if (is_nav6up)
{
isNav6 = true;
}
else
{
isNav4 = true;
}
}
function getStyleBySelector( selector )
{
if (!isNav6)
{
return null;
}
var sheetList = document.styleSheets;
var ruleList;
var i, j;
for (i=sheetList.length-1; i >= 0; i--)
{
ruleList = sheetList[i].cssRules;
for (j=0; j<ruleList.length; j++)
{
if (ruleList[j].type == CSSRule.STYLE_RULE && ruleList[j].selectorText == selector)
{
return ruleList[j].style;
}
}
}
return null;
}
function getIdProperty( id, property )
{
if (isNav6)
{
var styleObject = document.getElementById( id );
if (styleObject != null)
{
styleObject = styleObject.style;
if (styleObject[property])
{
return styleObject[ property ];
}
}
styleObject = getStyleBySelector( "#" + id );
return (styleObject != null) ?
styleObject[property] :
null;
}
else if (isNav4)
{
return document[id][property];
}
else
{
return document.all[id].style[property];
}
}
function setIdProperty( id, property, value )
{
if (isNav6)
{
var styleObject = document.getElementById( id );
if (styleObject != null)
{
styleObject = styleObject.style;
styleObject[ property ] = value;
}
}
else if (isNav4)
{
document[id][property] = value;
}
else if (isIE4)
{
document.all[id].style[property] = value;
}
}
function generic_move( id, xValue, yValue, additive )
{
var left = getIdProperty(id, "left");
var top = getIdProperty(id, "top");
var leftMatch, topMatch;
if (isNav4)
{
leftMatch = new Array( 0, left, "");
topMatch = new Array( 0, top, "");
}
else if (isNav6 || isIE4 )
{
var splitexp = /([-0-9.]+)(\w+)/;
leftMatch = splitexp.exec( left );
topMatch = splitexp.exec( top );
if (leftMatch == null || topMatch == null)
{
leftMatch = new Array(0, 0, "px");
topMatch = new Array(0, 0, "px");
}
}
left = ((additive) ? parseFloat( leftMatch[1] ) : 0) + xValue;
top = ((additive) ? parseFloat( topMatch[1] ) : 0) + yValue;
setIdProperty( id, "left", left + leftMatch[2] );
setIdProperty( id, "top", top + topMatch[2] );
}
function moveTo( id, x, y )
{
generic_move( id, x, y, false );
}
function moveBy( id, x, y)
{
generic_move( id, x, y, true );
}
function hex( n )
{
var hexdigits = "0123456789abcdef";
return ( hexdigits.charAt(n >> 4) + hexdigits.charAt(n & 0x0f) );
}
function getBackgroundColor( id )
{
var color;
if (isNav4)
{
color = document[id].bgColor;
}
else if (isNav6)
{
var parseExp = /rgb.(\d+),(\d+),(\d+)./;
var rgbvals;
color = getIdProperty( id, "backgroundColor" );
if (color)
{
rgbvals = parseExp.exec( color );
if (rgbvals)
{
color = "#" + hex( rgbvals[1] ) + hex( rgbvals[2] ) +
hex( rgbvals[3] );
}
}
return color;
}
else if (isIE4)
{
return document.all[id].backgroundColor;
}
return "";
}
function getDocument( divName )
{
var doc;
if (isNav4)
{
doc = window.document[divName].document;
}
else if (isNav6)
{
doc = document;
}
else if (isIE4)
{
doc = document;
}
return doc;
}
function stopError()
{
return true;
}
function findOwner( evt )
{
var node;
if (isNav6)
{
node = evt.target;
while (node)
{
if ( node.nodeType == Node.ELEMENT_NODE &&
node.nodeName == "DIV")
{
return node;
}
node = node.parentNode;
}
}
else if (isIE4)
{
node = window.event.srcElement;
while (node)
{
if (node.tagName == "DIV")
{
return node;
}
node = node.parentElement;
}
}
return null;
}
function dim( evt )
{
var divObj = findOwner( evt );
if (isNav6) { divObj.style.cursor = "default"; }
//divObj.style.color = "#B25600";
divObj.style.backgroundColor= "#343434";
this.className='mhead';
}
function getObject( nameStr )
{
if (isNav6)
{
return document.getElementById( nameStr );
}
else if (isIE4)
{
return document.all[nameStr];
}
}
function showMenu( evt )
{
var owner = findOwner( evt );
var divNum;
if (isNav6)
{
divNum = owner.attributes.getNamedItem("id").nodeValue;
}
else if (isIE4)
{
divNum = owner.id;
}
divNum = parseInt( divNum.substr(1));
if (getIdProperty( "s" + divNum, "display") != "block" )
{
setIdProperty("s" + divNum, "display", "block");
//document.images["i" + divNum].src = "img/bullet2.gif";
}
else
{
setIdProperty("s" + divNum, "display", "none");
//document.images["i" + divNum].src = "img/bullet1.gif";
}
}
function setupAction( node )
{
if (isNav6)
{
node.addEventListener( "click", showMenu, false);
node.addEventListener( "mouseover", highlight, false );
node.addEventListener( "mouseout", dim, false );
node.style.fontWeight = "bold";
}
else if (isIE4)
{
node.onclick = showMenu;
node.onmouseover = highlight;
node.onmouseout = dim;
}
}
function setupEvents()
{
var i;
var theNode;
for (i=0; i<vocabList.length; i++)
{
theNode = document.getElementById( "s" + i );
setupAction( theNode );
}
}
function setup()
{
var i;
var obj;
for (i=0; i < 60; i++)
{
obj = getObject( "m" + i );
setupAction( obj );
}
}
setBrowser();
function showAnswers()
{
setIdProperty( "answers", "visibility", "visible" );
}
setBrowser();
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function submitForm() { //v4.0
var obj,l,args=submitForm.arguments; val=document.MM_returnValue; val=(val==null)?true:val;
if(val){obj=MM_findObj(args[0]);l=args.length; if(obj){if(l>2){for (i=2; i<(l-1); i+=2)
{eval("obj."+args[i]+"='"+args[i+1]+"';")}} eval("obj."+args[1]+"();");}}
document.MM_returnValue = false;
}
function highlight( evt )
{
var divObj = findOwner( evt );
if (isNav6) { divObj.style.cursor = "pointer"; }
//divObj.style.color = "#FFEBB5";
divObj.style.backgroundColor= "#555555";
this.className='mhover';
}
//-->