
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.tamtamfotografie.com/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.tamtamfotografie.com/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.tamtamfotografie.com'
	  	 });
	  }
}
 


function perselector(id,url,text) {
 	new Ajax.InPlaceCollectionEditor(id, url, {   
 		collection: [['Tutti','Tutti'],['anna','anna'],['cattaneo','cattaneo'],['chifoto','chifoto'],['corriere','corriere'],['dipiu','dipiu'],['donnamoderna','donnamoderna'],['espresso','espresso'],['fcristiana','fcristiana'],['focus','focus'],['foto','foto'],['gente','gente'],['gioiatitti','gioiatitti'],['giornale','giornale'],['grazia','grazia'],['internazionale','internazionale'],['iodonna1','iodonna1'],['laterza','laterza'],['liberazione','liberazione'],['luana','luana'],['luca','luca'],['manifesto','manifesto'],['martina','martina'],['marzia','marzia'],['maurizio','maurizio'],['mdrn2','mdrn2'],['msperoni','msperoni'],['nmancini','nmancini'],['novella','novella'],['pansoldi','pansoldi'],['pinasi','pinasi'],['repubblica','repubblica'],['ricorda','ricorda'],['rossella','rossella'],['sandro','sandro'],['saracervo','saracervo'],['saratitti','saratitti'],['sette','sette'],['soletam1','soletam1'],['soletam2','soletam2'],['soletam3','soletam3'],['soletam4','soletam4'],['soletam5','soletam5'],['stampa','stampa'],['stern','stern'],['terre','terre'],['tustyle','tustyle'],['unita','unita'],['vistorcs','vistorcs'],['vita','vita'],['volpi','volpi']],   
 		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: [['CRO','Cronaca'],['CUL','Cultura'],['ECO','Economia'],['EST','Esteri'],['INT','Interni'],['MAG','Magazine'],['MIC','Milano'],['POL','Politica'],['ROM','Roma'],['SPE','Spettacolo'],['SPO','Sport'],],   
 		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 });
		}
	}
}
