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;

}

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 ? 'selected' : this.aTabs[iTabIndex].oElement.className + ' selected');

    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 );
    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( sType, sId, sBasePath ){

	this.sType = sType;
    this.sId = sId;
    this.sBasePath = sBasePath;
    this.aItems = new Array();
    this.iCurrent = 0;
    iVideoWidth = 260;
    iVideoHeight = 193;
}

function FPItem( sContent, sDescription ){
    this.sContent = sContent;
    this.sDescription = sDescription;
}

FPGallery.prototype.add = function( sContent, sDescription ){
    this.aItems.push( new FPItem( sContent, sDescription ) )
}

FPGallery.prototype.walk = function( iStep ){

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

    this.go( iIndex );

}


FPGallery.prototype.go = function( iIndex ){

    if ( iIndex == this.iCurrent ) return;

    if ( 'image' == this.sType ){
	    oImageEl = document.getElementById( 'fpg_image' + this.sId + "_" + iIndex );
	    if ( !oImageEl.src){
	        oImageEl.src = this.sBasePath + "__" + this.aItems[iIndex].sContent
	    }
	    for (var i = 0; i < this.aItems.length; i++){
	        document.getElementById( 'fpg_content' + this.sId + "_" + i ).style.display = ( iIndex == i ? "block" : "none")
	    }
	    oCounterEl = document.getElementById( 'fpg_counter' + this.sId );
	    if ( null != oCounterEl ) oCounterEl.innerHTML = ( iIndex + 1) + " din " + this.aItems.length;
	    oDescriptionEl = document.getElementById( 'fpg_description' + this.sId );
	    if ( null != oDescriptionEl ) oDescriptionEl.innerHTML = this.aItems[iIndex].sDescription;
    }else if( 'video' == this.sType ){
    	document.getElementById( 'fpg_vcontent' + this.sId ).innerHTML = "<object width=\"" + this.iVideoWidth+"\" height=\"" + this.iVideoHeight+"\"><param name=\"movie\" value=\"http://www.youtube.com/v/" + this.aItems[iIndex].sContent + "\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/" + this.aItems[iIndex].sContent + "\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"" + this.iVideoWidth+"\" height=\"" + this.iVideoHeight+"\"></embed></object>";
    	oCounterEl = document.getElementById( 'fpg_vcounter' + this.sId );
    	if ( null != oCounterEl ) oCounterEl.innerHTML = ( iIndex + 1) + " din " + this.aItems.length;
    	oDescriptionEl = document.getElementById( 'fpg_vdescription' + this.sId );
    	if ( null != oDescriptionEl ) oDescriptionEl.innerHTML = this.aItems[iIndex].sDescription;
    }

    this.iCurrent = iIndex;

}
*/

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