var ns6 = (!document.all && document.getElementById);

function setHeight(whichFrame,whichTable)
{
//	this function will set the frame height in a page
//	whichFrame - the frame that's getting it's height set.
//	whichTable - the id of the main table 

	var frameHeight;
	var pathFrame = '';

	if ( top.document.getElementById(whichFrame) )
	{
		pathFrame = top.document;
	}

	else if ( window.parent.document.getElementById(whichFrame) )
	{
		pathFrame = window.parent.document;
	}
		
	else
	{
		return;
	}
        
	frameHeight = document.getElementById(whichTable).offsetHeight;
	pathFrame.getElementById(whichFrame).height = frameHeight;   

//  Check if this frame is a childframe.  If it is, then enlarge 
//	the parent frame as well (if it is not big enough already.
    
    try
    {
		if (frameHeight > window.frames.parent.frameElement.height)
		{
			window.frames.parent.frameElement.height = frameHeight;
		}
	}
	catch (exception)
	{
	}
}

function closePopup()
{
	try
	{
		if (WindowIsOpen)
		{
			WindowIsOpen.close();
		}
	}
	catch(exception)
	{
	}
}

function setMaslool(whichPg)
{
//	show or hide home page from the maslool?	
	if ( whichPg == 'home' )
	{
		top.document.getElementById('homeMasloolLnk').style.display = 'none';
		top.document.getElementById('homeMasloolLnkArrw').style.display = 'none';
	}
	else
	{
		top.document.getElementById('homeMasloolLnk').style.display = '';
		top.document.getElementById('homeMasloolLnkArrw').style.display = '';
	}
}

function setHouseInFooter(typePg)
{
	if ( typePg == "home" )
	{
		top.document.getElementById('houseTitle').innerHTML = "הפוך אותנו לדף הבית";
		top.document.getElementById('houseLnk').onclick = makeHomePg;
	}
	else
	{
		top.document.getElementById('houseTitle').innerHTML = "לדף הבית";
		top.document.getElementById('houseLnk').onclick = returnToHomePg;
	}
}
	
function makeHomePg()
{
	top.document.getElementById('houseLnk').style.behavior='url(#default#homepage)';
    top.document.getElementById('houseLnk').setHomePage('http://www.iba.org.il/pilpel/');
}

function returnToHomePg()
{
	top.document.getElementById('mainIframe').src = 'HomePg.asp';
}

function playVideo(whichUrl)
{
    w = 320;
    h = ns6?376:286;
		
	LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		
	win=open(whichUrl,'recipeVideo',settings);
	win.opener=self;
		
	if(win.focus){win.focus();}
}

function SearchKatava() 
{
	WindowIsOpen=window.open('findKatavaPop.asp','findKatavaWin','height=210,width=325,top=190,left=250,status=no,toolbar=no,menubar=no,location=no');
}

function OdotYairPopup() 
{
	WindowIsOpen=window.open('YairKoren.htm','yairKorenWin','height=200,width=480,top=210,left=140,status=no,toolbar=no,menubar=no,location=no');
}

function YourRecipePopUp() {
	WindowIsOpen=window.open('YourRecipe.asp','yourRecipeWin','top=100,left=190,width=500,height=400,status=no,toolbar=no,menubar=no,location=no');
}

function replaceStr(string,text,by) 
{
	var stringLength = string.length
	var textLength = text.length;
	if ((stringLength == 0) || (textLength == 0)) return string;

	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,textLength))) return string;
	if (i == -1) return string;

	var newstr = string.substring(0,i) + by;

	if ( (i+textLength) < stringLength)
		newstr += replaceStr(string.substring(i+textLength,stringLength),text,by);

	return newstr;
}       

function NewBrowserMax(whichpage)
{
	// this function does not set the focus to itself
	// like the other ones.
	// it opens in a max sized window
	// the id for the window is '' and not null, so that
	// each page will open a new window, not replace the 
	// one opened before.
		
	settings='width='+screen.availWidth+',height='+screen.availHeight+',top=0,left=0,scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes';
	win=open(whichpage,'',settings);
	win.opener=self;
}
