
ddaccordion.init({
	headerclass: "top5link", //Shared CSS class name of headers group
	contentclass: "top5", //Shared CSS class name of contents group
	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
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: false, //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", "<img src='/images/top_5.gif' alt='Click to Open' class='top_5_image' />", "<img src='/images/top_5_close.gif' alt='Click to Close' class='top_5_image' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	onopenclose:function(){
		my_init();
		}
})

function TopFive(DIV, container){ 
 if(document.getElementById){
 var tar = document.getElementById(DIV);
 var sl = document.getElementById('top5_menu_' + DIV);
 var nav = document.getElementById('top5_menu');
 var links = nav.getElementsByTagName('a');
 var con = document.getElementById(container).getElementsByTagName("DIV");
 for(c=0; c < links.length; c++){
     links[c].className = 'link';
 }

 sl.className='selectedlink'
  if(tar.className == "hide"){
   for (var i=0; i<con.length; i++){
    if(con[i].className=='show'){
    con[i].className = "hide";}
   }
   tar.className = "show";
   

   if(tar.getAttribute("loaded")!="1"){
   
   	if(xmlhttp_top5=getAjaxObjTop5())
		{
			xmlhttp_top5.onreadystatechange=function()
			{
				if (xmlhttp_top5.readyState==4)
				{
					// 4 = "loaded"
					if (xmlhttp_top5.status==200)
					{
						// 200 = OK						
						eval(xmlhttp_top5.responseText);
					}
					else
					{
						alert("Problem getting XML data - TopFive(\""+DIV+"\",\""+container+"\")\n\nRe-Sending");
						//TopFive(DIV, container)
					}
				}
			};

			
			var frm=document.getElementById("cartForm");
			var params="top5_type="+DIV;
			//alert(document.location);
			params+="&current_url="+escape(document.location);

			xmlhttp_top5.open("POST","/store/?action=products.act_getTop5",true);
			xmlhttp_top5.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlhttp_top5.setRequestHeader("Content-length", params.length);
			xmlhttp_top5.setRequestHeader("Connection", "close");
			xmlhttp_top5.send(params);

		}
		else
		{
			alert("Your browser does not support AJAX.");
		}   	
   }   
  }
 }
}


var selectedTop5=null;
function my_init()
{	
	// check for if the top 5 bar has been opened
	if(document.getElementById("top5_div").style.display=="block"){
		// if no top5 type has been selected choose the first one
		if(selectedTop5==null){
			var idstr=document.getElementById("top5ul").getElementsByTagName("li")[0].id.toString().substring(3);			
			selectedTop5=idstr;
			TopFive('top5_'+idstr,'top5_content');
		}		
	}
}

document.onclick=function(){
	if(document.getElementById("top5_div")!=null){
		if(document.getElementById("top5_div").style.display=="block"){
				document.getElementById("top5link_anchor").click();
		}
	}
}

try{
	HTMLElement.prototype.click = function()
	{
		var evt = this.ownerDocument.createEvent('MouseEvents');
		evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
		this.dispatchEvent(evt);
	}
}catch(e){;}

function getAjaxObjTop5()
{
	var xmlhttp=false;
	if(window.XMLHttpRequest)
	{
		// code for all new browsers
		xmlhttp=new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		// code for IE5 and IE6
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}

	