var nrTabs;
var lungimeTabs = 0;
	
var spatiuTab  = 0;
	
var tabSelectat = 0;
	
var widthLeft   = 15;
var widthCenter = 70;
var widthRight  = 7;
	
var tabHeight   = 30;

var spatiuWidth;

var caleTab;

var MaxBuletinTab = 10;

//variabile pentru tab-urile noi cu jquery

var apasat = false;

	
function addTab(text,id, tabLink)
{						
	if(id == tabSelectat)
	{
		if(id != 1)
		{
			document.write('  <td background="' + caleTab + 'images/taboleftselected4.gif"   width="' + widthLeft +'" height="' + tabHeight + '">');						
		}
		else
		{
			document.write('  <td background="' + caleTab + 'images/taboleftselectedfirst.gif"   width="' + widthLeft +'" height="' + tabHeight + '">');
		}		
	}
	else
	{
		if(id - 1 == tabSelectat)
		{
			document.write('  <td background="' + caleTab + 'images/taboleftselected1.gif"   width="' + widthLeft +'" height="' + tabHeight + '">');			
		}
		else
		{
			document.write('  <td background="' + caleTab + 'images/taboleft.gif"   width="' + widthLeft +'" height="' + tabHeight + '">');
		}
	}
	//document.write('	 ');
	document.write('  </td>');
	if(tabSelectat == id)
	{			
		document.write('  <td width="' + widthCenter + '" height="' + tabHeight +'">');
	}
	else
	{
		document.write('  <td background="' + caleTab + 'images/tabocenter.gif" width="' + widthCenter + '" height="' + tabHeight +'">');
	}
	document.write('	<center>');		
	document.write('		<a href="' + tabLink + '">');
	if(id == tabSelectat)
	{
		document.write('<font size = "4">');
	}
	document.write(			text);
	if(id == tabSelectat)
	{
		document.write('</font>');
	}
	document.write('		</a>');
	document.write('	</center>');
	document.write('  </td>');
	if(id == tabSelectat)
	{
	 	if(id != nrTabs)
		{
			document.write('  <td background="' + caleTab + 'images/taborightselected3.gif"  width="' + widthRight + '" height="' + tabHeight + '">');		
		}
		else
		{
			document.write('  <td background="' + caleTab + 'images/taborightselectedlast.gif"  width="' + widthRight + '" height="' + tabHeight + '">');
		}
	}
	else
	{
		if(id + 1 == tabSelectat)
		{
			document.write('  <td background="' + caleTab + 'images/taborightselected2.gif"  width="' + widthRight + '" height="' + tabHeight + '">');
		}
		else
		{				
			document.write('  <td background="' + caleTab + 'images/taboright.gif"  width="' + widthRight + '" height="' + tabHeight + '">');
		}
	}
	//document.write('	 ');
	document.write('  </td>');
}

function addSpatiu(lungime,titlu)
{
	lungimeTabs = lungimeTabs + lungime;
	
	document.write('<td width="' + (lungime-15) + '">');
	document.write('<center>');
	if(titlu != null)
	{
		document.write(titlu);
	}
	document.write('</center>');
	document.write('</td>');
	document.write('	<td width="15"> ');	
	document.write('	</td>');	
	spatiuTab = lungime;
}

function selectie()
{
	document.write('</tr>');
	document.write('<tr>');
	if(tabSelectat>1)
	{
		document.write('	<td width="' + widthLeft+ '" background="' + caleTab + 'images/tabomargineleft.gif">');
		document.write('	</td>');
		document.write('	<td colspan="' + ((tabSelectat -1)* 3 - 1) + '" height="5" background="' + caleTab + 'images/taboselect.gif">');	
		document.write('	</td>');
		document.write('	<td colspan="3" height="5">');
		document.write('	</td>');
	}
	else
	{
		document.write('	<td width="' + widthLeft+ '" background="' + caleTab + 'images/tabobodyleft.gif">');
		document.write('	</td>');
		document.write('	<td colspan="2" height="5">');
		document.write('	</td>');
	}	
	document.write('	<td colspan="' + ((nrTabs-tabSelectat) * 3 + 1 )+ '" height="5" background="' + caleTab + 'images/taboselect.gif">');	
	document.write('	</td>');
	document.write('	<td width="15" height="5" background="' + caleTab + 'images/tabomargineright.gif">');	
	document.write('	</td>');
	document.write('</tr>');	
}

function tabLeftSide()
{
	document.write('<tr>');
	document.write('<td width="' + widthLeft +'" background="' + caleTab + 'images/tabobodyleft.gif">');
	document.write('</td>');
	document.write('<td colspan=' + (nrTabs*3 +1 -1)+ '>');
}

function tabRightSide()
{
	document.write('	<td width="15" background="' + caleTab + 'images/tabobodyright.gif">');
	document.write('	</td>');
}

function tabFooter()
{
	document.write('</td>');
	document.write('</tr>');
	document.write('<tr>');
	document.write('	<td colspan=' + (1 + nrTabs*3 + 1) + ' background="' + caleTab + 'images/tabofooter.gif">');
	document.write('	</td>');
	document.write('</tr>');
	document.write('</table>');
}

function tab(nr, selectat, tabWidth)
{
	nrTabs = nr;
	
	tabSelectat = selectat;
	
	//spatiuWidth = tabWidth;
	if(tabWidth!=null)
	{
		widthCenter = tabWidth;
	}	
	else
	{
		widthCenter = 70;
	}
	
	document.write('<table cellpadding = 0 cellspacing = 0>');
	document.write('	<tr>');
	for(i=1;i<=nr;i++)
	{
		
		if(tabSelectat == i)
		{
			document.write('<td width="' + widthLeft   + '" background="' + caleTab + 'images/taboleftselected3.gif" height="10">');
			document.write('</td>');
			document.write('<td width="' + widthCenter + '" background="' + caleTab + 'images/tabocenter.gif" height="10">');
			document.write('</td>');				
			document.write('<td width="' + widthRight  + '" background="' + caleTab + 'images/taborightselected4.gif">');
			document.write('</td>');				
		}
		else			
		{
			document.write('<td width="' + widthLeft + '">');
			document.write('</td>');
			document.write('<td width="' + widthCenter + '">');
			document.write('</td>');				
			document.write('<td width="' + widthRight + '">');
			document.write('</td>');				
		}			
		lungimeTabs = lungimeTabs + widthLeft + widthCenter + widthRight;
	}
	document.write('<td width="' + (tabWidth - lungimeTabs -15) + '">');
	document.write('</td>');	
	document.write('<td width="15">');
	document.write('</td>');	
	document.write('	</tr>');
	document.write('	<tr>');
}




function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}



	function schimbavar() {
			
			apasat = true;
	}

	function schimbafond(id) {


			if (apasat) {

			for (var i = 0; i < 9; i++) 	{
					if (document.getElementById(i+1))
						document.getElementById(i+1).className='';

			}
			document.getElementById(id).className='pushed';
			apasat = false;	
		} 
			
	}