

// @@@@@@@@@@@@@@@@@@@@@@@@
// @@@@ created by Vampard 8.1.2010 @@@@
// @@@@@@@@@@@@@@@@@@@@@@@@
var firstDo =0;
function loadNavi( nv_name, nv_borderStyle , nv_location , nv_position , nv_left , nv_top , nv_width , nv_height , nv_transparency , nv_image , nv_color)
{

	if(nv_name=='menu'){
		// div objects to control
		var menu = 	document.getElementById('menu_container');
		var content = document.getElementById('content_container');
		var menu1 = 	document.getElementById('menu');
		var content1 = document.getElementById('content');
		

		//a transparecy value
		var transValue = parseInt(nv_transparency);

		menu1.style.position= 'absolute';
		content1.style.position= 'absolute';
		content1.style.marginLeft= '0px';
		menu1.style.zIndex = '10';
		content1.style.zIndex = '5';
		
		var speed = 0.25;
		var bagicWid = 215;
		//cross browsing
		var scroll_top = $(window).scrollTop() ||  document.documentElement.scrollTop || document.body.scrollTop;
		var scroll_left = $(window).scrollLeft() ||  document.documentElement.scrollLeft || document.body.scrollLeft;
		var docWid = document.documentElement.clientWidth || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var docHei = document.documentElement.clientHeight || document.body.clientHeight|| window.innerHeight|| self.innerHeight;

		if(nv_borderStyle==1) //bar mode
		{
		
	
			switch(parseInt(nv_location))
			{
				case 1:	
					if(firstDo==0)
					{
						menu1.style.top = 0+ 'px';
						firstDo++;
					}

					menu.style.height =parseInt(docHei- 30)+'px';
					changeNavi.naturalMove(menu1,parseInt(menu1.style.top),scroll_top,speed);
					changeNavi.changedLocation (menu1 , content1 , '0px' , 0 + parseInt(scroll_top)+'px' , bagicWid + 'px' ,  '100%' ,  bagicWid + 'px' ,  '0px' ,  parseInt(docWid - bagicWid)+'px' , '100%');
					break;
				case 2:	
					if(firstDo==0)
					{
						
						menu1.style.top = 0+ 'px';
						firstDo++;
					}
					menu.style.height =parseInt(docHei- 30)+'px';
					changeNavi.naturalMove(menu1,parseInt(menu1.style.top),scroll_top,speed);
					changeNavi.changedLocation (menu1 , content1 , parseInt(docWid - bagicWid )+ 'px' ,  0 + parseInt(scroll_top)+'px' , bagicWid + 'px' ,  '100%' ,  '0px' ,  '0px' ,  parseInt(docWid - bagicWid )+ 'px' , '100%');
					break;
				case 3:	
					if(firstDo==0)
					{
						
						nv_width = Math.ceil(parseInt(nv_width) * parseInt( docWid ) / 1024);
						nv_height = Math.ceil(parseInt(nv_height) * parseInt( docHei ) / 768 );
						nv_left = Math.ceil(parseInt(nv_left) * parseInt( docWid ) / 1024);
						nv_top = Math.ceil(parseInt(nv_top)* parseInt( docHei ) / 768);

						menu1.style.overflow='visible';
						menu1.style.top = nv_top + 'px';
						firstDo++;
				
					}
					//real menu size
					menu.style.height =nv_height+'px';
					changeNavi.naturalMove(menu1,parseInt(menu1.style.top),parseInt(nv_top )+ scroll_top,speed);
					changeNavi.changedLocation (menu1 , content1 , 
					parseInt(nv_left) - parseInt(scroll_left)+ 'px' ,
					parseInt(nv_top) + parseInt(scroll_top)+'px' ,
					nv_width + 'px',
					nv_height + 'px',
					parseInt(nv_left) - parseInt(scroll_left) + nv_width + 'px' 
					, '0px' 
					,  parseInt(docWid) - ( parseInt(nv_left) - parseInt(scroll_left) + parseInt(nv_width )) +'px' 
					, '100%');
			
					break;
				case 4:	
					if(firstDo==0)
					{
						
						nv_width = Math.ceil(parseInt(nv_width) * parseInt( docWid ) / 1024);
						nv_height = Math.ceil(parseInt(nv_height) * parseInt( docHei ) / 768 );
						nv_left = Math.ceil(parseInt(nv_left) * parseInt( docWid ) / 1024);
						nv_top = Math.ceil(parseInt(nv_top)* parseInt( docHei ) / 768);
						
						menu1.style.overflow='visible';
						menu1.style.top = nv_top + 'px';
						firstDo++;
					}

					
					menu.style.height =nv_height+'px';

					changeNavi.naturalMove(menu1,parseInt(menu1.style.top),parseInt(nv_top )+ scroll_top,speed);
					changeNavi.changedLocation (menu1 , content1 , 
					parseInt(docWid) - ( parseInt(nv_left) + parseInt(nv_width) - parseInt(scroll_left) )+ 'px' ,
					parseInt(nv_top) + parseInt(scroll_top)+'px' ,
					nv_width + 'px',
					nv_height + 'px',
					'0px' , '0px' , parseInt(docWid) - ( parseInt(nv_left) - parseInt(scroll_left) )+ 'px' , '100%');

					break;

				default: 
					if(firstDo==0)
					{
						menu1.style.overflow='visible';
						menu1.style.top = nv_top + 'px';
						firstDo++;
					}


					menu.style.height =nv_height+'px';
					changeNavi.naturalMove(menu1,parseInt(menu1.style.top),parseInt(nv_top )+ scroll_top,speed);
					changeNavi.changedLocation (menu1 , content1 , parseInt(nv_left) - parseInt(scroll_left)+ 'px' ,  parseInt(nv_top) + parseInt(scroll_top)+'px' , nv_width + 'px', nv_height + 'px',  '0px' , '0px' ,  docWid+'px' , '100%');


			}

		}else //post mode
		{

			if(firstDo==0)
			{
				
				nv_width = Math.ceil(parseInt(nv_width) * parseInt( docWid ) / 1024);
				nv_height = Math.ceil(parseInt(nv_height) * parseInt( docHei ) / 768 );
				nv_left = Math.ceil(parseInt(nv_left) * parseInt( docWid ) / 1024);
				nv_top = Math.ceil(parseInt(nv_top)* parseInt( docHei ) / 768);

				menu1.style.top = nv_top + 'px';
				firstDo++;
			}

			menu1.style.overflow='visible';
			menu.style.height =nv_height+'px';
			changeNavi.naturalMove(menu1,parseInt(menu1.style.top),parseInt(nv_top )+ scroll_top,speed);
			changeNavi.changedLocation (menu1 , content1 , parseInt(nv_left) - parseInt(scroll_left)+ 'px' ,  parseInt(nv_top) + parseInt(scroll_top)+'px' , nv_width + 'px', nv_height + 'px',  '0px' , '0px' ,  docWid+'px' , '100%');

		}
		
		
		changeNavi.changedTransparency(transValue,menu);
		changeNavi.changedColor(nv_color,menu);
			
	}else return ;
	
setTimeout(function(){loadNavi( nv_name, nv_borderStyle , nv_location , nv_position , nv_left , nv_top , nv_width , nv_height , nv_transparency , nv_image , nv_color)},5);		
}


var changeNavi = {
	// m1T is nothing , natural move takes care of the top position
	changedLocation : function(menu1,content1,m1L, m1T, m1W, m1H, c1L, c1T, c1W, c1H)
	{
				
					menu1.style.left =m1L;
					menu1.style.width= m1W;
					menu1.style.height =m1H;
					content1.style.left = c1L;
					content1.style.top= c1T;
					content1.style.width= c1W;
					content1.style.height =c1H;

	},
	naturalMove : function(menu1,scrollFrom,scrollTo,speed){

			var scrollMove = 0;
			if (scrollTo !=  scrollFrom)
			{ 
					scrollMove = Math.ceil(Math.abs(scrollTo - parseInt(menu1.style.top)) * speed);

					if(scrollTo < scrollFrom )
					{
					scrollMove = -scrollMove ;
					}

				menu1.style.top=parseInt(menu1.style.top)+ parseInt(scrollMove)+'px';
			}		
	},
	changedTransparency : function(transValue,menu){
		//@@@@    about transparency    @@@@
		transValue = parseInt(transValue);
	
		//cross browsing
		var checkBW = whichBrs();
		if(checkBW == 'Internet Explorer' ){
		//	naDiv.style.filter = 'alpha(opacity='+transValue+')' ;	 //same one		
			menu.style.filter= 'progid:DXImageTransform.Microsoft.Alpha(opacity='+transValue+')'; 
		}else{
			 transValue *= 0.01; 
			 menu.style.opacity = transValue;
		}
	
	},
	changedColor : function(nv_color,menu){
			//@@@@    about background color @@@@

			menu.style.backgroundColor=nv_color;
		

	}
}




function whichBrs() {


var agt=navigator.userAgent.toLowerCase();


if (agt.indexOf("opera") != -1) return 'Opera';

4
if (agt.indexOf("staroffice") != -1) return 'Star Office';


if (agt.indexOf("webtv") != -1) return 'WebTV';


if (agt.indexOf("beonex") != -1) return 'Beonex';


if (agt.indexOf("chimera") != -1) return 'Chimera';


if (agt.indexOf("netpositive") != -1) return 'NetPositive';


if (agt.indexOf("phoenix") != -1) return 'Phoenix';


if (agt.indexOf("firefox") != -1) return 'Firefox';


if (agt.indexOf("safari") != -1) return 'Safari';


if (agt.indexOf("skipstone") != -1) return 'SkipStone';


if (agt.indexOf("msie") != -1) return 'Internet Explorer';


if (agt.indexOf("netscape") != -1) return 'Netscape';


if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';


if (agt.indexOf('\/') != -1) {


if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {


 

return navigator.userAgent.substr(0,agt.indexOf('\/'));}


else return 'Netscape';} else if (agt.indexOf(' ') != -1)


return navigator.userAgent.substr(0,agt.indexOf(' '));


else return navigator.userAgent;


}

