// JavaScript Document

ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: true, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs) ----  in this part we put plus.giff & munus.giff image
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})

var slideId = -1;
        var isAminating = false;
        var useSlide = true;
        var supportedBrowser = isSupported();


        function isSupported()
        {
            if (typeof document.documentElement.style.maxHeight != "undefined") 
            {
                return true;
            }
            return false;
        }

        function slideIn()
        {
            var layer = document.getElementById('theImg');
            if(layer.height < 130 )
            { 
                layer.height  += 2;
            }
            if(layer.width < 130)
            {
                layer.width += 2;
            } // 418 X 559
            if( (layer.height >= 130 ) && (layer.width >= 130) )
            {
              clearInterval(slideId);
              isAnimating = false;
            }
        }
        
        function OnImgMouseOver( ev , caller)
        {
            if(!supportedBrowser)
            {
                return;
            }

            if(!isAminating)
            {
            var elm = caller;
            isAminating = true;
                var parts = new Array();
                var layer = document.getElementById('PopUpLayer');
            if( layer  == null )
                {
                WriteLayers();
                layer = document.getElementById('PopUpLayer');
                }
                parts = elm.getAttribute('src').split('/');
                layer.innerHTML = '<div style="position: relative;margin:0;padding:0;left: 5px; top: 5px;background-color: black;"> <div style="background-color: silver;"> <div style="border: 1px solid black;position: relative;left: -5px;top: -5px;"><img id="theImg" height="0" width="0" src=' + elm.getAttribute('src').replace('92/69',"559/418")  + ' ></div></div> </div>';
                layer.style.top    =  NewfindPosY( elm ) + 'px';
                layer.style.left  =  NewfindPosX( elm ) + elm.width + 10 + 'px'; 
                layer.style.visibility = 'visible';
                slideId = setInterval(slideIn,1);
            }
        }

        function OnImgMouseOut(ev)
        {  
            if(!supportedBrowser)
            {
                return;
            }
            var layer = document.getElementById('PopUpLayer');
            if( layer  == null )
            {
                return;
            }
            layer.style.visibility = 'hidden';
            clearInterval(slideId);
            isAminating = false;
        }


        /**********************************************/
        /* positioning of popuplayer                  */
        /**********************************************/

        function NewfindPosX(obj)
        {
            var curleft = 0;
            if (obj.offsetParent)
            {
                while (obj.offsetParent)
                {
                    curleft += obj.offsetLeft
                    obj = obj.offsetParent;
                }
            }
            else if (obj.x)
                curleft += obj.x;
            return curleft;
        }

        function NewfindPosY(obj)
        {
            var curtop = 0;
            if (obj.offsetParent)
            {
                while (obj.offsetParent)
                {
                    curtop += obj.offsetTop
                    obj = obj.offsetParent;
                }
            }
            else if (obj.y)
                curtop += obj.y;
            return curtop;
        }

        function WriteLayers()
        {
          var body = document.getElementsByTagName('body')[0];
          var layer = document.createElement('div');
          layer.id = 'PopUpLayer';
          layer.name = 'PopUpLayer';
          layer.style.visibility = 'hidden';
          layer.style.position = 'absolute';
          body.appendChild(layer);
        }
