function loadMainPg()
{
	top.document.getElementById('mainIframe').src = "index.asp?classto=LuachRadio";
}

function checkParameters()
{
}

function showLnks(whichLnks)
{
//	hide the previous links and bring up the new.
//  the choice is: for the homePage "HomePgLinks" 
//	and for the inner pages: "KlaliPgLinks"

	if ( currentLnks != '' )
	{
		document.getElementById(currentLnks).style.display = 'none';
	}
	document.getElementById(whichLnks).style.display = '';
	currentLnks = whichLnks;
}

function setPage(whichPg)
{
//	hide the previous words from the maslool glisha and show the new.

	if ( currentPage != '' )
	{
		document.getElementById(currentPage + 'Maslool').style.display = 'none';
		document.getElementById(currentPage + "Lnk").className = "progRegular";
		document.getElementById(currentPage + "Lnk").onmouseout = setProgRollover;
	}
	document.getElementById(whichPg+ 'Maslool').style.display = '';
	document.getElementById(whichPg + "Lnk").className = "progRollover";
	document.getElementById(whichPg + "Lnk").onmouseout = '';

	currentPage = whichPg;
}

function setProgRollover()
{
	this.className = "progRegular";
}

function makeHomePg()
{
	top.document.getElementById('makeHomePageLnk').style.behavior='url(#default#homepage)';
    top.document.getElementById('makeHomePageLnk').setHomePage('http://www.iba.org.il/reception');
}

function setMenuLang(whichLang)
{
	if ( whichLang == currentMenuLang )
	{
		return;
	}
	
	var newlangObj = document.getElementsByName(whichLang);
	var lastLangObj = document.getElementsByName(currentMenuLang);
	var indxLang;
	
	document.getElementById(whichLang + "Lnk").className = "langRollover";
	document.getElementById(whichLang + "Lnk").onmouseout = '';

	if ( currentMenuLang != "" )
	{
		document.getElementById(currentMenuLang + "Lnk").className = "langRegular";
		document.getElementById(currentMenuLang + "Lnk").onmouseout = setLangRollover;
	}
	
	for (indxLang = 0; indxLang < newlangObj.length; indxLang++)
	{
		// show the new language.
		newlangObj[indxLang].style.display = '';
		
		// if a language was showing already then hide it.
		if ( lastLangObj.length > 0 )
		{
			lastLangObj[indxLang].style.display = 'none';
		}
	}
	currentMenuLang = whichLang;
}
		
function setLangRollover()
{
	this.className = "langRegular";
}

function organizeTabs()
{
	var openTableStr = "";
	var tabStr = "";
	var closeTabStr = "";
	var closeTableStr = "";
	var langStr = "";

	var numPerCol = 6;
	var boolTblOpen = false;
	var rowArry = new Array();
	var numRows = 0;
	var rowStr = "";
	
	openTableStr = "<tr><td valign='top'>" +
				   "<table border='0' cellspacing='0' cellpadding='0'>" +
				   "<tr><td background='Tedarim/images/Tedarim_lightBlue.gif' align='center'>" +
                   "  <img src='Tedarim/images/Tedarim_endOfBut.gif' " +
                   "    width='1' height='22'></td>";
    
    tabStr = "<td align='center' background='Tedarim/images/Tedarim_lightBlue.gif'>" +
             " <a style='height:22px;padding-top:4px;padding-bottom:3px;padding-left:15;padding-right:15px;' " + 
             "    class='RolloverBlue' border='0' ";
	
	closeTabStr = "</a></td><td background='Tedarim/images/Tedarim_lightBlue.gif' align='center'>" +
                  "  <img src='Tedarim/images/Tedarim_endOfBut.gif' " +
                  "    width='1' height='22'></td>";
             
	closeTableStr = "</tr></table></td></tr>";
	
	rowArry[numRows] = openTableStr;
	boolTblOpen = true;
	
	for (rowIndx = 0; rowIndx <= totalLangs; rowIndx ++)
	{
		//name :: langArray[rowIndx][0]);
		//code :: langArray[rowIndx][1]);

		rowArry[numRows] += tabStr + 
		                    "id='tabLnk" + langArray[rowIndx][1] + "' " +
		                    "href='javascript:getTabTbl(" + langArray[rowIndx][1] + ");'>" +
		                    langArray[rowIndx][0] + closeTabStr;

		if ( ((rowIndx + 1) % numPerCol) == 0 )
		{ 
		   rowArry[numRows] += closeTableStr;
		   boolTblOpen = false;
		   
		   if ( (rowIndx+1) <= totalLangs )
		   {
				numRows++;
				rowArry[numRows] = openTableStr;
				boolTblOpen = true;
		   }
		}
	}
	
	if (boolTblOpen)
	{
	   rowArry[numRows] += closeTableStr;
	}
	
	// build the rows up backwards so that the shortest row is on the top.
	for (rowIndx = 0; rowIndx <= numRows; rowIndx ++)
	{
		langStr = rowArry[rowIndx] + langStr;
	}
		
	document.getElementById("tdTabs").innerHTML = "<table border='0' cellspacing='0' cellpadding='0'>" +
	                                              langStr+ "</table>";
}

function getTabTbl(whichOne)
{
//	hide the previous table and show the new.

	if ( currentTab == whichOne )
	{
		return;
	}

	if ( currentTab != '' )
	{
		document.getElementById('tabTbl' + currentTab).style.display = 'none';
		document.getElementById('tabLnk' + currentTab).className = "RolloverBlue";
	}

	document.getElementById('tabTbl' + whichOne).style.display = '';
	document.getElementById('tabLnk' + whichOne).className = "CurrentTab";

	currentTab = whichOne;

	setHeight('mainIframe','tblMain','false');
	top.scrollTo(0,0);
	
}

function showAreaTbl(whichOne)
{
//	hide the previous area table and show the new.

	if ( currentAreaTbl == whichOne )
	{
		return;
	}

	if ( currentAreaTbl != '' )
	{
		document.getElementById(currentAreaTbl + 'Tbl').style.display = 'none';

		// if there was a kovetz then also hide it.
		try
		{
			document.getElementById(currentAreaTbl + 'Kovetz').style.display = 'none';
		}
		catch (exception) {}
	}

	document.getElementById(whichOne + 'Tbl').style.display = '';

	// if there was a kovetz then also show it.

	try
	{
		document.getElementById(whichOne + 'Kovetz').style.display = '';
	}
	catch (exception) {}

	currentAreaTbl = whichOne;
}

function openGalleryPic(mediaCd,entityCd)
{
	NewWinParamId('Index.asp?classto=TedarimOne&media_code=' + mediaCd + '&entity_code=' + entityCd, 500, 450,'winGallery','yes','yes');
}

function openDictionary(set_date)
{
	NewWinParamId('Index.asp?classto=TedarimKlali&type=dictionary&set_date=' + set_date, 360, 270,'winDictionary','no','no');
}

function divHeightMatchTbl(divObj,tblObj)
{
// this function will set the height of a scrolling div
// to match the height of the table requested.

// Parameters:
// whichDiv - the div that's getting it's height set.
// whichTable - the id of the table height wanted.

	var divHeight;

	if ( divObj == null )
	{
		return;
	}

	divHeight = tblObj.offsetHeight;

	divObj.style.height = divHeight;   
}   

function chooseQuestion(whichOne)
{
	if ( currentQuestion != '' )
	{
		document.getElementById("Tbl" + currentQuestion).style.display='none';
		document.getElementById("lnk" + currentQuestion).className = "RolloverQue";
	}

	document.getElementById("Tbl" + whichOne).style.display='';
	document.getElementById("lnk" + whichOne).className = "currentQuestion";
	document.getElementById('divInfo').scrollTop = 0;
	top.scrollTo(0,0);
	currentQuestion = whichOne;
}

function printDiv(whichEntity,iconNm)
{
	// hide the printer icon.
	document.getElementById(iconNm).style.visibility = 'hidden';
	
	var printPath = top.frames['TedarimPrintout'].document;

    // copy div to printout document
    printPath.getElementById("printContent").innerHTML = document.getElementById("divInfo").innerHTML;
    
//	print out the frame.
	top.frames['TedarimPrintout'].focus();
	top.frames['TedarimPrintout'].print();

	// reshow the printer icon.
	document.getElementById(iconNm).style.visibility = 'visible';
}

function setDirection(firstWord,whichYedia)
{
	var boolChangeDir = checkForRtl(firstWord);

	if (!boolChangeDir)
	{
		return;
	}
	
	try
	{
		document.getElementById("TDdesc" + whichYedia).align = "right";
		document.getElementById("TDdesc" + whichYedia).dir = "rtl";
	}
	catch(exception){}

	document.getElementById("main" + whichYedia).align = "right";
	document.getElementById("main" + whichYedia).dir = "rtl";

	try
	{
		document.getElementById("mainTD" + whichYedia).align = "right";
	}
	catch(exception){}

	document.getElementById("yedia" + whichYedia).align = "right";
	document.getElementById("yedia" + whichYedia).dir = "rtl";

	document.getElementById("date" + whichYedia).align = "right";
	
	try
	{
	//	align the main links table
		document.getElementById("links" + whichYedia).align = "right";
		document.getElementById("links" + whichYedia).dir = "rtl";

		var mainLinkObj = document.getElementById("links" + whichYedia);
		var linksObj = mainLinkObj.getElementsByTagName("TD");
		var linkIndx;
		
	//	align the individual links as well
		for (linkIndx=0; linkIndx < linksObj.length; linkIndx++)
		{
			linksObj[linkIndx].align = "right";
		}
	}
	catch(exception){}
}

//~~~~~~~~~~~~~~~~~~~~ Dictionary Combo Functions ~~~~~~~~~~~~~~~~~~~~~

		function closeOpenCombo()
		{
			if (comboOpen != '')
			{
		//		It was open so now close it.
				closeCombo(comboOpen);
			}
		}

		function SelectBoxAction(whichOne)
		{
			closeOpenCombo();

			if (whichOne == comboOpen)
			{
			//	not interested in opening a new one. Just wanted to close;
				comboOpen = '';
				return;
			}
			
		//	Open the new one.

			document.getElementById("tr" + whichOne).style.display='';
			document.getElementById("arrow" + whichOne).src = "Tedarim/images/ComboUp.gif";
			
			var selectedRow = document.getElementById("hid"+whichOne).value;
			
			if ( selectedRow != 0 && !ns6 )
			{
			    document.getElementById("td" + whichOne + selectedRow).focus();
			}
		    
			comboOpen = whichOne;
		}

		/* function changeDictionaryTxt(whichOne) */
		function changeDictionaryTxt()
		{
			var whichOne = document.getElementById("selectTerms").value;

			if ( currentTbl != '' )
			{
				document.getElementById("Tbl" + currentTbl).style.display='none';
			}

			document.getElementById("Tbl" + whichOne).style.display='';

			top.scrollTo(0,0);
			currentTbl = whichOne;
		}
			

		function closeCombo(whichOne)
		{
			document.getElementById("tr" + whichOne).style.display='none';
			document.getElementById("arrow" + whichOne).src = "Tedarim/images/ComboDown.gif";
		}

		function fillSelectBox(whichOne,choiceNum)
		{
			var newTxt = document.getElementById("td"+whichOne+choiceNum).innerHTML;
			var newHid = document.getElementById("tdHid"+whichOne+choiceNum).value;
			
			document.getElementById("cbo" + whichOne).value = replaceStr(newTxt,'<BR>',' ');

			var last = document.getElementById("hid"+whichOne).value;		
			
		//	highlight the row of the one that is currently in the select box.	
			if (choiceNum != 0)
			{
				document.getElementById("td" + whichOne + choiceNum).className = "selected";
			}

		//	unselect the previous one
			
			if ( (last != choiceNum) && (last != 0) )
			{
				document.getElementById("td" + whichOne + last).className = "unhighlighted";	
			}

		    if (last != 0)
		    {
				changeDictionaryTxt(newHid);
			}

			SelectBoxAction(whichOne);
			document.getElementById("hid" + whichOne).value = newHid;
		}

		function setHighlight(whichOne,choiceNum)
		{
			var current = document.getElementById("current"+whichOne).value;
			var newID = "td" + whichOne + choiceNum;
			var oldID = "td" + whichOne + current;

			// set the new one
			switch (document.getElementById(newID).className)
			{
				case "selectedHighLight":
				case "selected":
					document.getElementById(newID).className = "selectedHighLight";
					break;
				default :
					document.getElementById(newID).className = "highlighted";
			}	

			// reset the last one
			if ( current != 0 )		
			{
				switch (document.getElementById(oldID).className)
				{
					case "selectedHighLight":
					case "selected":
					    document.getElementById(oldID).className = "selected";
						break;
					default :
					    document.getElementById(oldID).className = "unhighlighted";
				}	
			}

			document.getElementById("current"+whichOne).value = choiceNum;
		}
//~~~~~~~~~~~~~~~~ End of Dictionary Combo Functions ~~~~~~~~~~~~~~~~~
