
if (navigator.appName=="Netscape"){ //Netscape 4.x 
  document.write("<link rel='stylesheet' href='../css/ad_netscape.css' type='text/css'>"); 
} else {
  document.write("<link rel='stylesheet' href='../css/ad.css' type='text/css'>"); 
}

var bookmarkurl="http://www.italiarap.com";
var bookmarktitle="ItaliaRap.com - Il Portale della Cultura Rap in Italia ";

function preferiti(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function home() {  
if(document.all)
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage('http://www.italiarap.com');
}

document.oncontextmenu = nocontextmenu; 
document.onmousedown = norightclick; 
if (window.Event) 
document.captureEvents(Event.MOUSEUP); 

function norightclick(e) 
{ if (window.Event) 
{ if (e.which == 2 || e.which == 3) 
{ return false; } 
} 
else 
{ if (event.button == 2 || event.button == 3) 
{ event.cancelBubble = true 
event.returnValue = false; 
return false; 
} 
} 
} 
function nocontextmenu() 
{ event.cancelBubble = true 
event.returnValue = false; 
return false; 
} 


function apriTerm(val){
		linkk= "term.php"
		window.open(linkk,"blank","toolbar=no,width=630,height=320,top=0,left=0")
}
function apriad(val){
		linkk= "ad.html"
		window.open(linkk,"blank","toolbar=no,width=550,height=720")
}

//bottone lista
function mouseover_lista(menu,page){
menu.style.background='#F3CB09';
menu.style.color='#F3CB09';
} 
function mouseover_listaCommunity(menu,page){
menu.style.background='#990500';
} 
function mouseover_listamy(menu,page){
menu.style.background='#eeeeee';
menu.style.color='#aaaaaa';
} 
function mouseout_listaCommunity(menu,page){
menu.style.background='#F9C300';
} 
function mouseout_lista(menu){
menu.style.background='#FFFFFF'
menu.style.color='#990500';
} 
//Lista in homepage
function mouseout_listahp(menu){
menu.style.background='#993639'
} 
//Lista in homepage per la gallery
function mouseout_listahpGallery(menu){
menu.style.background='#000000'
} 
//Lista in my
function mouseout_listamy(menu){
menu.style.background='#bbbbbb'
} 
//fine bottone lista

//NEWSLETTER
function inviaDati(){
	if (document.frmEmail.FEmail.value==""){
		alert("Inserisci la tua email");
	}else{
		document.frmEmail.FInviaN.value="true"
		document.frmEmail.submit();
	}
}

//Controllo Email 
function controlloEmail(t) { 
 	var pos=0;
	var alfabeto = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	var numeri = "0123456789";	
	var caratteri = alfabeto + numeri;

	for (i=0; i<(t.value.length); i++)
	{
		stringa = t.value.substring(i,i+1);
		pos = caratteri.indexOf(stringa);
	}

	if (t.value.length>0){
		if (t.value.indexOf ('@',0) == -1 || t.value.indexOf ('.',0) == -1 || 
			t.value.indexOf ('.',0) == 0 || t.value.indexOf ('@',0) == 0 || 
			t.value.indexOf ('.',0) == t.value.length-1 || t.value.indexOf ('@',0) == t.value.length-1) 

			pos = -1;
	}

	if (pos == -1){
		alert("Formato email non corretto") 
		t.select(); 
		return false; 
	}
}

// Submit per recupero password 
function inviaEventi(f)
 {
	var strErr = "";
	
	if (f.FTit.value.length==0)
		strErr = strErr +  "Evento?\n";
	if (f.FLoc.value.length==0)
		strErr = strErr +  "Location?\n";
	if (f.GG.value=="-" || f.MM.value=="-" || f.AA.value=="")
		strErr = strErr +  "Data?\n";
	if (f.FCit.value.length==0)
		strErr = strErr +  "Indirizzo?\n";
	if (f.FSta.value=="x" || f.FSta.value=="")
		strErr = strErr +  "Regione?\n";
	if (f.FDet.value.length==0)
		strErr = strErr +  "Descrizione?\n";
	
	if (strErr.length>0)
	{ 
		alert ("Attenzione: \n"+strErr);
	}else{
		f.FInviaEventi.value=true;
		f.submit();
	}
 }
 
function apriinvioart(idnot){
	linkk= "http://www.italiarap.com/ita/gen/emailarticle.php?idnot="+idnot
	window.open(linkk,"blank","toolbar=no,width=400,height=350")
}
function apriinvioartusa(idnot){
	linkk= "../gen/emailarticleUSA.php?idnot="+idnot
	window.open(linkk,"blank","toolbar=no,width=400,height=350")
}

function inviaCommento(f)
 {
	var strErr = "";

	if (f.FRes.value.length==0)
		strErr = strErr +  "Scrivere il nome\n";
	if (f.FDes.value.length==0)
		strErr = strErr +  "Scrivere il commento\n";
		
	if (strErr.length>0)
	{ 
		alert (strErr);
	}else{
		f.FInviaCom.value=true;
		f.submit();
	}
 }
 // **** GENERALE ****
// mode => 	T : Testo
//	   		N : Numerico	
// Controllo contenuto testuale / numerico
 function controlloTestoNumero(t,mode)
 {
 	var pos=0;
	var alfabeto = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "
	var caratteriSpeciali = "'|!£$%&/()?^" + "\x5C" 
	var caratteri = alfabeto + caratteriSpeciali;
	var numeri = "0123456789";	

	for (i=0; i<(t.value.length); i++)
	{
		stringa = t.value.substring(i,i+1);
		
		switch (mode){
			case "T" : pos = caratteri.indexOf(stringa);
			break;

			case "N" : pos = numeri.indexOf(stringa);
			break;
		}

		if (pos==-1)
			break;
	}
	
	if (mode == "T" && pos==-1) 
	{
		alert ("Questa casella accetta solo testo");
		t.select();
		return false;
	}
	
	if (mode == "N" && pos==-1)
	{
		alert ("Questa casella accetta solo valori numerici");
		t.select();
		return false;
	}
	
	return true;
 }

//Controllo Email 
function controlloEmail(t) { 
 	var pos=0;
	var alfabeto = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	var numeri = "0123456789";	
	var caratteri = alfabeto + numeri;

	for (i=0; i<(t.value.length); i++)
	{
		stringa = t.value.substring(i,i+1);
		pos = caratteri.indexOf(stringa);
	}

	if (t.value.length>0){
		if (t.value.indexOf ('@',0) == -1 || t.value.indexOf ('.',0) == -1 || 
			t.value.indexOf ('.',0) == 0 || t.value.indexOf ('@',0) == 0 || 
			t.value.indexOf ('.',0) == t.value.length-1 || t.value.indexOf ('@',0) == t.value.length-1) 

			pos = -1;
	}

	if (pos == -1){
		alert("Formato email non corretto") 
		t.select(); 
		return false; 
	}
}
 
 //bottone lista
function mouseover_lista(menu,page){
menu.style.background='#F3CB09';
menu.style.color='#F3CB09';
} 

function mouseout_lista(menu){
menu.style.background='#FFFFFF'
menu.style.color='#990500';
} 
//fine bottone lista
function open_tv(){
	linkk= "italiarap_tv.html"
	window.open(linkk,"blank","toolbar=no,width=430,height=660,top=0,left=0")
}
function open_radio(){
	linkk= "http://www.shoutcast.com/shoutcast_player?stationid=268&Genre=hip&ContentFlag=1&uc=U&isCallInternal=NO&related=yes"
	window.open(linkk,"blank","toolbar=no,width=840,height=620,top=0,left=0")
}
function inviaLink(f)
 {
	var strErr = "";

	if (f.FRes.value.length==0)
		strErr = strErr +  "Error: Title\n";
	
	if (f.FDes.value.length==0)
		strErr = strErr +  "Error: Description\n";

	if (f.FUrl.value.length==0)
		strErr = strErr +  "Error: Url\n";

	if (strErr.length>0)
	{ 
		alert (strErr);
	}else{
		f.FInviaCom.value=true;
		f.submit();
	}
 }
//-------------
//  COMMUNITY
//-------------
var xmlhttp

//---------------
//Stato Utente
//---------------
function loadXMLDocStatoUtente(url)
{
// codice per Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=xmlhttpChange
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// codice per  IExplore
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=xmlhttpChange
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}
function xmlhttpChange()
{
	if (xmlhttp.readyState == 4) {  
		var response = xmlhttp.responseText;  
		var update = new Array();  
		if(response.indexOf('|' != -1)) {  
			 update = response.split('|'); 
		}
		if (update[1] == "OK"){
			document.getElementById('statoUtente').innerHTML = update[0];
			document.form.Stato.value="";
		} 
	}  
}
// - Cambia Stato all'utente
function CambioStato(action) {
 var arg = document.form.Stato.value;
 var idute = document.form.idute.value;  
 var str = "ajax/cambiaStato.php?action="+action+"&arg="+arg+"&idute="+idute;
 loadXMLDocStatoUtente(str);
}
//-------------------
//Fine Stato Utente
//-------------------
//---------------
//Video YouTube
//---------------
function loadXMLDocVideo(url)
{
// codice per Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=xmlhttpChangeV
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// codice per  IExplore
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=xmlhttpChangeV
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}
function xmlhttpChangeV()
{
	if (xmlhttp.readyState == 4) {  
		var response = xmlhttp.responseText;  
		var update = new Array();  
		if(response.indexOf('|' != -1)) {  
			 update = response.split('|'); 
		}
		if (update[1] == "OK"){
			document.getElementById('statoVideo1').innerHTML = "<object width=\"425\" height=\"344\"><param name=\"movie\" value='"+update[0]+"' \"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src='"+update[0]+"' type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"425\" height=\"344\"></embed></object>";
			document.formVideo.Video.value="";
		} 
	}  
}
// - Cambia video all'utente
function CambioVideo(action) {
 var arg = document.formVideo.Video.value;
 var idute = document.formVideo.idute.value;  
 var str = "ajax/cambiaVideo.php?action="+action+"&arg="+arg+"&idute="+idute;
 loadXMLDocVideo(str);
}
//-------------------
//Fine Video
//-------------------
//-------------------
//Richiesta Amicizia
//-------------------
function loadXMLDocFriends(url)
{
// codice per Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=xmlhttpChangeFriends
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// codice per  IExplore
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=xmlhttpChangeFriends
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}
function xmlhttpChangeFriends()
{
	if (xmlhttp.readyState == 4) {  
		var response = xmlhttp.responseText;  
		var update = new Array();  
		if(response.indexOf('|' != -1)) {  
			 update = response.split('|'); 
		}
		if (update[1] == "OK"){
			document.getElementById('friends').style.display='none';
			document.getElementById('RichiestaFriends').style.display='';
			document.getElementById('RichiestaFriends').innerHTML = update[0];
		} 
	}  
}
function ReqFriends(action) {
 var arg = document.formFriends.TestoFriend.value;
 var idute = document.formFriends.idute.value;  
 var iddes = document.formFriends.iddes.value;
 var str = "ajax/friendRequest.php?action="+action+"&arg="+arg+"&idute="+idute+"&iddes="+iddes;
 loadXMLDocFriends(str);
}
//-------------------
//Fine Richiesta Amicizia
//-------------------


//-------------------
//Accetta Richiesta Amicizia
//-------------------
function loadXMLDocAccFriends(url)
{
// codice per Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=xmlhttpChangeAccFriends
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// codice per  IExplore
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=xmlhttpChangeAccFriends
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}
function xmlhttpChangeAccFriends()
{
	if (xmlhttp.readyState == 4) {  
		var response = xmlhttp.responseText;  
		var update = new Array();  
		if(response.indexOf('|' != -1)) {  
			 update = response.split('|'); 
		}
		if (update[1] == "OK"){
			document.location.href=update[0]+".html";
			//document.getElementById('RichiestaFriends').innerHTML = update[0];
		} 
	}  
}
function AccFriends(action) {
 var idute = document.formAccFriends.idute.value;  
 var iddes = document.formAccFriends.iddes.value;
 var str = "ajax/acceptFriendRequest.php?action="+action+"&idute="+idute+"&iddes="+iddes;
 loadXMLDocAccFriends(str);
}
//-------------------
//Fine Accetta Amicizia
//-------------------

//-------------------
//Inizio Wall
//-------------------
function loadXMLDocWall(url)
{
// codice per Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  xmlhttp.onreadystatechange=xmlhttpChangeWall
  xmlhttp.open("GET",url,true)
  xmlhttp.send(null)
  }
// codice per  IExplore
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
    if (xmlhttp)
    {
    xmlhttp.onreadystatechange=xmlhttpChangeWall
    xmlhttp.open("GET",url,true)
    xmlhttp.send()
    }
  }
}
function xmlhttpChangeWall()
{
	if (xmlhttp.readyState == 4) {  
		var response = xmlhttp.responseText;  
		var update = new Array();  
		if(response.indexOf('|' != -1)) {  
			 update = response.split('|'); 
		}
		if (update[1] == "OK"){
			document.location.href=update[0]+".html";
		} 
	}  
}
// - Aggiungi post in bacheca
function AddWall(action) {
 var arg = document.formWall.FWall.value;
 var idute = document.formWall.idute.value;  
 var iddes = document.formWall.iddes.value;  
 var str = "ajax/wall.php?action="+action+"&arg="+arg+"&idute="+idute+"&iddes="+iddes;
 loadXMLDocWall(str);
}
//-------------------
//Fine Wall
//-------------------

//-------------------
//Inizio Ricerca
//-------------------
function createRequestObject() {   
    var ro;   
    var browser = navigator.appName;   
    if(browser == "Microsoft Internet Explorer"){   
        ro = new ActiveXObject("Microsoft.XMLHTTP");   
    }else{   
        ro = new XMLHttpRequest();   
    }   
    return ro;   
}   
  
var http = createRequestObject();
     
function sndReq(action) {
	if (document.frmRicerca.FRicUte.value!=""){
		var arg = document.frmRicerca.FRicUte.value; 
		http.open('get', 'ajax/ajaxSearch.php?action='+action+'&arg='+arg);  
    http.onreadystatechange = handleResponse;    
    http.send(null); 
	}
}  
function handleResponse() {   
    if(http.readyState == 4){   
        var response = http.responseText;   
        var update = new Array();   
        if(response.indexOf('|' != -1)) {   
            update = response.split('|'); 
			if (update[1] == "OK"){   
				document.getElementById('messaggio').innerHTML = update[2]; 
			} else {
				document.getElementById('messaggio').innerHTML = "";
			}
        }   
    }   
}  
//-------------------
//Fine Ricerca
//-------------------
//-----------------------------
// VERIFICA CHE I CAMPI DEL
// FORM NON SIANO VUOTI
// 
//REGISTRAZIONE
//-----------------------------
function verificaForm(f){
  var strErrore = "";
  var errore = false;
 	
	for (i=0; i<f.elements.length; i++){
		strErrore = "err_"+f.elements[i].name;
		switch (f.elements[i].type){
		case "text":
		case "password":
			if (f.elements[i].value.length == 0){	
				errore = true;			
				document.getElementById(strErrore).innerHTML = "<img src='errore.jpg' alt='Errore!'>";
			}else{
				document.getElementById(strErrore).innerHTML = "";
			}
		break;
		case "select":
			if (f.elements[i].value == ""){
				errore = true;			
				document.getElementById(strErrore).innerHTML = "<img src='errore.jpg' alt='Errore!'>";
			}else{
				document.getElementById(strErrore).innerHTML = "";
			}
		break;
		}
	}
	
	if (errore==false){
		f.Attiva.value=true;
		f.submit();
	}
 }
 //-----------------------------
// VERIFICA CHE I CAMPI DEL
// FORM NON SIANO VUOTI
//-----------------------------
function verificaFormInfo(f){
  var strErrore = "";
  var errore = false;
 	
	for (i=0; i<f.elements.length; i++){
		strErrore = "err_"+f.elements[i].name;
		switch (f.elements[i].type){
		case "text":
		case "password":
			if (f.elements[i].value.length == 0){	
				errore = true;			
			}
		break;
		case "select":
			if (f.elements[i].value == ""){
				errore = true;			
			}
		break;
		}
	}
	
	if (errore==false){
		f.Attiva.value=true;
		f.submit();
	}
 }
 
//-----------------------------
// X TEXTAREA (MAXLENGTH)
// CONTROLLO FORM
//-----------------------------
function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}


function ricercaUtente(f)
 {
	var strErr = "";

	if (f.FRicUte.value.length==0)
		strErr = strErr +  "Name or Surname\n";
	
	if (strErr.length>0)
	{ 
		alert (strErr);
	}else{
		f.FInviaRic.value=true;
		f.submit();
	}
 }
 
 function inserisciFoto(f)
 {
	var strErr = "";
	
	if (f.FTitImg.value.length==0)
		strErr = strErr +  "Description\n";
	if (f.FImg.value.length==0)
		strErr = strErr +  "Photo\n";
	
	if (strErr.length>0)
	{ 
		alert ("Choose: \n"+strErr);
	}else{
		f.FInviaFoto.value=true;
		f.submit();
	}
 }
 
 function invitaUtente(f)
 {
	var strErr = "";
	var ok = "";
	
	if (f.FInvitaEmail.value.length==0){
		strErr = strErr + "Email\n";	
	} else {
		ok = controlloEmail(f.FInvitaEmail);
		if (ok==false) strErr = strErr + "Error\n";
	}
	
	if (strErr.length>0)
	{ 
		alert (strErr);
	}else{
		f.FInviaInvita.value=true;
		f.submit();
	}
 }
 
 function opPhoto(f,o,cod)
 {
	if (cod == "Y"){
		f.FOperaz.value=o;
		f.FInviaPhoto.value=true;
		f.submit();
	}
 }