//Jquery URL Plugin
jQuery.url=function(){var segments={};var parsed={};var options={url:window.location,strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var parseUri=function(){str=decodeURI(options.url);var m=options.parser[options.strictMode?"strict":"loose"].exec(str);var uri={};var i=14;while(i--){uri[options.key[i]]=m[i]||""}uri[options.q.name]={};uri[options.key[12]].replace(options.q.parser,function($0,$1,$2){if($1){uri[options.q.name][$1]=$2}});return uri};var key=function(key){if(!parsed.length){setUp()}if(key=="base"){if(parsed.port!==null&&parsed.port!==""){return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/"}else{return parsed.protocol+"://"+parsed.host+"/"}}return(parsed[key]==="")?null:parsed[key]};var param=function(item){if(!parsed.length){setUp()}return(parsed.queryKey[item]===null)?null:parsed.queryKey[item]};var setUp=function(){parsed=parseUri();getSegments()};var getSegments=function(){var p=parsed.path;segments=[];segments=parsed.path.length==1?{}:(p.charAt(p.length-1)=="/"?p.substring(1,p.length-1):path=p.substring(1)).split("/")};return{setMode:function(mode){strictMode=mode=="strict"?true:false;return this},setUrl:function(newUri){options.url=newUri===undefined?window.location:newUri;setUp();return this},segment:function(pos){if(!parsed.length){setUp()}if(pos===undefined){return segments.length}return(segments[pos]===""||segments[pos]===undefined)?null:segments[pos]},attr:key,param:param}}();


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: false, //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: false, //persist state of opened contents within browser session?
toggleclass: ["menuclosed", "menuopened"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
togglehtml: ["suffix", "<img src='/images/2008_arrow_4_sidemenu.gif' class='statusicon' />", "<img src='/images/2008_arrow_6_sidemenu.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded
animatespeed: "normal", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
oninit:function(expandedindices){ //custom code to run when headers have initalized
 /*if (expandedindices.length==0) {//if no expanded headers found in array
  alert(expandedindices.length);
 }else{
  for (var i=0; i<expandedindices.length; i++){ //loop through each expanded header and alert their contents
   alert(headers[expandedindices[i]].innerHTML);
  }
 }*/
	var strLinkPath = "";
	var strTopLinkPath = "";
	var strURLPath = jQuery.url.attr("path");
	var iCount = 0;
	 
	$('.submenu').each(function() {
			
		$(this).find("a").each(function() {
					
			if ($.browser.mozilla!=true) {
				strLinkPath = '/'+ $(this)[0].pathname;
			} else {
				strLinkPath = $(this)[0].pathname;
			}
			
		
			if (strLinkPath==strURLPath) {
				ddaccordion.expandone("submenuheader",iCount);
				$(this).css("background","#333333");
				$(this).css("background-image","url(/images/2008_fleche_orange.jpg)");
				$(this).css("background-repeat","no-repeat");
			}
		
		});
		
		iCount++;
		
	});
	
	$('.accordeonmenu').each(function() {
		 $(this).find("a").each(function() {
										 
			if ($.browser.mozilla!=true) {
				strTopLinkPath = '/'+ $(this)[0].pathname;
			} else {
				strTopLinkPath = $(this)[0].pathname;
			}
			
			if (strTopLinkPath==strURLPath) {
				$(this).css("background","#000000");
			}
			
		 });
	});
	
},
onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
  //alert(index);
}
});

	



