
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: "en",       
         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.photo-4.com/personal_htm/'	  	
		 });
	  }
	  if (editor=='FCKeditor2' && filetype=='htm') {
      tinyMCE.init({
         mode : "specific_textareas",
         editor_selector : "mceEditor",
 		 language: "en",       
         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.photo-4.com/personal_htm/'	  	
		 });
	  }
	  if (editor=='FCKeditor1' && filetype=='htm') {
      tinyMCE.init({
         mode : "specific_textareas",
         editor_selector : "mceEditor",
 		 language: "en",       
         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.photo-4.com'
	  	 });
	  }
}
 


function perselector(id,url,text) {
 	new Ajax.InPlaceCollectionEditor(id, url, {   
 		collection: [['Tutti','Any'],['4rodas','4rodas'],['abergamini','abergamini'],['acisport','acisport'],['acisport2010','acisport2010'],['adelaide','adelaide'],['agb2007','agb2007'],['agenciaistoe','agenciaistoe'],['alvolante','alvolante'],['andy_hone','andy_hone'],['annalaura','annalaura'],['anthony','anthony'],['antonecia','antonecia'],['astral','astral'],['aurelie','aurelie'],['auto','auto'],['autoaction','autoaction'],['automobilismo','automobilismo'],['autosprint','autosprint'],['bari','bari'],['branda','branda'],['brunete','brunete'],['cacha','cacha'],['carinha','carinha'],['carmignani','carmignani'],['carsten','carsten'],['clienteprova','clienteprova'],['cremonesi','cremonesi'],['decoster','decoster'],['duncanrim','duncanrim'],['eizo','eizo'],['eizo2009','eizo2009'],['esteban','esteban'],['fabtcw','fabtcw'],['farabola','farabola'],['faria','faria'],['fiaphoto','fiaphoto'],['fotos','fotos'],['frederic','frederic'],['fsantos','fsantos'],['giammarco','giammarco'],['gillesfoto','gillesfoto'],['graphiste','graphiste'],['grupozeta2010','grupozeta2010'],['gtavoni','gtavoni'],['inpagina','inpagina'],['ishikawa','ishikawa'],['jm','jm'],['joseph','joseph'],['keystone','keystone'],['keystonebr','keystonebr'],['kubota','kubota'],['lapresse','lapresse'],['lillini','lillini'],['liriwtcc','liriwtcc'],['luca2006','luca2006'],['magazine','magazine'],['martin','martin'],['marzoliandre','marzoliandre'],['mbrasil','mbrasil'],['mdonelli','mdonelli'],['mercedes','mercedes'],['miccione','miccione'],['michel','michel'],['minazzi','minazzi'],['moto2010ring','moto2010ring'],['motorionline','motorionline'],['motorline','motorline'],['motormagazine','motormagazine'],['motorsport','motorsport'],['nicoli','nicoli'],['nikos','nikos'],['nikoshellas2010','nikoshellas2010'],['omp','omp'],['oz','oz'],['ozbellin','ozbellin'],['panoramauto','panoramauto'],['partemi','partemi'],['peteras','peteras'],['petertyson','petertyson'],['petrobras','petrobras'],['photo4','photo4'],['photo4artitaly','photo4artitaly'],['photo4thalitanadry','photo4thalitanadry'],['piquetboss','piquetboss'],['playboy','playboy'],['puromotor','puromotor'],['quattroruote','quattroruote'],['racepictures','racepictures'],['racing','racing'],['rallyslalom','rallyslalom'],['ravaioli','ravaioli'],['revueauto','revueauto'],['riasoni','riasoni'],['risky','risky'],['rleme','rleme'],['rmoscia','rmoscia'],['roberta','roberta'],['romanopoli','romanopoli'],['rsmltd','rsmltd'],['sabelt','sabelt'],['saloes','saloes'],['simona','simona'],['solomoto','solomoto'],['sorrisi','sorrisi'],['specchia','specchia'],['sportauto','sportauto'],['sportweek','sportweek'],['starantino','starantino'],['stefan','stefan'],['stephane','stephane'],['taini','taini'],['tameokits','tameokits'],['teshima','teshima'],['testdrivept','testdrivept'],['trip','trip'],['tuttorally','tuttorally'],['umapress','umapress'],['uncoversport','uncoversport'],['universo','universo'],['venditti','venditti'],['vicentini','vicentini'],['vip','vip'],['willy','willy'],['wwwsinclair2009','wwwsinclair2009'],['xpbjerg','xpbjerg']],   
 		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.photo-4.com/catcollectionload.php',
 		collection: [['A1G','A1GP'],['DTX','DRIVER S TROPHTY'],['DTM','DTM'],['F30','F 3000'],['FGT','FIA GT'],['WTC','FIA WTCC'],['F3E','FORMULA 3 EURO SERIES'],['FMX','FORMULA MASTER'],['F1X','FORMULA ONE'],['F2X','FORMULA2'],['GP2','GP2 SERIES'],['GP3','GP3 SERIES'],['GTO','INT. GT OPEN'],['MSX','INT. MOTOR SHOW'],['OTI','INT. OTHERS'],['IRC','IRC RALLY'],['MSI','ITALIAN MOTOR SHOW'],['IOR','ITALIAN ON TRACK'],['500','-500'],['C1C','-C1 CUP'],['EGT','-EGTS'],['ETC','-ETCS'],['E3X','-EURO 3000'],['FRR','-FERRARI'],['F3X','-FORMULA 3'],['FAB','-FORMULA ABARTH'],['FAZ','-FORMULA AZZURRA'],['FGL','-FORMULA GLORIA'],['IPX','-IPS'],['IGT','-ITALIANO GT'],['ITX','-ITALIANO TURISMO'],['ITC','-ITCC'],['IPC','-PORSCHE CARRERA CUP'],['PRO','-PROTOTIPI'],['SEA','-SEAT ITALIA'],['SSX','-SUPERSTARS'],['TAX','-TROFEO ALFA 147'],['ITE','-TURISM ENDURANCE'],['OTH','ITALIAN OTHERS'],['IRA','ITALIAN RALLY'],['CIR','-CAMP. ITALIANO RALLY'],['TRA','-TROFEO RALLY ASFALTO'],['TRT','-TROFEO RALLY TERRA'],['IST','ITALIANO SUPERTURISMO'],['LMS','LE MANS SERIES'],['PSC','PORSCHE SUPER CUP'],['RLV','RALLY VARI'],['SLC','SEAT LEON EUROCUP'],['STO','STORY'],['TGT','TROFEO GT'],['USA','USA RACE'],['WRC','WRC RALLY']],   
 		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 = 'Archive'; var resetcat= 'SessionCookie(\'Categoria\',\'%\')'; break;
 		case 'event': var lvhsc = 'Event'; break;
 		case 'lightbox': var lvhsc = 'Lightbox'; break;
 		case 'group': var lvhsc = ''; break;
 		case 'personal': var lvhsc = ''; break;
 		case 'search': var lvhsc = 'Search'; 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 });
		}
	}
}
