function imgstatsfrom( ) {
	id	=	document.getElementById( 'statisticsfrom' );
	
	val	=	id.options[ id.selectedIndex ].value;
	document.getElementById( 'custdate' ).style.display	=	'none';
	
	if( val == '0' ) {
		document.getElementById( 'custdate' ).style.display = 'block';
	}
}

function imgstatsfrom1( ) {
	id	=	document.getElementById( 'stats1from' );
	
	val	=	id.options[ id.selectedIndex ].value;
	document.getElementById( 'custdate1' ).style.display	=	'none';
	
	if( val == '0' ) {
		document.getElementById( 'custdate1' ).style.display = 'block';
	}
}

function imgstatsfrom2( ) {
	id	=	document.getElementById( 'stats2from' );
	
	val	=	id.options[ id.selectedIndex ].value;
	document.getElementById( 'custdate2' ).style.display	=	'none';
	
	if( val == '0' ) {
		document.getElementById( 'custdate2' ).style.display = 'block';
	}
}

function imgstatsfrom3( ) {
	id	=	document.getElementById( 'stats3from' );
	
	val	=	id.options[ id.selectedIndex ].value;
	document.getElementById( 'custdate3' ).style.display	=	'none';
	
	if( val == '0' ) {
		document.getElementById( 'custdate3' ).style.display = 'block';
	}
}

function imgRenderGraph( ) {
	
	showWaitDialog( );
	img	=	document.getElementById( 'pCimage1' ).src;
	tmp	=	img.split( 'images.php?cid=' );
	l	=	tmp[ 1 ];
	
	getImageUrl2( l );
	
}

function imgRenderGraph2( ) {
	
	showWaitDialog( );
	img	=	document.getElementById( 'pCimage1' ).src;
	tmp	=	img.split( 'images.php?cid=' );
	l	=	tmp[ 1 ];
	
	getImageUrl3( l );
	
}

function imgRenderGraph4( ) {
	
	showWaitDialog( );
	img	=	document.getElementById( 'pCimage1' ).src;
	tmp	=	img.split( 'images.php?cid=' );
	l	=	tmp[ 1 ];
	
	getImageUrl4( l );
	
}

function imgRenderGraph5( ) {
	
	showWaitDialog( );
	img	=	document.getElementById( 'pCimage1' ).src;
	tmp	=	img.split( 'images.php?cid=' );
	l	=	tmp[ 1 ];
	
	getImageUrl5( l );
	
}

function selectTab( nr, tab1, tab2, type, form ) {
	
	showWaitDialog();
	img = document.getElementById( 'pCimage1' );
	id	=	document.getElementById( 'statisticsfrom' );
	id.selectedIndex	=	0;
	document.getElementById( 'statisticsfrom1' ).value = '';
	document.getElementById( 'statisticsfrom2' ).value = '';
	document.getElementById( 'custdate' ).style.display = 'none';
	for( i = 0; i < 100; i++ ) {
		if( document.getElementById( 'imgtab' + i ) ) {
			document.getElementById( 'imgtab' + i ).className = '';
		}
		else{
			break;
		}
	}
	document.getElementById( 'imgtab' + nr ).className = 'selected';
	
	for( i = 1; i < 100; i++ ) {
		if( document.getElementById( 'imgform' + i ) ) {
			document.getElementById( 'imgform' + i ).style.display = 'none';
		}
		else{
			break;
		}
	}
	document.getElementById( 'imgform' + form ).style.display = 'block';
	
	if( type != 'pie' ) {
		getImageUrl( tab1, tab2 );
	}
	else{
		getImageUrl( tab1, 'no' );
	}
}

function updateLinksTabs( ) {
	img	=	document.getElementById( 'pCimage1' ).src;
	tmp	=	img.split( 'images.php?cid=' );
	l	=	tmp[ 1 ];
	
	document.getElementById( 'linkacsv' ).href = '/dl.php?t=csv&d=' + l;
	document.getElementById( 'linkaexcel' ).href = '/dl.php?t=xls&d=' + l;
	document.getElementById( 'linkapdf' ).href = '/dl.php?t=pdf&d=' + l;
	document.getElementById( 'linkaimg' ).href = '/dl.php?t=img&d=' + l;
}

function checkToggle( f, field ) {
	for( i = 0; i < field.length; i++ ) {
		if( f.checked ) {
			field[ i ].checked = true;
		}
		else{
			field[ i ].checked = false;
		}
	}
}

function ShowHide( id ) {
	if( document.getElementById( id ).style.display == 'none' ) {
		document.getElementById( id ).style.display = 'block';
	}
	else{
		document.getElementById( id ).style.display = 'none';
	}
}

tinyMCE.init({
    mode : "textareas",
    theme : "advanced",
    theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,fontselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,image,cleanup",
    theme_advanced_buttons3 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "center",
    theme_advanced_statusbar_location : "bottom"
});