
/********************************************************************************************************
Funzione per chiudere finestra
********************************************************************************************************/
function chiudi(){
	window.close()
}
/********************************************************************************************************
Funzione per stampare pagina
********************************************************************************************************/
function stampa(){
	window.print()
}
/******************************************************************************************************
Funzione per aprire nuova finestra con riassunto del fumetto passandogli l'id del fumetto scelto
(l'ho lasciata perchè i javascript son dentro il db)
******************************************************************************************************/
function riassunto(numero){
	ciao = window.open('manga_riassunto.asp?ID=' + numero,'ciao','scrollbars=1,width=367,height=400,left=100,top=100,resizable=no');
	ciao.focus();
}	
/*******************************************************************************************************
Funzione per immagini random
*******************************************************************************************************/
function rnd_image(percorso){
   var now = new Date();
   var sec_divide = now.getSeconds();
   rnd_number = Math.floor(sec_divide/5);
   document.write('<a href="mailto:san@inuyasha.us?subject=E-mail da un amico di Inuyasha!" onMouseOver="window.status=\'Send me an e-mail\'; return true;" onMouseOut="window.status=\'\'"><img src="' + percorso + 'image' + rnd_number +'.gif" border="0" alt="Scrivimi"></a>');
}
/*********************************************************************************************************
funzione per inserire faccine 
*********************************************************************************************************/
function inserisciFaccine(code,nome){
	if (nome=="form1"){//guestbook da pop-up
		window.opener.document.form1.msg.value += ' ' + code + ' ';
		window.opener.document.form1.msg.focus();
	}
	else if (nome=="form2"){//fastchat
		window.opener.document.form2.msg.value += ' ' + code + ' ';
		window.opener.document.form2.msg.focus();
	}
	else if (nome=="frmControl"){//chat
		window.opener.document.frmControl.message.value += ' ' + code + ' ';
		window.opener.document.frmControl.message.focus();
	}
	else if (nome=="pippo"){//guestbook
		document.form1.msg.value += ' ' + code + ' ';
		document.form1.msg.focus();
	}
}
/*********************************************************************************************************
funzioni per rollover
**********************************************************************************************************/
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
/******************************************************************************************************
Funzione per aprire nuova finestra con path?id dinamici
******************************************************************************************************/
function popappina3(path,id,width,height,left,top){
	popappina = window.open(path+'?ID=' + id,'popappina2','scrollbars=1,width='+ width +',height='+ height +',left='+ left +',top='+ top +',resizable=no');
	popappina.focus();
}
/*******************************************************************************************************
controlli per guestbook
*******************************************************************************************************/
function guestbook () {
	var errore = "";

	//controllo inserimento nick
	if (document.form1.nome.value == ""){
		errore += "\n - Inserisci un nickname!";
	}
	//controllo lunghezza nick
	words = document.form1.nome.value.split(' ');
	for (var loop = 0; loop <= words.length - 1; ++loop){
		if (words[loop].length >= 27){
		errore += "\n - Ciascuna parola del nickname deve essere al massimo di 26 lettere.";
		}	
	}	
	//controllo inserimento commento
	if (document.form1.msg.value == ""){
		errore += "\n - Inserisci un commento!";
	}
	//controllo lunghezza parole commento
	words = document.form1.msg.value.split(' ');
	for (var loop = 0; loop <= words.length - 1; ++loop){
		if (words[loop].length >= 51){
		errore += "\n - Ciascuna parola del commento deve essere al massimo di 50 lettere.";
		}	
	}	
	//controllo presenza tag HTML
	for (var count = 0; count <= 6; ++count){
		if ((document.form1.elements[count].value.indexOf("<", 0) >= 0) && (document.form1.elements[count].value.indexOf(">", 0) >= 0)){
			errore += "\n - Non sono permessi tag HTML.";
		}			
	}
	//controllo mail
	if (document.form1.email.value != ""){
		if (document.form1.email.value.indexOf ('@',0) == -1 || document.form1.email.value.indexOf ('.',0)== -1)
		   errore += "\n - Inserisci un indirizzo e-mail valido! Es.: san@inuyasha.us";
	}
	//controllo sito
	if (document.form1.url.value != ""){
		if (document.form1.url.value.indexOf ('http://',0) == -1 || document.form1.url.value.indexOf ('.',0)== -1)
		   errore += "\n - Inserisci un URL corretto! Es.: http://www.inuyasha.us";
	}
	if (errore != ""){
		errore += alert(errore + "\n");
		return false;
	}
	return true;
}
/*******************************************************************************************************
controlli per newsletter
*******************************************************************************************************/
function newsletter () {
	var errore = "";
	//controllo inserimento mail
	if (document.frm_newletter.mail.value == ""){
		errore += "\n - Inserisci un indirizzo e-mail!";
	}
	//controllo mail
	if (document.frm_newletter.mail.value != ""){
		if (document.frm_newletter.mail.value.indexOf ('@',0) == -1 || document.frm_newletter.mail.value.indexOf ('.',0)== -1)
		   errore += "\n - Inserisci un indirizzo e-mail valido! Es.: san@inuyasha.us";
	}
	if (errore != ""){
		errore += alert(errore + "\n");
		return false;
	}
	return true;
}
/*******************************************************************************************************
controlli per pacchi
*******************************************************************************************************/
function checkPacchi() {
	var errore = "";	
	//controllo che sia inserito un nick
	if (document.frm_pacchi.nick.value == ""){
		errore += "\n - Inserisci un nick!";
	}	
	if (errore != ""){
		errore += alert(errore + "\n");
		return false;
	}
	else	{
	//chiedo conferma
		return confirm('Sei sicuro della tua scelta?');
	}
}
/*******************************************************************************************************
per opacità banner
*******************************************************************************************************/
/*
Gradual-Highlight Image Script II- 
By J. Mark Birenbaum (birenbau@ugrad.cs.ualberta.ca)
Permission granted to Dynamicdrive.com to feature script in archive
For full source to script, visit http://dynamicdrive.com
*/
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
/* object - image to be faded (actual object, not name);
 * destop - destination transparency level (ie 80, for mostly solid)
 * rate   - time in milliseconds between trasparency changes (best under 100)
 * delta  - amount of change each time (ie 5, for 5% change in transparency)
 */
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}
/*******************************************************************************************************
menù scorrevole
*******************************************************************************************************/
/*
	This script (c) 2000 Ivanopulo / DAMN -- http://www.damn.to
	You're free to use it, but please leave this message intact if you do it.
	
	Thanks alot to Marek for making this script NN6 compatible
	
	NN6 notice: It's *very* slow when it comes to timers, and it's an understatement!)
	
	Opera notice: Opera can identify itself as any browser, depending on value chosen
	in Preferences / Connections / Browser identification. This script assumes that it
	identifies itself as Opera. I dare not say it's a bold assumption, but it's default
	is MSIE 5. Go figure.
*/

var bNetscape4	 = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) == "4");
var bNetscape6	 = (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1) >= "5");
var bExplorer4plus = (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substring(0,1) >= "4");
var bOpera5		= (navigator.appName == "Opera" && navigator.appVersion.substring(0,1) >= "5" );

var nn6DivMenu; // specially for NN6 to speed up things at least a little
var topoffset = 1;
var wheigth;


function CheckUIElements()
{
	var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;
	
	if ( bNetscape4 ) {
		yMenuFrom   = document["divMenu"].top;
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	else if ( bExplorer4plus ) {
		yMenuFrom   = parseInt (divMenu.style.top, 10);
		yMenuTo	 = document.body.scrollTop + topoffset;
		wheight = document.body.clientHeight;
	}
	else if ( bNetscape6 ) {
		yMenuFrom   = nn6DivMenu.style.top.replace(/px/,"");
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	else if ( bOpera5 ) {
		yMenuFrom   = nn6DivMenu.style.top;
		yMenuTo	 = top.pageYOffset + topoffset;
		wheight = top.innerHeight;
	}
	
	
	timeoutNextCheck = 500;
	
	if ( yMenuFrom != yMenuTo && wheight >= 588 ) {
	
		if ( bNetscape6 )
			yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 10 );
		else
			yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 30 );
			
		if ( yMenuTo < yMenuFrom )
			yOffset = -yOffset;
		
		timeoutNextCheck = 10;

		if ( bNetscape4 )
			document["divMenu"].top += yOffset;
		else if ( bExplorer4plus )
			divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
		else if ( bOpera5 )
			nn6DivMenu.style.top += yOffset;
		else if ( bNetscape6 ) {
			nn6DivMenu.style.top = eval(nn6DivMenu.style.top.replace(/px/,"")) + yOffset;
			timeoutNextCheck = 50;
		}

		timeoutNextCheck = 10;
	}

	setTimeout ("CheckUIElements()", timeoutNextCheck);
}

function OnLoad()
{
	// we're not gonna be loaded in frames, no sir!
	if ( top.frames.length )
		top.location.href = self.location.href;
		
	// setting initial UI elements positions
	if ( bNetscape4 ) {
		document["divMenu"].top = top.pageYOffset + topoffset;
		document["divMenu"].visibility = "visible";
	}
	else if ( bExplorer4plus ) {
		divMenu.style.top = document.body.scrollTop + topoffset;
		divMenu.style.visibility = "visible";
	}
	else if ( bNetscape6 || bOpera5 ) {
		nn6DivMenu = document.getElementById('divMenu');
		nn6DivMenu.style.top = top.pageYOffset + topoffset;
		nn6DivMenu.style.visibility = "visible";
	}
	
	// initializing UI update timer
	CheckUIElements();
	return true;
}

