// JavaScript Document

function ReloadSecCode(simg) { //v3.0
    var d=new Date();
	
  document.getElementById(simg).src='CaptchaSecurityImages.php?width=100&height=40&characters=5&reload='+d.getTime();
}


//carica dinamicamente la foto del profilo utente
function userFotoUpload_old(upload_field)
{

    var re_text = /\.gif|\.jpg|\.png/i;
    var filename = upload_field.value;

    /* Checking file type */
    if (filename.search(re_text) == -1)
    {
        alert("Il file deve essere un'immagine jpg, gif o png.");
        upload_field.form.reset();
        return false;
    }
	if(confirm('Conferma caricamento della foto?')){
		//$('#loadingdlg').dialog('open');
		$('#loadingdlg').dialog('open');
		upload_field.form.submit();
	
		return true;
	}
}

function userFotoUpload(upload_field)
{

    var re_text = /\.gif|\.jpg|\.png/i;
    var filename = upload_field.value;

    /* Checking file type */
    if (filename.search(re_text) == -1)
    {
        alert("Il file deve essere un'immagine jpg, gif o png.");
        upload_field.form.reset();
        return false;
    }
	if(confirm('Conferma caricamento della foto?')){
		//$('#loadingdlg').dialog('open');
		$('#loadingdlg').dialog('open');
		var pact=upload_field.form.action;
		var ptarget=upload_field.form.action;
		var penctype=upload_field.form.enctype;
		upload_field.form.action="modules/gcon_community/imgupload.php"; 
		upload_field.form.target="upload_iframe" ;
		//upload_field.form.enctype="multipart/form-data";
		
		upload_field.form.submit();
		
		upload_field.form.action=pact;
		upload_field.form.target=ptarget;
		upload_field.form.enctype=penctype;
	
		return true;
	}
}

$(document).ready(function() {
	
	$(function() {
		$("#loadingdlg").dialog({
			bgiframe: true,
			autoOpen: false,
			modal: true,
			draggable: false,
			resizable:false,
			dialogClass: 'loadingdlg',
			closeOnEscape: true
		});
	});
	
	 if(document.getElementById("tabsprofile")!=null) {
			$("#tabsprofile").tabs();
	 }

	 if(document.getElementById("tabshomeprofile")!=null) {
			$("#tabshomeprofile").tabs();
	 }
	 if(document.getElementById("tabprofMsgs")!=null) {
			$("#tabprofMsgs").tabs();
	 }
	 if(document.getElementById("gccomm_usrphotos")!=null) {
			$("#gccomm_usrphotos a.usrph").lightbox({
				fitToScreen: false,
			    imageClickClose: false,
				navbarOnTop: true,
				fileBottomNavCloseImage : 'js/jquery-lightbox/images/close.gif',
				strings : {
					prevLinkTitle: 'immagine precedente',
					nextLinkTitle: 'immagine successiva',
					prevLinkText:  '&laquo; Precedente',
					nextLinkText:  'Successiva &raquo;',
					closeTitle: 'chiudi galleria immagini',
					image: 'Foto ',
					of: ' di '
				}
			
			});

	 }
	 
	 

	$(function() {
		$("#msgdialog").dialog({
			bgiframe: true,
			autoOpen: false,
			modal: true,
			resizable:false,
			buttons: {
				"Chiudi": function() {
					$(this).dialog('close');
				}
			}
		});
	});


try{
	$('.gctooltip').tooltip({showURL: false,top:-150});
}catch(e){}

});	

function ShowLoading(){
	$('#loadingdlg').dialog('open');
}

function closeLoading(){
	$('#loadingdlg').dialog('close');
}

function ShowMessage(msg){
	document.getElementById('msgdialogcnt').innerHTML=msg;
	$('#msgdialog').dialog('open');

}

tinyMCE.init({
        remove_script_host : false,
        convert_urls : true,
	mode : "specific_textareas",
	editor_selector : "mceEditor",
	theme : "advanced",
	width: "100%",
	height: "200",
	language: "it",
	plugins : "advlink,paste,directionality,fullscreen",		
  theme_advanced_buttons1 : " bold, italic, underline, strikethrough, justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,link",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_buttons4 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "none",
	theme_advanced_resizing : true,
	theme_advanced_resize_horizontal : false,
	paste_auto_cleanup_on_paste : true,
	paste_convert_headers_to_strong : false,
	paste_strip_class_attributes : "all",
	paste_remove_spans : false,
	paste_remove_styles : true,		
   forced_root_block : false,
   force_br_newlines : true,
   force_p_newlines : false,
   button_tile_map : true

});


tinyMCE.init({
        remove_script_host : false,
        convert_urls : true,
	mode : "exact",
	elements: "ANTE",
	theme : "advanced",
	width: "100%",
	height: "100px",
	language: "it",
	plugins : "advlink,paste,directionality,fullscreen",		
	  theme_advanced_buttons1 : " bold, italic, underline, strikethrough, justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,link",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_buttons4 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "none",
	theme_advanced_resizing : true,
	theme_advanced_resize_horizontal : false,
	paste_auto_cleanup_on_paste : true,
	paste_convert_headers_to_strong : false,
	paste_strip_class_attributes : "all",
	paste_remove_spans : false,
	paste_remove_styles : true,		
   forced_root_block : false,
   force_br_newlines : true,
   force_p_newlines : false,
   button_tile_map : true

});


function InsTinyMcePreIns(simg){
	
	//alert(9);
	//tinyMCE.execCommand('mceFocus', false, 'ANTE');
	tinyMCE.execInstanceCommand('ANTE', "mceFocus");
	//alert('d'+tinyMCE.getContent());
	tinyMCE.setContent(simg+tinyMCE.getContent());
}