
//This method is used to Show the first element of NeedList Module
function showFirstNeedList() {
    //Script will be run only on Live site
	if(Environment=="live")
    {
        //Call method to hide all collapsible items on Module   
        hideNeedListElement("categories");	   
    	
    	//Fetch all elements in NeedList module
	    var teaserElement = document.getElementById("categories");
	    var divTags = teaserElement.getElementsByTagName("div");	    
		var flag = "false";
		
		//set background color to blue for 1st element
		$(divTags).find(".module-content-3col:first").addClass("needlist-bg");		
		//Loop through all div elements and change the css class for the first list item
	    for(var count=0; (count<=divTags.length-1) && (flag != "true"); count++)
	    {

	        if (divTags[count].className == "toggle-button-MehrAnzeigen") {
	            divTags[count].className = "toggle-button-MehrAnzeigen display-none";
	        }
	        if (divTags[count].className == "toggle-button-Einklappen display-none") {
	            divTags[count].className = "toggle-button-Einklappen";
	        }

	        if (divTags[count].className == "needlist-details display-none")
		    {
			    divTags[count].className = "needlist-details";
				flag="true";
		    }

		}			
	}		
}

//This method is used to hide all collapsible elements of NeedList Module
function hideNeedListElement(obj) {
    //alert('hideNeedListElement');
    //Script will be run only on Live system
    if(Environment=="live")
    {	
	    teaserElement = document.getElementById("categories");
	    
	    //Fetch all elements in NeedList module
	    var divTags = teaserElement.getElementsByTagName("div");
	    var flag = "false";
		
		//Loop through all div elements and change the css class for the all list item
	    for(var count=0; (count<=divTags.length-1); count++)
	    {  
			if(divTags[count].className == "needlist-details")
		    {
			    divTags[count].className = "needlist-details display-none";
		    }
	        else if($(divTags[count]).hasClass('needlist-bg'))
	        {
	            $( divTags[count]).removeClass('needlist-bg')
	        }

	        if (divTags[count].className == "toggle-button-MehrAnzeigen display-none") {
	            divTags[count].className = "toggle-button-MehrAnzeigen";
	        }
	        if (divTags[count].className == "toggle-button-Einklappen") {
	            divTags[count].className = "toggle-button-Einklappen display-none";
	        }
	    }
		
    }
}

//This method is used to Show the collapsible element of NeedList Module
function showNeedListElement(teaserElement) {
    //Script will be run only on Live system
    if(Environment=="live") {

        var divTags = new Array();   
       if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) 
        {
            divTags = document.getElementById("categories").getElementsByTagName("div");            
             //Loop through all div elements and change the css class for the list item
            for(var count=0; (count<=divTags.length-1); count++)
            {
                if(divTags[count].className == "needlist-details display-none")
	            {
		            divTags[count].className = "needlist-details";
	            }

	            if (divTags[count].className == "toggle-button-MehrAnzeigen") {
	                divTags[count].className = "toggle-button-MehrAnzeigen display-none";
	            }
	            if (divTags[count].className == "toggle-button-Einklappen display-none") {
	                divTags[count].className = "toggle-button-Einklappen";
	            }

            }                   
        }
        //Call method to hide all collapsible items on Module    
        hideNeedListElement("categories");
        var parentDiv = $(teaserElement).parents(".module-content-3col.needlistCont");
        divTags = $(parentDiv).find("div");
        for(var count=0; (count<=divTags.length-1); count++)
        {
            if(divTags[count].className == "needlist-details display-none")
            {
	            divTags[count].className = "needlist-details";
            }
            if (divTags[count].className == "toggle-button-MehrAnzeigen") {
                divTags[count].className = "toggle-button-MehrAnzeigen display-none";
            }
            if (divTags[count].className == "toggle-button-Einklappen display-none") {
                divTags[count].className = "toggle-button-Einklappen";
            }          
        } 
        //Set the background color as blue       
        $(parentDiv).addClass('needlist-bg');
	}
}

//Set the background color as blue
function changeBackgroundColorMouseHover(teaserElement) {
    obj = document.getElementById("categories");
    var divTags = obj.getElementsByTagName("div");
    
    //Loop through all div elements and change the css class for the all list item
    for (var count = 0; (count <= divTags.length - 1); count++) {
        if ($(divTags[count]).hasClass('needlist-hover-bg')) {
            
            $(divTags[count]).removeClass('needlist-hover-bg')
        }
    }
    $(teaserElement).addClass('needlist-hover-bg');
}

//Set the background color as blue
function changeBackgroundColorMouseOut(teaserElement) {
    obj = document.getElementById("categories");
    var divTags = obj.getElementsByTagName("div");

    //Loop through all div elements and change the css class for the all list item
    for (var count = 0; (count <= divTags.length - 1); count++) {
        if ($(divTags[count]).hasClass('needlist-hover-bg')) {

            $(divTags[count]).removeClass('needlist-hover-bg')
        }
    }
}


//Call Methos to show first item expanded by default
showFirstNeedList();
