	// return a command-line (GET URL Location.search) parameter
function getQueryParam(sName,sSearchLocation) {
    var sSearch=sSearchLocation; // copy value, just in case. i dont want to manipulate the real location.href by mistake...
    if (typeof(sSearch    )=='undefined') sSearch=document.location.search;
    if (typeof(sSearch.search)=='string') sSearch=sSearch.search;  // in case we got a Location object
    sSearch=sSearch.toString().replace(/^\?/,''); // remove first ?
    sSearch='&'+sSearch+'&';
    
    var res=sSearch.match(new RegExp('&'+sName+'=([^&]*)','i'));
    if (res && res.length>1) {
        return res[1];
    }else{
        return null;
    }
}

// return html content for the menu
function createHTMLMenu(aMenu) {
	var s,i,j,k;
	var myurl;
	var stext;
	var shref;
  var where = new Array();
  var myurl=location.href;
	var atarget;
  for (i=0;i<aMenu.length-1;i++) {
    if (aMenu[i].href==myurl) {
	    where[0]=i;
	  	break;
	  }
		if (typeof(aMenu[i].aLinks)!=="undefined") {
 	  	for (j=0;j<aMenu[i].aLinks.length-1;j++) {
   		  if (aMenu[i].aLinks[j].href==myurl) {
   		    where[0]=i;
   		    where[1]=j;
   				break;
   			}
				if (typeof(aMenu[i].aLinks[j].aLinks)!=="undefined") {
   			  for (k=0;k<aMenu[i].aLinks[j].aLinks.length-1;k++) {
   		      if (aMenu[i].aLinks[j].aLinks[k].href==myurl) {
   		        where[0]=i;
     		      where[1]=j;
     					where[2]=k;
     				  break;
     			  }
     	  	} // for k
				} // defined k
   		} // for j
		} // defined j
  } // for i
  s="<ul>";
    for (i=0;i<aMenu.length-1;i++) {
	    stext=aMenu[i].text;
		  shref=aMenu[i].href;
      if (typeof(aMenu[i].aLinks)=="undefined") {
				s+='<li><a href="' + shref + '"';
			  if (myurl==aMenu[i].href) s+=' class="current"';
	      if (typeof(aMenu[i].target)!="undefined") s+=' target="_blank"';
				s+='>' + stext + '</a></li>';
			}
			else {
			  s+=(i==where[0])? '<li class="open">':'<li class="hidden">';
				s+='<a href="' + shref + '"';
			  if (myurl==aMenu[i].href) s+=' class="current"';
	      if (typeof(aMenu[i].target)!="undefined") s+=' target="_blank"';
				s+='>' + stext + '</a><ul>';
  	  	for (j=0;j<aMenu[i].aLinks.length-1;j++) {
    		  stext=aMenu[i].aLinks[j].text;
    			shref=aMenu[i].aLinks[j].href;
          if (typeof(aMenu[i].aLinks[j].aLinks)=="undefined") {
    				s+='<li><a href="' + shref + '"';
    			  if (myurl==aMenu[i].aLinks[j].href) s+=' class="current"';
    	      if (typeof(aMenu[i].aLinks[j].target)!="undefined") s+=' target="_blank"';
    				s+='>' + stext + '</a></li>';
    			}
    			else {
    			  s+=((j==where[1]) && (i==where[0]))? '<li class="open">':'<li class="hidden">';
	  				s+='<a href="' + shref + '"';
	  		    if (myurl==aMenu[i].aLinks[j].href) s+=' class="current"';
	          if (typeof(aMenu[i].aLinks[j].target)!="undefined") s+=' target="_blank"';
		  		  s+='>' + stext + '</a><ul>';
    			  for (k=0;k<aMenu[i].aLinks[j].aLinks.length-1;k++) {
        		  stext=aMenu[i].aLinks[j].aLinks[k].text;
        			shref=aMenu[i].aLinks[j].aLinks[k].href;
     				  s+='<li><a href="' + shref + '"';
							if (myurl==aMenu[i].aLinks[j].aLinks[k].href) s+=' class="current"';
	            if (typeof(aMenu[i].aLinks[j].aLinks[k].target)!="undefined") s+=' target="_blank"';
						  s+='>' + stext + '</a></li>';
      	  	} // for 3
						s+="</ul></li>"
					} // defined 3
    		} // for 2
				s+="</ul></li>"
			} // defined 2
    } // for 1
	s+="</ul>";
	return s;
}

var aMenu = [
  { href: "http://www.free.org.il/act/new.html",
    text: "איך אני יכול לעזור?",
    aLinks: [
      { href: "http://www.free.org.il/act/new/regular.html",
        text: "פעילויות קבועות"},
      { href: "http://www.shevi.org.il/xhtml/act/02_fight4rights.html",
        text: "האבקו למען זכויותיהם",
				target: true},
      { href: "http://www.shevi.org.il/html/other/Yarticles_lecturs.htm",
        text: "הזמנת הרצאה",
				target: true},
      { href: "http://www.free.org.il/act/new/sign.html",
        text: "חתימה על עצומות"},
      { href: "http://www.free.org.il/act/new/banners.html",
        text: "הפצת באנרים"},
      {end:"end of items"}
  ]},
  { href: "http://www.free.org.il/act/tools.html",
    text: "כלים לפעילות",
    aLinks: [
      { href: "http://www.free.org.il/act/tools/protest.html",
        text: "הפגנות ומשמרות מחאה"},
      { href: "http://www.free.org.il/act/tools/letters.html",
        text: "כתיבת מכתבים"},
      { href: "http://www.free.org.il/act/tools/internet.html",
        text: "הפצת מידע באינטרנט"},
      { href: "http://www.free.org.il/act/tools/atzu.html",
        text: "החתמה על עצומות"},
      { href: "http://www.free.org.il/act/tools/fliers.html",
        text: "חלוקת פלאיירים"},
      { href: "http://www.free.org.il/act/tools/duchan.html",
        text: "דוכן הסברה"},
      { href: "http://www.free.org.il/act/tools/commer.html",
        text: "פרסומת רחוב"},
      { href: "http://www.free.org.il/act/tools/iton.html",
        text: "עיתון קיר"},
      { href: "http://www.free.org.il/act/tools/e_yun.html",
        text: "יום עיון"},
      {end:"end of items"}
  ]},
  { href: "http://www.free.org.il/act/dfus.html",
    text: "חומרי דפוס"
	},
  { href: "http://www.free.org.il/gallery/act/gallery_act.html",
    text: "תמונות מפעילויות"
	},
  {end:"end of menus"}
];

// add the menu to screen
var oMenu=document.getElementById("right-nav");
if (oMenu) {
	oMenu.innerHTML = createHTMLMenu(aMenu);
}
