
function isshort(id) {
	
	if (id == 'Password') var len = 6;
	else if (id == 'Login') var len = 4;
	else if (id == 'new_cat_code') var len = 3;
	else var len = 4;
 	if ($(id).value.length < len) {
		var tp = $(id).type;
		$(id).style.color="white";
		$(id).style.backgroundColor="red";
		var temp = $(id).value;
		$(id).value="TOO SHORT";
		$(id).type="text";
		setTimeout("$('"+id+"').value='"+temp+"';$('"+id+"').style.color=\"gray\";$('"+id+"').style.backgroundColor=\"white\";$('"+id+"').type='"+tp+"';",1140);
		$(id).focus();return true;
	}
	else 
		return false;
}

ajaxSave = function (id) {var ed = tinyMCE.get('text.position.'+id); new Ajax.Updater('script','instantedit.php',{postBody: 'editorId=home.content.position.".$positionid."&value='+ed.getContent()});}

function MomaMceStart(editor,filetype) {
	  if (editor=='FCKeditor3') {
      tinyMCE.init({
         mode : "specific_textareas",
         editor_selector : "mceEditor",
 		 language: "it",       
         plugins : "paste, save",
		 theme_advanced_buttons1 : "save,|,justifyleft,justifycenter,justifyright,justifyfull,backcolor,forecolor,fontsizeselect,bold,italic,underline,link,unlink",
		 theme_advanced_buttons2 : "",
		 theme_advanced_buttons3 : "",
		 theme_advanced_buttons4 : "",
		 theme_advanced_toolbar_location : "bottom",
         theme_advanced_toolbar_align : "left",
         theme : "advanced",
         relative_urls : false,
         remove_script_host : false,
         document_base_url : 'http://www.fotoa3.it/personal_htm/'	  	
		 });
	  }
	  if (editor=='FCKeditor2' && filetype=='htm') {
      tinyMCE.init({
         mode : "specific_textareas",
         editor_selector : "mceEditor",
 		 language: "it",       
         plugins : "safari,pagebreak,table,save,advhr,advimage,advlink,emotions,insertdatetime,preview,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,template",
         theme_advanced_buttons1 : "bold,italic,underline,cut,copy,paste,justifyleft,justifycenter,justifyright,justifyfull,hr,removeformat,fontselect,fontsizeselect,forecolor,backcolor,preview,link,unlink,anchor,image,cleanup,code, ",
         theme_advanced_buttons2 : "tablecontrols,|,formatselect,undo,redo,",
         theme_advanced_buttons3 : "",
         theme_advanced_buttons4 : "",
         theme_advanced_toolbar_location : "top",
         theme_advanced_toolbar_align : "left",
         theme : "advanced",
         relative_urls : false,
         remove_script_host : false,
         document_base_url : 'http://www.fotoa3.it/personal_htm/'	  	
		 });
	  }
	  if (editor=='FCKeditor1' && filetype=='htm') {
      tinyMCE.init({
         mode : "specific_textareas",
         editor_selector : "mceEditor",
 		 language: "it",       
         plugins : "safari,pagebreak,table,save,advhr,advimage,advlink,emotions,insertdatetime,preview,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,template",
         theme_advanced_buttons1 : "bold,italic,underline,cut,copy,paste,justifyleft,justifycenter,justifyright,justifyfull,hr,removeformat,fontselect,fontsizeselect,forecolor,backcolor,preview,link,unlink,anchor,image,cleanup,code, table, row_props,,cell_props,delete_col,delete_row,delete_table,col_after,col_before,row_after,row_before,",
         theme_advanced_buttons2 : "",
         theme_advanced_buttons3 : "",
         theme_advanced_buttons4 : "",
         theme_advanced_toolbar_location : "top",
         theme_advanced_toolbar_align : "left",
         theme : "advanced",
         relative_urls : false,
         remove_script_host : false,
         document_base_url : 'http://www.fotoa3.it'
	  	 });
	  }
}
 


function perselector(id,url,text) {
 	new Ajax.InPlaceCollectionEditor(id, url, {   
 		collection: [['Tutti','Tutti'],['a3chiambre','a3chiambre'],['adecaroli','adecaroli'],['alessandra','alessandra'],['angela','angela'],['anitag','anitag'],['barbara','barbara'],['bella','bella'],['berto','berto'],['chiara','chiara'],['class','class'],['corio','corio'],['cristiana','cristiana'],['dani','dani'],['davide','davide'],['dcampanella','dcampanella'],['elena','elena'],['eleonora','eleonora'],['farina','farina'],['fede','fede'],['francesca','francesca'],['francescagissi','francescagissi'],['gabriella','gabriella'],['gerardi','gerardi'],['gigi','gigi'],['grazia','grazia'],['isabella','isabella'],['lastampa','lastampa'],['leda','leda'],['lucarini','lucarini'],['luisa','luisa'],['martina','martina'],['momapix','momapix'],['mondo','mondo'],['nazario','nazario'],['nunzia','nunzia'],['oggi','oggi'],['paola','paola'],['paolacorapi','paolacorapi'],['renata','renata'],['repub','repub'],['roberta','roberta'],['roberto','roberto'],['sandro','sandro'],['sara','sara'],['tedeschi','tedeschi'],['tiziana','tiziana'],['valentina','valentina'],['venerdi','venerdi']],   
 		value: 0,  
       	okButton: true,
       	cancelLink: true,
       	cancelControl: 'button',
       	cancelText: 'No',
       	submitOnSelect: true,
       	clickToEditText: text, 
 		ajaxOptions: {method: 'get'} //override so we can use a static for the result 
 		});  	
} 



function ajaxselector(id,url,text) {
 	new Ajax.InPlaceCollectionEditor(id, url, {   
 		collection: [['S11','Categoria1,Sub11'],['S12','Categoria1,Sub12'],['CT2','Categoria2'],['CT3','Categoria3'],],   
 		value: 0,  
       	okButton: true,
       	cancelLink: true,
       	cancelControl: 'button',
       	cancelText: 'No',
       	submitOnSelect: true,
       	clickToEditText: text, 
 		ajaxOptions: {method: 'get'} //override so we can use a static for the result 
 		});  	
}


function streamify(element,basedir,width,height,id,autostart,screenshoot) {	
  	var so = new SWFObject('3rd/flvplayer/player.swf',element+'mpl',width,height,'9');
  	so.addParam('allowfullscreen','true');
  	so.addParam('wmode','transparent');
  	so.addParam('allowscriptaccess','always');
  	so.addParam("allowfullscreen","true");
	so.addParam('allowscriptaccess','always');
	so.addVariable('file', 'Preview'+id+'.flv');
	so.addVariable('image','Preview'+id+'.jpg');
	so.addVariable('autostart',autostart);
	so.addVariable('stretching','exactfit');
	so.addVariable('bufferlength','3');
	so.addVariable('streamer','http://'+basedir+'/3rd/xmoov/xmoov.php');
	so.addVariable('enablejs','true');
	if (screenshoot) {
		//so.addVariable('plugins','snapshot-1');
		//so.addVariable('snapshot.data','false');
		//so.addVariable('snapshot.script','snapshot.php');
		so.addVariable('plugins','screenshoot-1');
		so.addVariable('screenshoot.submiturl','snapshot.php?id='+id);
	}
	so.write(element);
}




function MYdecodeURIComponent(string) {
	if (/%$|%\/[0-9]+$/i.test(string)) {newstring=string;} 
	else {newstring=decodeURIComponent(string);}
	return newstring;
}
function MYencodeURIComponent(string) {
	if (/%$|%\/[0-9]+$/i.test(string)) {newstring=string;}
	else {newstring=encodeURIComponent(string);}
	return newstring;
}

function updatehistory(hsc) {
	var myhsc = hsc.gsub(/\/.*/,'');
	var lvhsc = myhsc;
	var hvhsc = hsc.replace(myhsc,'').replace('/','').replace('\+',' ').replace('\&dw=1','');
 	var hvhsc = MYdecodeURIComponent(hvhsc);
 	switch (myhsc) {
 		case 'archive': var lvhsc = 'Archivio'; var resetcat= 'SessionCookie(\'Categoria\',\'%\')'; break;
 		case 'event': var lvhsc = 'Servizio'; break;
 		case 'lightbox': var lvhsc = 'Lightbox'; break;
 		case 'group': var lvhsc = ''; break;
 		case 'personal': var lvhsc = ''; break;
 		case 'search': var lvhsc = 'Ricerca'; hvhsc = '<i>'+hvhsc+'</i>'; break;
			
 	}

	if (!/photo/i.test(hsc)  && !/folder/i.test(hsc)) {
		if (navigator.userAgent.indexOf("Firefox")!=-1) var gsubded = MYencodeURIComponent(hsc.gsub(/ /,'+').replace('\&dw=1',''));
		else var gsubded = hsc.gsub(/ /,'+').replace('\&dw=1','');
		if ($(gsubded)) new Effect.Pulsate(gsubded, { from: 0.3, pulses: 5, duration: 2 });
		else if ($('history_space')) {
			$('history_space').insert({ after : '<li id="'+gsubded+'" class="history foot_grid"><a href="./#'+ gsubded +'" onclick=\"reloadAnchor=true;'+ resetcat +'\" class="foot_grid">'+(lvhsc.substr(0, 1).toUpperCase() + lvhsc.substr(1)+' '+hvhsc)+'</a>'}); //decodeURIComponent
			new Effect.Pulsate(gsubded, { from: 0.3, pulses: 5, duration: 2 });
		}
	}
}
