function getContent(offset,limit,qs,ord,inc){
	if(inc == "usersform"){
		$("#uloadimg").load("inc."+inc+".php",{offset:offset,limit:limit,qs:qs,ord:ord});
	} else if(inc == "photographerform"){
		$("#uloadimg").load("inc."+inc+".php",{offset:offset,limit:limit,qs:qs,ord:ord});
	} else if(inc == "shopform"){
		$("#uloadshopimg").load("inc."+inc+".php",{offset:offset,limit:limit,qs:qs,ord:ord});
	} else if(inc == "uloadgallery"){
		$("#uloadimg").load("inc."+inc+".php",{offset:offset,limit:limit,qs:qs,ord:ord});
	}  else if(inc == "ploadimg"){
		$("#uloadimg").load("inc."+inc+".php",{offset:offset,limit:limit,qs:qs,ord:ord});
	} else {
		$("#"+inc).load("inc."+inc+".php",{offset:offset,limit:limit,qs:qs,ord:ord});
	}	
}

function openWindow (url,tit,widgets) {
	popupWin = window.open (url,tit,widgets);
	popupWin.focus();
}

function show_hide(id){
	if(document.getElementById(id).style.display == "block") {
		document.getElementById(id).style.display = "none";
	}
	else if(document.getElementById(id).style.display == "" || document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	}
	return;
}

function loadImg(divtoshow,srcimg,file){	
	show_hide(divtoshow);
	document.getElementById(srcimg).src = file;
}

function getSmallCall(annomesegiorno,nome_campo){
	$("#smallcal").load("inc.small_cal.php",{annomesegiorno:annomesegiorno,nome_campo:nome_campo});
	if(document.getElementById("smallcal").style.display == "" || document.getElementById("smallcal").style.display == "none") {
		document.getElementById("smallcal").style.display = "block";
	}
}

function setCampoData(data,nome_campo){	
	document.getElementById(nome_campo).value = data;
	show_hide('smallcal');	
}


//***************************************
//USER FUNCTION
//***************************************

function getCal(annomesegiorno){
	$("#cal").load("cal.inc.php?annomesegiorno=" + annomesegiorno,"");
}

function addEventForm(id,tab){
	$("#eventadd").load("eventadd.inc.php",{id:id,tab:tab});		
}

function sendEmail(){
	$("#email_sender").load("activation_again.php","");
}

function meetPeople(id1,id2,action,divdest){
	$("#"+divdest).load("inc.meetpeople.php",{id1:id1,id2:id2,action:action,divdest:divdest});
}

function meetShop(idshop,action){
	$("#meetshop").load("inc.meetshop.php",{idshop:idshop,action:action});	
}

function send_mess(form_mess){	
	titmess = document.getElementById("titmess").value;
	mess = document.getElementById("mess").value;
	id1 = document.getElementById("id1").value;
	id2 = document.getElementById("id2").value;	
	divdest = document.getElementById("divdest").value;	
	$("#"+divdest).load("inc.meetpeople.php",{titmess:titmess,mess:mess,id1:id1,id2:id2,action:"do",divdest:divdest});
}

function send_mess_shop(form_mess){	
	titmess = document.getElementById("titmess").value;
	mess = document.getElementById("mess").value;
	email = document.getElementById("email").value;
	spamco = document.getElementById("spamco").value;
	idshop = document.getElementById("idshop").value;
	if(mess=="" && titmess=="")$("#msg").load("all_message.php",{msg:'oshopmsg'});
	else if(email=="")$("#msg").load("all_message.php",{msg:'oemail'});
	else if(spamco!="7Y6HG5")$("#msg").load("all_message.php",{msg:'ospamco'});
	else $("#meetshop").load("inc.meetshop.php",{titmess:titmess,mess:mess,email:email,idshop:idshop,action:"do",spamco:spamco});
}

function reademail(id_email,updt){
	$("#reademail"+id_email).load("inc.reademail.php",{id_email:id_email,updt:updt});	
}

function changeimgstatus(id_img,id_users,action){
	$("#manageimg").load("inc.manageimg.php",{id_img:id_img,id_users:id_users,action:action});
}

function breakfr(id_logged,id_users,inc){
	$("#"+inc).load("inc.breakfr.php",{id_logged:id_logged,id_users:id_users,inc:inc});	
}

function eventdet(id_events,id_usershop,tab){
	$("#uevent").load("eventedit.inc.php",{id_events:id_events,id_usershop:id_usershop,tab:tab});	
}

function getFP(nick_p,email_p,type_p){
	$("#forgotpassword").load("hje6r7hsk.php",{nick_p:nick_p,email_p:email_p,type_p:type_p});	
}

function manageRequest(id1, id2, accept,sw_fr){
	$("#managerequest").load("manage_request.php?id1="+id1+"&id2="+id2+"&accept="+accept+"&sw_fr="+sw_fr,"");	
}

function addPhoto(id_users){
	$("#addphoto").load("addphoto.php",{id_users:id_users});
}

function vota(id_img,realid){
	if(id_img+realid == "home_1"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_3"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_4"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_5"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_6"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_7"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_8"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_9"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		if(document.getElementById("home_rate"+realid).value == "1"){
			document.getElementById("home_1"+realid).src = "images/stella_grigia.gif"
			document.getElementById("home_rate"+realid).value = 0;
		} else {
			document.getElementById("home_rate"+realid).value = 1;
		}			
	} else if(id_img+realid == "home_2"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_4"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_5"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_6"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_7"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_8"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_9"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_rate"+realid).value = 2;
	} else if(id_img+realid == "home_3"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_4"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_5"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_6"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_7"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_8"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_9"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_rate"+realid).value = 3;
	} else if(id_img+realid == "home_4"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_4"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_5"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_6"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_7"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_8"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_9"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_rate"+realid).value = 4;
	} else if(id_img+realid == "home_5"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_4"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_5"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_6"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_7"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_8"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_9"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_rate"+realid).value = 5;
	} else if(id_img+realid == "home_6"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_4"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_5"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_6"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_7"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_8"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_9"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_rate"+realid).value = 6;
	} else if(id_img+realid == "home_7"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_4"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_5"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_6"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_7"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_8"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_9"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_rate"+realid).value = 7;
	} else if(id_img+realid == "home_8"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_4"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_5"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_6"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_7"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_8"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_9"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_rate"+realid).value = 8;
	} else if(id_img+realid == "home_9"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_4"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_5"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_6"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_7"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_8"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_9"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_10"+realid).src = "images/stella_grigia.gif";
		document.getElementById("home_rate"+realid).value = 9;
	} else if(id_img+realid == "home_10"+realid) {
		document.getElementById("home_1"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_2"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_3"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_4"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_5"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_6"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_7"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_8"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_9"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_10"+realid).src = "images/stella_accesa.gif";
		document.getElementById("home_rate"+realid).value = 10;
	} 		
}

function doRate(idtoberated,what){
	//mi prendo il valore e chiamo a seconda ratephoto o ratepeople	o rateuser_img	
	if(what=="rateuserimg"){
		var hr = document.getElementById("home_rate"+idtoberated).value;
		$("#rateuserimg"+idtoberated).load("do.rateuserimg.php",{idtoberated:idtoberated,home_rate:hr});
	} else if(what=="rategallery"){
		var hr = document.getElementById("home_rate"+idtoberated).value;
		$("#rategallery"+idtoberated).load("do.rategallery.php",{idtoberated:idtoberated,home_rate:hr});
	} else {
		var hr = document.getElementById("home_rate").value;
		$("#ratepeople").load("do."+what+".php",{idtoberated:idtoberated,home_rate:hr});
	}	
}

function doNextRate(hr,id,quale){
	if(hr>0){
		doRate(id,quale);		
	} else {
		document.getElementById("home_1").focus();
		$("#msg").load("all_message.php",{msg:'noratenonext'});
	}
}

function doRate_sw(id_sw,home_or_away){
	$("#rating").load("do.ratesw.php?id_sw="+id_sw+"&home_or_away="+home_or_away,"");
}

function updatescreenrate(currrate,realid){
	$("#home"+realid).load("screenratepeople.php?home="+currrate,"");
}

function updatescreenrate_sw(newrate_home, newrate_away){
	$("#home").load("screen.php?home="+newrate_home,"");
	$("#away").load("screen.php?away="+newrate_away,"");
}

function doButton(divid){
	bottoni = document.getElementById(divid+"_b");	
	if(divid == "assbyshop"){		
		if(document.getElementById(divid).style.display == "block")html = "<a href=\"javascript:show_hide('"+divid+"');show_hide('assbyshopu');show_hide('contaassbyshop');doButton('"+divid+"');\" title=\"close\">[X]</a>";
		else html = "<a href=\"javascript:show_hide('"+divid+"');show_hide('assbyshopu');show_hide('contaassbyshop');doButton('"+divid+"');\" title=\"open\">[-]</a>";
	} else {
		if(document.getElementById(divid).style.display == "block")html = "<a href=\"javascript:show_hide('"+divid+"');doButton('"+divid+"');\" title=\"close\">[X]</a>";
		else html = "<a href=\"javascript:show_hide('"+divid+"');doButton('"+divid+"');\" title=\"open\">[-]</a>";
	}
	bottoni.innerHTML = html;
}

function doInnerHtml(divid,html){
	bottoni = document.getElementById(divid);
	bottoni.innerHTML = html;
}

//***************************************
//SHOP FUNCTION
//***************************************

function getProduct(id_collection,dove){
	$("#"+dove).load("inc."+dove+".php?qs=idIS_"+id_collection,"");
}

function getProductSearch(id_collection,dove,dp){
	$("#"+dove).load("inc."+dove+".php?qs=idIS_"+id_collection,{divprod:dp});
}


function getCollectionList(idshop,selecollection){
	$("#selcollection").load("inc.listcollection.php",{idshop:idshop,selecollection:selecollection});
}

function doProduct(modulo,caso){		
	//faccio un check dei campi per l'inserimento del prodotto e poi a seconda del caso (1,2,3) faccio update o insert
	//IL CHECK VA RAFFINATO!!! ********************************
	if(modulo.product.value == ""){
		$("#msg").load("all_message.php",{msg:'noprodins'});
		modulo.product.focus();
		return;
	} else if(modulo.prezzo.value == ""){
		$("#msg").load("all_message.php",{msg:'noprezzo'});
		modulo.product.focus();
		return;
	} else {
		if(caso == "1" || caso == "2")modulo.submit();
		else if(caso == "3"){
		
		}
	}		
}

function dodelprod(id_product,idshop){
	$("#delproduct").load("delproduct.php",{id_product:id_product,idshop:idshop});
}

function check_collection(modulo,action){
	if(modulo.collection.value == ""){
		$("#msg").load("all_message.php",{msg:'nocollins'});
		modulo.collection.focus();
		return;	
	} else if(modulo.startdate.value == ""){
		$("#msg").load("all_message.php",{msg:'nostartdate'});
		modulo.startdate.focus();
		return;	
	} else {
		if(action == "edit"){
			$("#pres_coll").load("inc.updatecollection.php",{id_shop:modulo.id_shop.value,idcoll:modulo.id_collection.value,coll:modulo.collection.value,pres: modulo.presentation.value,stdt:modulo.startdate.value});
		} else {
			$("#pres_coll").load("inc.addcollection.php",{id_shop:modulo.id_shop.value,coll:modulo.collection.value,pres: modulo.presentation.value,stdt:modulo.startdate.value});
		}			
	}
}

function doshopassoc(modulo,id_shop,fkstyle,idphoto,offset){
	if((typeof(modulo.top) != "undefined") && modulo.top.checked==true)top = id_shop;
	else top = 0;	
	if((typeof(modulo.bottom) != "undefined") && modulo.bottom.checked==true)bottom = id_shop;
	else bottom = 0;
	if((typeof(modulo.one_piece) != "undefined") && modulo.one_piece.checked==true)one_piece = id_shop;
	else one_piece = 0;
	if((typeof(modulo.shoes) != "undefined") && modulo.shoes.checked==true)shoes = id_shop;
	else shoes = 0;
	if((typeof(modulo.hat) != "undefined") && modulo.hat.checked==true)hat = id_shop;
	else hat = 0;
	if((typeof(modulo.accessories) != "undefined") && modulo.accessories.checked==true)accessories = id_shop;
	else accessories = 0;
	$("#shopassoc").load("do.shopassoc.php",{id_shop:id_shop,fkstyle:fkstyle,idphoto:idphoto,top:top,bottom:bottom,one_piece:one_piece,shoes:shoes,hat:hat,accessories:accessories,offset:offset});
}

function countAssByShop(idshop,shoplimit){
	$("#contaassbyshop").load("inc.contaassbyshop.php",{idshop:idshop,shoplimit:shoplimit});
}

function delcollection(idcoll,idshop){
	$("#products").load("inc.delcoll.php",{idcoll:idcoll,idshop:idshop});
}

function doMap(idshop){
	$("#msg").load("inc.ugoogle.php",{idshop:idshop});
}

//FUNZIONI DEL CARRELLO

function addRemoveItem(act,idproduct,quantity,curr,ids){
	$("#cart").load("cart.php",{action:act,idp:idproduct,qty:quantity,currency:curr,id_shop:ids});
}

function doCheckOut(ids,curr){
	$("#msg").load("checkout.php",{id_shop:ids,currency:curr});
}

function pay(modulo,curr){
	$("#order").load("do.order.php",{customer_name:modulo.customer_name.value,customer_email:modulo.customer_email.value,address:modulo.address.value,products:modulo.products.value,fk_shop:modulo.fk_shop.value,total:modulo.total.value,currency:curr});
}

function yourorder(idshop, action){
	$("#yourorder").load("inc.yourorder.php",{idshop:idshop,action:action});
}

function searchorder(formord){	
	ordercode = document.getElementById("ordercode").value;
	idshop = document.getElementById("idshop").value;
	$("#msg").load("inc.yourorder.php",{action:"do",ordercode:ordercode,idshop:idshop});
}

function dofeedback(rate,ido){
	$("#dofeedback").load("do.feedback.php",{home_rate:rate,idtoberated:ido});
}

function orderDet(prod,curr,idor){
	$("#msg").load("inc.orderdet.php",{prodotti:prod,currency:curr,id_orders:idor});
}

//*******************************************************
//FUNZIONI DI VALIDAZIONE DEL FORM
//*******************************************************

function isEmail(what){
   var i=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
   if(!i.test(what)){return false;}
   return true;
}

// checkPatternChars : checks a specific pattern of typed chars
function checkPatternChars(nm,vlu,pattern,required){
  if ( required === undefined ) {
      required = false;
   } 
  if(!required && vlu==""){
    return true;
  }
  if (!pattern.test(vlu)){
	$("#msg").load("all_message.php",{msg:'o'+nm+'_chars'});	
    return false;
  }
  else { 
    return true; 
  }
}

function validateFileExtension(fld) {
	if(!/(\.gif|\.jpg|\.jpeg)$/i.test(fld)) return false;
	else return true;
}

function check_campi_image(modulo){	
	if(modulo.img_uload.value == ""){
		$("#msg").load("all_message.php",{msg:'noimg'});
		modulo.img_uload.focus();
		return;	
	} 
	if(!validateFileExtension(modulo.img_uload.value)){
		$("#msg").load("all_message.php",{msg:'invalidfile'});
		modulo.img_uload.focus();
		return;	
	}
	modulo.submit();	
}


//forse non serve
function check_campi(modulo){
	if(document.getElementById("img").value == ""){
		alert('image not present');
		document.getElementById("img").focus();
		return;	
	} 
	modulo.submit();
}


function check_campi_log(modulo){
	if(modulo.nick.value == ""){
		$("#msg").load("all_message.php",{msg:'nonickins'});
		modulo.nick.focus();
		return;
	}
	if(modulo.passw_log.value == ""){
		$("#msg").load("all_message.php",{msg:'nopassins'});
		modulo.passw_log.focus();
		return;
	}
	if(modulo.type.value == ""){
		$("#msg").load("all_message.php",{msg:'notypeins'});
		modulo.type.focus();
		return;
	}
modulo.submit();
}

function check_code(code){	
	if(code == ""){
		$("#msg").load("all_message.php",{msg:'nocodeins'});

	} else {
		$("#uloadimg").load("searchphoto.php",{code:code});		
	}	
}


function check_campi_shop(modulo){

	if(modulo.terms_check.checked==false){
		$("#msg").load("all_message.php",{msg:'oterms'});
		modulo.terms_check.focus();
		return;	
	} 
	//prima cosa controllo i campi email e nick qualora non siano gia esistenti
	if(modulo.shop_name.value != modulo.oldshop_name.value){
		$.get("check.php", { what:"shop_name_txt",tab:"shop",valore:modulo.shop_name.value },
		  function(data){
			if(data == "shop_name_txt"){
			$("#msg").load("all_message.php",{msg:'shop_nameex'});
			modulo.shop_name.focus();
			return;
			}
		 });
	}

	if(modulo.email.value != modulo.oldemail.value){
		$.get("check.php", { what:"email_txt",tab:"shop",valore:modulo.email.value },
		  function(data){
			if(data == "email_txt"){
			$("#msg").load("all_message.php",{msg:'shop_emailex'});
			modulo.email.focus();
			return;
			}
		 });
	}

	if(modulo.shop_name.value == ""){
		$("#msg").load("all_message.php",{msg:'oshopname'});
		modulo.shop_name.focus();
		return;	
	} else if(modulo.contact_name.value == ""){
		$("#msg").load("all_message.php",{msg:'ocontact_name'});
		modulo.contact_name.focus();
		return;	
	} else if (modulo.email.value == ""){
		$("#msg").load("all_message.php",{msg:'oemail'});
		modulo.email.focus();
		return;	
	} else if (modulo.address.value == ""){
		$("#msg").load("all_message.php",{msg:'oaddress'});
		modulo.address.focus();
		return;	
	} else if (modulo.password.value == ""){
		$("#msg").load("all_message.php",{msg:'opassword'});
		modulo.password.focus();
		return;	
	} else if (modulo.password_c.value == ""){
		$("#msg").load("all_message.php",{msg:'opassword_c'});
		modulo.password_c.focus();
		return;	
	} else if (modulo.password_c.value != modulo.password.value){
		$("#msg").load("all_message.php",{msg:'opass_not_v'});
		modulo.password_c.focus();
		return;	
	} else if (modulo.nazionality.value == "0"){
		$("#msg").load("all_message.php",{msg:'onazionality'});
		modulo.nazionality.focus();
		return;	
	} else if (modulo.town.value == "0" && modulo.new_town.value == ""){
		$("#msg").load("all_message.php",{msg:'otown'});
		modulo.town.focus();
		return;	
	}  else if (!isEmail(modulo.email.value)){
		$("#msg").load("all_message.php",{msg:'oemail_not_v'});
		modulo.email.focus();
		return;	
	} else {
		//VALIDARE IL NOME UTENTE, PASSWORD, NOME, 
		var pattern;
		// SHOP_NAME (lettere, numeri, e i segni . _ -)
		//se lo shop name contiene spazi glielo riscrivo con gli _ al posto degli spazi

		pattern = /^([a-zA-Z0-9\.\_\-]{3,16})+$/;
		if(!checkPatternChars('shop_name',modulo.shop_name.value,pattern,true)) {
			modulo.shop_name.value = modulo.shop_name.value.replace(" ","_");
			modulo.shop_name.focus();
			return;
		}
		//PASSWORD
		pattern = /^[a-zA-Z0-9\_\.\xE0\xE8\xE9\xF9\xF2\xEC\x27]{6,12}/;
		if(!checkPatternChars('password',modulo.password.value,pattern,true)) {
			modulo.password.focus();
			return;
		}		
		//CONTACT_NAME
		pattern = /^([a-zA-Z\xE0\xE8\xE9\xF9\xF2\xEC\x27]\s?)+$/;
		if(!checkPatternChars('contact_name',modulo.contact_name.value,pattern,true)) {
			modulo.contact_name.focus();
			return;
		}	
	}

	modulo.submit();
}


function check_campi_users(modulo){
	if(modulo.terms_check.checked==false){
		$("#msg").load("all_message.php",{msg:'oterms'});
		modulo.terms_check.focus();
		return;	
	} 

	//prima cosa controllo i campi email e nick qualora non siano gia esistenti a meno che l'user non abbia cambiato nulla
	if(modulo.nick.value != modulo.oldnick.value){
		$.get("check.php", { what:"nick_txt",tab:"users",valore:modulo.nick.value },
		  function(data){
			if(data == "nick_txt"){
			$("#msg").load("all_message.php",{msg:'nickex'});
			modulo.nick.focus();
			return;
			}
		 });
	}

	if(modulo.email.value != modulo.oldemail.value){
		$.get("check.php", { what:"email_txt",tab:"users",valore:modulo.email.value },
		  function(data){
			if(data == "email_txt"){
			$("#msg").load("all_message.php",{msg:'emailex'});
			modulo.email.focus();
			return;
			}
		 });
	}


	if(modulo.name.value == ""){
		$("#msg").load("all_message.php",{msg:'oname'});
		modulo.name.focus();
		return;	
	} else if (modulo.nick.value == ""){
		$("#msg").load("all_message.php",{msg:'onick'});
		modulo.nick.focus();
		return;	
	} else if (modulo.email.value == ""){
		$("#msg").load("all_message.php",{msg:'oemail'});
		modulo.email.focus();
		return;	
	} else if (modulo.password.value == ""){
		$("#msg").load("all_message.php",{msg:'opassword'});
		modulo.password.focus();
		return;	
	} else if (modulo.password_c.value == ""){
		$("#msg").load("all_message.php",{msg:'opassword_c'});
		modulo.password_c.focus();
		return;	
	} else if (modulo.password_c.value != modulo.password.value){
		$("#msg").load("all_message.php",{msg:'opass_not_v'});
		modulo.password_c.focus();
		return;	
	} else if (modulo.nazionality.value == "0"){
		$("#msg").load("all_message.php",{msg:'onazionality'});
		modulo.nazionality.focus();
		return;	
	} else if (modulo.usertype.value == "0"){
		$("#msg").load("all_message.php",{msg:'ousertype'});
		modulo.usertype.focus();
		return;	
	} else if (modulo.town.value == "0" && modulo.new_town.value == ""){
		$("#msg").load("all_message.php",{msg:'otown'});
		modulo.town.focus();
		return;	
	}  else if (modulo.style.value == "0" && modulo.new_style.value == ""){
		$("#msg").load("all_message.php",{msg:'ostyle'});
		modulo.style.focus();
		return;	
	} else if (!isEmail(modulo.email.value)){
		$("#msg").load("all_message.php",{msg:'oemail_not_v'});
		modulo.email.focus();
		return;	
	} else {
		//VALIDARE IL NOME UTENTE, PASSWORD, NOME, 
		var pattern;
		// NICK (lettere, numeri, e i segni . _ -)
		pattern = /^([a-zA-Z0-9\.\_\-]{3,12})+$/;
		if(!checkPatternChars('nick',modulo.nick.value,pattern,true)) {
			modulo.nick.focus();
			return;
		}
		//PASSWORD
		pattern = /^[a-zA-Z0-9\_\.\xE0\xE8\xE9\xF9\xF2\xEC\x27]{6,12}/;
		if(!checkPatternChars('password',modulo.password.value,pattern,true)) {
			modulo.password.focus();
			return;
		}		
		//NOME
		pattern = /^([a-zA-Z\xE0\xE8\xE9\xF9\xF2\xEC\x27]\s?)+$/;
		if(!checkPatternChars('name',modulo.name.value,pattern,true)) {
			modulo.name.focus();
			return;
		}
	}
	//creo il valore corretto del campo data:
	modulo.birthdate.value = modulo.birthdate_anno.value+"-"+modulo.birthdate_mese.value+"-"+modulo.birthdate_giorno.value;
	modulo.submit();
}


function check_campi_events(modulo){

	if(modulo.date.value == ""){
		$("#msg").load("all_message.php",{msg:'odate'});
		modulo.date.focus();
		return;	
	} else if (modulo.timeinfo.value == ""){
		$("#msg").load("all_message.php",{msg:'otimeinfo'});
		modulo.timeinfo.focus();
		return;	
	} else if (modulo.title.value == ""){
		$("#msg").load("all_message.php",{msg:'otitle'});
		modulo.title.focus();
		return;	
	} else if (modulo.testo.value == ""){
		$("#msg").load("all_message.php",{msg:'otesto'});
		modulo.testo.focus();
		return;	
	} else if (modulo.where.value == ""){
		$("#msg").load("all_message.php",{msg:'owhere'});
		modulo.where.focus();
		return;	
	} 
	modulo.submit();
}

function helpicon(quale){
	$("#msg").load("helpicon.php",{hi:quale});
}

//SEARCH FUNCTION
function search(modulo, cosa, limit){
	//usersearch
	if(cosa == 'listusersFAZOOTERS' || cosa == 'listusersDESIGNERS'){
		if(cosa == 'listusersFAZOOTERS')qs = "utIS_1";
		else if(cosa == 'listusersDESIGNERS')qs = "utIS_2";
		cosa = 'listusers';
		name = modulo.name.value;
		style = modulo.style.value;
		town = modulo.town.value;
		nazionality = modulo.nazionality.value;
		if(name == "")name = "0";
		qs = qs+"_AND_nameIS_"+name;
		if(style == "")style = "0";
		qs = qs+"_AND_styleIS_"+style;
		if(town == "")town = "0";
		qs = qs+"_AND_townIS_"+town;
		if(nazionality == "")nazionality = "0";
		qs = qs+"_AND_nationalityIS_"+nazionality;
	} else if(cosa == 'listshop'){
		qs = "";
		shop_name = modulo.shop_name.value;
		item = modulo.item.value;
		town = modulo.town.value;
		nazionality = modulo.nazionality.value;
		if(shop_name == "")shop_name = "0";
		qs = qs+"_AND_shopnameIS_"+shop_name;
		if(item == "")item = "0";
		qs = qs+"_AND_itemIS_"+item;
		if(town == "")town = "0";
		qs = qs+"_AND_townIS_"+town;
		if(nazionality == "")nazionality = "0";
		qs = qs+"_AND_nationalityIS_"+nazionality;
	} else if(cosa == 'browsestyle'){
		qs = "";
		name = modulo.name.value;
		dove = modulo.dove.value;
		town = modulo.town.value;
		nazionality = modulo.nazionality.value;
		if(name == "")name = "0";
		qs = qs+"_AND_nameIS_"+name;
		if(dove == "")dove = "0";
		qs = qs+"_AND_doveIS_"+dove;
		if(town == "")town = "0";
		qs = qs+"_AND_townIS_"+town;
		if(nazionality == "")nazionality = "0";
		qs = qs+"_AND_nationalityIS_"+nazionality;
	} else if(cosa == 'listgallery'){
		qs = "";
		name = modulo.name.value;
		item = modulo.item.value;
		category = modulo.category.value;
		nazionality = modulo.nazionality.value;
		if(name == "")name = "0";
		qs = qs+"_AND_nameIS_"+name;
		if(item == "")item = "0";
		qs = qs+"_AND_itemIS_"+item;
		if(category == "")category = "0";
		qs = qs+"_AND_categoryIS_"+category;
		if(nazionality == "")nazionality = "0";
		qs = qs+"_AND_nationalityIS_"+nazionality;
	} else if(cosa == 'listphotographer'){
		qs = "";
		name = modulo.name.value;
		town = modulo.town.value;
		nazionality = modulo.nazionality.value;
		if(name == "")name = "0";
		qs = qs+"_AND_nameIS_"+name;
		if(town == "")town = "0";
		qs = qs+"_AND_townIS_"+town;
		if(nazionality == "")nazionality = "0";
		qs = qs+"_AND_nationalityIS_"+nazionality;
	}

	getContent(0,limit,qs,'',cosa);

}

function comp_sub(id_users,id_comp){
	$("#mng_comp").load("comp_sub.php",{id_users:id_users,id_comp:id_comp});
}


function getMatchDet(id_matches){
	$("#match_det_"+id_matches).load("match_det.php",{id_matches:id_matches});
}

function doRate_comp(id_matches,home_or_away){
	$("#rating").load("do.ratematches.php",{id_matches:id_matches,home_or_away:home_or_away});
}


function check_campi_photographer(modulo){
	

	//prima cosa controllo i campi email e nick qualora non siano gia esistenti a meno che l'user non abbia cambiato nulla
	
	if(modulo.email.value != modulo.oldemail.value){
		$.get("check.php", { what:"email_txt",tab:"users",valore:modulo.email.value },
		  function(data){
			if(data == "email_txt"){
			$("#msg").load("all_message.php",{msg:'emailex'});
			modulo.email.focus();
			return;
			}
		 });
	}


	if(modulo.name.value == ""){
		$("#msg").load("all_message.php",{msg:'oname'});
		modulo.name.focus();
		return;	
	} else if (modulo.email.value == ""){
		$("#msg").load("all_message.php",{msg:'oemail'});
		modulo.email.focus();
		return;	
	} else if (modulo.password.value == ""){
		$("#msg").load("all_message.php",{msg:'opassword'});
		modulo.password.focus();
		return;	
	} else if (modulo.password_c.value == ""){
		$("#msg").load("all_message.php",{msg:'opassword_c'});
		modulo.password_c.focus();
		return;	
	} else if (modulo.password_c.value != modulo.password.value){
		$("#msg").load("all_message.php",{msg:'opass_not_v'});
		modulo.password_c.focus();
		return;	
	} else if (modulo.nazionality.value == "0"){
		$("#msg").load("all_message.php",{msg:'onazionality'});
		modulo.nazionality.focus();
		return;	
	} else if (modulo.town.value == "0" && modulo.new_town.value == ""){
		$("#msg").load("all_message.php",{msg:'otown'});
		modulo.town.focus();
		return;	
	} else if (!isEmail(modulo.email.value)){
		$("#msg").load("all_message.php",{msg:'oemail_not_v'});
		modulo.email.focus();
		return;	
	} else {
		//VALIDARE IL NOME UTENTE, PASSWORD, NOME, 
		var pattern;
		
		//PASSWORD
		pattern = /^[a-zA-Z0-9\_\.\xE0\xE8\xE9\xF9\xF2\xEC\x27]{6,12}/;
		if(!checkPatternChars('password',modulo.password.value,pattern,true)) {
			modulo.password.focus();
			return;
		}		
		//NOME
		pattern = /^([a-zA-Z\xE0\xE8\xE9\xF9\xF2\xEC\x27]\s?)+$/;
		if(!checkPatternChars('name',modulo.name.value,pattern,true)) {
			modulo.name.focus();
			return;
		}
	}
	
	modulo.submit();
}