function getUserValues(dataName) {
	answer = null;
	try {
		myDataToFind = 'document.' + dataName;
		answer = eval(myDataToFind);
	} catch (e) {
		answer = 'naah';
	}
	return(answer);
}

// for user FILE UPLOAD - guest access
function reloadUploadSelectPage() {
	//removed
}

function openFileBrowseWindow_user(frameName,elementID) {
	document.userUploaderFrameName = frameName;
	document.userUploaderElementID = elementID;
	try {
		if (is_ie) {
			document.frames("IMGupload-G").document.form1.file.click();
		} else {		
			document.getElementById("IMGupload-G").contentDocument.getElementById("file").click();
		}
	} catch(e) {
		alert("FILE UPLOAD NOT AVAILABLE!");
	}
}

function eliminaUploadFile_user() {
	try {
		if (is_ie) {
			document.frames("IMGupload-G").document.form1.reset();
		} else {		
			document.getElementById("IMGupload-G").contentDocument.getElementById("form1").reset();
		}
	} catch(e) {
			//do nothing
	}
}

function imageSelected_user(filePath) {//setting selected FILE Name - 
	if (is_ie) {
		try {//inframe
			document.frames("superFScontainer_Site").document.frames(document.userUploaderFrameName).document.getElementById(document.userUploaderElementID).SetVariable("_root.nomeAllegato",filePath);
		} catch(e) {//trying with popup win
			try {
				document.frames("superFScontainer_Site").eval(document.userUploaderFrameName).document.frames("popp").document.getElementById(document.userUploaderElementID).SetVariable("_root.nomeAllegato",filePath);
				document.frames("superFScontainer_Site").eval(document.userUploaderFrameName).focus();
			} catch(e) {
				alert("FILE UPLOAD NOT AVAILABLE!");
			}
		}
	} else {//must make it work 4 not ie browsers
		alert("FILE UPLOAD NOT AVAILABLE!");
	}
}

function startUploadFile_user() {	
	document.userUploaderFrameName = arguments[0];//frame/window name
	document.userUploaderElementID = arguments[1];//elementID
	//alert('startUpload @ ' + document.userUploaderFrameName.name + " - " + document.userUploaderElementID);	
	if (is_ie) {
		document.frames("IMGupload-G").form1.submit();
	} else {
		document.getElementById("IMGupload-G").contentDocument.getElementById("form1").submit();
	}
}
function fileUploadFinished() {
	if (is_ie) {
		try {//inframe
			document.frames("superFScontainer_Site").document.frames(document.userUploaderFrameName).document.getElementById(document.userUploaderElementID).SetVariable("_root.fileUploadState",'OK');
		} catch(e) {//trying with popup win		
			try {
				document.frames("superFScontainer_Site").eval(document.userUploaderFrameName).document.frames("popp").document.getElementById(document.userUploaderElementID).SetVariable("_root.fileUploadState",'OK');
				document.frames("superFScontainer_Site").eval(document.userUploaderFrameName).focus();
			} catch(e) {
				alert('cannot notify upload interface!: \n'+e.message);
			}
		}
	}
	//alert(document.userUploaderFrameName + ' : ' + document.userUploaderElementID);
	//reloadUploadSelectPage();
}

//

function setCurrentArticle(areaID,articleID,artTitle,myFrameNum) {//is called when another page is loaded in the frameset or AREA has changed
	//!!if area -> articleID must be -1 and viceVersa!!
	if (document.user_userAccessGroup == 0 || document.user_userAccessGroup == 1) { //only for SuperAdmin or Admin //ie there is JK in MP
		if (articleID != -1) {//article change in frame [myFrameNum]		
		} else if (areaID != -1) {		
		}
		document.currentArticleNumber = articleID;
		document.MP.SetVariable("_root.articleID",articleID);//for editor when you editing current Article //
		document.MP.SetVariable("_root.currentAreaSelID",areaID);		
		document.MP.SetVariable("_root.currArticleSelFrame",myFrameNum);//for editor when you editing current Article //		
		document.MP.SetVariable("_root.currArtChangerSignal",1);//signals MainPanel that change is needed in currentArticle object
		//alert('mfn:' + myFrameNum);
	}
}

function normalUserInit() {//-enter with guest
	document.siteRootRef = './';
	setFSprops(document.UG_areaFStype,document.UG_areaWidth,document.UG_areaHeight,document.UG_areaAlignment);
	getSiteFrameset();
}

function setFSprops(FStype,FSwidth,FSheight,FSalignment) {
	document.getElementById("contTable_Site").width = FSwidth;
	document.getElementById("contTable_Site").align = FSalignment;
	if (is_ie) {
		if (FStype < 100) {//means that areaHeight is fixed to windowHeight
			framesetHeight = '100%';
			framesetOverflow = 'hidden';
		} else {
			framesetHeight = FSheight;
			framesetOverflow = 'auto';
		}
		document.getElementById("containerLayer_Site").style.overflow = framesetOverflow;
		document.getElementById("contTable_Site").height = framesetHeight;
	} else {
		if (FStype < 100) {//means that areaHeight is fixed to windowHeight
			framesetHeight = '100%';
			framesetOverflow = 'hidden';
		} else {
			framesetHeight = FSheight;
			framesetOverflow = 'auto';
		}
		//document.getElementById("containerLayer_Site").style.overflow = framesetOverflow;
		document.getElementById("containerLayer_Site").style.height = framesetHeight;
		document.getElementById("contTable_Site").height = framesetHeight;
	}
}
//--------------------------------------------------------------------------------------------SITO FRAMESET
function getSiteFrameset() {//load AREA >>> arg_0 is lastVisitedAreaID
	SH_containerS(0);
	window.status = '';	
	if (is_ie) {
		document.getElementById("superFScontainer_Site").document.onload = loadPhase_1();	
	} else if ((is_gecko) || (is_nav) || (is_opera)) {
		//alert('is_gecko!');
		document.getElementById("superFScontainer_Site").onload = loadPhase_1();	
	}
	if ((document.lastVisitedAreaID) && (document.lastVisitedAreaID != undefined)) {
		page2Get = document.siteRootRef + document.baseFolder_html + 'FS_' + document.lastVisitedAreaID + '.htm';
	} else {
		page2Get = document.siteRootRef + document.baseFolder_html + 'FS_' + document.UG_areaID + '.htm';
	}
	
	if ((is_gecko) || (is_nav) || (is_opera)) {		
		//frames["superFScontainer_Site"].location.href = page2Get;
		//alert('safari! - ' + window.document.getElementById("superFScontainer_Site").name);
		document.getElementById("superFScontainer_Site").src = page2Get;
	} else if (is_ie) {
		frames["superFScontainer_Site"].location.href = page2Get;
		//document.getElementById("superFScontainer_Site").location.href = page2Get;
		siteFSLoaded();
		//loadPhase_3();
	} else {
		document.getElementById("superFScontainer_Site").src = page2Get;
	}
		
}
function loadPhase_1() {//AREA is loaded
	maxWaitIntervalNum = 50;
	myFSLoaded_TO = setInterval(loadPhase_2,10);
}
function loadPhase_2() {//try to load requested page in mainFrame
	err=0;
	try {
		if (document.userPageReq != -1) {//if user has requested a specific page
			page2Get = document.siteRootRef + document.baseFolder_html + 'page_' + document.userPageReq + '.html';
				if (is_ie) {
					document.frames("superFScontainer_Site").document.frames("mainFrame").document.location.href = page2Get;
				} else {
					document.getElementById("superFScontainer_Site").contentDocument.getElementById("mainFrame").contentDocument.location.href = page2Get;
				}			
		}
	} catch(e) {
		err=1;
	}
	maxWaitIntervalNum--;
	if (maxWaitIntervalNum<=0) {//interupted - not waiting any more		
		err=0;
	}
	if (err==1) {
		window.status += '.';//continue waiting
	} else {
		clearInterval(myFSLoaded_TO);
		myFSLoaded_TO = null;
		maxWaitIntervalNum = 50;
		window.status = '';
		myFSLoaded_TO = setInterval(loadPhase_3,10);
	}
}
function loadPhase_3() {//try to load users home page in mainFrame
	//alert('iemac! - ' + document.userPageGoAuto);
	err=0;
	try {
		if ((document.userPageReq == -1) && (document.userPage != -1) && (document.userPageGoAuto == 'Y')) {//if user has NOT requested a specific page but has home page
			page2Get = document.siteRootRef + document.baseFolder_html + 'page_' + document.userPage + '.html';
				if (is_ie) {
					document.frames("superFScontainer_Site").document.frames("mainFrame").document.location.href = page2Get;
				} else {
					document.getElementById("superFScontainer_Site").contentDocument.getElementById("mainFrame").contentDocument.location.href = page2Get;
					//will throw error but goes ok
				}			
		}
	} catch(e) {
		err=1;
		//alert('ERROR! - ' + e.message);
	}	
	maxWaitIntervalNum--;
	if (maxWaitIntervalNum<=0) {//interupted - not waiting any more		
		err=0;
	}
	if (err==1) {
		window.status += '.';
	} else {
		clearInterval(myFSLoaded_TO);
		myFSLoaded_TO = null;
		window.status = '';
		siteFSLoaded();
	}
}
function siteFSLoaded() {
	document.siteMode = 0;		
	SH_containerS(1);
}

//--------------------------------------SITO FRAMESET - END
function reloadJK() {//gets called by loginDB panel after session variables have been set in remoteLogger.asp
	location.reload();	
}
function EXITJACKSKITCHEN() {
	document.location.href = '/superIndex/abandonSession.asp';
}
//---------------------------------------------------------------------SHOW HIDE functions
function SH_containerE(SH) {	
	if (SH == 0) {
		document.getElementById("containerLayer").style.visibility = 'hidden';
	} else {
		document.getElementById("containerLayer").style.visibility = 'visible';
	}
}
function SH_containerS(SH) {	
	if (SH == 0) {
		document.getElementById("containerLayer_Site").style.visibility = 'hidden';
	} else {
		document.getElementById("containerLayer_Site").style.visibility = 'visible';
	}
}

function SHdataFrame(SH) {
	if (SH == 0) {
		document.getElementById("updater").style.visibility = 'hidden';
	} else {
		document.getElementById("updater").style.visibility = 'visible';
	}
}
function SHframeContainer(SH) {
	if (SH == 0) {
		if (is_ie) {
			document.frames("superFScontainer").document.all.Fcontainer.style.visibility = 'hidden';
		} else {
			document.getElementById("superFScontainer").contentDocument.getElementById("Fcontainer").style.visibility = 'hidden';
		}
	} else {
		if (is_ie) {
			document.frames("superFScontainer").document.all.Fcontainer.style.visibility = 'visible';
		} else {
			document.getElementById("superFScontainer").contentDocument.getElementById("Fcontainer").style.visibility = 'visible';
		}		
	}
}
function SHframeContainerCover(SH) {	
	if (SH == 0) {
		if (is_ie) {
			document.frames("superFScontainer").document.all.frameCover.style.visibility = 'hidden';
		} else {
			document.getElementById("superFScontainer").contentDocument.getElementById("frameCover").style.visibility = 'hidden';
		}
	} else {
		if (is_ie) {
			document.frames("superFScontainer").document.all.frameCover.style.visibility = 'visible';
		} else {
			document.getElementById("superFScontainer").contentDocument.getElementById("frameCover").style.visibility = 'visible';
		}		
	}
}
