function alertkey(e) 
{
	  if( !e ) {
		//if the browser did not pass the event information to the
		//function, we will have to obtain it from the event register
		if( window.event ) {
			//DOM
			e = window.event;
		} else {
			//TOTAL FAILURE, WE HAVE NO WAY OF REFERENCING THE EVENT
			sequence="";
			return;
		}
	}
	
	if( typeof( e.which ) == 'number' ) {
		//NS 4, NS 6+, Mozilla 0.9+, Opera
		e = e.which;
	} else if( typeof( e.keyCode ) == 'number'  ) {
		//IE, NS 6+, Mozilla 0.9+
		e = e.keyCode;
	} else if( typeof( e.charCode ) == 'number'  ) {
		//also NS 6+, Mozilla 0.9+
		e = e.charCode;
	} else {
		//TOTAL FAILURE, WE HAVE NO WAY OF OBTAINING THE KEY CODE
		sequence="";				
		return;
	}

	sequence = sequence + e;
	
	//window.alert('The key pressed has keycode ' + e + ' and is key ' + String.fromCharCode( e ) );
	
	if(sequence=='1716106')
	{
		var vect = new Array("84", "73", "32", "65", "77", "79", "32", "80", "73", "78", "65");
		
		msg = "";
		
		for (i=0; i<12;i++) 
		{
			msg = msg + String.fromCharCode( vect[i] );
		}			
		
		window.alert(msg);
		
		sequence="";
	}
	else	
	{	
		//window.alert('DEBUG KEY: ' + sequence);
	}
}

function abUrbeCondida() {
	var bigbang=new Date(2009, 04, 23);
	//Set 1 day in milliseconds
	var one_day=1000*60*60*24;
	//Set the two dates
	today=new Date();
	//Calculate difference btw the two dates, and convert to days
	return Math.ceil((today.getTime()-bigbang.getTime())/(one_day)) + " Dies Ab Urbe Condita";
}
		
function Get_Cookie(name) 
{ 
   var start = document.cookie.indexOf(name+"="); 
   var len = start+name.length+1; 
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";",len); 
   if (end == -1) end = document.cookie.length; 
   return unescape(document.cookie.substring(len,end)); 
} 

function Set_Cookie(name,value,expires,path,domain,secure) 
{ 
	expires = expires * 60*60*24*1000;
	var today = new Date();
	var expires_date = new Date( today.getTime() + (expires) );
	var cookieString = name + "=" +escape(value) + 
	   ( (expires) ? ";expires=" + expires_date.toGMTString() : "") + 
	   ( (path) ? ";path=" + path : "") + 
	   ( (domain) ? ";domain=" + domain : "") + 
	   ( (secure) ? ";secure" : ""); 
	document.cookie = cookieString; 
}

function checkRegisterCookie()
{	
	cookiename=Get_Cookie('mondoaloe_register');

	if (cookiename!=null && cookiename!="")
	{
		return 1;
	}
	else 
	{												
		alert('La tua registrazione è scaduta, oppure i cookie sono stati cancellati dal tuo browser.\n\nPrima di accedere alle sezioni di acquisto della Forever Living FLP\ncompila il modulo di iscrizione nella sezione REGISTRATI di questo sito.\n\nGrazie per la tua collaborazione.');
		return 0;
	}			
	return 1;
}		

function Maximize() 
{				
	if (document.all) 			   
	{ 
		//ie
		top.window.moveTo(0,0); 
		top.window.resizeTo(screen.availWidth,screen.availHeight); 
	} 
	else if (document.layers || document.getElementById) 
	{ 
	   if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth)
		{
			//Op
			top.window.moveTo(0,0); 
			top.window.outerHeight = top.screen.availHeight; 
			top.window.outerWidth = top.screen.availWidth; 					
		} 
	} 
	
	self.moveTo(0,0);
	self.window.outerHeight = self.screen.availHeight; 
	self.window.outerWidth  = self.screen.availWidth; 
}

function checkRegisterCookie()
{	
	cookiename=Get_Cookie('mondoaloe_register');

	//alert(cookiename);
	
	if (cookiename!=null && cookiename!="")
	{
		return 1;
	}
	else 
	{												
		alert('La tua registrazione è scaduta, oppure i cookie sono stati cancellati dal tuo browser.\n\nPrima di accedere alle sezioni di acquisto della Forever Living FLP\ncompila il modulo di iscrizione nella sezione REGISTRATI di questo sito.\n\nGrazie per la tua collaborazione.');
		return 0;
	}			
	return 1;
}
		
function AddToFavorites(key,value,url,description)
{ 	
	//alert(key + "\n" + value + "\n" + url + "\n" + description);

	cookiename=Get_Cookie(key);

	if (cookiename!=null && cookiename!="")
	{
		return 1;
	}
	else 
	{												
		Set_Cookie(key,value,7);
		
		if (window.external) 
		{ 
			window.external.AddFavorite(url,description);
			return 0;
		}	
		
		return 1;
	}
}

function openPMID(id)
{ 	
	url = "http://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&cmd=DetailsSearch&term=";
	url = url + id;
	url = url + "%5Buid%5D&log$=activity";
	
	newwindow=window.open(url,'','width=1100,height=850,scrollbars,resizable,left=100,top=20'); 
	
	if (window.focus){
		newwindow.focus()
	};
}

function openMultimediaNews()
{ 
    url = "http://shop.foreverliving.it/fstore/modules/flp_news/multimedia_files/";	
	nameMth = new Array('gennaio','febbraio','marzo','aprile','maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre','dicembre');  
	syear = new Date(today.getTime()).getYear();
	
	if( syear.length!=4 )
	{
	  //subyear = syear.substr(1, 2);
	  subyear = "10";

	  syear = "20" + subyear; 
	}
		
	url = url + nameMth[(new Date( today.getTime())).getMonth()];
	url = url + "_";
	url = url + syear;
	url = url + "/notiziario_";
	url = url + nameMth[(new Date( today.getTime())).getMonth()];
	url = url + "_";
	url = url + syear;
	url = url + ".html";
	
	newwindow = window.open(url,'','width=1100,height=850,scrollbars,resizable,left=80,top=50'); 
	
	if (window.focus){
		newwindow.focus()
	};
	 
    return;	
}

function ViewContentPageDebug() {
	    alert ("Location: " + window.location.href)
	    alert ("Doc Title: " + window.document.title)
	    alert ("First child: " + document.body.firstChild.nodeName)

	    var frameElem = document.getElementsByTagName("IFRAME")[0]
	    var frameWnd = window.frames[0]
	    alert ("Frame Element src: " + frameElem.src)

	    if (navigator.appName=="Microsoft Internet Explorer") {
	        alert ("Frame Element HTML: " + frameElem.outerHTML)
	        alert ("Frame Element doc Title: " + frameElem.document.title)          // containing document
			alert ("Frame Element Doc Title: " + frameElem.Document.title)          // contained document
			alert ("Frame Element Body HTML: " + frameElem.Document.body.outerHTML)

		    // Can we go up?
			alert ("Going up: " + frameElem.Document.parentWindow.frameElement.document.title)  // Access is denied
	    } 
		else {
			if (navigator.appName=="Opera") {        // Opera
		            alert ("Frame Element HTML: " + frameElem.outerHTML)                    // Opera cleans this up
		            alert ("Frame Element doc Title: " + frameElem.document.title)          // containing document
				    alert ("Frame Element nextSibling: " + frameElem.nextSibling.outerHTML)
			}
			else {                                 // Netscape
			    alert ("Frame Element HTML: " + frameElem.innerHTML)
			    alert ("Frame Element nextSibling: " + frameElem.nextSibling.innerHTML) // Bye Dad
			    alert ("Frame Element firstChild: " + frameElem.firstChild.nodeName)    // #text
			}
		}
}

function HideFrame(frameid){
	var allIfr = document.getElementsByTagName('iframe');
	for(var i=0;i<allIfr.length;i++){
		var iframe = allIfr[i];
		if(frameid==iframe.id){
			iframe.parentNode.removeChild(iframe); 
		}
	}	
	setTimeout("HideFrame(':2.container')",3000);
}

function HideGTranslateFrame(){
	setTimeout("HideFrame(':2.container')",3000);	
}
