﻿	$(document).ready(function() {
			$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

	$("ul.topnav li span").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});
//Details popup
$(".details-popup a").hover(function() {
$(this).next("div").stop(true, true).animate({opacity: "show", top: "-60"}, "slow");
}, function() {
$(this).next("div").animate({opacity: "hide", top: "-70"}, "fast");
});	
		
});

function showBubble(e,text1){
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < 500);

	if(document.all)e = event;
	
	var obj = document.getElementById('bubble_tool');
	var objImg = document.getElementById('img_' + text1);
	var tmpString = null;
	
	document.getElementById('ProductTitle_popup').innerHTML = document.getElementById('prodTitle_' + text1).innerHTML;
	if(document.getElementById('AuthorHidden_' + text1) != null)
	{
		document.getElementById('lblAuthor_popup').innerHTML = document.getElementById('AuthorHidden_' + text1).value;
	}
	if(document.getElementById('DescriptionHidden_' + text1) != null)
	{
		document.getElementById('lblDescription_popup').innerHTML = document.getElementById('DescriptionHidden_' + text1).value;
	}
	
	if(document.getElementById('UPCHidden_' + text1) != null)
	{
		tmpString = document.getElementById('UPCHidden_' + text1).value;
		document.getElementById('lblUPCText').innerHTML = 'UPC:&nbsp;';
		document.getElementById('lblUPC').innerHTML = tmpString;
	}
	
	tmpString = document.getElementById('ISBN10Hidden_' + text1).value.trim();
	document.getElementById('lblISBN10Text').innerHTML = 'ISBN 10:&nbsp;';
	document.getElementById('lblISBN10').innerHTML = tmpString;
	
	tmpString = document.getElementById('ISBN13Hidden_' + text1).value.trim();
	document.getElementById('lblISBN13Text').innerHTML = 'ISBN 13:&nbsp;';
	document.getElementById('lblISBN13').innerHTML = tmpString;
		
	if(document.getElementById('lblTerritoryText') != null && document.getElementById('IsDealerHidden').value)
	{
		tmpString = document.getElementById('TerritoryHidden_' + text1).value;
		if(tmpString.length > 0)
		{
			document.getElementById('lblTerritoryText').innerHTML = 'Territory:&nbsp;';
			document.getElementById('lblTerritory').innerHTML = tmpString;
		}
	}
	
	if(document.getElementById('lblCategoryText') != null)
	{
		tmpString = document.getElementById('CategoryHidden_' + text1).value;
		if(tmpString.length > 0)
		{
			document.getElementById('lblCategoryText').innerHTML = 'Category:&nbsp;';
			document.getElementById('lblCategory').innerHTML = tmpString;
		}
	}
	
	if(document.getElementById('lblStatusText') != null && document.getElementById('IsDealerHidden').value)
	{
		tmpString = document.getElementById('StatusHidden_' + text1).value;
		if(tmpString.length > 0)
		{
			document.getElementById('lblStatusText').innerHTML = 'Status:&nbsp;';
			document.getElementById('lblStatus').innerHTML = tmpString;
		}
	}
	
	if(document.getElementById('lblVersionText') != null)
	{
		tmpString = document.getElementById('VersionHidden_' + text1).value;
		if(tmpString.length > 0)
		{
			document.getElementById('lblVersionText').innerHTML = 'Version:&nbsp;';
			document.getElementById('lblVersion').innerHTML = tmpString;
		}
	}
	
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	
	//get position
	var curleft = curtop = 0;
	if (objImg.offsetParent)
	{
		do {
			curleft += objImg.offsetLeft;
			curtop += objImg.offsetTop;
		}while(objImg = objImg.offsetParent);
	}
	
	var leftPos = curleft + 90;
	if(getWidth()/2 < curleft)
	{
		leftPos = curleft - 360;
	}
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	
	var topPos = curtop - getScrollY();
	if(obj.clientHeight + topPos > getHeight())
	{
		topPos = getHeight() - obj.clientHeight;
	}
	if(topPos < 0) topPos=0;
	obj.style.top = topPos + getScrollY() + 'px';
	//window.alert(objImg.offsetLeft);
	//obj.style.top = e.clientY - obj.offsetHeight -70 + st + 'px';
}	

function hideBubble()
{
	document.getElementById('bubble_tool').style.display = 'none';
	
}

function getWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  //window.alert( 'Width = ' + myWidth );
  return myWidth;
}

function getHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Height = ' + myHeight );
  return myHeight;
}

function getScrollY()
{
	var scrOfY = 0;

if( typeof( window.pageYOffset ) == 'number' )
{
	//Netscape compliant
	scrOfY = window.pageYOffset;
} else if( document.body && document.body.scrollTop) {
	//DOM compliant
	scrOfY = document.body.scrollTop;
} else if( document.documentElement && document.documentElement.scrollTop) {
	//IE6 standards compliant mode
	scrOfY = document.documentElement.scrollTop;
}
return scrOfY ;
}

function popupWindowPlayer(url) {  
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=360,height=220,screenX=150,screenY=150,top=150,left=150') ;
}