window.oPos = 0;
window.firstRun = 0;
window.bKeep = true;
window.oSel = ""

//********************* FSCOMMANDS **************************************
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function menuProduct_DoFSCommand(command, args) {
	var fscommandObj = InternetExplorer ? menuProduct : document.menuProduct; 
	
	
	window.bKeep = true

	sInput = args;
	//Split
	sArray = sInput.split(",");
	//item
	nItem = Number( sArray[0] );
	
	nSize = Number( sArray[1] );
	
	
	
	if ( command == "open" ){ fShowmenu( nItem, nSize ) }
	
	if ( document.all ){
		if ( command == "keep" ){ 
			window.document.subs.SetVariable( "_root.tracker.fActivity", true ); 
		}
	}
}
// Hook for Internet Explorer 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
        document.write('<SCRIPT LANGUAGE=VBScript\> \n'); 
        document.write('on error resume next \n'); 
        document.write('Sub menuProduct_FSCommand(ByVal command, ByVal args)\n'); 
        document.write('  call menuProduct_DoFSCommand(command, args)\n'); 
        document.write('end sub\n'); 
        document.write('</SCRIPT\> \n'); 
} 



function subs_DoFSCommand(command, args) {
	var fscommandObj = InternetExplorer ? subs : document.subs; 

	sInput = args;
	//Split
	sArray = sInput.split(",");
	//item
	nItem = Number( sArray[0] );
	nSize = Number( sArray[1] );

	if ( command == "resize" ){ fSubHeight( nItem, nSize ) }
	if ( document.all ){
		if ( command == "close"  ){ closeMenu () }
	}
}
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
        document.write('<SCRIPT LANGUAGE=VBScript\> \n'); 
        document.write('on error resume next \n'); 
        document.write('Sub subs_FSCommand(ByVal command, ByVal args)\n'); 
        document.write('  call subs_DoFSCommand(command, args)\n'); 
        document.write('end sub\n'); 
        document.write('</SCRIPT\> \n'); 
} 

//********************* FSCOMMANDS END **************************************

function fShowmenu( item, size ){	

	if ( item == window.oSel ) return;
	window.oSel = item;
	
	if ( document.all ) window.document.subs.SetVariable( "_root.tracker.fActivity", true );

	document.getElementById( "sub" ).style.display = "block"; 

	var oBody = document [ document.documentElement ? "documentElement" : "body" ];

	window.oPos = size;
	
	// move submenu out of sight ::
	document.getElementById( "sub" ).style.top 		= -705 + "px"; 
	
	var menu = document.getElementById( "menuProduct" );
	
	// place submenu leftside ::
	if ( item == 0 )
	{
		document.getElementById( "sub" ).style.left = findPosX ( menu ) - 1 + "px"
	}
	else
	{
		document.getElementById( "sub" ).style.left =  findPosX ( menu ) + parseInt ( size ) - 16 + "px"; 
	}

	// change variable in submenu ::
	if ( document.all ) 
	{	
		window.document.subs.SetVariable( "_root.tracker.windowsItem", item );
		window.document.subs.SetVariable( "_root.tracker.state", "run" );
	
		if( ( navigator.appVersion.indexOf( 'Mac' ) > 1 ) || window.opera )
		{
			document.getElementById( "sub" ).innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' id='subs'><embed src='/include/swf/sub.swf?id=" + item + "&menuXml=" + novoProductXmlUrl + "' id='mozSub' quality='high' scale='noscale'  bgcolor='#FFFFFF' swLiveConnect='true'  name='subs' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>"
		}
	}
	else
	{		
		document.getElementById( "sub" ).innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' id='subs'><embed src='/include/swf/sub.swf?id=" + item + "&menuXml=" + novoProductXmlUrl + "' id='mozSub' quality='high' scale='noscale'  bgcolor='#FFFFFF' swLiveConnect='true'  name='subs' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed></object>"
	}
	
	if( document.all ){ 
	} else {	
		
		var oFlash = document.getElementsByTagName( "object" );
		var nAmountOfItems = 0;
		var nNotMenu = 0;
		
		for ( i = 0; i <  oFlash.length; i++ ){
			if  ( oFlash.item( i ).parentNode.className == "novoproducttop" || oFlash.item( i ).parentNode.id == "sub" ){ 
			}else{
				nAmountOfItems += 1;
				nNotMenu = i;
			}
		}
		if ( nNotMenu > 0 ){
//			oHeight = document.defaultView.getComputedStyle(oFlash.item( nNotMenu ),null).getPropertyValue('height')
//			oFlash.item( nNotMenu ).parentNode.style.height = oHeight;
//			oFlash.item( nNotMenu ).style.display = "none";
		}
	}
	// initialize closemenu when body is clicked ::
	oBody.onclick = closeMenu;
}

function changeUrl ( url, target ){
	if ( target == "current" ){
		document.location = url;
	}else{
		window.open( url )	
	}
}

function closeMenu () {
	// hide dropdown ::
	document.getElementById( "sub" ).style.top 		=	-705 + "px"; 
	document.getElementById( "sub" ).style.display 		=	"none"; 
	
	window.oSel = ""
	
	if ( document.all ){
		// tell flash to reset topmenu ::
		window.document.menuProduct.SetVariable( "_root.tracker.bReset", "true" );
		window.document.menuProduct.SetVariable( "_root.tracker.oGod", "" );
	}else{
		var oFlash = document.getElementsByTagName( "object" );
		var nAmountOfItems = 0;
		var nNotMenu = 0;
		
		for ( i = 0; i <  oFlash.length; i++ ){
			if  ( oFlash.item( i ).parentNode.className == "novoproducttop" || oFlash.item( i ).parentNode.id == "sub" ){ 
			}else{
				nAmountOfItems += 1;
				nNotMenu = i;
			}
		}
		if ( nNotMenu > 0 ){
			oHeight = document.defaultView.getComputedStyle(oFlash.item( nNotMenu ),null).getPropertyValue('height')
			oFlash.item( nNotMenu ).parentNode.style.height = oHeight;
			oFlash.item( nNotMenu ).style.display = "block";
		}
	}
}

function closeParentMenu (){
	
	if ( window.bKeep ) return;
	
	window.oSel = ""
	
	document.getElementById( "sub" ).style.top 		=	-705 + "px"; 
	document.getElementById( "sub" ).style.display 		=	"none"; 
	
	if ( document.all ){
		// tell flash to reset topmenu ::
		window.document.menuProduct.SetVariable( "_root.tracker.bReset", "true" );
		window.document.menuProduct.SetVariable( "_root.tracker.oGod", "" );
	}
}



function fSubHeight ( height, width ){
	
	menuExtra ()
	
	// crop object ::
	if ( ( navigator.appVersion.indexOf( 'Mac' ) > 1 ) || window.opera ){
		document.getElementById( "mozSub" ).style.height 		= 	parseInt( height ) + "px"; 
		document.getElementById( "mozSub" ).style.height 		=	parseInt( width ) + 55 + "px";
	}else{
		if ( document.all ){ 
			document.getElementById( "subs" ).style.height 		=	parseInt( height ) + 2 + "px"; 
			document.getElementById( "subs" ).style.width 		=	parseInt( width ) + 55 + "px";
		}else{
			document.getElementById( "mozSub" ).style.height 	=	parseInt( height ) + 0 + "px"; 
			document.getElementById( "mozSub" ).style.width 	=	parseFloat( width ) + 55 + "px";
		}
	}
	//crop element ;;
	document.getElementById( "sub" ).style.height 	= height + "px"; 
	document.getElementById( "sub" ).style.width 	= width + "px"; 
	document.getElementById( "sub" ).style.top 		= 126 + "px"; 
	
	
	
	// display submenu ::
	document.getElementById( "sub" ).style.visibility = "visible";
	if ( document.all ){
		if( window.firstRun == 1 ){
			document.getElementById( "sub" ).style.top 		= 126 + "px";
		}else{
			document.getElementById( "sub" ).style.top 		= -705 + "px";
			window.firstRun += 1;
		}
	}else{
		document.getElementById( "sub" ).style.top 		= 127 + "px";
		
		if( window.firstRun == 1 ){
			
			document.getElementById( "sub" ).style.top 		= 127 + "px";
		}else{
			document.getElementById( "sub" ).style.top 		= -705 + "px";
			window.firstRun += 1;
		}
	}
	if ( document.all ){
		window.document.subs.SetVariable( "_root.tracker.state", "" );
	}
}


function menuExtra (){
	if ( document.all ){
		document.getElementById( "sub" ).onmouseover = fKeep;
		document.getElementById( "sub" ).onmouseout = fRemove;	
		document.getElementById( "menuProduct" ).parentNode.onmouseover = fKeep ;
		document.getElementById( "menuProduct" ).parentNode.onmouseout = fRemove;
	}
}

function fKeep(){
	window.bKeep = true;
	document.getElementById( "sub" ).style.display = "block"
}

function fRemove(){
	window.bKeep = false;
	setTimeout ( closeParentMenu, 1000 );
}

function findPosY( obj ){
	var curtop = 0;
	if ( obj.offsetParent ){
		while ( obj.offsetParent ){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if ( obj.y )
		curtop += obj.y;
	return curtop;
}

function findPosX( obj ){
	var curleft = 0;
	if ( obj.offsetParent ){
		while ( obj.offsetParent ){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if ( obj.x )
		curleft += obj.x;
	return curleft;
}

window.onresize = function (){
	window.status = document.getElementById( "sub" ).style.left 
	var menu = document.getElementById( "menuProduct" );
	document.getElementById( "sub" ).style.left = findPosX ( menu ) + parseInt ( window.oPos ) - 21  + "px"
}

function testColor (){
	if ( screen.colorDepth == 32 ){
		if ( document.all )	window.document.menuProduct.SetVariable( "_root.tracker.oColorSet", "32" );
	}
}
