function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
	  return pair[1];
    }
  }
  //alert('Query Variable ' + variable + ' not found');
}

/*function marknavi_old(intsvc, svccolor, level1, level2) {
	//var p = getQueryVariable("p").split("_");
	$("#"+intsvc).accordion('activate', (level1-1) );
	$("#navi"+level1).css("border-left","3px solid "+ svccolor);
	$("#navi"+level1).css("color","3px solid "+ svccolor);
	$("#plus"+level1).click();
	$("#sub"+level1+" li:nth-child("+level2+")").css("border-left","3px solid "+ svccolor);
}*/

function marknavi(intsvc) {

	var markcolor;
	
	switch(intsvc) {
		case "industrialsvc":
		markcolor = "#50b948";
		break;
		case "subseasvc":
		markcolor = "#00a7e9";
		break;
		case "trainingsvc":
		markcolor = "#ed1c24";
		break;
	}

	currentfile = location.href.substring(location.href.lastIndexOf('/')+1);
	//alert(currentfile);
	
	//check level 1
	$("#"+intsvc+" a").each(function() {
		currHref = $(this).attr("href");
		//alert(currHref);
		if (currHref == currentfile) {
			currId = $(this).attr("id");
			
			//determing if its first level or second level, second level links has no id
			if (currId=="") {
				//second level
				currId = $(this).parent().parent().parent().attr("id");
				currId = currId.slice(3);
				$("#navi"+currId).css("border-left","3px solid "+ markcolor);
				$("#navi"+currId).css("color","#000000"); //for font color
				$("#"+intsvc).accordion('activate', (currId-1));
				$(this).css("border-left","3px solid "+ markcolor);
				$(this).css("color","#000000"); //for font color
				
			} else {
				//first level
				currId = currId.slice(4);
				$(this).css("border-left","3px solid "+ markcolor);
				$(this).css("color","#000000"); //for font color
				$("#"+intsvc).accordion('activate', (currId-1));
			}
			
			
			
			//alert(currHref + currId);
		}
	});

}

$(document).ready(function(){

	$("#header").load('top_header.html');
	$("#bluebar").load('top_navi.html');
	$("#belowbluebar").load('svc_navi.html');
	$("#bluebar_footer").load('footer_navi.html');
	
});
