
Df.createNS('rckp.left.nav', window);

Event.observe(window, 'load', function(e){
    
    //accordian effect
    var boxs = new rckp.left.nav.BoxCollection($('modules'));
   
   
});


rckp.left.nav.BoxCollection = function (element) {
    this.element = $(element);
    this.boxs = [];
	this.storeData = {};
	this.getURL = location.href;
	
	if(!this.element)
	{
		if($("cNavParaBlk"))
			if($("parametricFilters")){
				$("parametricFilters").style.visibility = "hidden";
				$("cNavParaBlk").style.visibility = "hidden";
			}
		return;
	}
	
    $A(this.element.childElements()).each(function(v,i){
        
        this.boxs.push(new rckp.left.nav.Box(v));
		

		switch(v.down('h2').innerHTML)
		{
			case "Size" : v.down('h2').style.backgroundImage = "none";
			this.storeData.sizeInfo = v.down('div').innerHTML;
			v.down('div').innerHTML = "<ul><li><a href='#'>See all available sizes <img src ='/images/parametric_nav_size_arrow.png' border='0'></a></li></ul><div id=\"sizeChart\"><div id=\"closeSizeChart\"><a href=\"#\">Close</a></div></div>";		
			
			v.down('a').observe('click', this.ShowSizeChart.bind(this,i));
			$("closeSizeChart").observe('click',this.ShowSizeChart.bind(this));
			break;
			
			case "Shop By Style" : 
			v.down('h2').observe('click', this.open.bind(this,i));
			v.down('h2').observe('click', this.HideSizeChart.bind(this,i));
			v.down('h2').style.backgroundImage = "url('/images/parametric_nav_arrow_up.png')";
			v.down('div').style.display = "block";
			break;				
			
			case "Men's Collections" : 
			v.down('h2').addClassName("collection");
			v.down('div').style.display = "block";

			break;
			
			case "Men's Technologies" : 
			v.down('h2').addClassName("collection");
			v.up('div').style.marginBottom = "15px";
			v.down('div').style.marginBottom = "15px";
			v.down('div').style.display = "block";
			
				if($("parametricFilters1"))
				{
					$("parametricFilters").insert($("parametricFilters1"));
					$("parametricFilters1").style.display = "block";
					$("parametricFilters").style.visibility = "visible";
					return;
		
				}
			break;
	
			case "Style" : 
			v.down('h2').observe('click', this.open.bind(this,i));
			v.down('h2').observe('click', this.HideSizeChart.bind(this,i));
			v.down('h2').style.backgroundImage = "url('/images/parametric_nav_arrow_up.png')";
			v.down('div').style.display = "block";
			break;	
	
			case "Shop By Type" : 
			v.down('h2').observe('click', this.open.bind(this,i));
			v.down('h2').observe('click', this.HideSizeChart.bind(this,i));
			v.down('h2').style.backgroundImage = "url('/images/parametric_nav_arrow_up.png')";
			v.down('div').style.display = "block";
			break;
		
/*			
			case "Color" : 
			v.down('h2').observe('click', this.open.bind(this,i));
			if(this.getURL.search('category/index.jsp')>0) {
				 v.down('h2').style.backgroundImage = "url('/images/parametric_nav_arrow_down.png')";
			   v.down('div').style.display = "none";
		  } else {
		     v.down('h2').style.backgroundImage = "url('/images/parametric_nav_arrow_up.png')";
		  	 v.down('div').style.display = "block";
		  }
			break;
*/			
			default : v.down('h2').observe('click', this.open.bind(this,i));
			  v.down('h2').observe('click', this.HideSizeChart.bind(this,i));
				if((this.getURL.search('family')>0) || (this.getURL.search('search')>0))
				{
					v.down('h2').style.backgroundImage = "url('/images/parametric_nav_arrow_up.png')";
					v.down('div').style.display = "block";
				}
				else
				{
					v.down('div').style.display = "none";
				}
			break;
			
		}
		
		$("parametricFilters").style.visibility = "visible";
		
        
    }.bind(this));
    
    
    return this;
}



rckp.left.nav.BoxCollection.prototype.ShowSizeChart = function()
{
	$("sizeChart").insert(this.storeData.sizeInfo);
	this.storeData = {};
	
	
	
	if($("sizeChart").style.display == "block")
	{
		$("sizeChart").style.display = "none";
		$("closeSizeChart").style.display = "none";
	}
	else
	{
		$("sizeChart").style.display = "block";
		$("closeSizeChart").style.display = "block";
	}
	
}

rckp.left.nav.BoxCollection.prototype.HideSizeChart = function()
{
	if($("sizeChart") != null)
	{
		if($("sizeChart").style.display == "block")
		{
			$("sizeChart").style.display = "none";
			$("closeSizeChart").style.display = "none";
		}
	}
}

rckp.left.nav.BoxCollection.prototype.open = function (index) {
  
    for (var i=0; i < this.boxs.length; i++) {
        if (i == index) {
            this.boxs[i].open(index);
				
        } else {
            //this.boxs[i].close();
        }
    }
    
    return this;
}


rckp.left.nav.Box = function (element, collection) {
    
    this.element = $(element);
    this.desc = this.element.down('div');
	this.desc.style.display = 'block';
    this.body = this.desc;

   	this.maxHeight = parseInt(this.body.offsetHeight + 30);
    
    return this;
 
}

rckp.left.nav.Box.prototype.open = function (index) {
	if(this.desc.style.display == 'block')
	{
		this.close();
		return;
	}
	
    this.desc.style.display = 'block';

    this.element.animator({height: this.maxHeight});
	var isIE6 = Df.browser();
	if(isIE6.ie6 == 0)
    this.body.animator({opacity: 1});
    var getH2 = $(this.element).select('h2');
	

		
	if($$('html,body,modules')){
	getH2[0].style.backgroundImage = "url('/images/parametric_nav_arrow_up.png')";
	}
    
}

rckp.left.nav.Box.prototype.close = function () {
	
	if(this.desc.style.display == 'none')
	{
		this.open();
		
	}
	
    this.desc.style.display = 'none';
	$("separator").show();
    this.element.animator({height: 20});
	
	var isIE6 = Df.browser();
	if(isIE6.ie6 == 0)
    this.body.animator({opacity: .01});
    var getH2 = $(this.element).select('h2');
	if($$('html,body,modules'))
	{
	getH2[0].style.backgroundImage = "url('/images/parametric_nav_arrow_down.png')";
	}
    
}





    