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+ 'arhiva/stiri/?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;

    var aTables = document.getElementsByTagName('table');
	for (var i = 0; i < aTables.length; i++) {
	    if ( /tt_table/i.test( aTables[i].id ) ){
	        oTTable = new TTable( aTables[i] );
	        //oTTable.show( document.getElementById( 'tt_tab_module_1_2' ) );
	    }
	}

}

function TTable( oElement ){

    this.sId = oElement.id.substr( 9 );
    aTds = oElement.getElementsByTagName("td");
    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;

    if ( oTab.iSufixLen==2){
        if ( oTrigger.className == (oTab.sBaseClass+'_01') ) return false;
        for (var i = 0; i < this.aTabs.length; i++) {
            this.aTabs[i].oElement.className=this.aTabs[i].sBaseClass+'_00';
        }
        oTrigger.className=this.aTabs[iTabIndex].sBaseClass+'_01';
    }else if( oTab.iSufixLen==3 ){
        if ( oTrigger.className == (oTab.sBaseClass+'_010') ) return false;
        for (var i = 0; i < this.aTabs.length; i++) {
            if ( i == iTabIndex ){
                this.aTabs[i].oElement.className=this.aTabs[i].sBaseClass+'_010';
            }else if ( i == ( iTabIndex - 1 )){
                this.aTabs[i].oElement.className=this.aTabs[i].sBaseClass+'_001';
            }else if ( i == ( iTabIndex + 1 )){
                this.aTabs[i].oElement.className=this.aTabs[i].sBaseClass+'_100';
            }else{
                this.aTabs[i].oElement.className=this.aTabs[i].sBaseClass+'_000';
            }
        }
    }

    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.sId = oElement.id.substr( 7 );
    aChunks = oElement.className.split("_");
    this.sBaseClass = oElement.className.substr(0, oElement.className.lastIndexOf("_") );
    this.iSufixLen    = oElement.className.length - this.sBaseClass.length - 1 ;
    this.oElement   = oElement;
}

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

function FPGallery( sId, sBasePath ){
    this.sId = sId;
    this.sBasePath = sBasePath;
    this.aImages = new Array();
    this.iCurrent = 0;
}

function FPImage( sImage, sDescription ){
    this.sImage = sImage;
    this.sDescription = sDescription;
}

FPGallery.prototype.add = function( sImage, sDescription ){
    this.aImages.push( new FPImage( sImage, sDescription ) )
}

FPGallery.prototype.walk = function( iStep ){

    this.iCurrent = this.iCurrent + iStep;
    if ( this.iCurrent > (this.aImages.length - 1 ) ) this.iCurrent = 0;
    if ( this.iCurrent == -1 ) this.iCurrent = this.aImages.length - 1;

    oImageEl = document.getElementById( 'fpg_image' + this.sId + "_" + this.iCurrent );
    if ( !oImageEl.src){
        oImageEl.src = this.sBasePath + "__" + this.aImages[this.iCurrent].sImage
    }
    for (var i = 0; i < this.aImages.length; i++){
        document.getElementById( 'fpg_content' + this.sId + "_" + i ).style.display = ( this.iCurrent == i ? "block" : "none")
    }



    document.getElementById( 'fpg_counter' + this.sId ).innerHTML = "Imaginea " + ( this.iCurrent + 1) + " din " + this.aImages.length;
    document.getElementById( 'fpg_description' + this.sId ).innerHTML = this.aImages[this.iCurrent].sDescription;
}

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

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;
}