function printpage() {
	var newurl = location.href + "?print=yes";	
	var url = location.href.toString();
	var regex = new RegExp("(.*)\\?(.*)");	
	var match = url.match(regex);
	if(match != null) {
		newurl = match[1] + "?print=yes&" + match[2];
		
	}	
	window.open(newurl,"printwin");
}
function winClose() {
     myWindow.close()
}

var myWindow;
function showMenu(menuId) {
	if (menuId == '99_99_99') {
		myWindow = window.open("welcome.html", "tinyWindow", 'width=550, height=350, left=20, top=20, resizable=0')		
		self.setTimeout('winClose()', 8000)
	}
	else {
	
		var divname = 'smenu' + menuId + '';
		var regex = new RegExp("smenu(\\d+)_(\\d+)_(\\d+)");
		var matcharray = divname.toString().match(regex);

		var menulink = document.getElementById("menu" + menuId);
		if(menulink)
			menulink.className = "linktextblue";
		if(matcharray != null) {
			level1 = matcharray[1];
			level2 = matcharray[2];
			level3 = matcharray[3];


			menu1 = document.getElementById("smenu" + level1 + "_00_00");
			if (menu1)
			{
				menu1.style["display"] = "block";
				var menulink = document.getElementById("menu" + level1 + "_00_00");
				if(menulink)
					menulink.className = "linktextblue";
			}
			menu2 = document.getElementById("smenu" + level1 + "_" + level2 + "_00");
			if (menu2 && level2 != "00")
			{
				menu2.style["display"] = "block";
				var menulink = document.getElementById("menu" + level1 + "_" + level2 + "_00");
				if(menulink)
					menulink.className = "linktextblue";
			}
		}      
	}    
}

//array listing the pages omitted in english version
var omittedenglish = new Array('sfaa_news.asp', 'handbook.asp', 'annual.asp', 'membershiplist.asp', 'adress_buy.asp', 'speeches.asp', 'books.asp', 'articles.asp', 'studies.asp', 'event_coop.asp', 'acc_commission.asp', 'adm_commission.asp', 'decharge.asp','sfaa_club_details.asp');
function inList(needle, haystack) {
	var temp = new Array();
	temp = haystack;
	for (var i=0; i < temp.length; i++) {
		if (temp[i] == needle) {
			return temp[i];
		}
	}
	return false;
}

function changeLanguage(sessionLanguage, newLanguage) {
	
	var url = location.href.toString();
	var regex = new RegExp("(.*)\\/" + sessionLanguage + "\\/(.*)");	
	var match = url.match(regex);
	if(match != null) {
		//not good..a small heck can re-consider later
		if(match[2].toString().match(/our_jobs/) && newLanguage != 'de') {
			if(newLanguage == 'fr') {
				alert("French version not available for this page")
			}
			else {
				alert("English version not available for this page")
			}			
			return false;
		}
		//special cases 
		if(match[2].toString().match(/01_04_01/) && newLanguage == 'en') {
			alert("English version not available for this page")
			return false;
		}
		//check if the page is omitted in english
		var pagename = match[2].toString();
		var pageregex = new RegExp("(.*)[\\?,#](.*)");	
		var pagematch = pagename.match(pageregex);
		if(pagematch != null) {
			pagename = pagematch[1];
		}
		if(inList(pagename, omittedenglish) && newLanguage == 'en') {
			alert("English version not available for this page")
			return false;
		}
		location.href = match[1] + "/" + newLanguage + "/" + match[2];
		
	}
}

function popup(url, width, heigth) {
	var newwindow = window.open (url, "newwindow", "width=" + width + ",heigth=" + heigth + ", location=0,status=0,scrollbars=1,menubar=0"); 
	if (window.focus) {newwindow.focus()}
	return false;
	
}

function showletterlink() {
	var letters = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X', 'Y', 'Z');
	var linkstr = '';
	for (var key in letters) {
		linkstr += "<a href='#' onclick='location.hash=\"anchor-"+ letters[key] + "\";'>" + letters[key] + "</a>&nbsp;&nbsp;";
	}
	
	return linkstr;
	
}
