var selected_btn_main = "";
var selected_btn_top;
var Is4OrUp=1,IsExplor=1;


function TopClicked(s_node_id, s_url, c_advert) 
{
	if(c_advert == 1)
	{
		OpenBdiCode();
	}
	else
	{
		if(s_node_id == "English")
			top.location.href = s_url;
		else
			top.main_frame.location.href = s_url;
	}
	return;
}

function prepareURL(url) 
{
	url = url.toLowerCase();
	url = url.substring(url.indexOf("/secure"),url.length)
	return url;
}
/***************************************************************************************
  Description:	Updates the current hevra or person
  Parameters:	n_bdi				- Number.	The N_BDI 
 				n_code				- Number.	The C_TAAGID ot C_ID 	
 				n_update_hevra		- Boolean.	Indicates wether the update is for a hevra
 				s_main_url			- String.	The main frame Url
 				n_open_win			- Boolean.	Indicates wether to open a new window
 				n_from_link			- Boolean.	
 				IsMvkrNtRg			- Boolean.	Indicates wether the mevaker is not registered
 				n_x_pos				- Number.	The x axis window position
 				n_y_pos				- Number.	The y axis window position
 				n_height			- Number.	The window height
 				n_width				- Number.	The window width
 				s_btn_Top			- String.	The top frame button to select
 				s_btn_right			- String.	The right frame button to select
 				b_side_change_url	- Boolean.	Indicates wether the right frame button selection should invoke a Url change
 				
  Return:		Nothing
****************************************************************************************/
function UpdateTopNew(n_bdi, n_code, n_update_hevra, s_main_url, n_open_win, n_from_link, IsMvkrNtRg, n_x_pos, n_y_pos,
						n_height , n_width, s_btn_Top, s_btn_right, b_side_change_url)
{
	
	if (!n_x_pos || !n_y_pos)
	{
		n_x_pos = 100;
		n_y_pos = 100;
	}
	
	if (!n_height || !n_width)
	{
		n_height = 360;
		n_width	= 270;
	}
	
	if ( n_update_hevra > 0 )
	{
		if(s_main_url == "0")
		{
			
			//"BdiIski.asp?FromLink=<%=FromLink%>&N_BDI=<%=nBdi%>&C_TAAGID=<%=C_TAAGID%>&N_RESHIMA=<%=N_RESHIMA_SEGMENTA%>&FlgUpdHev=<%=flgUpdHev%>&WCI=CompanyData";
			s_main_url = "BdiIski.asp?FromLink=" + n_from_link + "?N_BDI=" + n_bdi + "&C_TAAGID="
				 + n_code + "&FlgUpdHev=" + n_update_hevra+ "&WCI=CompanyData";
		}
		//strUrl="ol_iski_zihui.asp?N_BDI=" + nBdi + "&C_TAAGID=" + code + "&flgUpdHev=" + upd;
		//if( n_open_win != "0" )
		//	strUrl += "&NoZihui="+escape(UrlLoc);
		//else
		//{ 
			//AddToZihui="MvkrBtnRgt=Zihui&MvkrBtnTop=Asakim&";
			//if(n_open_win != 1)
			//{
				//top.MvkrBtnRgt = "Zihui";
				//top.MvkrBtnTop = "Asakim";
				//top.MvkrBtnRgt = s_btn_right;
				//top.MvkrBtnTop = s_btn_Top;
			//}
			//if(FromLink!=null) 
		    //    strUrl+ = "&FromLink=" + FromLink;
		//}
		var s_url = "default.aspx?N_BDI=" + n_bdi+ "&C_TAAGID=" + n_code + "&MainUrl=" + escape(s_main_url) 
			+ "&BtnTop=" + s_btn_Top + "&BtnRight=" + s_btn_right	+ "&IturEsekParams=" 
			+ top.SaveIturEsekPrm + "&RashamIturParams=" + top.saveRashamIturPrm + "&SideChangeUrl=" + b_side_change_url;
		if(n_open_win == 1)
		{
			OpenWin(s_url, "MainWin" + n_code , n_x_pos, n_y_pos ,n_height ,n_width , 1, 0, 1, 0);
		}
		else
		{
			top.location.href = s_url;
			////if(IsMvkrNtRg==1)
			//{
			//	top.main_frame.table_frame.location.href=strUrl;  //for maagar hevrot visitor
			//	top.nUser=0;
			//}	
			//top.main_frame.location.href = strUrl;
		}
	}
	else
	{
		OpenWin("Link2Id.asp?Type=2&N_BDI=" + n_bdi + "&Id=" + n_code, "Link_to_"+ n_code, n_x_pos, n_y_pos, n_height, n_width, 1, 0, 1, 0);
	}
}

function new_button (img_name,img_status,btn_no) 
{
	button [img_name] = new button (img_name,img_status,btn_no);
	return;
}

function button (img_name,img_status,btn_no)
{
	if (document.images) 
	{
	    if(btn_no!=null) 
			img_name = img_name.substring(0,img_name.indexOf("_"));
		img_path  = "/secure/images/";
		this.img_off_src = img_path + img_name + "_n.gif";
		this.img_on_src = img_path + img_name + "_p.gif";
	}
	this.img_status = img_status;
	return;
}



function mouseover (img_name,win_doc)
{
	if (document.images && (img_name != selected_btn_top) && (img_name != selected_btn_Side) && (img_name != selected_btn_main)) 
	   {
			if( button[img_name] )
			{
				win_doc.images[img_name].src = button[img_name].img_on_src;
				window.status = button [img_name].img_status;
			}
			else
				window.status = "";
	   }
    return;
}

function mouseout (img_name,win_doc) 
{
	if (document.images && (img_name != selected_btn_top) && (img_name != selected_btn_Side) && (img_name != selected_btn_main)) 
	    {
			if( button[img_name] )
				win_doc.images[img_name].src = button [img_name].img_off_src;
			window.status = "";
	    }
	return;
}

		
		
function IsViaMenu()
{
	//To be filled later
}
//=======================================================================
function OpenWin(s_url, s_name, n_x, n_y, n_width, n_height, n_scroll, b_toolbar, b_menubar, b_location)
{
	var o_win;
	var nWidthMax = Math.round(0.85*window.screen.availWidth);
	var nHeightMax = Math.round(0.85*window.screen.availHeight);
	if(n_width == null)
	{		
		n_width	= nWidthMax;
	}
	else
	{
		n_width = Math.min(n_width,nWidthMax);
	}
	if(n_height == null)
	{					
		n_height = nHeightMax;
	}
	else
	{
		n_height = Math.min(n_height,nHeightMax);
	}
	if(window.opener && !((typeof(window.opener.name) == "unknown")||(typeof(window.opener.name) == "undefined")))
	{
		o_win = top.window.opener.window.top.window.open(s_web_root_secure + s_url ,s_name, "width=" + n_width  + ",height=" + n_height + 
					",top=" + n_x + ",left=" + n_y+ ",location=" + b_location + 
					",toolbar=" + b_toolbar + ",fullscreen=no,resizable=yes,scrollbars=" +
					n_scroll +",menubar=" + b_menubar);
	}
	else
	{
		o_win = top.window.open(s_web_root_secure +  s_url, s_name, "width=" + n_width +
				",height=" + n_height + ",top=" + n_x + ",left=" + n_y +
				",toolbar=" + b_toolbar + ",location=" + b_location + 
				",fullscreen=no,resizable=yes,scrollbars=" + n_scroll +
				",menubar=" + b_menubar);
	}
	o_win.focus();
}
	
function opn_new_win( ref, loc, WinSize)
{
	if( WinSize == 1)
	{
		strTop	= 100; 
		strLeft	= 100;
	}
	else if(WinSize==4||WinSize==6)
	{
		strTop	= 50;
		strLeft	=250;
	}
	else
	{
		strTop	=20;
		strLeft	=10;
	}	
	var win;
	
	if(window.opener && !((typeof(window.opener.name)=="unknown")
					||(typeof(window.opener.name)=="undefined")))
	{
		w_width		= eval("top.window.opener.window.top.w_width"  + WinSize);
		w_height	= eval("top.window.opener.window.top.w_height" + WinSize);		
		win			= top.window.opener.window.top.window;
	}
	else
	{
		w_width		= eval("top.w_width"+WinSize);
		w_height	= eval("top.w_height"+WinSize);
		win			= top.window;		
	}
	var nWidthMax = Math.round(0.85*win.screen.availWidth);
	var nHeightMax = Math.round(0.85*win.screen.availHeight);	
	w_width		= Math.min(w_width,nWidthMax);
	w_height	= Math.min(w_width,nHeightMax);
	win			= win.open(s_web_root_secure + ref, loc, "width=" + w_width + ",height=" + w_height +
							",top=" + strTop + ",left=" + strLeft + 
						",toolbar=no,fullscreen=no,resizable=yes,scrollbars=yes,menubar=yes");
	win.focus();
	return;
}

function OpenBdiCode()
{
	var n_width		= 800;//window.screen.availWidth * 0.85;
	var n_height	= 550;//window.screen.availHeight * 0.85;
	
	var s_options = "width=" + n_width + ",height=" + n_height + 
					",top=27,left=27" +
					",toolbar=1,location=0" + 
					",fullscreen=no,resizable=yes,scrollbars=1" +
					",menubar=0";
				
	window.open("http://www.bdicode.co.il", "BdiCode", s_options)
	
}
