dayName = new Array("", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
monName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
now = new Date

function apriChat() {

	var LeftPosition = (screen.width) ? (screen.width-770)/2 : 0; 
	var TopPosition = (screen.height) ? (screen.height-600)/2 : 0; 

	window.open('http://www.rhcp.it/chat.htm','','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=yes,top='+TopPosition+',left='+LeftPosition+',copyhistory=no,width=800,height=550');
	return false;

}

function ctrlPoll(frm) {
	var iCount;
	iCount=0;
	for (i=0;i<frm.elements.length-1;i++) {
		if (frm.risposta[i].checked) {
			frm.submit();
			return false;
		} else {
			iCount=iCount+1;
		}
		if (iCount==frm.elements.length-1) {
			alert("E' obbligatorio selezionare almeno una risposta.");
			return false;
		}
	}
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validate() { 
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validate.arguments;
  for (i=0; i<(args.length-3); i+=4) { 
  test=args[i+2];
 message=args[i+3];
 val=MM_findObj(args[i]);
   
  
    if (val) { 
  nm=val.name; 
  if ((val=val.value)!="") {
         if (test.indexOf('isEmail')!=-1) { 
     p=val.indexOf('@');
           if (p<1 || p==(val.length-1)) errors+='- '+message+' deve contenere un indirizzo e-mail valido.\n';
         } else if (test!='R') {
           if (isNaN(val)) errors+='- '+message+' deve contenere un numero.\n';
           if (test.indexOf('inRange') != -1) { 
      p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
              if (val<min || max<val) errors+='- '+message+' deve contenere un numero compreso tra '+min+' e '+max+'.\n';
        } 
    } 
  } else if (test.charAt(0) == 'R') 
   errors += '- '+message+' è un campo obbligatorio.\n'; 
  }
 } 
  if (errors) {
   alert('Si sono verificati i seguenti errori:\n'+errors);
 return false;
  } else {
   return true;
 //document.MM_returnValue = (errors == '');
  }
}

function MM_validate_ENG() { 
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validate_ENG.arguments;
  for (i=0; i<(args.length-3); i+=4) { 
  test=args[i+2];
 message=args[i+3];
 val=MM_findObj(args[i]);
   
  
    if (val) { 
  nm=val.name; 
  if ((val=val.value)!="") {
         if (test.indexOf('isEmail')!=-1) { 
     p=val.indexOf('@');
           if (p<1 || p==(val.length-1)) errors+='- '+message+' must be a valid e-mail address.\n';
         } else if (test!='R') {
           if (isNaN(val)) errors+='- '+message+' must be a number.\n';
           if (test.indexOf('inRange') != -1) { 
      p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
              if (val<min || max<val) errors+='- '+message+' must be a number between '+min+' and '+max+'.\n';
        } 
    } 
  } else if (test.charAt(0) == 'R') 
   errors += '- '+message+' is required.\n'; 
  }
 } 
  if (errors) {
   alert('The following errors occurred:\n'+errors);
 return false;
  } else {
   return true;
 //document.MM_returnValue = (errors == '');
  }
}

function PlaySong(SongURL){
	PopUp = window.open (SongURL, "Crescendo", "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizeable=no,copyhistory=no,width=200,height=30")
	return false;
}

function addbookmark(){
	var bookmarkurl="http://www.redhotchilipeppers.it"
	var bookmarktitle="The Red Hot Chili Peppers World"
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function controlla(frm) {
	var testo = new String(frm.Find.value);
	var sezione = new String(frm.Section.value);

	if (testo.length < 3) {
		alert("E' obbligatorio inserire almeno tre caratteri.");
		frm.Find.focus();
		return false;
	}
	if(sezione.length == 0) {
		alert("Seleziona una sezione.");
		return false;
	}
	if(testo.indexOf("%") != -1) {
		alert("Carattere di ricerca non valido.");
		frm.Find.focus();		
		return false;
	}
}

function controllaENG(frm) {
	var testo = new String(frm.Find.value);
	var sezione = new String(frm.Section.value);

	if (testo.length < 3) {
		alert("You must insert at least 3 characters.");
		frm.Find.focus();
		return false;
	}
	if(sezione.length == 0) {
		alert("Select a section.");
		return false;
	}
	if(testo.indexOf("%") != -1) {
		alert("Invalid sarch characters");
		frm.Find.focus();		
		return false;
	}
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function apri(valore) {
	var LeftPosition = (screen.width) ? (screen.width-500)/2 : 0; 
	var TopPosition = (screen.height) ? (screen.height-350)/2 : 0; 
	var r; 
	r = window.open('detail_poll.asp?id_poll='+ valore + '','test', 'scrollbars=yes, toolbar=no, location=no,directories=no,status=no,menubar=no, resizable=no,top='+TopPosition+', left='+LeftPosition+',width=450,height=425'); 
	r.focus(); 
}

function fntPopup(spath,id, sleft) {
	var LeftPosition = (screen.width) ? (screen.width-800)+ sleft : 0; 
	var r; 
	//r = window.open(spath + 'lyric.asp?num_lyric=' + id,'', 'scrollbars=yes, toolbar=no, location=no,directories=no, status=no, menubar=yes, resizable=no,top=10,left=' + LeftPosition + ',width=350,height=600');
	r = window.open(spath + 'lyric.asp?num_lyric=' + id,'', 'scrollbars=yes, toolbar=no, location=no,directories=no, status=no, menubar=yes, resizable=no,top=10,left=20,width=350,height=600');
 	r.focus(); 
	return false;
}

function fntPopupTrad(spath,id, sleft) {
	var LeftPosition = (screen.width) ? (screen.width-800)+ sleft : 0; 
	var r; 
	r = window.open(spath + 'lyric.asp?num_lyric=' + id,'', 'scrollbars=yes, toolbar=no, location=no,directories=no, status=no, menubar=yes, resizable=no,top=30,left=600,width=350,height=600');
 	r.focus(); 
	return false;
}

function fntPopupvid(nome) {
	var r; 
	r = window.open(nome,'test', 'scrollbars=no, toolbar=no, location=no,directories=no, status=no, menubar=no, resizable=no,top=10,left=10,width=450,height=295');
 	r.focus(); 
	return false;
}

function fntPopupPar(nome, sleft) {
	var LeftPosition = (screen.width) ? (screen.width-500)/2 : 0; 
	var TopPosition = (screen.height) ? (screen.height-350)/2 : 0; 
	r = window.open(nome, '', 'scrollbars=yes, toolbar=no, location=no,directories=no, status=no, menubar=yes, resizable=no,top=' + TopPosition + ',left=' + LeftPosition + ',width=350,height=530');
 	r.focus(); 
	return false;
}

function fntPopup_var(nome, largh, alt, top, left, menu) {
	var LeftPosition = (screen.width) ? (screen.width-500) : 0; 
	var r; 
	r = window.open(nome, '', 'scrollbars=yes, toolbar=no, location=no,directories=no, status=no, menubar=yes, resizable=no,top=10,left=' + LeftPosition + ',width=' + largh + ',height=' + alt);
 	r.focus(); 
	return false;
}

/*function fntPopup(nome, largh, alt, top, left, menu) {
	var r; 
	r = window.open(nome, '', 'scrollbars=yes, toolbar=no, location=no,directories=no, status=no, menubar=' + menu + ', resizable=no,top=' + top + ',left=' + left + ',width=' + largh + ',height=' + alt);
 	r.focus(); 
	return false;
}*/

function changeForum(frm) {
	if (frm.cmbForum.options[frm.cmbForum.selectedIndex].value == -1) {
		alert('Seleziona un forum.');
		return false;
	}
	frm.forumID.value = frm.cmbForum.options[frm.cmbForum.selectedIndex].value ;//frm.cmbForum.value
	frm.submit()
	return false;

}

function goSubmit(frm) {
	frm.submit();
	return false;
}

function ctrlLogin(frm) {
	if (frm.txt_username.value.length==0) {
		alert("Inserire la username.");
		frm.txt_username.focus();
		return false;
	}
	if (frm.txt_pwd.value.length==0) {
		alert("Inserire la password.");
		frm.txt_pwd.focus();
		return false;
	}
	frm.submit();
	return false;
}

function printFlash(nome,w,h) {

      var objFlash = "<object codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+w+"' height='"+h+"' align='center' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'>";
      objFlash += "<param value='sameDomain' name='allowScriptAccess' />";
      objFlash += "<param name='movie' value='/images/"+nome+"' />";
      objFlash += "<param name='quality' value='high' />";
      objFlash += "<param name='wmode' value='transparent' />";
      objFlash += "<param value='#ffffff' name='bgcolor' />";
      objFlash += "<embed src='/images/"+nome+"' quality='high' wmode='transparent' bgcolor='#ffffff' width='"+w+"' height='"+h+"' align='center' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/>'";
      objFlash += "</object>";

	  document.write(objFlash);
}