//The function rel2abs returns the absolute adress of the argument "page"
//If "page" is already an absolute adress => no change
//Else the adress is build from the concatenation of the path of the page calling the script + the value of "page"

function rel2abs(page) {

path = "http://"

if	((page.substring(0,5).toLowerCase() != 'http:') && 
	(page.substring(0,5).toLowerCase() != 'file:') && 
	(page.substring(0,1) != '/') && 
	(page.substring(0,1) != '\\')){
    
	origin = window.location.href.split("/")
	
	if (page.substring(0,3) == "../") {
			for (i=2;i<origin.length-2;i++) {path += origin[i] + "/"}
			page = page.replace("../","")
		}
	else {
			for (i=2;i<origin.length-1;i++) {path += origin[i] + "/"}
		}
	
	out = escape(path + page)
	} 

else {
	out = escape(page)
	}
return out
}

function lpm(menu, page) { 

	myframe = ""
	myurl = ""

	if (menu == '') {
		menu='no'
	}
	

	if (page == '') {
		page='no'
		}

	if (menu.toLowerCase() == 'no') {
		if (page.toLowerCase() == 'no') {return}
		else {
		myframe = "principal"
		myurl = page
		nframe = 1
		} 
	}
	else {
		if (page.toLowerCase() == 'no') {
			myframe = "atccmenu"
			myurl = menu
			nframe = 1
			} 
		else  {
			nframe = 2
			}
	}
	if (nframe == 1) {
		try{top.frames(myframe).location.href = myurl}
		catch(er) {
			try{parent.frames(myframe).location.href = myurl}
			catch(er) {
				try{parent.parent.frames(myframe).location.href = myurl}
				catch(er){
				alert("Frame not found")
				}
			}
		}
	} else {
		try{top.atccmenu.location.href = menu;
		    top.principal.location.href = page}
		catch(er) {
			try{parent.atccmenu.location.href = menu;
			    parent.principal.location.href = page}
			catch(er) {
				try{parent.parent.atccmenu.location.href = menu; 				    				    parent.parent.principal.location.href = page}
				catch(er){
				alert("Frame not found - 2")
				}
			}
		}

	}
	
} 
	
