var metod="POST";
var postData=null;
//var host='http://localhost/';
var host='http://www.estasi.it/';
var isCheckNickname="";
var insertNickname;
var adminMsg=null;
var isNickname;
var XMLHttpRequestObject = false;
var formObj;
if (window.XMLHttpRequest) {
	XMLHttpRequestObject = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
	XMLHttpRequestObject = new ActiveXObject('Microsoft.XMLHTTP');
}
function getData(dataSource, divID)
	{
	if(XMLHttpRequestObject) {
		//document.getElementById("debugg").style.visibility='visible';
		 if (postData==null)postData="--";
		//document.getElementById("debugg").innerHTML="postdata="+postData+ ":"+ dataSource + "<br>" + divID;
		if (divID!="void"  && divID!="checknick")var obj = document.getElementById(divID);
		XMLHttpRequestObject.open(metod,host+ dataSource);
		XMLHttpRequestObject.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		//obj.innerHTML="postdata="+host+ postData+ ":"+ dataSource + "<br>" + divID;
		//if (divID!="void")obj.innerHTML+="richiesta inviata";
		XMLHttpRequestObject.onreadystatechange = function()
		
			{
			if (XMLHttpRequestObject.readyState == 4 &&
			XMLHttpRequestObject.status == 200) {
			if (divID!="void" && divID!="checknick")
			 {
			 	if(divID=="msg"){
			 	obj.value  =XMLHttpRequestObject.responseText;
				}else{
					obj.innerHTML  =XMLHttpRequestObject.responseText;
					}
			 	
			 	if(divID=="thumbBox")thumbnailviewer.centerDiv(document.getElementById("thumbBox"));
			 	
			 	}
			 
			 else if (divID=="checknick"){
			 	
			 	isNickname=XMLHttpRequestObject.responseText;
				isCheckNickname=true;
			 
			 	//document.getElementById("deb").innerHTML+="*" + XMLHttpRequestObject.responseText+"*<br>";
			 
			 	checkform_r();
			 	}
			
			postData="";
			
			
			//if (serviceDelete>0)serviceDeleted(XMLHttpRequestObject.responseText);
			
			
			}
	}
XMLHttpRequestObject.send(postData);
}
}




function confirmAjax(text,link_,div){
	if(confirm(text)){
			getData(link_,div);
		}	
	}

	function confirmAction(str,url){
		if(confirm(str)){
			window.open(url,'_top');
			}	
	}
function deleteObject(text,link_){
	if(confirm(text)){
		window.open(link_,'_top')
		}	
	}
	
function deleteVideo(n){
	deleteObject('Eliminare il video? ','/section/user/delete_video.php?idv='+n);
	}
	

function deleteFoto(n){
	deleteObject('Eliminare la foto ? ','/section/user/delete_foto.php?id_='+n);
	}
	
function setAdminMsg(t){
	
	if(t.checked){adminMsg=2;}else{adminMsg=1;}
		
	}
	
function closeAdminMsg(){
	document.getElementById("adminMsg").style.visibility="hidden";
	document.getElementById("overlay1").style.visibility="hidden";
	getData('section/user/setAdminMsg.php?adminMsg='+adminMsg,'ms1');
}

function login(){
	postData="";
	var err=""
	if(!document.getElementById("username").value)err="Inserire  Username\n";
	if(!document.getElementById("username").value)err+="Inserire  Password\n";
	if (err){
		alert(err)
		return;
		}else{
		postData="&usernameLog="+document.getElementById("username").value+"&passwordLog="+document.getElementById("password").value;
			getData('/ind.php?p=ind&cmd=cmd&action=loginE','formE');
		
		}
	
	
	}		
	
	
	function vota(n){
		
		//document.getElementById("thumbBox").innerHTML="ciao";
			getData('/ind.php?p=ind&cmd=cmd&action=getVotaTools&des='+n,'thumbBox');
		}
		
	function votaPhoto(n){
		
		//document.getElementById("thumbBox").innerHTML="ciao";
			getData('/ind.php?p=ind&cmd=cmd&action=getVotaToolsPhoto&des='+n,'thumbBox');
		}
	
	
		
	function noShow(n){
		var alertmsg;
		switch (n){
			case "1": alertmsg="Per visualizzare il video è necessario effettuare il Log IN."; break;
			case "2": alertmsg="Per visualizzare il video è necessario essere utente certificato."; break;
			case "3": alertmsg="Per visualizzare il video è necessario avere almeno una foto abilitata."; break;
			
			
			}
		
		
		document.getElementById("thumbBox").innerHTML="<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\"  width=\"425\" height=\"200\" id=\"player\" align=\"middle\"><param name=\"allowFullScreen\" value=\"true\" /><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"/section/flash/alert.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"wmode\" value=\"transparent\" /><param name=\"bgcolor\" value=\"#ffffff\" /><param name=\"FlashVars\" value=\"alertmsg="+alertmsg+"\"><embed src=\"/section/flash/alert.swf\" flashvars=\"alertmsg="+alertmsg+"\" quality=\"high\" bgcolor=\"#ffffff\" width=\"425\" height=\"200\" wmode=\"transparent\" name=\"player\" align=\"middle\" allowScriptAccess=\"sameDomain\" allowFullScreen=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>";
	thumbnailviewer.centerDiv(document.getElementById("thumbBox"));
	
		
		
		}	


function closeBox(){
	//document.getElementById("thumbBox").innerHTML="ssssssssss";
	thumbnailviewer.thumbBox.innerHTML="";
	thumbnailviewer.thumbBox.style.visibility="visible";
}	



function checkFormMsg(){
	if(document.getElementById("oggetto").value==""){
		alert("Attenzione\nInserire il testo dell'oggetto");
		return false;
	}
	if(document.getElementById("msg").value==""){
		alert("Attenzione\nInserire il testo del messaggio");
		return false;
	}
	
	postData="";
	postData+="&oggetto="+escape(document.getElementById("oggetto").value)+ "&msg="+escape(document.getElementById("msg").value)+"&desID="+document.getElementById("desID").value;
	getData('/ind.php?p=ind&cmd=cmd&action=sendMsg','sendMsg');
	
}


			
function checkFormComment(){
	
	if(document.getElementById("commento").value==""){
		alert("Attenzione\nInserire un commento ");
		return false;
	}
	postData="";
	postData+="&commento="+escape(document.getElementById("commento").value)+ "&desID="+document.getElementById("desID").value;
	getData('/ind.php?p=ind&cmd=cmd&action=sendComment','sendComment');
	
}


function checkFormMemo(del){
	
	if(del==1){
		document.getElementById("memo").value="";
		
		}
	
	postData="";
	postData+="&memo="+escape(document.getElementById("memo").value)+ "&usernameM="+document.getElementById("usernameM").value+ "&username_memo="+document.getElementById("username_memo").value;
	getData('/ind.php?p=ind&cmd=cmd&action=sendMemo&del='+del,'sendMemo');
}


		
		
function sendMsg(n){
	getData('/ind.php?p=ind&cmd=cmd&action=formMsg&desID='+n,'sendMsg');
	}
	
function addFavorite(n){
	confirmAjax('Aggiungere questo utente nella tua Lista Preferiti ? ','/ind.php?p=ind&cmd=cmd&action=addFavorite&desID='+n,'favorite');
}

function addBlackList(n){
	confirmAjax('Aggiungere questo utente nella tua Lista Nera ? ','/ind.php?p=ind&cmd=cmd&action=addBlackList&desID='+n,'blacklist'+n);
}
	
	
function sendNickname(){
	postData="&Unickname="+document.getElementById("Unickname").value;
       		
			getData('/ind.php?p=ind&cmd=cmd&action=sendNickName','insNickname');
	
	
	}	
	
function checklen(el,n){
		//alert("Attenzione. Inserire massimo " +n+ " caratteri" +el.value);
	if(el.value.length>n){
		
		alert("Attenzione. Inserire massimo " +n+ " caratteri" );
		}
	
	
	}	
	
function formsearchn(){
	
	window.open('/index.php?section=searchn&q='+document.getElementById("q").value,'_self');
	return false;
	
	
	}	