num_pag=-1;
curr_pag=-1;
num_item_casting_list=0;
casting_max_items_per_page=10;
casting_list_pos=0;
/*
1	ragazza_hostess
2	ragazza_high_level
3	ragazza_top_class
4	ragazza_man
5	ragazza_da_attribuire
6	azienda
*/
current_codice_categoria='ragazza_top_class';
casting_list=new Array();
ricerca_avanzata_corrente="div_ricerca_avanzata_avanzata";
help_catalogo_aperto=false;
int_chiudi_help_catalogo=undefined;
help_castinglist_aperto=false;
int_chiudi_help_castinglist=undefined;
scheda_dettaglio_su_video=false;

function inizializza(){
	$('tracer').innerHTML=$('tracer').innerHTML+"Prototype Version:"+Prototype.Version+"<br>";
	
	$('loading').visible=false;
	
	if (visualizzaCastingListRegister_oninit) {
		visualizzaCastingListRegister();
	}
	//accept: 'tessuto_per_'+silouettes[id].zone[i].categoria,
	// definisco la casting list come target per il drop
	Droppables.add('container_castinglist', {
		// quando viene droppata la thumb di una ragazza ...
		// 		... appendo in container_castinglist un nuovo div
	   	onDrop: function(element){
	   				// se č giā in casting list non succede niente
	   				aggiungiAllaCastingList(element);
	   			}
	   }
	);

	if (num_pag<0) {
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	op: 'getNumPagineImmaginiAll',
			  	howmany: 44
			  },
			  onComplete: function(transport){
			  	var obj;
			  	obj=eval(transport.responseText);
			  	//alert(obj[0].num_pag);
			  	num_pag=obj[0].num_pag;
			  	aggiungiNumeriPagina(num_pag,'caricaPagina');
			  	step2();
			  }
			}
		);
	}
	function step2(){
		caricaPagina(0);
		aggiornaVisibilitaFreccieCastingList();
	}

}
// svuota container_pages poi inserisce i numeri di pagina che saranno linkati alla funzione specificata
function aggiungiNumeriPagina(num_pag,nomeFunzione){
	var obj,i,contDiv,new_a;
	var newDivMsg,newSelect,newOption;
	contDiv=$('container_pages');
  	removeAllChilds(contDiv);
  	/*
  	for(i=0;i<num_pag;i++){
  		new_a=document.createElement('a');
  		new_a.setAttribute('href','javascript: '+nomeFunzione+'('+i+');');
  		new_a.innerHTML=(i+1);
  		Element.addClassName(new_a,'pagine');
  		contDiv.appendChild(new_a);
  	}
  	*/
  	newDivMsg=document.createElement('span');
  	newDivMsg.innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  	Element.addClassName(newDivMsg,'bianco_11');
  	contDiv.appendChild(newDivMsg);
  	newSelect=document.createElement('select');
//  	newSelect.style.backgroundColor="#e458c0";
  	newSelect.style.backgroundColor="#fff";
  	for(i=0;i<num_pag;i++){
  		newOption = document.createElement('option');
	  	newOption.text = (i+1);
	  	newOption.value = i;
	  	try {
	    	newSelect.add(newOption, null); // standards compliant; doesn't work in IE
	  	}
	  	catch(ex) {
	    	newSelect.add(newOption); // IE only
	  	}
	} 
  	contDiv.appendChild(newSelect);
  	
  	Event.observe(newSelect, 'change', function(e) {
		  //alert(Event.element(e).selectedIndex);
		  if (nomeFunzione=='caricaPagina')
		  	caricaPagina(Event.element(e).selectedIndex);
		  if (nomeFunzione=='caricaPaginaCerca')
		  	caricaPaginaCerca(Event.element(e).selectedIndex);
		  if (nomeFunzione=='caricaPaginaCercaAvanzato')
		  	caricaPaginaCercaAvanzato(Event.element(e).selectedIndex);
		  if (nomeFunzione=='caricaPaginaCercaAlfabetica')
		  	caricaPaginaCercaAlfabetica(Event.element(e).selectedIndex);
		  if (nomeFunzione=='caricaPaginaCercaPreferite')
		  	caricaPaginaCercaPreferite(Event.element(e).selectedIndex);
		});
}

//	appendo in container_castinglist un div:
//	<div id="casting_div_img_IDAllegato" class="castingItem" style="float: left">		(copio la proprietā idpersona dal droppato)
//		<a class="bianco_small" href=""javascript: removeFromCastingList('casting_div_img_IDAllegato');">ELIMINA</a>
//		<div class="thumbs_bordo_bianco">
//			<img class="only_margin1" src="...." style="z-index: 0;" />
//			<div class="tab_CodiceCategoria" style="z-index: 5;">
//				<img src="/img/spacer.gif" width="58" height="7" />
//			</div>				
//		</div>
//		<span class="bianco_small"><br>Nome</span>
//	</div>
//
//	element č un oggetto che deve avere le seguenti proprietā:
//  - idpersona
//  - id				č un id univoco (ad esempio l'idallegato)
//  - imgPath
//  - codicecategoria
//  - nome
function aggiungiAllaCastingList(element){
	var new_div,new_img,new_a,new_span,nomeStr="";
	var new_div2,new_div3,new_img2;
	
	// se no l'ho giā inserita nella casting list
	if (casting_list.indexOf(element.idpersona)==-1) {	   				
		// ... inserisco l'id della ragazza nell'array globale casting_list
		casting_list.push(element.idpersona);
		
		new_div=document.createElement('div');
		new_div.idpersona=element.idpersona;
		new_div.setAttribute("id","casting_"+element.id);
		Element.addClassName(new_div,'castingItem');
		
		new_a=document.createElement('a');
		new_a.setAttribute('href',"javascript: removeFromCastingList('casting_"+element.id+"');");
		new_a.innerHTML=langLabels['catalogo.box_casting_list.elimina']+"<br>";
		Element.addClassName(new_a,'bianco_small');
		new_div.appendChild(new_a);
		
		new_div2=document.createElement('div');
		Element.addClassName(new_div2,'thumbs_bordo_bianco');
		
		new_img=document.createElement('img');
		new_img.idpersona=element.idpersona;
		new_img.src=element.imgPath;
		Element.addClassName(new_img,'only_margin1');
		Element.setStyle(new_img,{"z-index": "0"});
		new_div2.appendChild(new_img);
		
		new_div3=document.createElement('div');
  		Element.setStyle(new_div3,{'z-index': '5'})
  		Element.addClassName(new_div3,'tab_'+element.codicecategoria);
  		new_img2=document.createElement('img');
  		new_img2.src="/img/spacer.gif";
  		new_img2.setAttribute("width","58");
  		new_img2.setAttribute("height","7");
  		new_div3.appendChild(new_img2);
  		new_div2.appendChild(new_div3);
		
		new_div.appendChild(new_div2);
		
		new_span=document.createElement('span');
		nomeStr=element.nome;
		if (element.nome.length>12)
			nomeStr=element.nome.substr(0,12);
		new_span.innerHTML=nomeStr;
		Element.addClassName(new_span,'bianco_small');
		new_div.appendChild(new_span);
		
		Element.setStyle(new_div,{"float": "left"});
		$('container_castinglist').appendChild(new_div);
		// ... aggiorno il contatore della thumbs nella casting list
		num_item_casting_list++;
		$('contatore_castinglist').innerHTML=num_item_casting_list;	
		// ... aggiorno la visibilitā dei vari elementi della casting list
		aggiornaVisibilitaFreccieCastingList();
		
		
		Event.observe(new_div, 'dblclick', function(e) {
		  //alert(Event.element(e).idpersona);
		  var obj;
		  obj=new Object();
		  obj.idpersona=Event.element(e).idpersona;
		  visualizzaSchedaDettaglio(obj);
		});
		
	}
}

function isLoadingVisible(){
	return($('loading').visible);
}

function toggleLoading(){
	if ($('loading').visible){
		$('loading').setStyle({visibility: "hidden"});
		$('loading').visible=false;
	} else {
		$('loading').setStyle({visibility: "visible"});
		$('loading').visible=true;
	}
}

/*
1	ragazza_hostess
2	ragazza_high_level
3	ragazza_top_class
4	ragazza_man
5	ragazza_da_attribuire
6	azienda
*/
function settaCategoria(id){
	nascondiSchedaDettaglio();
	if (id==0){
		$('img_intestazione').src="/fe/img/"+langCode+"/catalogo_ragazza_hostess.gif";
		current_codice_categoria="ragazza_hostess";
	}
	if (id==1){
		$('img_intestazione').src="/fe/img/"+langCode+"/catalogo_ragazza_high_level.gif";
		current_codice_categoria="ragazza_high_level";
	}
	if (id==2){
		$('img_intestazione').src="/fe/img/"+langCode+"/catalogo_ragazza_top_class.gif";
		current_codice_categoria="ragazza_top_class";
	}
	if (id==3){
		//if (debugmode) {
			$('img_intestazione').src="/fe/img/"+langCode+"/catalogo_ragazza_man.gif";
			current_codice_categoria="ragazza_man";
		/*} else {
			document.location="/fe/man.php";
		}*/
	}
	//if (id==0 || id==1 || id==2 || (id==3 && debugmode)){
		resettaBoxRicercaSemplice();
		cerca();
	//}
}

function leftMenu2GotoPage(id){
	settaCategoria(id);
}

function caricaPagina(np){
	//alert("caricaPagina:"+np);
	toggleLoading();
	if (np!=curr_pag){
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	op: 'getImmaginiAll',
			  	page: np,
			  	howmany: 44,
			  	codicecategoriacorrente: current_codice_categoria
			  },
			  onComplete: function(transport){
			  	immagini=eval(transport.responseText); 
			  	curr_pag=np;
			  	// se la pagina catalogo.php viene aperta con la richiesta di visualizzare una scheda di dettaglio
			  	// la funzione visualizzaDettaglioDaLinkEsterno chiamerā la visualizzaDettaglio passandogli
			  	// i parametri necessari altrimenti sarā una funzione vuota
			  	visualizzaDettaglioDaLinkEsterno();
			  	mostraImmagini();
			  	toggleLoading();
			  }
			} 
		);
	}
}

function resettaBoxRicercaSemplice(){
	var obj;
	obj=document.getElementById('cerca_altezza');
	obj.selectedIndex=0;
	obj=document.getElementById('cerca_taglia');
	obj.selectedIndex=0;
	obj=document.getElementById('cerca_seno');
	obj.selectedIndex=0;
	obj=document.getElementById('cerca_vita');
	obj.selectedIndex=0;
	obj=document.getElementById('cerca_fianchi');
	obj.selectedIndex=0;
	obj=document.getElementById('cerca_scarpe');
	obj.selectedIndex=0;
	obj=document.getElementById('cerca_occhi');
	obj.selectedIndex=0;
	obj=document.getElementById('cerca_capelli');
	obj.selectedIndex=0;
	//obj=document.getElementById('cerca_localita');
	//obj.selectedIndex=0;
	obj=document.getElementById('cerca_idregione');
	if (obj!=undefined)
		obj.selectedIndex=0;
}

function caricaPaginaCerca(np){
	//alert("caricaPagina:"+np);
	toggleLoading();
	if (np!=curr_pag){
		//annonascita: getSelectedValue('cerca_annonascita'),
		//localita: getSelectedValue('cerca_localita'),
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	op: 'getImmaginiCerca',
			  	page: np,
			  	howmany: 44,
			  	codicecategoriacorrente: current_codice_categoria,
			  	altezza: getSelectedValue('cerca_altezza'),
			  	taglia: getSelectedValue('cerca_taglia'),
			  	seno: getSelectedValue('cerca_seno'),
			  	vita: getSelectedValue('cerca_vita'),
			  	fianchi: getSelectedValue('cerca_fianchi'),
			  	scarpe: getSelectedValue('cerca_scarpe'),
			  	occhi: getSelectedValue('cerca_occhi'),
			  	capelli: getSelectedValue('cerca_capelli'),
			  	siglanazione: getSelectedValue('cerca_idnazione'),
			  	siglaregione: getSelectedValue('cerca_idregione'),
			  	siglaprovincia: getSelectedValue('cerca_idprovincia')
			  },
			  onComplete: function(transport){
			  	immagini=eval(transport.responseText); 
			  	curr_pag=np;
			  	mostraImmagini();
			  	toggleLoading();
			  }
			} 
		);
	}
}

function caricaPaginaCercaAvanzato(np){
	//alert("caricaPagina:"+np);
	toggleLoading();
	if (np!=curr_pag){
		//tagliocapelli: getSelectedValue('cerca_avanzata_tagliocapelli'),
		//localita: getSelectedValue('cerca_avanzata_localita'),
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	op: 'getImmaginiCercaAvanzato',
			  	page: np,
			  	howmany: 44,
			  	codicecategoriacorrente: current_codice_categoria,
			  	altezza: getSelectedValue('cerca_avanzata_altezza'),
			  	taglia: getSelectedValue('cerca_avanzata_taglia'),
			  	seno: getSelectedValue('cerca_avanzata_seno'),
			  	vita: getSelectedValue('cerca_avanzata_vita'),
			  	fianchi: getSelectedValue('cerca_avanzata_fianchi'),
			  	scarpe: getSelectedValue('cerca_avanzata_scarpe'),
			  	occhi: getSelectedValue('cerca_avanzata_occhi'),
			  	capelli: getSelectedValue('cerca_avanzata_capelli'),
			  	annonascita: getSelectedValue('cerca_avanzata_annonascita'),
			  	lingua1: getSelectedValue('cerca_avanzata_lingua1'),
			  	livellolingua1: getSelectedValue('cerca_avanzata_livellolingua1'),
			  	lingua2: getSelectedValue('cerca_avanzata_lingua2'),
			  	livellolingua2: getSelectedValue('cerca_avanzata_livellolingua2'),
			  	lingua3: getSelectedValue('cerca_avanzata_lingua3'),
			  	livellolingua3: getSelectedValue('cerca_avanzata_livellolingua3'),
			  	capacitaattrice: ($('cerca_avanzata_capacita_attrice').checked ? 's' : 'n'),
			  	capacitacantante: ($('cerca_avanzata_capacita_cantante').checked ? 's' : 'n'),
			  	capacitaballerina: ($('cerca_avanzata_capacita_ballerina').checked ? 's' : 'n'),
			  	capacitarollerblade: ($('cerca_avanzata_capacita_rollerblade').checked ? 's' : 'n'),
			  	disponibiletourleader: ($('cerca_avanzata_disponibile_tourleader').checked ? 's' : 'n'),
			  	disponibileanimazione: ($('cerca_avanzata_disponibile_animazione_discoteca').checked ? 's' : 'n'),
			  	disponibilecubista: ($('cerca_avanzata_disponibile_cubista').checked ? 's' : 'n'),
			  	disponibileserviziointimo: ($('cerca_avanzata_disponibile_servizifotointimo').checked ? 's' : 'n'),
				ecm: ($('cerca_avanzata_disponibile_ecm').checked ? 's' : 'n'),
				idnazione: getSelectedValue('cerca_avanzata_idnazione'),
				siglaregione: getSelectedValue('cerca_avanzata_idregione'),
		  		siglaprovincia: getSelectedValue('cerca_avanzata_idprovincia'),
		  		localita: getSelectedValue('cerca_avanzata_localita'),
   		  		esperienza: getSelectedValue('cerca_avanzata_esperienza'),
	  	  	   	video: ($('cerca_avanzata_con_video').checked ? 's' : 'n'),
				idcategoriabudget: getSelectedValue('cerca_avanzata_categoriabudget'),
				budget: getSelectedValue('cerca_avanzata_budget')
			  },
			  onComplete: function(transport){
			  	immagini=eval(transport.responseText);
			  	curr_pag=np;
			  	mostraImmagini();
			  	toggleLoading();
			  }
		});
	}
}

function caricaPaginaCercaAlfabetica(np){
	var iniziale,sel;
	sel=document.getElementById('iniziale_ricerca_alfabetica');
	iniziale=sel.options[sel.selectedIndex].value;
	//alert("caricaPagina:"+np);
	toggleLoading();
	if (np!=curr_pag){
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	op: 'getImmaginiCercaAlfabetica',
			  	page: np,
			  	howmany: 44,
			  	codicecategoriacorrente: current_codice_categoria,
			  	iniziale: iniziale
			  },
			  onComplete: function(transport){
			  	immagini=eval(transport.responseText); 
			  	curr_pag=np;
			  	mostraImmagini();
			  	toggleLoading();
			  }
			} 
		);
	}
}

function caricaPaginaCercaPreferite(np){
	var iniziale,sel;
	sel=document.getElementById('iniziale_ricerca_alfabetica');
	iniziale=sel.options[sel.selectedIndex].value;
	//alert("caricaPagina:"+np);
	toggleLoading();
	if (np!=curr_pag){
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	op: 'getImmaginiCercaPreferite',
			  	page: np,
			  	howmany: 44,
			  	codicecategoriacorrente: current_codice_categoria
			  },
			  onComplete: function(transport){
			  	immagini=eval(transport.responseText); 
			  	curr_pag=np;
			  	mostraImmagini();
			  	toggleLoading();
			  }
			} 
		);
	}
}

// mostra le immagini presenti nell'array globale  "immagini"
function mostraImmagini(){
	var i,objContainer,newDiv,newImg,imgPath;
	var newDiv2,newDiv3,new_span,nomeStr,newImg2;
	objContainer=$('container_immagini');
	removeAllChilds(objContainer);
	// per ogni immagine nell'array viene creato un div:
	//		<div id="div_img_IDAllegato" class="thumbs_div">									(viene aggiunte proprietā imgPath,nome,codicecategoria,idpersona)
	//			<div class="thumbs_bordo_bianco">
	//				<img id="img_IDAllegato" class="only_margin1" style="z-index: 0;" />		(viene aggiunta proprietā IDPersona)
	//				<div class="tab_CodiceCategoria" style="z-index: 5;">
	//					<img src="/img/spacer.gif" width="58" height="7" />
	//				</div>
	//			</div>
	//			<span class="bianco_small"><br>Nome</span>
	//		</div>
  	for (i=0;i<immagini.length;i++){
  		//alert(i);
  		newDiv=document.createElement('div');
  		newDiv.setAttribute("id","div_img_"+immagini[i].IDAllegato);
  		newDiv.setAttribute("title",immagini[i].IDPersona);
  		Element.addClassName(newDiv,'thumbs_div');
  		newDiv2=document.createElement('div');
  		Element.addClassName(newDiv2,'thumbs_bordo_bianco');
  		newImg=document.createElement('img');
  		newImg.setAttribute("id","img_"+immagini[i].IDAllegato);
  		newImg.setAttribute("alt",immagini[i].IDPersona);
  		newImg.IDPersona=immagini[i].IDPersona;
  		newDiv3=document.createElement('div');
  		Element.setStyle(newDiv3,{'z-index': '5'})
  		Element.addClassName(newDiv3,'tab_'+immagini[i].CodiceCategoria);
  		newImg2=document.createElement('img');
  		newImg2.src="/img/spacer.gif";
  		newImg2.setAttribute("width","58");
  		newImg2.setAttribute("height","7");
  		newDiv3.appendChild(newImg2);
  		//Element.setStyle(newImg,{visibility: 'hidden'})
  		Element.setStyle(newDiv,{visibility: 'hidden'})
  		if (immagini[i].Originale=='s'){
  			//newImg.src="/upl/foto/o/thumbs/"+immagini[i].NomeFile;
  			imgPath="/upl/foto/o/thumbs/"+immagini[i].NomeFile;
  		} else {
  			//newImg.src="/upl/foto/t/thumbs/"+immagini[i].NomeFile;
  			imgPath="/upl/foto/t/thumbs/"+immagini[i].NomeFile;
  		}
  		Element.addClassName(newImg,'only_margin1');
  		Element.setStyle(newImg,{'z-index': '0'})
  		newDiv2.appendChild(newImg);
  		newDiv2.appendChild(newDiv3);
  		newDiv.appendChild(newDiv2);
  		new_span=document.createElement('span');
		nomeStr=immagini[i].Nome;
		if (immagini[i].Nome.length>12)
			nomeStr=immagini[i].Nome.substr(0,12);
		new_span.innerHTML=nomeStr;
		Element.addClassName(new_span,'bianco_small');
		newDiv.appendChild(new_span);
  		newDiv.imgPath=imgPath;
  		newDiv.nome=immagini[i].Nome;
  		newDiv.idpersona=immagini[i].IDPersona;
  		newDiv.codicecategoria=immagini[i].CodiceCategoria;
  		objContainer.appendChild(newDiv);
  		//loadImage("img_"+immagini[i].IDAllegato,imgPath,0.4);
  		loadImageInto("div_img_"+immagini[i].IDAllegato,"img_"+immagini[i].IDAllegato,imgPath,0.1);
  		
  		new Draggable(newDiv,{revert:true});
  		Event.observe(newDiv, 'dblclick', function(e) {
		  //alert(Event.element(e).id);;
		  var id;
		  obj=$('div_'+Event.element(e).id); 
		  id=Event.element(e).IDPersona;
		  //window.open('/fe/dettaglio.php?id='+id);
		  visualizzaSchedaDettaglio(obj);
		});
  	}	
}

function getSelectedValue(selId){
	var obj;
	obj=$(selId);
	if (obj!=null && obj.selectedIndex!=null)
		return obj.options[obj.selectedIndex].value;
	else
		return "";
}

function cerca(){
	nascondiSchedaDettaglio();

	if (!isLoadingVisible()){
		toggleLoading();
		// Elimino i numeri di pagina
		contDiv=$('container_pages');
		removeAllChilds(contDiv);
		// Determino il numero di pagine ed inserisco i numeri di pagina
		// localita: getSelectedValue('cerca_localita'),
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	op: 'getNumPagineImmaginiCerca', 
			  	howmany: 44,
			  	altezza: getSelectedValue('cerca_altezza'),
			  	taglia: getSelectedValue('cerca_taglia'),
			  	seno: getSelectedValue('cerca_seno'),
			  	vita: getSelectedValue('cerca_vita'),
			  	fianchi: getSelectedValue('cerca_fianchi'),
			  	scarpe: getSelectedValue('cerca_scarpe'),
			  	occhi: getSelectedValue('cerca_occhi'),
			  	capelli: getSelectedValue('cerca_capelli'),
			  	siglanazione: getSelectedValue('cerca_idnazione'),
			  	siglaregione: getSelectedValue('cerca_idregione'),
			  	siglaprovincia: getSelectedValue('cerca_idprovincia'),
			  	codicecategoriacorrente: current_codice_categoria
			  },
			  onComplete: function(transport){
				  toggleLoading();
		  		  // ... ed inserisco i numeri di pagina
			  	  var obj;
				  obj=eval(transport.responseText);
			      num_pag=obj[0].num_pag;
		  		  aggiungiNumeriPagina(num_pag,'caricaPaginaCerca');
		  		  if (num_pag>0)
			  	  	step2();
			  	  else
			  	  	$('noRisultati').setStyle({visibility: "visible"});
			  }
		} 
	);
	}
	// Mostro le immagini
	function step2(){
		curr_pag=-1;
		caricaPaginaCerca(0);
	}
}

function cercaAvanzato(){

if (!isLoadingVisible()){
	toggleLoading();

	// Elimino i numeri di pagina
	contDiv=$('container_pages');
	removeAllChilds(contDiv);
	nascondiRicercheAvanzate();
	// Determino il numero di pagine ed inserisco i numeri di pagina
	// tagliocapelli: getSelectedValue('cerca_avanzata_tagliocapelli'),
	// localita: getSelectedValue('cerca_localita'),
	new Ajax.Request('/fe/service.php', {
		  method: 'get',
		  parameters: {
		  	op: 'getNumPagineImmaginiCercaAvanzato', 
		  	howmany: 44,
		  	altezza: getSelectedValue('cerca_avanzata_altezza'),
		  	taglia: getSelectedValue('cerca_avanzata_taglia'),
		  	seno: getSelectedValue('cerca_avanzata_seno'),
		  	vita: getSelectedValue('cerca_avanzata_vita'),
		  	fianchi: getSelectedValue('cerca_avanzata_fianchi'),
		  	scarpe: getSelectedValue('cerca_avanzata_scarpe'),
		  	occhi: getSelectedValue('cerca_avanzata_occhi'),
		  	capelli: getSelectedValue('cerca_avanzata_capelli'),
		  	annonascita: getSelectedValue('cerca_avanzata_annonascita'),
		  	lingua1: getSelectedValue('cerca_avanzata_lingua1'),
		  	livellolingua1: getSelectedValue('cerca_avanzata_livellolingua1'),
		  	lingua2: getSelectedValue('cerca_avanzata_lingua2'),
		  	livellolingua2: getSelectedValue('cerca_avanzata_livellolingua2'),
		  	lingua3: getSelectedValue('cerca_avanzata_lingua3'),
		  	livellolingua3: getSelectedValue('cerca_avanzata_livellolingua3'),
		  	capacitaattrice: ($('cerca_avanzata_capacita_attrice').checked ? 's' : 'n'),
		  	capacitacantante: ($('cerca_avanzata_capacita_cantante').checked ? 's' : 'n'),
		  	capacitaballerina: ($('cerca_avanzata_capacita_ballerina').checked ? 's' : 'n'),
		  	capacitarollerblade: ($('cerca_avanzata_capacita_rollerblade').checked ? 's' : 'n'),
		  	disponibiletourleader: ($('cerca_avanzata_disponibile_tourleader').checked ? 's' : 'n'),
		  	disponibileanimazione: ($('cerca_avanzata_disponibile_animazione_discoteca').checked ? 's' : 'n'),
		  	disponibilecubista: ($('cerca_avanzata_disponibile_cubista').checked ? 's' : 'n'),
		  	disponibileserviziointimo: ($('cerca_avanzata_disponibile_servizifotointimo').checked ? 's' : 'n'),
			ecm: ($('cerca_avanzata_disponibile_ecm').checked ? 's' : 'n'),
		  	idnazione: getSelectedValue('cerca_avanzata_idnazione'),
			siglaregione: getSelectedValue('cerca_avanzata_idregione'),
		  	siglaprovincia: getSelectedValue('cerca_avanzata_idprovincia'),
		  	localita: getSelectedValue('cerca_avanzata_localita'),
		  	esperienza: getSelectedValue('cerca_avanzata_esperienza'),
		  	video: ($('cerca_avanzata_con_video').checked ? 's' : 'n'),
		  	codicecategoriacorrente: current_codice_categoria,
			idcategoriabudget: getSelectedValue('cerca_avanzata_categoriabudget'),
			budget: getSelectedValue('cerca_avanzata_budget')
		  },
		  onComplete: function(transport){
		  	  // ... ed inserisco i numeri di pagina
			  toggleLoading();
		  	  var obj;
			  obj=eval(transport.responseText);
			  num_pag=obj[0].num_pag;
		  	  aggiungiNumeriPagina(num_pag,'caricaPaginaCercaAvanzato');
		  	  if (num_pag>0)
				step2();
			  else
				$('noRisultati').setStyle({visibility: "visible"});
		  }
		} 
	);
}
	// Mostro le immagini
	function step2(){
		curr_pag=-1;
		caricaPaginaCercaAvanzato(0);
	}
}

function cercaAlfabetica(){
	var iniziale,sel;
	// Elimino i numeri di pagina
	contDiv=$('container_pages');
	removeAllChilds(contDiv);
	// Determino il numero di pagine ed inserisco i numeri di pagina
	sel=document.getElementById('iniziale_ricerca_alfabetica');
	iniziale=sel.options[sel.selectedIndex].value;
	if (iniziale!=undefined && iniziale!=''){
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	op: 'getNumPagineImmaginiCercaAlfabetica', 
			  	howmany: 44,
			  	iniziale: iniziale,
			  	codicecategoriacorrente: current_codice_categoria
			  },
			  onComplete: function(transport){
			  	  // ... ed inserisco i numeri di pagina
			  	  var obj;
				  obj=eval(transport.responseText);
			      num_pag=obj[0].num_pag;
			  	  aggiungiNumeriPagina(num_pag,'caricaPaginaCercaAlfabetica');
			  	  if (num_pag>0)
			  	  	step2();
			  	  else
			  	  	$('noRisultati').setStyle({visibility: "visible"});
			  }
			} 
		);
	}
	// Mostro le immagini
	function step2(){
		curr_pag=-1;
		caricaPaginaCercaAlfabetica(0);
	}
}

function cercaPreferite(){
	var iniziale,sel;
	// Elimino i numeri di pagina
	contDiv=$('container_pages');
	removeAllChilds(contDiv);
	// Determino il numero di pagine ed inserisco i numeri di pagina
	sel=document.getElementById('iniziale_ricerca_alfabetica');
	iniziale=sel.options[sel.selectedIndex].value;

	new Ajax.Request('/fe/service.php', {
		  method: 'post',
		  parameters: {
		  	op: 'getNumPagineImmaginiCercaPreferite', 
		  	howmany: 44,
		  	codicecategoriacorrente: current_codice_categoria
		  },
		  onComplete: function(transport){
		  	  // ... ed inserisco i numeri di pagina
		  	  var obj;
			  obj=eval(transport.responseText);
		      num_pag=obj[0].num_pag;
		  	  aggiungiNumeriPagina(num_pag,'caricaPaginaCercaPreferite');
		  	  if (num_pag>0)
				step2();
			  else
				$('noRisultati').setStyle({visibility: "visible"});
		  }
		} 
	);
	// Mostro le immagini
	function step2(){
		curr_pag=-1;
		caricaPaginaCercaPreferite(0);
	}
}

function aggiornaVisibilitaFreccieCastingList(){
	/*
	$('next_castinglist').show();
	$('prev_castinglist').show();
	*/
	if ((num_item_casting_list-casting_list_pos)>casting_max_items_per_page)
		$('next_castinglist').show();
	else
		$('next_castinglist').hide();
	if (casting_list_pos>0)
		$('prev_castinglist').show();
	else
		$('prev_castinglist').hide();
}
function castingListSlideLeft(){
	if ((num_item_casting_list-casting_list_pos)>casting_max_items_per_page){
		//new Effect.MoveBy('container_castinglist', 0, -62 , {duration: 0.3,  transition: Effect.Transitions.slowstop})
		new Effect.Move('container_castinglist', {y: 0, x: -62, mode: 'relative', duration: 0.3, transition: Effect.Transitions.sinoidal});
		casting_list_pos++;
		aggiornaVisibilitaFreccieCastingList();
	}
}
function castingListSlideRight(){
	if (casting_list_pos>0){
		new Effect.MoveBy('container_castinglist', 0, 62 , {duration: 0.3,  transition: Effect.Transitions.slowstop})
		casting_list_pos--;
		aggiornaVisibilitaFreccieCastingList();
	}
}

function removeFromCastingList(objId){
	var obj;
	obj=$(objId);
	//alert(printObj(obj));
	casting_list.pop(obj.idpersona);
	obj.parentNode.removeChild(obj);
	num_item_casting_list--;
	$('contatore_castinglist').innerHTML=num_item_casting_list;
	aggiornaVisibilitaFreccieCastingList();
}

function castingListRegister(){
	visualizzaCastingListRegister();
}

function visualizzaCastingListRegister(){
	if (num_item_casting_list>0){
		//$('casting_list_complimenti').hide();
		nascondiSchedaDettaglio();
		$('box_copri_centrale').show();
		$('box_casting_list_register').show();
	}
}
function nascondiCastingListRegister(){	
	$('box_casting_list_register').hide();
	$('box_copri_centrale').hide();
}

function castingListDoRegister(){
	var obj;
	obj=$('casting_list_register_form');
	reqParameters={
	  	op: 'registerCastingList',
	  	userid: obj.userid.value,
	  	Richiesta: obj.Richiesta.value,
	  	Periodo: obj.Periodo.value,
	  	Budget: obj.Budget.value,
	  	ContattatemiVia: obj.ContattatemiVia.value,
	  	Ragazze: arrayToPHP(casting_list)
	};
	if (obj.userid.value==undefined || obj.userid.value==null || obj.userid.value==""){
		reqParameters.Username=obj.usn.value;
		reqParameters.Pwd=obj.pwd.value;
	}
	new Ajax.Request('/fe/service.php', {
		  method: 'post',
		  parameters: reqParameters,
		  onComplete: function(transport){
		  	step2(transport);
		  }
		} 
	);
	// Mostro le immagini
	function step2(transport){
		var risp;
		var d = new Date();
		risp=eval(transport.responseText); 
		if (risp[0].status_code=="OK"){
			// ricarico la pagina catalogo autologgando l'azienda
			alert(langLabels['catalogo.box_casting_list.JSmsg.richiesta_registrata']);
			//document.location="/fe/areariservata_aziende.php?alid="+risp[0].userid+"&wsx="+risp[0].wsx;
			document.location="/fe/catalogo.php?seed="+d.getMilliseconds();
		} else {
			alert(langLabels['catalogo.box_casting_list.JSmsg.login_ko']);
		}
	}
}

function registerAziendaFromCastingList(){
	// prima metto la casting list in sessione
	new Ajax.Request('/fe/service.php', {
		  method: 'post',
		  parameters: {
		  	  op: 'putCastingListOnSession',
		  	  castinglist: casting_list.join(',')
		  },
		  onComplete: function(transport){
		  	step2(transport);
		  }
		} 
	);
	// poi passo alla form di iscrizione
	function step2(transport){
		var risp;
		risp=eval(transport.responseText);
		document.location="/fe/iscrizione_aziende.php";
	}
}

function visualizzaRicercheAvanzate(){
	nascondiSchedaDettaglio();

	$('box_copri_centrale').show();
	$('box_ricerche_avanzate').show();
}
function nascondiRicercheAvanzate(){	
	$('box_ricerche_avanzate').hide();
	$('box_copri_centrale').hide();
}

function visualizzaSchedaDettaglio(element){
	var objContainer,id,codiceCategoriaRagazza;
	//alert("visualizzaSchedaDettaglio: "+element.idpersona);
	// nascondo la castinglistregister se era aperta
	nascondiCastingListRegister();
	// nascondo il container dei numeri di pagina e della ricerca alfabetica
	$('container_pages').hide();
	$('container_select_ricerca_alfabetica').hide();
	id=element.idpersona;
	// imposto il "link alla scheda"
	$('a_link_scheda').href="/fe/catalogo.php?idSchedaDettaglio="+id;
	// al div scheda_dettaglio appiccichiamo l'oggetto che trasporta i dati necessari per la aggiungiAllaCastinglist
	$('scheda_dettaglio').elemento=element;
	$('scheda_dettaglio').show();
	toggleLoading();
	// svuoto i vari container;
	$('dettaglio_container_dati_personali').innerHTML="";
	objContainer=$('dettaglio_container_slideshow');
	removeAllChilds(objContainer);
	//objContainer=$('dettaglio_container_fotobig');
	//removeAllChilds(objContainer);
	// carico i dati della ragazza
	new Ajax.Request('/fe/service.php', {
		  method: 'post',
		  parameters: {
		  	  op: 'getPersona',
		  	  id: id
		  },
		  onComplete: function(transport){
		  	step2(transport);
		  }
		} 
	);
	// compilo l'anagrafica
	function step2(transport){
		var risp;
		var str="";
		var strTaglia;
		risp=eval(transport.responseText);
		codiceCategoriaRagazza=risp[0].CodiceCategoria;
		aggiustaHeaderDettaglio(risp[0].CodiceCategoria);
		str+=langLabels['commons.nome']+": "+risp[0].Nome+' '+risp[0].Cognome.substr(0,1).toUpperCase()+".<br>";
		//str+="Cognome: "+risp[0].Cognome+"<br>";
		//if (risp[0].NazioneNascita!='')
		//	str+="Nazione di nascita: "+risp[0].NazioneNascita+"<br>";
		if (risp[0].AnnoNascita!='')
			str+=langLabels['catalogo.box_ricerca.anno_nascita']+": "+risp[0].AnnoNascita+"<br>";
		if (risp[0].Altezza!='' && risp[0].Altezza!='0')
			str+=langLabels['catalogo.box_ricerca.altezza']+": "+risp[0].Altezza+"<br>";
		/*
		strTaglia='';
		if (risp[0].TagliaVestiti!='' && risp[0].TagliaVestiti!='0'){
			if (risp[0].TagliaVestiti==39)
				strTaglia="38/40";
			if (risp[0].TagliaVestiti==41)
				strTaglia="40/42";
			if (risp[0].TagliaVestiti==43)
				strTaglia="42/44";
			if (risp[0].TagliaVestiti==45)
				strTaglia="44/46";
			if (strTaglia=='')
				strTaglia=risp[0].TagliaVestiti;
		*/
			strTaglia=risp[0].TagliaVestiti;
			str+=langLabels['catalogo.box_ricerca.taglia']+": "+strTaglia+"<br>";
		//}
		if (risp[0].MisureSeno!='' && risp[0].MisureSeno!='0')
			str+=langLabels['catalogo.scheda_dettaglio.seno']+": "+risp[0].MisureSeno+"<br>";
		if (risp[0].MisureVita!='' && risp[0].MisureVita!='0')
			str+=langLabels['catalogo.box_ricerca.vita']+": "+risp[0].MisureVita+"<br>";
		if (risp[0].MisureFianchi!='' && risp[0].MisureFianchi!='0')
			str+=langLabels['catalogo.box_ricerca.fianchi']+": "+risp[0].MisureFianchi+"<br>";
		if (risp[0].TagliaScarpe!='' && risp[0].TagliaScarpe!='0')
			str+=langLabels['catalogo.box_ricerca.scarpe']+": "+risp[0].TagliaScarpe+"<br>";
		if (risp[0].ColoreOcchi!='')
			str+=langLabels['catalogo.box_ricerca.occhi']+": "+risp[0].ColoreOcchi+"<br>";
		if (risp[0].ColoreCapelli!='')
			str+=langLabels['catalogo.box_ricerca.capelli']+": "+risp[0].ColoreCapelli+"<br>";
		/*
		if (risp[0].ProvinciaDomicilio!="-" && risp[0].ProvinciaDomicilio!="")
			str+="Provincia di domicilio: "+risp[0].ProvinciaDomicilio+"<br>";
		if (risp[0].RegioneDomicilio!="-" && risp[0].RegioneDomicilio!="")
			str+="Regione di domicilio: "+risp[0].RegioneDomicilio+"<br>";
		*/
		
		/*
		if (risp[0].LocalitaResidenza!=''){
			str+="Cittā: "+risp[0].LocalitaResidenza;
			if (risp[0].CittaAppoggio!='' && risp[0].CittaAppoggio.indexOf(risp[0].LocalitaResidenza)>-1){
				str+=", "+risp[0].CittaAppoggio+"<br>";
			}else{
				str+="<br>";
			}
		}else{
			if (risp[0].CittaAppoggio!=''){
				str+="Cittā: "+risp[0].CittaAppoggio+"<br>";
			}
		}
		*/

		/*
		if (risp[0].CittaAppoggio!=''){
			str+="Cittā: "+risp[0].CittaAppoggio;

			if (risp[0].LocalitaResidenza!='' && risp[0].CittaAppoggio.indexOf(risp[0].LocalitaResidenza)==-1){
				str+=", "+risp[0].LocalitaResidenza;
			}
			str+="<br/>";
		}else{
			if (risp[0].LocalitaResidenza!=''){
				str+="Cittā: "+risp[0].LocalitaResidenza+"<br>";
			}
		}*/
		
		if (risp[0].Citta!='')
			str+=langLabels['catalogo.scheda_dettaglio.citta']+": "+risp[0].Citta+"<br>";
		if (risp[0].Regioni!='')
			str+=langLabels['catalogo.scheda_dettaglio.regioni']+": "+risp[0].Regioni+"<br>";
		if (risp[0].Esperienze!='')
			str+=langLabels['catalogo.scheda_dettaglio.esperienze']+": "+risp[0].Esperienze+"<br>";
		//if (risp[0].RegioniPersona!='')
		//	str+="Regioni: "+risp[0].RegioniPersona+"<br>";
		if (risp[0].LingueConosciute!='')
			str+=langLabels['catalogo.box_ricerca.lingue_conosciute']+": "+risp[0].LingueConosciute+"<br>";
		if (risp[0].Patente=='s')
			str+=langLabels['catalogo.scheda_dettaglio.possesso_patente_si']+"<br>";
		//else
		//	str+="Possesso patente: No<br>";
		if (risp[0].Automunita=="s")
			str+=langLabels['catalogo.scheda_dettaglio.automunita_si']+"<br>";
		//else
		//	str+="Automunita: No<br>";
		if (risp[0].CapacitaArtistiche!='')
			str+=langLabels['catalogo.box_ricerca.capacita_artistiche']+": "+risp[0].CapacitaArtistiche+"<br>";
		//if (risp[0].CapacitaAltro!='')
		//	str+=langLabels['catalogo.scheda_dettaglio.altre_capacita']+": "+risp[0].CapacitaAltro+"<br>";
		//alert(str);
		str+="<br>ID: "+risp[0].Id+"<br>";
		$('dettaglio_container_dati_personali').innerHTML=str;
		
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	  op: 'getListaLavoriDisponibile',
			  	  id: id
			  },
			  onComplete: function(transport){
			  	step3(transport);
			  }
			} 
		);
	}
	// compilo la lista dei lavori cui ha dato disponibilitā
	function step3(transport){
		var risp;
		var prevStr;
		risp=eval(transport.responseText);
		prevStr=$('dettaglio_container_dati_personali').innerHTML;
		if (risp[0].lista_lavori!='')
			$('dettaglio_container_dati_personali').innerHTML=prevStr+langLabels['catalogo.scheda_dettaglio.disponibile_servizi']+": "+risp[0].lista_lavori;
		
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	  op: 'getImmaginiPersona',
			  	  id: id
			  },
			  onComplete: function(transport){
			  	step4(transport);
			  }
			} 
		);
	}
	// inserisco la immagini secondo lo schema:
	/*
		<div class="imageElement">
			<h3></h3>
		    <p></p>
        	<img src="/upl/foto/t/59737_004.jpg" class="full" />
		    <img src="/upl/foto/t/thumbs/sg/59737_004.jpg" class="thumbnail" />
		</div>
	*/
	function step4(transport){
		var risp,i;
		var newDiv,newImg,newImg2,objContainer;
		var imgPath,bigImgPath,firstBigImgPath;
		var newH3,newP;
		toggleLoading();
		risp=eval(transport.responseText);
		objContainer=$('dettaglio_container_slideshow');
		//removeAllChilds(objContainer);
		firstBigImgPath="";
		for(i=0;i<risp.length;i++){
			//alert(risp[i].NomeFile);
			newDiv=document.createElement('div');
	  		Element.addClassName(newDiv,'imageElement');
	  		newH3=document.createElement('h3');
	  		newP=document.createElement('p');
	  		newDiv.appendChild(newH3);
	  		newDiv.appendChild(newP);
	  		newImg=document.createElement('img');
	  		Element.addClassName(newImg,'full');
	  		newImg2=document.createElement('img');
	  		Element.addClassName(newImg2,'thumbnail');
	  		Element.addClassName(newImg,'dettaglio_thumbs');
	  		if (risp[i].Originale=='s'){
	  			imgPath="/upl/foto/o/thumbs/"+risp[i].NomeFile;
	  			bigImgPath="/upl/foto/o/"+risp[i].NomeFile;
	  		} else {
	  			imgPath="/upl/foto/t/thumbs/sg/"+risp[i].NomeFile;
	  			bigImgPath="/upl/foto/t/"+risp[i].NomeFile;
	  		}
	  		newImg.src=bigImgPath;
	  		newImg2.src=imgPath;
	  		newDiv.appendChild(newImg);
	  		newDiv.appendChild(newImg2);
	  		objContainer.appendChild(newDiv);
		}
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	  op: 'getAltriAllegatiPersona',
			  	  id: id
			  },
			  onComplete: function(transport){
			  	step5(transport);
			  }
			} 
		);
		
		var myGallery2 = new Gallery($('dettaglio_container_slideshow'),{timed: true});
	}
	/*
		<div class="dettaglio_sotto_thumbs">				<-- per il bordo bianco
			<div class="dettaglio_maschera_thumbs">			<-- maschera per ottenere il bordo bianco
				<img src="XXX" class="dettaglio_thumbs">	<-- per posizionare l'immagine sotto la maschera
			</div>
		</div>
	*/
	function step4_old(transport){
		var risp,i;
		var newDiv,newDiv2,newImg,objContainer;
		var imgPath,bigImgPath,firstBigImgPath;
		toggleLoading();
		risp=eval(transport.responseText);
		objContainer=$('dettaglio_container_thumbs');
		//removeAllChilds(objContainer);
		firstBigImgPath="";
		for(i=0;i<risp.length;i++){
			//alert(risp[i].NomeFile);
			newDiv=document.createElement('div');
	  		Element.addClassName(newDiv,'dettaglio_sotto_thumbs');
	  		newDiv2=document.createElement('div');
	  		Element.addClassName(newDiv2,'dettaglio_maschera_thumbs');
	  		newDiv.appendChild(newDiv2);
	  		newImg=document.createElement('img');
	  		Element.addClassName(newImg,'dettaglio_thumbs');
	  		if (risp[i].Originale=='s'){
	  			imgPath="/upl/foto/o/thumbs/"+risp[i].NomeFile;
	  			bigImgPath="/upl/foto/o/"+risp[i].NomeFile;
	  		} else {
	  			imgPath="/upl/foto/t/thumbs/"+risp[i].NomeFile;
	  			bigImgPath="/upl/foto/t/"+risp[i].NomeFile;
	  		}
	  		if (firstBigImgPath=="")
	  			firstBigImgPath=bigImgPath;
	  		newImg.src=imgPath;
	  		newDiv2.appendChild(newImg);
	  		objContainer.appendChild(newDiv);
	  		newImg.fotoBig=bigImgPath;
	  		
	  		Event.observe(newImg, 'click', function(e) {
			  //alert(Event.element(e));
			  var fotoBig;
			  fotoBig=Event.element(e).fotoBig;
			  impostaFotoBigDettaglio(fotoBig);
			});
		}
		// poi incollo la prima immagine
		impostaFotoBigDettaglio(firstBigImgPath);
		
		new Ajax.Request('/fe/service.php', {
			  method: 'post',
			  parameters: {
			  	  op: 'getAltriAllegatiPersona',
			  	  id: id
			  },
			  onComplete: function(transport){
			  	step5(transport);
			  }
			} 
		);
	}
	// se c'č il video ne associo il path al div "dettaglio_video" in modo che poi possa essere
	// visualizzato
	// altrimenti NON LO SO
	function step5(transport){
		var risp,i;
		risp=eval(transport.responseText);
		//se il video non c'e nascondo il pulsante
		if (risp.length>0){
			$('dettaglio_video').videoPath=risp[0].NomeFile;
			//$('img_dettaglio_head_3').setStyle({visibility: "visible"});
			//$('img_dettaglio_head_3').src='img/sm_showbiz_videoOff.jpg';
			aggiustaHeaderDettaglio(codiceCategoriaRagazza);
			$('dettaglio_pulsante_foto').show();
			$('dettaglio_pulsante_video').show();
		} else {
			$('dettaglio_video').videoPath="";
			//$('img_dettaglio_head_3').setStyle({visibility: "hidden"});
			if (codiceCategoriaRagazza=="ragazza_hostess"){
				$('img_dettaglio_head_3').src='img/sm_showbiz_videoNo.jpg';
			}
			if (codiceCategoriaRagazza=="ragazza_high_level"){
				$('img_dettaglio_head_3').src='img/sm_highLevel_videoNo.jpg';
			}
			if (codiceCategoriaRagazza=="ragazza_top_class"){
				$('img_dettaglio_head_3').src='img/sm_topClass_videoNo.jpg';
			}
			if (codiceCategoriaRagazza=="ragazza_man"){
				$('img_dettaglio_head_3').src='img/sm_men_videoNo.jpg';
			}
			$('dettaglio_pulsante_foto').hide();
			$('dettaglio_pulsante_video').hide();
		}
		//alert($('dettaglio_video').videoPath);
	}
}

function aggiustaHeaderDettaglio(CodiceCategoria){
	var i,id;
	var img1,img2,img3,img4;
	if(CodiceCategoria=="ragazza_hostess"){
		img1="sm_showbiz.jpg";
		img2="sm_showbiz_fotoOn.jpg";
		img3="sm_showbiz_videoOff.jpg";
		img4="sm_showbiz_chiudi.jpg";
	}
	if(CodiceCategoria=="ragazza_high_level"){
		img1="sm_highLevel.jpg";
		img2="sm_highLevel_fotoOn.jpg";
		img3="sm_highLevel_videoOff.jpg";
		img4="sm_highLevel_chiudi.jpg";
	}
	if(CodiceCategoria=="ragazza_top_class"){
		img1="sm_topClass.jpg";
		img2="sm_topClass_fotoOn.jpg";
		img3="sm_topClass_videoOff.jpg";
		img4="sm_topClass_chiudi.jpg";
	}
	if(CodiceCategoria=="ragazza_man"){
		img1="sm_men.jpg";
		img2="sm_men_fotoOn.jpg";
		img3="sm_men_videoOff.jpg";
		img4="sm_men_chiudi.jpg";
	}
	$('img_dettaglio_head_1').src="img/"+img1;
	$('img_dettaglio_head_2').src="img/"+langCode+"/"+img2;
	$('img_dettaglio_head_3').src="img/"+langCode+"/"+img3;
	$('img_dettaglio_head_4').src="img/"+langCode+"/"+img4;
}

function impostaFotoBigDettaglio(imgPath){
	var objContainer,newImg;
	objContainer=$('dettaglio_container_fotobig');
	removeAllChilds(objContainer);
	newImg=document.createElement('img');
	newImg.src=imgPath;
	objContainer.appendChild(newImg);
}

function nascondiSchedaDettaglio(){
	$('scheda_dettaglio').hide();
	if (scheda_dettaglio_su_video)
		nascondiTabVideoDettaglio();
	// riscopro il container dei numeri di pagina e della ricerca alfabetica
	$('container_pages').show();
	$('container_select_ricerca_alfabetica').show();
}

function visualizzaTabVideoDettaglio(){
	var img2,img3
	var so;
	//alert('visualizzaTabVideoDettaglio');
	img2=$('img_dettaglio_head_2').src;
	img3=$('img_dettaglio_head_3').src;
	//alert(img2.substr(0,img2.length-6)+"On.jpg");
	$('img_dettaglio_head_2').src=img2.substr(0,img2.length-6)+"Off.jpg";
	//alert(img3.substr(0,img3.length-7)+"On.jpg");
	$('img_dettaglio_head_3').src=img3.substr(0,img3.length-7)+"On.jpg";
	$('dettaglio_tab_video').show();
	//var so = new SWFObject("/fe/swf/palla.swf", "flashvideoragazza", "300", "200", "8", "#ffffff");
	if ($('dettaglio_video').videoPath!=''){
		so = new SWFObject("/fe/swf/video_modelle.swf", "flashvideoragazza", "320", "277", "8", "#525051");
		so.addVariable("nomefile", $('dettaglio_video').videoPath);
		so.write("dettaglio_video");
	} else {
		$('dettaglio_video').innerHTML='<img src="/fe/img/novideo2.gif" width="320" height="155" alt="">';
	}
  	scheda_dettaglio_su_video=true;
}
function nascondiTabVideoDettaglio(){
	var img2,img3
	removeAllChilds($('dettaglio_video'));
	$('dettaglio_tab_video').hide();
	img2=$('img_dettaglio_head_2').src;
	img3=$('img_dettaglio_head_3').src;
	//alert(img2.substr(0,img2.length-7)+"On.jpg");
	$('img_dettaglio_head_2').src=img2.substr(0,img2.length-7)+"On.jpg";
	//alert(img3.substr(0,img3.length-6)+"On.jpg");
	$('img_dettaglio_head_3').src=img3.substr(0,img3.length-6)+"Off.jpg";
	scheda_dettaglio_su_video=false;
}
function aggiungiDettaglioAllaCastingList(){
	aggiungiAllaCastingList($('scheda_dettaglio').elemento);
}

/*     HELPS      */
function visualizzaHelpCatalogo(){
	new Effect.Parallel([
		new Effect.Scale('help_catalogo', 100, {scaleContent: false, scaleFrom: 0.0, scaleMode: { originalHeight: 200, originalWidth: 200 }}),
		new Effect.Move('help_catalogo',{ x: -200, y: 0, mode: 'relative'})
		],{afterFinish: step2});
	function step2(){
		help_catalogo_aperto=true;
		if (int_chiudi_help_catalogo!=undefined)
			clearInterval(int_chiudi_help_catalogo);
		int_chiudi_help_catalogo=setInterval(function(){
			nascondiHelpCatalogo();
		},10000);
	}
}
function nascondiHelpCatalogo(){
	if (int_chiudi_help_catalogo!=undefined){
		clearInterval(int_chiudi_help_catalogo);
		int_chiudi_help_catalogo=undefined;
	}
	new Effect.Parallel([
		new Effect.Scale('help_catalogo', 0, {scaleContent: false, scaleFrom: 100.0, scaleMode: { originalHeight: 200, originalWidth: 200 }}),
		new Effect.Move('help_catalogo',{ x: 200, y: 0, mode: 'relative'})
		],{afterFinish: step2});
	function step2(){
		help_catalogo_aperto=false;
	}
}
function toggleVisibilitaHelpCatalogo(){
	if (!help_catalogo_aperto){
		visualizzaHelpCatalogo();
	} else {
		nascondiHelpCatalogo();
	}
}

function visualizzaHelpCastinglist(){
	new Effect.Parallel([
		new Effect.Scale('help_castinglist', 100, {scaleContent: false, scaleFrom: 0.0, scaleMode: { originalHeight: 200, originalWidth: 200 }}),
		new Effect.Move('help_castinglist',{ x: -200, y: -200, mode: 'relative'})
		],{afterFinish: step2});
	function step2(){
		help_castinglist_aperto=true;
		if (int_chiudi_help_castinglist!=undefined)
			clearInterval(int_chiudi_help_castinglist);
		int_chiudi_help_castinglist=setInterval(function(){
			nascondiHelpCastinglist();
		},5000);
	}
}
function nascondiHelpCastinglist(){
	if (int_chiudi_help_castinglist!=undefined){
		clearInterval(int_chiudi_help_castinglist);
		int_chiudi_help_castinglist=undefined;
	}
	new Effect.Parallel([
		new Effect.Scale('help_castinglist', 0, {scaleContent: false, scaleFrom: 100.0, scaleMode: { originalHeight: 200, originalWidth: 200 }}),
		new Effect.Move('help_castinglist',{ x: 200, y: 200, mode: 'relative'})
		],{afterFinish: step2});
	function step2(){
		help_castinglist_aperto=false;
	}
}
function toggleVisibilitaHelpCastinglist(){
	if (!help_castinglist_aperto){
		visualizzaHelpCastinglist();
	} else {
		nascondiHelpCastinglist();
	}
}
/*     HELPS fine    */

/*  Ricerca semplice basata su ISO31662   */
function aggiornaRegioniRicerca(){
	var siglaNazione;
	siglaNazione=$('cerca_idnazione').getValue();
	removeAllChilds($('cercaSubdivision1'));
	removeAllChilds($('cercaSubdivision2'));
	if (siglaNazione=='')
		return;
	new Ajax.Updater(
		'cercaSubdivision1', 
		'/fe/geoService.php', 
		{ 	method: 'get',
			parameters: {
				op: 'getRegioniCerca',
				countryCode: siglaNazione,
				idName: 'cerca_idregione'
			}
		}
	);
}
function aggiornaProvinceRicerca(){
	var siglaRegione;
	var siglaNazione;
	siglaNazione=$('cerca_idnazione').getValue();
	siglaRegione=$('cerca_idregione').getValue();
	removeAllChilds($('cercaSubdivision2'));
	if (siglaRegione=='')
		return;
	new Ajax.Updater(
		'cercaSubdivision2', 
		'/fe/geoService.php', 
		{ 	method: 'get',
			parameters: {
				op: 'getProvinceCerca',
				countryCode: siglaNazione,
				regCode: siglaRegione,
				idName: 'cerca_idprovincia'
			}
		}
	);
}
/*  Ricerca semplice basata su ISO31662  FINE  */

/*  Ricerca Avanzata basata su ISO31662   */
function aggiornaRegioniRicercaAvanzata(){
	var siglaNazione;
	siglaNazione=$('cerca_avanzata_idnazione').getValue();
	removeAllChilds($('cercaAvanzataSubdivision1'));
	removeAllChilds($('cercaAvanzataSubdivision2'));
	removeAllChilds($('cercaAvanzataSubdivision3'));
	if (siglaNazione=='')
		return;
	new Ajax.Updater(
		'cercaAvanzataSubdivision1', 
		'/fe/geoService.php', 
		{ 	method: 'get',
			parameters: {
				op: 'getRegioniCercaAvanzata',
				countryCode: siglaNazione,
				idName: 'cerca_avanzata_idregione'
			}
		}
	);
}
function aggiornaProvinceRicercaAvanzata(){
	var siglaRegione;
	var siglaNazione;
	siglaNazione=$('cerca_avanzata_idnazione').getValue();
	siglaRegione=$('cerca_avanzata_idregione').getValue();
	removeAllChilds($('cercaAvanzataSubdivision2'));
	removeAllChilds($('cercaAvanzataSubdivision3'));
	if (siglaRegione=='')
		return;
	new Ajax.Updater(
		'cercaAvanzataSubdivision2', 
		'/fe/geoService.php', 
		{ 	method: 'get',
			parameters: {
				op: 'getProvinceCercaAvanzata',
				countryCode: siglaNazione,
				regCode: siglaRegione,
				idName: 'cerca_avanzata_idprovincia'
			}
		}
	);
}
function aggiornaLocalitaRicercaAvanzata(){
	var siglaRegione;
	var siglaNazione;
	var siglaProvincia;
	siglaNazione=$('cerca_avanzata_idnazione').getValue();
	siglaRegione=$('cerca_avanzata_idregione').getValue();
	siglaProvincia=$('cerca_avanzata_idprovincia').getValue();
	removeAllChilds($('cercaAvanzataSubdivision3'));
	if (siglaProvincia=='')
		return;
	new Ajax.Updater(
		'cercaAvanzataSubdivision3', 
		'/fe/geoService.php', 
		{ 	method: 'get',
			parameters: {
				op: 'getLocalitaCercaAvanzata',
				countryCode: siglaNazione,
				regCode: siglaRegione,
				provCode: siglaProvincia,
				idName: 'cerca_avanzata_localita'
			}
		}
	);
}
/*  Ricerca Avanzata basata su ISO31662  FINE   */

