//***Jack's Kitchen v.1.0.0 open functions
var agt=navigator.userAgent.toLowerCase();
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
			&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
			&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_opera = (agt.indexOf("opera") != -1);
// *** PLATFORM ***
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);
var is_linux = (agt.indexOf("inux")!=-1);


		



function MM_swapImage(callerFrameName,ImgObjName,newSrc) {
	if (callerFrameName) {
		if ((is_gecko) || (is_nav) || (is_opera)) {
			document.getElementById(callerFrameName).contentDocument.getElementById(ImgObjName).src = newSrc;
		} else if (is_ie) {
			myObjectName = 'document.all.' + ImgObjName;
			document.frames(callerFrameName).eval(myObjectName).src = newSrc;
		}
	}
}
//---------------------------------------------------------------------------------------
function showThisImage(OName,thePage,windowWidth2open,windowHeight2open) {//(1)	--should be in disuse
	myParentsName = this.name;
	if (myParentsName == 'superFScontainer_Site') {//only in siteViewMode
		theWindow = OName;
		if ((is_gecko) || (is_nav) || (is_opera)) {
			windowWidth2open = windowWidth2open - 11;
		} else if (is_ie) {
			windowWidth2open = windowWidth2open - 9;
		}
		myChromlessWindow(thePage,'new',windowWidth2open,windowHeight2open,theWindow);
	}	
}

function openThisURL(protocolType,where2Go,winW,winH) {//(2)//protocolType - 0='', 1=http 2=https 3=mailto 4=ftp
	myParentsName = this.name;
	if (myParentsName == 'superFScontainer_Site') {//only in siteViewMode
		if(!winW) {
			winW = 640;
		}
		if(!winH) {
			winH = 480;
		}	
		theWinName = 'popupwindow_' + Math.floor(100000*Math.random());
		if (protocolType != 3) {
			theFeatures = 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+winW+',height='+winH+'';
			myNewWin = window.open(where2Go,theWinName,theFeatures);
			myNewWin.focus();
			//myNewWin.resizeTo(winW,winH);
		} else {
			sendEmailTo(where2Go);
		}
	}
}
function downloadThisObject(what2Download) {//(3)
	myParentsName = this.name;
	if (myParentsName == 'superFScontainer_Site') {//only in siteViewMode
		window.open(what2Download,"DLwin");
	}	
}
function goToUsersPage() {//10
	myParentsName = this.name;
	if (myParentsName == 'superFScontainer_Site') {
		try {
			userPageNum = Number(parent.getUserValues('userPage'));
			page2Get = 'page_' + userPageNum + '.html';
			if (userPageNum != -1) {
					if ((is_gecko) || (is_nav) || (is_opera) || (is_ie && is_mac)) {
						//alert('GECKO OPEN IN: '+ parent.document.getElementById("superFScontainer_Site").contentDocument.getElementById("mainFrame").location.href);
						frames['mainFrame'].location.href = page2Get;
						//document.getElementById("mainFrame").contentDocument.location.href = page2Get;						

					} else if (is_ie) {
						popup = "mainFrame";				
						setTimeout(openWithDelay,10);			
					}					
					ATitle = 'userHomePage(' + userPageNum + ')';
					myFrameNum = 5;
					followLink(-1,userPageNum,ATitle,myFrameNum);
			}
		} catch(e) {
			//caught
			alert('PROBLEMS!  : '+e.message+'   -   '+window.name);
		}
	}
}

function showSearchResults(searchResultsPage,searchThis) {
	if (searchThis.length > 0) {
		thePage = searchResultsPage + '?searchThis=' + searchThis;	
		myChromlessWindow(thePage,'searchResults',700,400,'search results for: ' + searchThis);
	}
}
function searchClickedThis(foundAID) {
	pageTitle = 'found page: ' + foundAID;
	showThisLink('mainFrame', 'mainFrame', foundAID, '', 0, 0, pageTitle);
}

function showThisLink(fromFrame, toFrame, param1, param2, param3, param4, param5) {	//(4) opens another page  1=artID 2=popUp 3=width 4=height 5=title
		myParentsName = this.name;
		//alert(myParentsName);
		if (myParentsName == 'superFScontainer_Site') {
				theWindow = param5;
				thePage = 'page_' + param1 +'.html';
				popup = toFrame;
				windowWidth2open = param3;
				windowHeight2open = param4;
				if (popup == 'popup') {
					windowWidth2open = windowWidth2open + 12;//corrections for popup art
					windowHeight2open = windowHeight2open + 55;//corrections for popup art
					randomPopperName = 'popper_' + Math.floor(100000*Math.random());
					myChromlessWindow(thePage,randomPopperName,windowWidth2open,windowHeight2open,theWindow);					
				} else {//it must be 'inframe'
					page2Get = 'page_' + param1 +'.html';					
					if ((is_gecko) || (is_nav) || (is_opera) || (is_ie && is_mac)) {
						//alert('GECKO OR IEMAC');
						frames[popup].location.href = page2Get;
					} else if (is_ie) {
							//alert('IE+WIN');
							setTimeout(openWithDelay,10);
					}					
				}
				//alert JK about page change
				if (toFrame == 'mainFrame') {
					myFrameNum = 5;
				} else {
					myFrameNum = Number(toFrame.substring(toFrame.length-1,toFrame.length));//frame_1 strips last char
				}
				followLink(-1,param1,param5,myFrameNum);
		} else {
			//alert('NOT ALLOWED: ' + myParentsName);
		}
}
function openWithDelay() {
	//alert('delay');
	if ((is_gecko) || (is_nav) || (is_opera)) {
		//alert('GECKO!');
		frames[popup].location.href = page2Get;
	} else if (is_ie) {
		//alert('IE');
		document.frames(popup).document.location.href = page2Get;
	}	
	//return true;
}

function goBack() {//JK is NOT alerted about page change
	history.back();
}

function showUserOrders() {//(5)
	alert('Elenco ordini per questo utente NON disponibile.');
}

function showUserCart() {//(6)
	productOrder(-1);
}
function printThisFrame(toFrame) {//7
	myParentsName = this.name;
	if (myParentsName == 'superFScontainer_Site') {//only in siteViewMode	
		if (is_ie) {
			document.frames(toFrame).self.focus();
		}
		print();
	}
}
function sendEmailTo(mailAddress) {//8
	myParentsName = this.name;
	if (myParentsName == 'superFScontainer_Site') {//only in siteViewMode
		location.href = mailAddress;
	}
}

function changeAreaFS(FSnumber,FSwidth,FSheight,FSalignment) {//9 - needs width and alignment ----and areaExternalBackground
		try {
			parent.SH_containerS(0);
		} catch (e) {}		
		myParentsName = this.name;
		if (myParentsName == 'superFScontainer_Site') {//only in siteViewMode
			FSname = './FS_' + FSnumber + '.htm';
			document.location.href = FSname;
			
			if (!FSwidth) {//isNaN(
				FSwidth = 796;
				FSalignment = 'center';
			}			
			if (Number(FSheight) == 0) {
				FStype = 0;
			} else {
				FStype = 100;
			}
			try {
				parent.setFSprops(FStype,FSwidth,FSheight,FSalignment);
			} catch (e) {}
			followLink(FSnumber,-1,'AREA CHANGE',-1);
		}
		try {
			parent.SH_containerS(1);
		} catch (e) {}	
}
//-indirect js functions
function myChromlessWindow(myURL,winname,winWidth,winHeight,winTitle) {//this is called from NEWSREADER	
	posLeft = (screen.width - winWidth) / 2;
	if (posLeft<0) {posLeft=0;}
	posTop = (screen.height - winHeight) / 2;
	if (posTop<0) {posTop=0;}
	
	popupWindow = window.open("",winname,"status=yes,resizable=yes,width="+winWidth+",height="+winHeight+",left="+posLeft+",top="+posTop);
	popupWindow.document.open();	
	popupWindow.document.writeln('<html><head><title>'+winTitle+'</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>');		
	popupWindow.document.writeln("<script language='JavaScript' type='text/JavaScript'>");
	popupWindow.document.writeln("function MM_swapImage(callerFrameName,ImgObjName,newSrc) {");
	popupWindow.document.writeln("   if (callerFrameName) {");
	popupWindow.document.writeln("      if ((window.opener.is_gecko) || (window.opener.is_nav) || (window.opener.is_opera)) {");
	popupWindow.document.writeln("         document.getElementById(callerFrameName).contentDocument.getElementById(ImgObjName).src = newSrc;");
	popupWindow.document.writeln("      } else if (window.opener.is_ie) {");
	popupWindow.document.writeln("         myObjectName = 'document.all.' + ImgObjName;");
	popupWindow.document.writeln("         document.frames(callerFrameName).eval(myObjectName).src = newSrc;");
	popupWindow.document.writeln("      }");
	popupWindow.document.writeln("   }");
	popupWindow.document.writeln("}");
	popupWindow.document.writeln("function sendEmailTo(destinatario) {window.opener.sendEmailTo(destinatario);}");
	popupWindow.document.writeln("function showThisImage(OName,thePage,windowWidth2open,windowHeight2open) {window.opener.showThisImage(OName,thePage,windowWidth2open,windowHeight2open);}");
	popupWindow.document.writeln("function showThisLink(fromFrame, toFrame, param1, param2, param3, param4, param5) {window.opener.showThisLink(fromFrame, toFrame, param1, param2, param3, param4, param5);}");
	popupWindow.document.writeln("function changeAreaFS(areaID, areaWidth, areaAlign) {window.opener.changeAreaFS(areaID, areaWidth, areaAlign);}");
	popupWindow.document.writeln("function searchClickedThis(AID) {window.opener.searchClickedThis(AID);}");
	
	popupWindow.document.writeln("function downloadThisObject(myObject) {window.opener.downloadThisObject(myObject);}");
	
	popupWindow.document.writeln("function openFileBrowseWindow_user(winName,objName) {");
	popupWindow.document.writeln("		window.opener.parent.openFileBrowseWindow_user(document.winReference,objName);");	
	popupWindow.document.writeln("}");
	
	popupWindow.document.writeln("function reloadUploadSelectPage() {window.opener.parent.reloadUploadSelectPage();}");
	
	popupWindow.document.writeln("function startUploadFile_user(winName,objName) {");
	popupWindow.document.writeln("		window.opener.parent.startUploadFile_user(document.winReference,objName);");				  
	popupWindow.document.writeln("}");
	
	popupWindow.document.writeln("function productOrder_getID(callerFrameName,callerObjectID) {");
	popupWindow.document.writeln("		//alert('document.winReference: '+document.winReference);");
	popupWindow.document.writeln("		try {window.opener.productOrder_getID(document.winReference,callerObjectID);} catch(e){}");				  
	popupWindow.document.writeln("}");
	popupWindow.document.writeln("function productOrder_exitSC() {window.opener.productOrder_exitSC(document.winReference);}");
	popupWindow.document.writeln("function goBack() {window.close();}");
	popupWindow.document.writeln("function openOnlineTransferWindow(URL2GET) {window.opener.openOnlineTransferWindow(URL2GET);}");
	popupWindow.document.writeln("function closeOnlineTransferWindow() {window.opener.closeOnlineTransferWindow();}");	
	popupWindow.document.writeln("</script>");	
	popupWindow.document.writeln('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">'); 
	popupWindow.document.writeln('<iframe src="'+myURL+'" name="'+winname+'" id="popp" width="100%" height="100%" width=100% height=100% marginwidth=0 marginheight=0 align="middle" scrolling=auto frameborder=0 hspace=0 vspace=0></iframe>'); 	
	popupWindow.document.writeln('</body></html>');	

	popupWindow.document.close();
	popupWindow.document.winReference=popupWindow;
	popupWindow.focus();
	popupWindow.resizeTo(winWidth,winHeight);
}

function productInfo(artLink,prodDesc) {
	myParentsName = this.name;
	if (myParentsName == 'superFScontainer_Site') {//only in siteViewMode
		if (artLink == -1) {
			if (prodDesc) {
				alert(prodDesc);
			}			
		} else {
			fromFrame = 'mainFrame';
			toFrame = 'mainFrame';			
			showThisLink(fromFrame, toFrame, artLink, 'inFrame', 1, 1, 'prodInfo');//(4) opens another page  1=artID 2=popUp 3=width 4=height 5=title
		}
	}
}
function productOrder(PID) {//guest(if allowed) or registered user
	//if (((parent.document.sc_canUseGuest=='Y')&&(parent.document.user_userAccessGroup==2))||(parent.document.authenticated=='True')) {
	//do this control in swf
		myParentsName = this.name;
		if (myParentsName == 'superFScontainer_Site') {//only in siteViewMode
			//alert('ordering: ' + PID);
			document.thisOrderPID = Number(PID);
			artLink = Number(parent.getUserValues('sc_aid'));//document.sc_aid			
			fromFrame = 'mainFrame';
			toFrame = String(parent.getUserValues('sc_apos'));//document.sc_apos
			if (toFrame=='popup') {
				document.inOrOut = 'popup';
				pW =  Number(parent.getUserValues('sc_pW'));
				pH =  Number(parent.getUserValues('sc_pH'));
				thePage = 'page_' + artLink +'.html';
				theWindowTitle='Shopping cart';
				popperName = 'shoppingCartPopper';
				pW = pW + 12;//corrections for popup art
				pH = pH + 55;//corrections for popup art			
				myChromlessWindow(thePage,popperName,pW,pH,theWindowTitle);	
			} else {
				document.inOrOut = 'inFrame'
				pW = 1;
				pH = 1;
				showThisLink(fromFrame, toFrame, artLink, document.inOrOut, pW, pH, 'ORDER');//(4) opens another page  1=artID 2=popUp 3=width 4=height 5=title
			}				
		}
	//} else {
		//alert('You must register before you can order products!');
	//}
}

function productOrder_getID(callerFrameNameRef,callerObjectID) {//executed automatically by shoppingcart
	if (callerFrameNameRef == 'inframe') {
		callerFrameNameRef = String(parent.getUserValues('sc_apos'));
	}
	document.SC_CFNR = callerFrameNameRef;
	document.SC_COID = callerObjectID;
	try {//not mozilla proof!!!?
		document.frames(document.SC_CFNR).document.getElementById(document.SC_COID).SetVariable("_root.requestedID",document.thisOrderPID);
	} catch(e) {
		//alert('NOT INFRAME! \n'+e.message);	
	}	
	try {//in popup 'popp'
		eval(document.SC_CFNR).document.frames("popp").document.getElementById(document.SC_COID).SetVariable("_root.requestedID",document.thisOrderPID);
		eval(document.SC_CFNR).focus();
	} catch(e) {
		//alert('NOT POPP! \n'+e.message);		
	}	
}
function productOrder_concludeTransaction() {
	try {//not mozilla proof!!!?
		document.frames(document.SC_CFNR).document.getElementById(document.SC_COID).SetVariable("_root.gotResponseFromBank",true);
	} catch(e) {
		//alert('NOT INFRAME! \n'+e.message);	
	}
	try {//in popup 'popp'
		eval(document.SC_CFNR).document.frames("popp").document.getElementById(document.SC_COID).SetVariable("_root.gotResponseFromBank",true);
		eval(document.SC_CFNR).focus();
	} catch(e) {
		//alert('NOT POPP! \n'+e.message);		
	}	
}
function productOrder_exitSC() {
	if (document.inOrOut=='popup') {//if in popup it will send the window object as arg0
		document.SC_CFNR = arguments[0];
		eval(document.SC_CFNR).close();
	} else {
		history.back();
	}
}
function openOnlineTransferWindow(URL2GET) {
	document.bankingWindow = window.open(URL2GET,"ONLINE_BANK");
}
function closeOnlineTransferWindow() {
	document.bankingWindow.close();
}
function followLink(FSnumber,articleID,articleTitle,myFrameNumber) {
	try {
		if (parent.setCurrentArticle) {
			parent.setCurrentArticle(FSnumber,articleID,articleTitle,myFrameNumber);//site mode
		} else if (parent.parent.setCurrentArticle) {
			parent.parent.setCurrentArticle(FSnumber,articleID,articleTitle,myFrameNumber);//areaMode/userMode
		}
	} catch (e) {}
}
function LOGOUT_FROM_JACKSKITCHEN() {
	//parent.document.frames("superFScontainer_Site").location = '/superIndex/abandonSession.asp';
	parent.EXITJACKSKITCHEN();
}