var sSubmittedForm = '';
function disableMultipleSubmit( sForm ){
    if ( '' == sSubmittedForm ){
        sSubmittedForm = sForm;return true;
    }
    return false;
}

function jump(){
    sSelectedMonth = document.calendar.calendar_month.options[ document.calendar.calendar_month.selectedIndex ].value;
    sSelectedYear = document.calendar.calendar_year.options[document.calendar.calendar_year.selectedIndex].value
    window.location = sRoot+ 'c=m&v=' + sSelectedYear + '-' + sSelectedMonth;
}



function bookmarksite(title, url) {
		if (document.all)
			window.external.AddFavorite(url, title);
		else if (window.sidebar)
			window.sidebar.addPanel(title, url, "");
	}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function parseTT( sTableId ){

	if ( !/tt_table/i.test( sTableId ) ) return;
	oTableElement = document.getElementById( sTableId );
	if ( null == oTableElement ) return;
	oTTable = new TTable( oTableElement );
	return;

}

function TTable( oElement ){

    this.sId = oElement.id.substr( 9 );
    aTds = oElement.getElementsByTagName("li");
    this.aTabs= new Array();
	for (var i = 0; i < aTds.length; i++) {
	    if ( /tt_tab/i.test( aTds[i].id ) ){
	        this.aTabs.push( new TTab( aTds[i] ) );
	    }
	}

	var _o = this;
	for (var i = 0; i < this.aTabs.length; i++) {
        this.aTabs[i].oElement.onclick = function() {
            _o.show(this); return false;
		}
	}

}

TTable.prototype.show = function( oTrigger ) {

    oTab = null;
    iTabIndex = null;

    for (var i = 0; i < this.aTabs.length; i++) {
        if ( oTrigger.id == this.aTabs[i].oElement.id ){
            oTab = this.aTabs[i];
            iTabIndex = i;
            break;
        }
    }

    if ( oTab==null ) return false;

	for (var i = 0; i < this.aTabs.length; i++) {
		if ( 0 == i ){
			this.aTabs[i].oElement.className='first';
		}else if ( i == ( this.aTabs.length - 1 ) ){
			this.aTabs[i].oElement.className='last';
		}else{
			this.aTabs[i].oElement.className='';
		}
	}
    this.aTabs[iTabIndex].oElement.className = ( ''==this.aTabs[iTabIndex].oElement.className ? 'activ' : this.aTabs[iTabIndex].oElement.className + ' activ');

    this.hideAll();
    document.getElementById( 'tt_content_'+this.aTabs[iTabIndex].sId ).style.display="block";

}

TTable.prototype.hideAll = function() {
    for (var i = 0; i < this.aTabs.length; i++) {
        document.getElementById( 'tt_content_'+this.aTabs[i].sId ).style.display="none";
    }
}

function TTab( oElement ){

	this.bLoaded = false;
    this.sId = oElement.id.substr( 7 );
    this.oElement   = oElement;

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function swPollView( iPollId ){

    oFCont = document.getElementById( "polls" + iPollId + "_form" );
    if ( oFCont == null ) return;
    oVCont = document.getElementById( "polls" + iPollId + "_view" );

    if ( 'block'==oFCont.style.display){
        oFCont.style.display = 'none';
        oVCont.style.display = 'block';
        if ( ''==oVCont.innerHTML ){ xajax_pollfetch( iPollId ) };
    }else{
        oFCont.style.display = 'block';
        oVCont.style.display = 'none';
    }

}

function pollvote( iPollId ){

    oForm = document.getElementsByName( 'polls' + iPollId )[0];
    iOptionId = getpolloption( oForm );
    if ( iOptionId==null ) return;
    xajax_pollvote( iPollId, iOptionId );


}

function getpolloption( oForm ){
    for(var i=0; i<oForm.poll_option.length; i++){
        if ( oForm.poll_option[i].checked ) return oForm.poll_option[i].value;
    }
    return null;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function FPGallery( sId ){
	this.sId = sId;
	this.aItems = new Array();
	this.oCurrent = null;
}

FPGallery.prototype.add = function( sType, sId, sContent, sDescription ){
	this.aItems.push( new FPGalleryItem( sType, sId, sContent, sDescription ) );
}

FPGallery.prototype.load = function( sId ){

	if ( this.oCurrent!=null && this.oCurrent.sId==sId ) return;

	document.getElementById( this.sId + '_player' ).style.display = 'none';
	for (var i = 0; i < this.aItems.length; i++){
		if ( 'image'== this.aItems[i].sType ) document.getElementById( 'c_' + this.aItems[i].sId ).style.display = 'none';
		//document.getElementById( 'i_' + this.aItems[i].sId ).className="";
		if ( sId==this.aItems[i].sId ) this.oCurrent = this.aItems[i];
	}

	//document.getElementById( 'i_' + this.oCurrent.sId ).className="selected";
	if ( 'video'==this.oCurrent.sType ){
		document.getElementById( this.sId + '_player' ).innerHTML = this.oCurrent.sContent;
		document.getElementById( this.sId + '_player' ).style.display = 'inline';
	}else if ( 'image'==this.oCurrent.sType ){
		oContainer = document.getElementById( 'c_' + this.oCurrent.sId );
		oImage = oContainer.getElementsByTagName('img')[0];
		oImage.src = this.oCurrent.sContent;
		oContainer.style.display = 'inline';
	}
	document.getElementById( this.sId + '_description' ).innerHTML = this.oCurrent.sDescription;

}

function FPGalleryItem( sType, sId, sContent, sDescription ){
	this.sType = sType;
	this.sId = sId;
    this.sContent = sContent;
    this.sDescription = sDescription;
}