// JavaScript Document

/* Credits:
Max Jacob, {xzoert} "myGuru();"
Arno Peck, Lorenzo Becchi 
his friends
*/

/* upload message */

function nowUploading() {

document.getElementById('popconsolle').style.display = 'none';
document.getElementById('poploading').style.display = 'block';
//alert('fatto');
document.imageUpload.submit();
}

/* apertura popup */

function WOFocusWin( name ) {
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize+''
	eval( "if( this."+name+") this."+name+".moveTo("+LeftPosition+","+topPosition+"); this."+name+".focus();" );
		
}

function WOOpenWin( name, url, ctrl ) {
	eval( "this."+name+"=window.open('"+url+"','"+name+"','"+ctrl+"');" );
	window.setTimeout( "top.winOpener.focusWin('"+name+"');", 300 );
}

function WinOpener() {
		this.openWin=WOOpenWin;
		this.focusWin=WOFocusWin;
}
	
top.winOpener=new WinOpener();


function go2url(url) {
	window.location = url;
}


function setcolor( c ) {
   document.getElementById('flags').value=""+c+"";
}


/* funzione preview picked image */


function DoPreview(inputf,placeholder) {
	
	path = document.getElementById(inputf).value;
	document.getElementById(placeholder).src = 'file://' + path;
}



/* Credits:
Max Jacob, {xzoert} "myGuru();"
Arno Peck, Lorenzo Becchi 
his friends
*/

// Tabbatore

		var TBX_onstyle="background-color:#a0a;";
		var TBX_offstyle="background-color:#0f0;";
	
		function TBX_init() {
			// browse the document and find all TBX_* tags
			TBX_browse( document.documentElement );
		}
		
		TBX_all=null;
		
		
		function TBX_handler( btn, id, tab ) {
			TBX_all[id]=this;
			this.id = id;
			this.tab=tab;
			this.btn=btn;
			this.handleClick=TBX_handleClick;
			btn.onclick=this.handleClick;
			this.show=TBX_show;
			this.hide=TBX_hide;
		}

		TBX_current=null;
		
		function TBX_show() {
			this.tab.style.display="block";
			if( TBX_current ) TBX_current.hide();
			TBX_current=this;
			var cn = this.btn.className;
			if( !cn ) cn = "";
			else cn=cn.replace( "TBX_inactive" );
			cn+=" TBX_active";
			cn=cn.replace( "  ", " " );
			this.btn.className=cn;
		}
		
		function TBX_hide() {
			this.tab.style.display="none";
			var cn = this.btn.className;
			if( !cn ) cn = "";
			else cn=cn.replace( "TBX_active" );
			cn+=" TBX_inactive";
			cn=cn.replace( "  ", " " );
			this.btn.className=cn;
		}

		function TBX_handleClick() {
			var th=TBX_all[this.id];
			if( th == TBX_current ) return;
			th.show();
		}
		
		function TBX_browse( n ) {
		
			var id = n.id;
			var idx = -1;
			if( id!=null && id.indexOf) idx=id.indexOf( "TBX_" );
			if( id != null && idx==0 && id.substring(5,id.length).indexOf( "_" )<0 ) {
				var tab = document.getElementById( id+"_tab" );
				if( tab ) {
					if( TBX_all == null ) {
						// initialize the TBX_all and keep this  tab visible
						TBX_all=new Array();
						var th = new TBX_handler( n, id, tab );
						th.show();
					}
					else {
						var th = new TBX_handler( n, id, tab );
						th.hide();						
					}
				}
			}
			for( var i = 0; i<n.childNodes.length; i++ ) {
				if( n.nodeType == 1 ) 
					TBX_browse( n.childNodes[i] );
			}
		
		}



	function textCounter( field, countfield, maxlimit ) {
	  if ( field.value.length > maxlimit )
	  {
		field.value = field.value.substring( 0, maxlimit );
		alert( 'In questo campo sono permessi soltanto '+ maxlimit +' caratteri.' );
		return false;
	  }
	  else
	  {
		countfield.value = maxlimit - field.value.length;
	  }
}


function submitform()
{
  document.logform.submit();
}

/*
* callExternalInterface flash as
*/


function callExternalInterface(moviename, n) {
    thisMovie(moviename).changeTrack(n);
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}
	
