// Default configuration follows structure:
// div[#uniqueId] h3 tag[.toggle]

// The below lines let you re-configure
// but .toggle click event must be nested
// inside ID container

// From your container id use a > for
// each level down the toggle switch is.
togglePath =">"; // where the on click event happens
toggleTextPath =">"; // where the open close text is embedded

// Path which points from .toogle
// to container with ID
parentPath ='.parent("div")'; // .parent("h3").parent("div")

// Define the tag you want to show/collapse
// Use a tag name or class within your container
hideObjectType =".hide_slider";

// Set the appended button text
closeText = "Close";
openText = "Open";

// SlickerBox as default will display a close state
// Add in ID's which you wish to set to default as open

// Add arrow images to click event?
// Attach via css bakground-image
// Without JavaScript degrades gracefully

var defaultIdsSetOpen = new Array("strengthen_the_pipeline");
var defaultIdsSetOpen2 = new Array("grow_the_business");	 
var defaultIdsSetOpen3 = new Array("reshape_the_business");
var defaultIdsSetOpen4 = new Array("promote_a_culture");

$(document).ready(function(){      
						   
	//alert('hoi');
	url = document.location.href;
	//alert(url);
	query_string = url.substring(url.indexOf("?"));
	//alert(query_string);
	//didler="";
	//if (query_string == "?a=1")
	//{
		//didler=1;
		//alert(didler);
	//}
	
	if (query_string=="?a=2") 
	{
		//alert("didler");
		matey = defaultIdsSetOpen2;
	}
	else if(query_string=="?a=3") 
	{
		//alert("no dider");
		matey = defaultIdsSetOpen3;
	}
	else if(query_string=="?a=4") 
	{
		//alert("no dider");
		matey = defaultIdsSetOpen4;
	}
	else
	{
		matey = defaultIdsSetOpen;
	}
		
	var toggleClass = new Array();    
    toggleClass = $(".toggle");    
    for (i=0; i<toggleClass.length; i++)
    {        
        var toggleClassIds = null;
        eval('toggleClassIds =$(toggleClass[i])'+parentPath+'.attr("id")');
		
		
		
		
        if (toggleClassIds == matey)
        {
            $('#'+toggleClassIds+' '+hideObjectType).show();
			$("#"+toggleClassIds+" .toggle span").text(closeText)
            $("#"+toggleClassIds+" .toggle").addClass("open");
        }
        else
        {
            $('#'+toggleClassIds+' '+hideObjectType).hide();
            $("#"+toggleClassIds+" .toggle").addClass("closed");
            $("#"+toggleClassIds+" .toggle span").text(openText);
        }
    }      
	
	$('.toggle').hover(function(){                                    
       	var qid = null;
		eval('qid=$(this)'+parentPath+'.attr("id")');
		$("#"+qid + togglePath + ".toggle").addClass("hover");
		}, function(){
		var qid = null;
		eval('qid=$(this)'+parentPath+'.attr("id")');
		$("#"+qid + togglePath + ".toggle").removeClass("hover");	
	});
	
    $('.toggle').click(function(){                                    
        var qid = null;
        eval('qid=$(this)'+parentPath+'.attr("id")');
        return slickerBox(qid);
        return false;
    });     
});

function slickerBox(qid){
    var textLocation = $("#"+qid+" "+toggleTextPath+" .toggle span").text();    
    if (textLocation == openText)
    {
        $("#"+qid + togglePath + ".toggle span").text(closeText);
        $("#"+qid + togglePath + ".toggle").removeClass("closed");
        $("#"+qid + togglePath + ".toggle").addClass("open");
    }
    else if (textLocation == closeText)
    {
        $("#"+qid + togglePath + ".toggle span").text(openText);
        $("#"+qid + togglePath + ".toggle").removeClass("open");
        $("#"+qid + togglePath + ".toggle").addClass("closed");
    }    
    $('#'+qid+' '+hideObjectType).slideToggle(400);
    return false;
}
