// JavaScript Document

startPos = navigator.appVersion.indexOf('MSIE') + 5
version = navigator.appVersion.substring(startPos, startPos + 1)

NS = (document.layers) ? 1 : 0
IE = (document.all) ? 1: 0
isMac = navigator.userAgent.indexOf('Mac') > 0

self.onError=null
var menuY = 0, menuX, scrolling = false, showCartContent = false
var firstTime = true, firstScroll = true
var g_bResize = false
var g_bFirstLoad = true
var g_idAction, g_idActionScroll
function getWinWidth()
{

  if (document.layers)
    return(window.innerWidth);
  else if (document.all)
    return(document.body.clientWidth);
  else
    return(null);
}

function getWinHeight()
{

  if (document.layers)
    return(window.innerHeight);
 else if (document.all)
    return(document.body.clientHeight);
  else
    return(null);
}


function smoothscrollMenu()
{		
	if(!(IE || NS)) return
	var sTop = IE? document.body.scrollTop: self.pageYOffset

	if(IE && !isMac && (version >= 5))
	{
	  if(firstScroll || g_bResize)
	  { 
		MENUTOP = 134;		
	    menuY -= MENUTOP		
	    firstScroll = false
		g_bResize = false;
	  }
	}
	else
	{
	  if(firstScroll || g_bResize)
	  { 
		MENUTOP = 134;		
	    menuY -= MENUTOP		
	    firstScroll = false
		g_bResize = false;
	  }
	}
	if(sTop != menuY)
	{
	    scrolling = Math.abs(sTop - menuY) > 2 //** Threshold for stopping scroll fucnt

		var move = 0.1 * (sTop - menuY) //** Velocity depends on the gap
		if(move > 0)
		{	
			move = Math.ceil(move);
			if(IE){ 
          		document.all.theArtist.style.pixelTop += move;
			}
		    else { 
				document.theArtist.top += move;
			}
  		    menuY += move;
  		}   
    	else //if(move > 0)
  		{
  		 move = Math.floor(move)
  		 var d = IE? document.all.theArtist.style.pixelTop: document.theArtist.top
  		 if((d + move) > MENUTOP )
  		 {
  			if(IE){
				document.all.theArtist.style.pixelTop += move				
			}
  			else {
				document.theArtist.top += move				
			}
  		 }
  		 menuY += move
  		}
    } 
    else //if(sTop != menuY)
    {
     if(showCartContent)
      {
       showCallout(2, 'gpcart')
       showCartContent = false
      }
     scrolling = false
     //window.clearInterval(g_idActionScroll);  // Stop action interval
    }
}
function moveFromBelow()
{ 	
  var fMove
  var iStop = IE? document.body.scrollTop: self.pageYOffset
  menuX = ((getWinWidth() - 760)/2);	
  if(NS) menuX -= 16;
  // alert ('menuY =' + menuY + 'iStop ='+iStop);
  fMove = Math.ceil(0.1 * (menuY-iStop));
  if (Math.abs(menuY - iStop) > 2)
  {if(IE){ 
  		document.all.theArtist.style.pixelTop -= fMove;
    }
   else {
    	document.theArtist.top -= fMove;
    }
   menuY -= fMove;
  }
  else
	window.clearInterval(g_idAction);  
}
function setXPos()
{   	
	if(!(IE || NS)) return;
    if (IE && g_bFirstLoad)
	    { 		
		 menuX = ((getWinWidth() - 760)/2);	
		 menuY = (getWinHeight());
		 g_idAction = window.setInterval("moveFromBelow()",5);
		 g_bFirstLoad = false;
		 }
	else
		if (IE)
		{
			 menuX = ((getWinWidth() - 760)/2);	
			 menuY = (getWinHeight());
		}

	if (NS)
	{
		menuX = ((window.innerWidth-760)/2);	
		menuY = (window.innerHeight-48);
	}
	
	if (getWinWidth() < 760)
	{	
		menuX = 0;
	}

	if(IE)
		{		
			document.all.theArtist.style.pixelLeft = (menuX + 10)
			document.all.theArtist.style.pixelTop = (menuY)	
			document.all.theArtist.style.visibility = "visible"	
			document.all.lyExh.style.pixelLeft = (menuX + 472)
		} 
	else
		{	
			document.theArtist.left = (menuX)
			document.theArtist.top = (menuY)
			document.theArtist.visibility = "show"
			document.lyExh.left = (menuX + 472)

		}


	if(firstTime)
	{	
		if(NS || IE) g_idActionScroll = window.setInterval("smoothscrollMenu()", 1)
		firstTime = false
	}
}