/**

Unobtrusive JavaScript

**/

window.onload = init;

function init() {
	initMenu();
	setActiveTab();


}


function initMenu() {

	//get the url of the current page
	var url = window.location.href;

	//split the url
	var vars = url.split("/");
	
	//get the last name
	var htmldoc = vars[vars.length-2];
	
	//if its the price or service pages, display sub menu
	if (htmldoc == "price" || htmldoc == "service") {
		//alert("here:"+htmldoc);
		document.getElementById(htmldoc+"Menu").style.display = "block";
	}
	

}


function setActiveTab() {

	var menuItems = document.getElementById("mainMenu");
	
	//get the url of the current page
	var url = window.location.href;

	//split the url
	var vars = url.split("/");
	
	//get the last name in the url
	var htmlPage = vars[vars.length-1];
	
	// get the subsection. i.e service or prices
	var htmlSection = vars[vars.length-2];
	
	var lis = document.getElementsByTagName("li");
	
	var formElement = document.getElementById("aspnetForm");
	var aspxPage = formElement.getAttribute("action");
	
	
	// clear previous active tab
	for (var j=0; j< lis.length; j++) {
		lis[j].setAttribute("class", "");
	}
	
	// set register tab
	if (aspxPage == "registerok.aspx") {
		document.getElementById("register.aspx").setAttribute("class", "active");
		document.getElementById("register.aspx").className = "active";
	}
	
	// set price & service section tab
	if (htmlSection == "service") {
		//set active tab
		document.getElementById("services.aspx").setAttribute("class", "active");
		document.getElementById("services.aspx").className = "active";
	}
	
	else if (htmlSection == "price") {
		//set active tab
		document.getElementById("pricelist.aspx").setAttribute("class", "active");
		document.getElementById("pricelist.aspx").className = "active";
	}
	
	else {
		// set new active tab
		for (var i=0; i< lis.length; i++) {
			if(lis[i].getAttribute("id") == aspxPage) {
			   
				lis[i].setAttribute("class", "active");
				lis[i].className = "active";
			}
		}
	}
	
	
	
}

function openInNewWindow(url) {

	newwindow = window.open(url);
        if (window.focus) {
      		newwindow.focus()
      	}
        return false;


}
