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 createTooltip( sId, sTitle, sText, sStyle ) {

	new Tip( sId , sText , {
		title: sTitle,
		style: sStyle,
		fixed: true,
		//hideOn: { element: 'tip', event: 'mouseout' },
		hideOn: false, // disable the normal hide event, because we only want to use the hideAfter option
		hideAfter: 0.2,
		hideOthers : true,
		hook: { target: 'bottomRight', tip: 'topLeft' }
	});
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function parseTT( sTableId, sTabContainer ){

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

}

function TTable( oElement, sTabContainer ){

    this.sId = oElement.id.substr( 9 );
    aTds = oElement.getElementsByTagName(sTabContainer);
    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 ? 'curent' : this.aTabs[iTabIndex].oElement.className + ' curent');

    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, _embed ){

	_embed  = ( _embed ? true : false );
	_prefix = ( _embed ? "embed_polls" : "polls");
    oFCont = document.getElementById( _prefix + iPollId + "_form" );
    if ( oFCont == null ) return;
    oVCont = document.getElementById( _prefix + iPollId + "_view" );
    if ( 'block'==oFCont.style.display){
        oFCont.style.display = 'none';
        oVCont.style.display = 'block';
        if ( ''==oVCont.innerHTML ){ xajax_pollfetch( iPollId, _embed ) };
    }else{
        oFCont.style.display = 'block';
        oVCont.style.display = 'none';
    }

}

function pollvote( iPollId, _embed ){

	_embed  = ( _embed ? true : false );
	_prefix = ( _embed ? "embed_polls" : "polls");
    oForm = document.getElementsByName( _prefix + iPollId )[0];
    iOptionId = getpolloption( oForm );
    if ( iOptionId==null ) return;
    xajax_pollvote( iPollId, iOptionId, _embed );

}

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;
	this.iCurrent = 0

}


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';
		if ( document.getElementById( 'i_' + this.aItems[i].sId ) ) document.getElementById( 'i_' + this.aItems[i].sId ).className = document.getElementById( 'i_' + this.aItems[i].sId ).className.replace("selected", "");
		if ( sId==this.aItems[i].sId ) this.oCurrent = this.aItems[i];
	}

	if ( document.getElementById( 'i_' + this.oCurrent.sId ) ) 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;

}

FPGallery.prototype.walk = function( iStep ){

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


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

   	oContainer = document.getElementById( 'c_' + this.aItems[this.iCurrent].sId );
   	oImage = oContainer.getElementsByTagName('img')[0];
   	oImage.src = this.aItems[this.iCurrent].sContent;
   	document.getElementById( this.sId + '_counter' ).innerHTML = this.iCurrent+1;
   	document.getElementById( 'c_' + this.aItems[this.iCurrent].sId ).style.display = 'inline';

/*	    oImageEl = document.getElementById( 'fpg_image' + this.sId + "_" + this.iCurrent );
	    if ( !oImageEl.src){
	        oImageEl.src = this.sBasePath + "__" + this.aItems[this.iCurrent].sContent
	    }
	    for (var i = 0; i < this.aItems.length; i++){
	        document.getElementById( 'fpg_content' + this.sId + "_" + i ).style.display = ( this.iCurrent == i ? "block" : "none")
	    }*/
	    //document.getElementById( 'fpg_counter' + this.sId ).innerHTML = ( this.iCurrent + 1) + " din " + this.aItems.length;
    	//document.getElementById( 'fpg_description' + this.sId ).innerHTML = this.aItems[this.iCurrent].sDescription;



}

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



function MidnightCaller(){
	this.aCalls = new Array();
}

MidnightCaller.prototype.add = function ( sFunc, sArgs ){
	this.aCalls.push( new Array( sFunc, sArgs ) );
}



MidnightCaller.prototype.callall = function (){
	for (var i = 0; i < this.aCalls.length; i++){
		_aCall = this.aCalls[i];
		eval( _aCall[0] + "(" + _aCall[1] + ")" );
	}
}
//var oMidnightMan = new MidnightCaller();


function rank_over( iRank, iId ){
	for(i=1;i<=iRank;i++){
		document.images['star' + iId + '_' + i].src = _preload.src;
	}
}

function rank_out( iCurrentRank, iId ){
	for(i=1;i<=iMaxRank;i++){
		document.images['star' + iId + '_' + i].src = ( i<=iCurrentRank ? sStarOn : sStarOff );
	}
}

function rank_it( sModule, iId, iRank ){
	//alert ( sModule );
	//document.getElementById('stars'+iId).innerHTML = "<img src='" + sLoadingImage + "'>";
	xajax_rank( sModule, iId, iRank );
}



delta_font_size = 0;
content_font_size = 0;
default_font_size = 14;

function change_font_size( container, _delta ){

	_element = document.getElementById( container );
	if ( null == _element ) return;

	delta_font_size+= _delta;
	if ( delta_font_size==-default_font_size ){
		delta_font_size-= _delta;
		return;
	}

	content_font_size = default_font_size + delta_font_size;
	_element.style.fontSize = content_font_size + "px";

}
