
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'],['abril','abril'],['acisport','acisport'],['adelaide','adelaide'],['alvolante','alvolante'],['anthony','anthony'],['antonecia','antonecia'],['astral','astral'],['auto','auto'],['automobilismo','automobilismo'],['autooggi','autooggi'],['autosprint','autosprint'],['branda','branda'],['brunete','brunete'],['cacha','cacha'],['campioni','campioni'],['carmignani','carmignani'],['carsten','carsten'],['claudio','claudio'],['clienteprova','clienteprova'],['cremonesi','cremonesi'],['decoster','decoster'],['duncanrlm','duncanrlm'],['dustinxpb','dustinxpb'],['eizo2009','eizo2009'],['esteban','esteban'],['estebandelgado','estebandelgado'],['fabtcw','fabtcw'],['farabola','farabola'],['faria','faria'],['fiaphoto','fiaphoto'],['frederic','frederic'],['fsantos','fsantos'],['germany','germany'],['giammarco','giammarco'],['gillesfoto','gillesfoto'],['graphiste','graphiste'],['gtavoni','gtavoni'],['inpagina','inpagina'],['ishikawa','ishikawa'],['keystone','keystone'],['kubota','kubota'],['liriwtcc','liriwtcc'],['magazine','magazine'],['martin','martin'],['marzoliandre','marzoliandre'],['mbrasil','mbrasil'],['mdonelli','mdonelli'],['mercedes','mercedes'],['miccione','miccione'],['minazzi','minazzi'],['motorline','motorline'],['motormagazine','motormagazine'],['nikoshellas2010','nikoshellas2010'],['omp','omp'],['oz','oz'],['ozbellin','ozbellin'],['partemi','partemi'],['peteras','peteras'],['petertyson','petertyson'],['photo4','photo4'],['photo4artitaly','photo4artitaly'],['photo4thalitanadry','photo4thalitanadry'],['piquetboss','piquetboss'],['playboy','playboy'],['quattroruote','quattroruote'],['ravaioli','ravaioli'],['revueauto','revueauto'],['riasoni','riasoni'],['risky','risky'],['rmoscia','rmoscia'],['roberta','roberta'],['rsmltd','rsmltd'],['saloes','saloes'],['simmi','simmi'],['sorrisi','sorrisi'],['specchia','specchia'],['sportweek','sportweek'],['starantino','starantino'],['stephane','stephane'],['superstars','superstars'],['taini','taini'],['tameokits','tameokits'],['teshima','teshima'],['testdrivept','testdrivept'],['thorsten','thorsten'],['trobson','trobson'],['tuttorally','tuttorally'],['umapress','umapress'],['uncoversport','uncoversport'],['vicentini','vicentini'],['willy','willy'],['wwwsinclair2009','wwwsinclair2009']],   
 		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: [['A1G','A1GP'],['A50','ABARTH EUROPE,ABART 500 TROPHY'],['DTX','DRIVER S TROPHTY'],['DTM','DTM'],['F30','F 3000'],['FER','FERRARI'],['FGT','FIA GT'],['WTC','FIA WTCC'],['F2X','FORMULA 2'],['F3E','FORMULA 3 EURO SERIES'],['FMX','FORMULA MASTER'],['F1X','FORMULA ONE'],['GP2','GP2 SERIES'],['GTO','INT. GT OPEN'],['MSX','INT. MOTOR SHOW'],['OTI','INT. OTHERS'],['IRC','IRC RALLY'],['MSI','ITALIAN MOTOR SHOW'],['IOT','ITALIAN ON TRACK'],['500',' . 500'],['C1C',' . C1 CUP'],['EGT',' . EGTS'],['ETC',' . ETCS'],['E3X',' . EURO 3000'],['F3X',' . FORMULA 3'],['FAZ',' . FORMULA AZZURRA'],['FGL',' . FORMULA GLORIA'],['IPX',' . IPS'],['IGT',' . ITALIANO GT'],['ITX',' . ITALIANO TURISMO'],['ITC',' . ITCC'],['IPC',' . PORSCHE CARRERA CUP'],['PRO',' . PROTOTIPI'],['SSX',' . SUPERSTARS'],['TAX',' . TROFEO ALFA 147'],['ITE',' . TURISM ENDURANCE'],['OTH','ITALIAN OTHERS'],['IRL','ITALIAN RALLY'],['ITA',' . '],['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',
       	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) {	
  	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');
	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 a = '<li class="foot_grid" id="'+hsc+'1" onmouseover="setover(\''+hsc+'1\');apri(\'vertical'+hsc+'1\');" onmouseout="setout(\''+hsc+'1\')"><span id="'+hsc+'1default">'+hsc+'</span><ol class="verticalcontent" id="vertical'+hsc+'1">';
 	var hvhsc = hsc.replace(myhsc,'').replace('/','').replace('\+',' ').replace('\&dw=1','');
 	var hvhsc = MYdecodeURIComponent(hvhsc);
 	switch (myhsc) {
 		case 'archive': var lvhsc = 'Archive'; 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>'+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="./?PHPSESSID=2421946b56ad627d5d725a73f441dc33#'+ gsubded +'" onclick=\"reloadAnchor=true;\" 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 });
		}
	}
}
