// Java Document

//frame check and set
var iframe
if (location.href.indexOf('?iframe=') != -1 ){
iframe=location.href.slice(location.href.indexOf('?iframe=')+8)}


else iframe='http://gx3.netsons.org/wpress/' //'http://gx3.netsons.org/manutenzione.html'
function setframe() {document.getElementById("main").src=iframe}


//index javasctipt style
function geth(){
bh = window.innerHeight;
if (!bh) bh = document.documentElement.clientHeight;
return bh;
}

function resize(theelem,newh,topmargin){
document.getElementById(theelem).style.height=bh-topmargin+"px";
}

function fit(){
idtofit="main";
topmargin=88;
resize(idtofit,geth(),topmargin);
}

window.onload = fit;
window.onresize = fit;

//resolution check
wid= screen.width;
hei= screen.height;
if (screen.width<800)
{
 alert('Attenzione :\n\nQuesto sito è ottimizzato per una risoluzione di almeno 800 pixels di larghezza\n\nTu stai usando una risoluzione di '+wid+'x'+hei+' pixels, che è inferiore a quanto suggerito\n ');
}

/* auto maximize

if (document.all ) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
top.window.moveTo(0,0);
}
else if (document.layers || document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
	top.window.moveTo(0,0);
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
*/

//disable rightclick
document.oncontextmenu = function(){return false}
		   if(document.layers) {
		       window.captureEvents(Event.MOUSEDOWN);
			       window.onmousedown = function(e){
				           if(e.target==document)return false;	
						       }
							   }
							   else {document.onmousedown = function(){return false}}


//Time
function show2()
{
if (!document.all && !document.getElementById)
return
thelement=document.getElementById? document.getElementById("tick2"): document.all.tick2
var Digital=new Date();
var hours=Digital.getHours();
var minutes=Digital.getMinutes();
var seconds=Digital.getSeconds();
var blk;

if (seconds % 2 == 0) blk=":";
else blk='<span style="color:#000000">:</span>';

if (minutes<=9)
minutes="0"+minutes
if (hours<=9)
hours="0"+hours
var ctime=hours+"&nbsp;"+blk+"&nbsp;"+minutes;
thelement.innerHTML=ctime;
setTimeout("show2()",1000);
}

//Date
function typedate()
{
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Dom","Lun","Mar","Mer","Gio","Ven","Sab")
var montharray=new Array("Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic")
document.write("<span class=\"clockstyle\">"+dayarray[day]+" "+daym+" "+montharray[month]+"</span>")
}


	
//Generici

function CreateBookmarkLink() {
        title="Gx3 Home"; 
        url="http://gx3.altervista.org";
            var res = confirm("Istruzioni:\n1) Clicca su ok per far scomparire questa finestra\n2) Premi insieme in sequenza i tasti 'Ctrl+D'")
     }
	 
function sendmail(mail) {
            var res = confirm("Stai per invarmi una E-Mail\nSostituisci [AT] con il simbolo @\nOppure annulla")
			if (res == true) { parent.location.href = "mailto:"+mail+"?subject=From Website - Comment" }
			}

var klink;
function OpenPage()   {
    pazzw = prompt("Please enter password or \"test\"");
	if (pazzw == "undefined" || pazzw == false || pazzw == null) {alert("No password ?\n\n... no party !!!\n "); return}
	if (pazzw == "test") klink="site/testgallery/index.html";
	else  klink="site/"+pazzw+"/index.html";
	parent.main.location.href = klink;
}

//scambio immagine
function swpimg(nimage, container)
{
document.getElementById(container).src = nimage;	
}

//upmenu java
function javamen()
{
menu=document.getElementById("jmenu")
var mitem = new Array();
var build = new String;

mitem[0] = new Array('Stereogrammi','stereog.html');
mitem[1] = new Array('Applett Java','javaapp.html');
mitem[2] = new Array('Stupidario','stupidario.html');

for (i=0; i<mitem.length; i++) build=build+'&nbsp;&nbsp;<a href="'+mitem[i][1]+'">'+mitem[i][0]+'</a>&nbsp;&nbsp;-';
build= build.slice(0,build.length-1);
jmenu.innerHTML=build;
}


//Gestione cookie
function createCookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}




//browser detect
var browser = navigator.appName;
var arl =navigator.appVersion;
browser = browser.slice(0,5);


if (browser == "Micro" ) {
	arl=arl.slice(arl.indexOf("MSIE")+5,arl.indexOf("MSIE")+6);
	hs=readCookie('microsoftexpire');
	if ( hs!='yes' && arl<=6) 
	alert("Stai Usando una versione troppo vecchia di Internet Explorer \nPotresti avere problemi di visualizzazione del sito.\n\nQuesto messaggio si ripetera' solo dopo 7 giorni che mancherai da qui\n ...o se cancelli i cookies \n\n(scarica firefox che e' meglio...)");
	createCookie('microsoftexpire','yes',7);
	}


