var last_scroll_offset = 0;

// Allow the scroll navigation feature only in IE browsers versions 6 and up, to be on the safe side
var browser_name     = '';
var version_str = '';
// alert('App full name = ' + navigator.appName +  '  ver. ' + navigator.appVersion);
var compatible_with_nav_scrolling = 1;

//if (navigator.userAgent.indexOf('Firefox') !=-1) { compatible_with_nav_scrolling = 0;}

if(navigator.userAgent.indexOf('MSIE') !=-1) { // IE
	compatible_with_nav_scrolling = 1;
} else {
	compatible_with_nav_scrolling = 0;
}


if (navigator.userAgent.indexOf('Chrome') !=-1) { compatible_with_nav_scrolling = 0;}
if (navigator.userAgent.indexOf('Firefox') !=-1) { compatible_with_nav_scrolling = 0;}
if (navigator.userAgent.indexOf('Opera') !=-1) { compatible_with_nav_scrolling = 0;}
if (navigator.userAgent.indexOf('Safari') !=-1) { compatible_with_nav_scrolling = 0;}


//if (0) {
//     if (browser_name == '') {
//	version_str = navigator.appVersion;
//	parens = version_str.indexOf('(');
//	parene = version_str.indexOf(')');
//	in_paren = version_str.substring(parens+1,parene-1);
//	if (in_paren.indexOf('MSIE') != -1) {
//		temp = in_paren.split('MSIE');
//		browser_version = parseFloat(temp[1]);
//		if (browser_version >= 6) compatible_with_nav_scrolling = 1;
		// alert('version is ' + browser_version + '    compatability = ' + compatible_with_nav_scrolling);
//	}
//    }
//}

function windowSizeScrollCompatible() { 
	if (compatible_with_nav_scrolling == 0) return(0);
	//if (document.body.clientWidth < 1005) return (0); 
	//alert('height: ' + document.body.clientHeight);
	if (document.body.clientHeight < 670) return(0); 
	return (1);
}


// must set the var position_top to the value set for position:relative;top:<whatever value>
// position_top & box_height are parameter that needs to be determined, they are not calculated!
var position_top = 0;
var box_height = 480;
// note: initial_distance_from_top & document_height are calculated values in the script in the file wz_tooltip.js (this file must be included in the HTML doc for scrolling to happen!)
var initial_distance_from_top = 0;
var document_height = 8000;

//if (windowSizeScrollCompatible()==1) {
if (compatible_with_nav_scrolling) { 
document.write('<div id="top_navigation_box" name="top_navigation_box" style="position:relative; top:0px; right:0px; width:100px" onresize="showSlideBanner();"><IFRAME SRC="/topnavigation2.htm" name="frame3" width=150 height=' + box_height + ' frameborder="no" border="0" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no"></IFRAME></div>');
}
else {
document.write('<DIV ALIGN="right" STYLE="padding: 0px 5px;">');

document.write('<H5><a style="text-decoration: none" CLASS="white" HREF="/generalOverview"> <b>הפלי"ם</b></a></h5>');
document.write('<H5><a style="text-decoration: none" CLASS="white" HREF="/Hahapala/mainpage"><span dir=rtl><B>&#1492;&#1492;&#1506;&#1508;&#1500;&#1492; - &#1506;&#1500;&#1497;&#1492; &#1489;\'</B></span></a></H5> ');    
document.write('<H5><A CLASS="white" HREF="/Arrests/mainpage" STYLE="text-decoration: none;"><B>&#1502;&#1495;&#1504;&#1493;&#1514; &#1502;&#1506;&#1510;&#1512; &#1492;&#1502;&#1506;&#1508;&#1497;&#1500;&#1497;&#1501;</B></A></h5> ');      

document.write('<H5><a style="text-decoration: none" CLASS="white" HREF="/KhabalaYamit/mainpage"> <B>&#1492;&#1502;&#1488;&#1489;&#1511; &#1492;&#1510;&#1502;&#1493;&#1491;  &#1493;&#1495;&#1489;&#1500;&#1492; &#1497;&#1502;&#1497;&#1514;</B></a></H5>');      
document.write('<H5><a style="text-decoration: none" CLASS="white" HREF="/Hamosad_lealiya_bet/mainpage"> <B><span dir=rtl>&#1492;&#1502;&#1493;&#1505;&#1491; &#1500;&#1506;&#1500;&#1497;&#1492; &#1489;\'</span></B></a></h5>');
document.write('<H5><A CLASS="white" HREF="/Gidhonim/mainpage" STYLE="text-decoration: none;"><B>הגדעונים</B></A></H5>');

document.write('<H5><A CLASS="white" HREF="/Hakhavura/mainpage" STYLE="text-decoration: none;"><B>החבורה</B></A></H5> ');      
document.write('<H5><A CLASS="white" HREF="/HaverimMesaprim/mainpage" STYLE="text-decoration: none;"><B>חברים מספרים</B></A></H5>');
document.write('<H5><a style="text-decoration: none" CLASS="white" HREF="/Volunteers/mainpage"> <B>מתנדבי חו"ל</B></a></h5>');

document.write('<H5><A CLASS="white" HREF="/OniyotRekhesh/mainpage" STYLE="text-decoration: none;"><B>אוניות הרכש</B></A></H5>');
document.write('<H5><a CLASS="white" HREF="/IDF_Navy/mainpage" STYLE="text-decoration: none;"><B>מפלי"ם לחיל הים</B></a></h5>');
document.write('<H5><A CLASS="white" HREF="/Rishonim/mainpage" STYLE="text-decoration: none;"><B>ראשוני ראשונינו</B></A></h5>');

document.write('<H5><A CLASS="white" HREF="/PGallery/mainpage" STYLE="text-decoration: none;"><B>&#1502;&#1510;&#1490;&#1493;&#1514;</B></A></H5>');
document.write('<H5><A CLASS="white" HREF="/Books_Movies/mainpage" STYLE="text-decoration: none;"><B>ספרים,  סרטים, ושירים</B></A></h5>');
document.write('<H5><A CLASS="white" HREF="/Izkor/Izkor" STYLE="text-decoration: none;"><B>נזכור את חברינו</B></A></H5>');

document.write('</DIV>');
}





function  showSlideBanner() { 
	if (windowSizeScrollCompatible()==1) document.getElementById("top_navigation_box").style.display="block"; 
	// else document.getElementById("top_navigation_box").style.display="none";
 
}



function slideScroll() { 
	setTimeout("niceSlide()", 10); 
}



if (windowSizeScrollCompatible()==1) { 
	// window.onresize = showSlideBanner;  
	window.onscroll = slideScroll; 
}



function niceSlide() {

	if (windowSizeScrollCompatible()==0) {
		document.getElementById("top_navigation_box").style.top = position_top;
		last_scroll_offset = 0;
		return;
	}
	var dy = document.body.scrollTop - last_scroll_offset;

	if ( (dy >0) && (   (last_scroll_offset  + initial_distance_from_top + box_height) >  document_height) ) return;

	
if (dy!=0) {
		
if(dy > 0) incVal = 1; else incVal = -1;
		
if (unsignNum(dy)>200) step = 7; 
else if (unsignNum(dy)>100) step = 5; 
else if (unsignNum(dy)>40) step = 3; 
else step = 1;

		last_scroll_offset = last_scroll_offset + incVal * step;
		
document.getElementById("top_navigation_box").style.top = last_scroll_offset + position_top;
		
setTimeout("niceSlide()", 10);
	
}

}



function unsignNum(n){ 
	if(n<0) return (n * -1); else return (n); 
}
