// Newsky Group (c) 2007 - Tutti i diritti riservati
// Ultima revisione: 22/04/2007

if ( document.location.search.length > 0 )
{
if ( !( IE = navigator.userAgent.indexOf("MSIE ") != -1 ) && navigator.userAgent.indexOf("Firefox") == -1 )
{ alert("Si è verificato un errore. :-(\nIl Deathclock è stato testato con Internet Explorer e Firefox, e potrebbe non funzionare con altri browser.") }
else if ( confirm("Si è verificato un errore. :-(\nPuoi inviarci una mail per segnalarci l'errore e aiutarci a risolverlo.\nNel messaggio saranno indicate le risposte che hai dato e alcune informazioni sul tuo browser e sistema operativo. Tali informazioni saranno usate *unicamente* per cercare di risalire al motivo del problema. Se vuoi puoi aggiungere altre informazioni che ritieni utili/significative per capire il problema.") )
{ link = "mailto:nicholas@newsky.it?subject=[Newsky.it] Segnalazione errori&body=Grazie! [ Pagina " + document.location.toString().substring(0,document.location.toString().indexOf('?')) + " ]   Risposte: " + escape(document.location.search) + " - Sys info: " + navigator.userAgent + " // " + navigator.platform + " // " + screen.width + " - Altre informazioni utili:"
IE ? window.open(link) : document.location = link }
location.replace("index.htm")
}

function opt(text, value)
{
if ( text == null || value == null ) { text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" ; value = "|" }
document.write("<option value='" + value + "'>" + text + "</option>")
}

function initialize()
{
document.modulo.D1.value = document.modulo.D2.value = document.modulo.D3.value = document.modulo.D4.value = document.modulo.D5.value = document.modulo.D6.value = document.modulo.D7.value = document.modulo.D8.value = document.modulo.D9.value = document.modulo.D10.value = document.modulo.D11.value = document.modulo.D12.value = "|"
done = false
switchD1()
switchD2()
switchD3()
switchD4()
switchD5()
switchD6()
switchD7()
switchD8()
switchD9()
switchD10()
switchD11()
switchD12()
}

function switchD1()
{
D1 = document.modulo.D1.value
if ( D1 == 20 ) { text = "I tuoi genitori saranno felici!" }
else if ( D1 == 14 ) { text = "Vabbè vabbè, può succedere..." }
else if ( D1 == 8 ) { text = "Magari quando c'è qualche brutta interrogazione, eh? :-)" }
else if ( D1 == 2 ) { text = "Non è un buon motivo per andare a spasso o a prendere il sole!" }
else if ( D1 == -4 ) { text = "A bere o a lavare i piatti?" }
else { text = null }
comment("D1x",text)
}

function switchD2()
{
D2 = document.modulo.D2.value
if ( D2 == 20 ) { text = "Miseria, sei un(a) santo/a!" }
else if ( D2 == 15 ) { text = "Ma va! Non ti crede nessuno! :-)" }
else if ( D2 == 10 ) { text = "Non facciamoci prendere troppo la mano..." }
else if ( D2 == 5 ) { text = "Ricordati che esiste anche il voto di condotta! (Pfff...)" }
else if ( D2 == 0 ) { text = "A 'sto punto è meglio se stai da Gigi..." }
else { text = null }
comment("D2x",text)
}

function switchD3()
{
D3 = document.modulo.D3.value
if ( D3 == 20 ) { text = "Yawn, mi vien sonno solo a pensarci..." }
else if ( D3 == 16 ) { text = "Già ti vedo alla Normale di Pisa!" }
else if ( D3 == 12 ) { text = "Mah, contento/a te..." }
else if ( D3 == 8 ) { text = "Materie non propriamente \"fondamentali\"..." }
else if ( D3 == 4 ) { text = "Interessi condivisibili, ma non scolasticamente parlando :-P" }
else { text = null }
comment("D3x",text)
}

function switchD4()
{
D4 = document.modulo.D4.value
if ( D4 == 20 ) { text = "Se lo dici te..." }
else if ( D4 == 15 ) { text = "Dev'essere difficile, hai tutta la mia stima!" }
else if ( D4 == 10 ) { text = "Tranqui, 6 in buona kompa! :)" }
else if ( D4 == 5 ) { text = "Questi ragazzi d'oggi, gioventù bruciata..." }
else if ( D4 == 0 ) { text = "Fai come se fossi a casa tua eh..." }
else { text = null }
comment("D4x",text)
}

function switchD5()
{
D5 = document.modulo.D5.value
if ( D5 == 20 ) { text = "Ma sei sempre lì a studiare! E stacca un'attimo!" }
else if ( D5 == 14 ) { text = "Sperando che non ci sia la solita fila..." }
else if ( D5 == 8 ) { text = "Quei santi! Dovresti far loro una statua..." }
else if ( D5 == 2 ) { text = "Cosa?! Ma lo sai che ti fa male? Drogato/a!" }
else if ( D5 == -4 ) { text = "Lascia perdere, con quello che costa oggi la benzina..." }
else { text = null }
comment("D5x",text)
}

function switchD6()
{
D6 = document.modulo.D6.value
if ( D6 == 20 ) { text = "Io proprio non ti capisco... " }
else if ( D6 == 16 ) { text = "I professori ringraziano" }
else if ( D6 == 12 ) { text = "Perché, non dormi la notte se non studi?" }
else if ( D6 == 8 ) { text = "Guarda che non è un'attenuante..." }
else if ( D6 == 4 ) { text = "Ma che ca... non ci crede nessuno!" }
else { text = null }
comment("D6x",text)
}

function switchD7()
{
D7 = document.modulo.D7.value
if ( D7 == 20 ) { text = "Beato/a te!" }
else if ( D7 == 16 ) { text = "Ehh, quella qualche volta gioca brutti scherzi!" }
else if ( D7 == 12 ) { text = "Io con 50€ sottobanco me la cavo... ;-)" }
else if ( D7 == 8 ) { text = "Che tristezza... :-(" }
else if ( D7 == 4 ) { text = "Ormai è la tua seconda casa!" }
else { text = null }
comment("D7x",text)
}

function switchD8()
{
D8 = document.modulo.D8.value
if ( D8 == 20 ) { text = "Immorale?! Ma va?? Veramente? Cribbio..." }
else if ( D8 == 16 ) { text = "Sono le persone come te che fanno andare avanti la classe!" }
else if ( D8 == 12 ) { text = "Non farti beccare però!" }
else if ( D8 == 8 ) { text = "L'arte scolastica più antica del mondo..." }
else if ( D8 == 4 ) { text = "Hai ragione... e poi potresti slogarti il polso, vero?" }
else { text = null }
comment("D8x",text)
}

function switchD9()
{
D9 = document.modulo.D9.value
if ( D9 == 20 ) { text = "Bene! Ci vuole <b>cul</b>tura! " }
else if ( D9 == 16 ) { text = "Non t'affaticare troppo però! Prima si studia!" }
else if ( D9 == 12 ) { text = "Viva la poltroneria!" }
else if ( D9 == 8 ) { text = "Interessante... serve una mano?" }
else if ( D9 == 4 ) { text = "Eh, magari... magari...  " }
else { text = null }
comment("D9x",text)
}

function switchD10()
{
D10 = document.modulo.D10.value
if ( D10 == 20 ) { text = "Ottimo, continua così!" }
else if ( D10 == 17 ) { text = "Tutti uniti contro le ingiustizie dei prof!" }
else if ( D10 == 14 ) { text = "Sarai mica svizzero/a?" }
else if ( D10 == 11 ) { text = "Insomma, non è mica un carcere..." }
else if ( D10 == 8 ) { text = "Ma sei sempre al bar da Gigi??" }
else { text = null }
comment("D10x",text)
}

function switchD11()
{
D11 = document.modulo.D11.value
if ( D11 == 20 ) { text = "Vabbè, era per dire... :-P" }
else if ( D11 == 15 ) { text = "Anche perché non puoi fare molto altro" }
else if ( D11 == 10 ) { text = "Tanto vince lui..." }
else if ( D11 == 5 ) { text = "Calma! Non te la prendere così!" }
else if ( D11 == 0 ) { text = "No comment, spero di non doverti <b>mai</b> parlare!" }
else { text = null }
comment("D11x",text)
}

function switchD12()
{
D12 = document.modulo.D12.value
if ( D12 == 20 ) { text = "Abbiamo un genietto qui..." }
else if ( D12 == 15 ) { text = "L'importante è cavarsela" }
else if ( D12 == 10 ) { text = "Ma sì, alla peggio farai fare alla classe una sana risata" }
else if ( D12 == 5 ) { text = "Non sperare di cavartela così, il quinto emendamento non vale a scuola..." }
else if ( D12 == 0 ) { text = "Mi hai convinto, ci vengo anch'io da Gigi!" }
else { text = null }
comment("D12x",text)
}

function comment(id,text)
{
if ( text == null ) { text = "Rispondi alla domanda!" }
document.getElementById(id).innerHTML = text
}

function calculate()
{
if ( D1 == "|" ) { error(1) }
else if ( D2 == "|" ) { error(2) }
else if ( D3 == "|" ) { error(3) }
else if ( D4 == "|" ) { error(4) }
else if ( D5 == "|" ) { error(5) }
else if ( D6 == "|" ) { error(6) }
else if ( D7 == "|" ) { error(7) }
else if ( D8 == "|" ) { error(8) }
else if ( D9 == "|" ) { error(9) }
else if ( D10 == "|" ) { error(10) }
else if ( D11 == "|" ) { error(11) }
else if ( D12 == "|" ) { error(11) }
else
{
if ( !done ) { /*alert("Ricorda che puoi richiedere il tuo Diploma cliccando sul relativo link in fondo alla pagina.")*/ }
scrollTo(0,1100)
done = true
score = -(-D1-D2-D3-D4-D5-D6-D7-D8-D9-D10-D11-D12)-2
hash = Math.round(Math.sqrt(1 + D1/2 + D2/3 + D3/5 + D4/7 + D5/11 + D6/13 + D7/17 + D8/19 + D9/23 + D10/29 + D11/31 + D12/37)*1000)
k = 19-Math.floor(score/12)
score = Math.floor(score/2.4)/10
IE ? document.styleSheets(1).addRule("#bar1","background-image: url('"+base+"deathclock/_/bar-sc.jpg')") : document.styleSheets[1].insertRule("#bar1 { background-image: url('"+base+"deathclock/_/bar-sc.jpg') }",document.styleSheets[1].cssRules.length)
document.getElementById("verdict").innerHTML = "L'esclusivo e infallibile Studentclock di Newsky.it ti attribuisce un voto di<br><span id='scorex'>0,0</span><br>che ti vale il rango di <span id='classx'></span>&nbsp;(<a href='javascript:levelsList(" + (k+1) + ")'>a che livello sono?</a>):"
document.getElementById("classx").innerHTML = levels[k][0]
if ( screen.width < 1000 )
{ IE ? document.styleSheets(1).addRule("#defx","letter-spacing: -1px") : document.styleSheets[1].insertRule("#defx { letter-spacing: -1px }",document.styleSheets[1].cssRules.length)
IE ? document.styleSheets(1).addRule("#mottox","letter-spacing: -1px") : document.styleSheets[1].insertRule("#mottox { letter-spacing: -1px }",document.styleSheets[1].cssRules.length) }
else
{ IE ? document.styleSheets(1).addRule("#defx","letter-spacing: 0px") : document.styleSheets[1].insertRule("#defx { letter-spacing: 0px }",document.styleSheets[1].cssRules.length)
IE ? document.styleSheets(1).addRule("#mottox","letter-spacing: 0px") : document.styleSheets[1].insertRule("#mottox { letter-spacing: 0px }",document.styleSheets[1].cssRules.length) }
def = levels[k][1]
motto = levels[k][2+hash%4]
document.getElementById("defx").innerHTML = def + "<span style='color: #FFFFFF; font-weight: normal'>.</span>"
document.getElementById("mottox").innerHTML = "<span style='color: #FFFFFF; font-weight: normal'>Dicono i professori: </span>\"" + motto + "\"<span style='color: #FFFFFF; font-weight: normal'>.</span>"
countdown(score*0.05)
window.setTimeout("countdown(" + (score*0.1) + ")",50)
window.setTimeout("countdown(" + (score*0.15) + ")",100)
window.setTimeout("countdown(" + (score*0.2) + ")",150)
window.setTimeout("countdown(" + (score*0.25) + ")",200)
window.setTimeout("countdown(" + (score*0.3) + ")",250)
window.setTimeout("countdown(" + (score*0.35) + ")",300)
window.setTimeout("countdown(" + (score*0.4) + ")",350)
window.setTimeout("countdown(" + (score*0.45) + ")",400)
window.setTimeout("countdown(" + (score*0.5) + ")",450)
window.setTimeout("countdown(" + (score*0.55) + ")",500)
window.setTimeout("countdown(" + (score*0.6) + ")",550)
window.setTimeout("countdown(" + (score*0.65) + ")",600)
window.setTimeout("countdown(" + (score*0.7) + ")",650)
window.setTimeout("countdown(" + (score*0.75) + ")",700)
window.setTimeout("countdown(" + (score*0.8) + ")",750)
window.setTimeout("countdown(" + (score*0.85) + ")",800)
window.setTimeout("countdown(" + (score*0.9) + ")",850)
window.setTimeout("countdown(" + (score*0.95) + ")",900)
window.setTimeout("countdown(" + (score) + ")",950)
}
}

function error(q)
{
alert("Non hai risposto alla domanda " + q + "!")
}

function countdown(score)
{
xscore = ( score < 1 ? "0" : "" ) + Math.round(score*10)
document.getElementById("scorex").innerHTML = xscore.substring(0,1) + "," + xscore.substring(1,2)
IE ? document.styleSheets(1).addRule("#bar1","width: "+Math.round(70*score)+"px!important") : document.styleSheets[1].insertRule("#bar1 { width: "+Math.round(70*score)+"px!important }",document.styleSheets[1].cssRules.length)
}

function attestation()
{
if ( !done ) { alert("Devi chiedere il verdetto prima!") }
else
{ window.open("richiesta.htm?" + score,"richiesta","height=295,width=600,status=no,scrollbars=no,toolbar=no,menubar=no,location=no,resizable=no") }
}

function levelsList(level)
{
n = level == null ? "" : "?" + level
window.open("livelli.htm"+n,"livelli","height=450,width=350,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no,resizable=no")
}