var linkControlJS_AllowGotoURL = true;

if (window.top.topFrame) {
	if (window.top.topFrame.linkControlJS_EnableRightClick)
		window.top.topFrame.linkControlJS_EnableRightClick();
	window.top.topFrame.linkControlJS_AllowGotoURL = true;
	
	if (window.top.mainFrame.folderFrame) {
		if (window.top.mainFrame.folderFrame.linkControlJS_EnableRightClick)
			window.top.mainFrame.folderFrame.linkControlJS_EnableRightClick();
		window.top.mainFrame.folderFrame.linkControlJS_AllowGotoURL = true;
	}	
	
	/*if (window.top.mainFrame.folderFrame) {
		if (! window.top.topFrame.directoryInit) {
			window.top.mainFrame.folderFrame.linkControlJS_EnableRightClick();
			window.top.mainFrame.folderFrame.linkControlJS_AllowGotoURL = true;
		}
		else
			window.top.topFrame.directoryInit = false;
	}*/
}

	

function linkControlJS_GotoURL(url, target, disableAllowGotoURL, needPopup) {

	if (! linkControlJS_AllowGotoURL)
		return;
	
	if (disableAllowGotoURL)  
		linkControlJS_DisableGotoURL()
		
	if (needPopup)
		linkControlJS_showProcessingLayer()
	
		
	if (target == "") {
		window.location = url;
	}
	else {
		eval("window." + target + ".location = '" + url + "'" )
	}
	
	return;

}

function linkControlJS_DisableAllFormElement() {
	var theForm = null;
	
	for (i=0 ; i < document.forms.length ; i++) {
		theForm = document.forms[i]
		for (j = 0 ; j < theForm.elements.length ; j++)  {
			ele = theForm.elements[j]
			if (ele.type == "button" || ele.type == "select-one")
				ele.disabled = true;
		}
	}
}

function linkControlJS_SubmitForm(theForm) {
	if (! linkControlJS_AllowGotoURL)
		return;

	theForm.submit();
	linkControlJS_DisableGotoURL()
	linkControlJS_DisableAllFormElement();
	linkControlJS_showProcessingLayer();
	 	
}


function linkControlJS_DisableGotoURL() {
	linkControlJS_AllowGotoURL = false;
	linkControlJS_DisableRightClick();
	
	if (window.top.topFrame) {
		window.top.topFrame.linkControlJS_DisableRightClick();
		window.top.topFrame.linkControlJS_AllowGotoURL = false;
	}
	
	if (window.top.mainFrame.folderFrame) {
		window.top.mainFrame.folderFrame.linkControlJS_DisableRightClick();
		window.top.mainFrame.folderFrame.linkControlJS_AllowGotoURL = false;
	}
}

function linkControlJS_EnableGotoURL() {
	linkControlJS_AllowGotoURL = true;
	linkControlJS_EnableRightClick();
	
	if (window.top.topFrame) {
		window.top.topFrame.linkControlJS_EnableRightClick();
		window.top.topFrame.linkControlJS_AllowGotoURL = true;
	}
	
	if (window.top.mainFrame.folderFrame) {
		window.top.mainFrame.folderFrame.linkControlJS_EnableRightClick();
		window.top.mainFrame.folderFrame.linkControlJS_AllowGotoURL = true;
	}
}

function linkControlJS_showProcessingLayer() {
	MM_showHideLayers('ProcessingLayer','','show')
	document.all.ProcessingLayer.style.top = parseInt(document.all.ProcessingLayer.style.top) + parseInt(document.body.scrollTop);
	
	var theForm = null;
	
	for (i=0 ; i < document.forms.length ; i++) {
		theForm = document.forms[i]
		for (j = 0 ; j < theForm.elements.length ; j++)  {
			ele = theForm.elements[j]
			if (ele.type.indexOf("select") != -1 )
				ele.style.visibility = "hidden"; 
		}
	}
}


var linkControlJS_Message="Popup Menu Disabled!";

function linkControlJS_ClickIE4(){
	if (event.button==2){
		alert(linkControlJS_Message);
		return false;
	}
}

function linkControlJS_ClickNS4(e){
	if (document.layers||document.getElementById&&!document.all){
		if (e.which==2||e.which==3){
			alert(linkControlJS_Message);
			return false;
		}
	}
}


function linkControlJS_DisableRightClick() {
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown=linkControlJS_ClickNS4;
	}
	else if (document.all&&!document.getElementById){
		document.onmousedown=linkControlJS_ClickIE4;
	}
	
	document.oncontextmenu=new Function("alert(linkControlJS_Message);return false")

}

function linkControlJS_EnableRightClick() {
	if (document.layers){
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown=null;
	}
	else if (document.all&&!document.getElementById){
		document.onmousedown=null;
	}
	
	document.oncontextmenu=null;

}