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


function perselector(id,url,text) {
 	new Ajax.InPlaceCollectionEditor(id, url, {   
 		collection: [['Tutti','Tutti'],['aconforti','aconforti'],['alef','alef'],['avvenire','avvenire'],['batman','batman'],['bnoizeux','bnoizeux'],['bodino','bodino'],['boroli','boroli'],['bourbon','bourbon'],['carbonara','carbonara'],['ceciliafleg','ceciliafleg'],['celona','celona'],['cesare','cesare'],['chiaracorio','chiaracorio'],['chiaragilardo','chiaragilardo'],['cinnamon','cinnamon'],['coccinella','coccinella'],['cramelli','cramelli'],['cristelli','cristelli'],['daniela','daniela'],['di_donfrancesco','di_donfrancesco'],['donati','donati'],['donnamod','donnamod'],['donnamoderna','donnamoderna'],['dovecitta','dovecitta'],['doveg','doveg'],['ebozzetti','ebozzetti'],['eden','eden'],['elenavilla','elenavilla'],['emanuela','emanuela'],['esarni','esarni'],['expansionitalia','expansionitalia'],['fabio','fabio'],['fabrizia','fabrizia'],['fotosky','fotosky'],['frammenti','frammenti'],['gabri','gabri'],['gente','gente'],['george','george'],['giammo','giammo'],['gioiaimago','gioiaimago'],['giorgia','giorgia'],['giunti','giunti'],['grieco','grieco'],['guida','guida'],['guidemondo','guidemondo'],['guidemondo2','guidemondo2'],['ipzs','ipzs'],['joseph72','joseph72'],['laura','laura'],['leonardo','leonardo'],['lifemax','lifemax'],['lucaselmi','lucaselmi'],['lucavolpi','lucavolpi'],['luciana','luciana'],['Luna','Luna'],['marco99','marco99'],['martacarenzi','martacarenzi'],['mcasali','mcasali'],['millo63','millo63'],['momapix','momapix'],['momapix2','momapix2'],['mpinna','mpinna'],['muster1239','muster1239'],['mvarisco','mvarisco'],['pagliardini','pagliardini'],['paola','paola'],['patriziai','patriziai'],['pfortunelli','pfortunelli'],['piemonteparchi','piemonteparchi'],['pillina','pillina'],['pincat','pincat'],['preti','preti'],['pterragni','pterragni'],['quitouring','quitouring'],['quitouring1','quitouring1'],['ravello','ravello'],['realy','realy'],['repfoto','repfoto'],['retouring','retouring'],['ribaunz','ribaunz'],['rosaria28','rosaria28'],['rossella','rossella'],['sara','sara'],['saraesposito','saraesposito'],['sfabbri','sfabbri'],['soluzionisubito','soluzionisubito'],['support','support'],['toni','toni'],['touring','touring'],['traveller','traveller'],['tudares','tudares'],['tuttoturismo','tuttoturismo'],['valentina','valentina']],   
 		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, {   
		//loadCollectionURL: 'http://www.realyeasystar.com/catcollectionload.php',
 		collection: [['ARC','Architettura'],['ART','Arte'],['ATG','Artigianato'],['ATT','Attualità'],['BTN','Botanica'],['ECM','Economia '],['EFF','Effetti'],['FNA','Fenomeni Naturali'],['FST','Feste e Popoli'],['GST','Gastronomia'],['GEO','Geografia'],['AFR','-Africa'],['AMR','-America'],['AS','-Asia'],['ERP','-Europa'],['ITL','-Italia'],['OCN','-Oceania'],['IND','Industria'],['LCL','locali storici '],['MSC','musica'],['OGG','Oggetti'],['PSG','Paesaggi'],['VIP','Personaggi'],['RPR','Reportage'],['SPO','Sport'],['SDA','Stampe d\'autore'],['STO','Storia'],['ANT','-Antica'],['MD','-Media'],['MDR','-Moderna'],['PRS','-Preistoria'],['TEC','Tecnica'],['TRS','Turismo e Sport '],['UMT','Umanità'],['ZLG','Zoologia']],   
 		value: 0,  
       	okButton: true,
       	cancelLink: true,
       	cancelControl: 'button',
       	loadingText: 'aa',
       	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);
	var hvhsd = hvhsc.match(/([^/]*)([\/]*)(.*)/);
	
	
 	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>'+hex2str(hvhsd[1])+hvhsd[2]+hvhsd[3]+'</i>'; break;
			
 	}

	if (!/photo/i.test(hsc)  && !/folder/i.test(hsc)) {
		if (navigator.userAgent.indexOf("Firefox")!=-1) var gsubded = (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 });
		}
	}
}
