// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.



var IE = false;
var xVersatz = 80;
var yVersatz = -150;

if (document.layers)	{document.captureEvents(Event.MOUSEMOVE);}
else if (document.all)  {var IE = true;document.onmousemove = getMouseXY;}
document.onmousemove = getMouseXY;

// Maus Pos ermitteln
function getMouseXY(e)
{
	if (IE)
	{ 
		// default
		tempX = event.clientX + document.body.scrollLeft + xVersatz;
		tempY = event.clientY + document.body.scrollTop + yVersatz;

		if (document.documentElement && !document.documentElement.scrollTop)// IE6 +4.01 but no scrolling going on
		{
			tempX = event.clientX + document.body.scrollLeft + xVersatz;
			tempY = event.clientY + document.body.scrollTop + yVersatz;
		}
		else if (document.documentElement && document.documentElement.scrollTop)// IE6 +4.01 and user has scrolled 
		{
			tempX = event.clientX + document.documentElement.scrollLeft + xVersatz;
			tempY = event.clientY + document.documentElement.scrollTop + yVersatz;
		}
		else if (document.body && document.body.scrollTop)	// IE5 or DTD 3.2 					
		{}
	}
	else
	{ 
		// x-y pos.s NS
		tempX = e.pageX + xVersatz;
		tempY = e.pageY + yVersatz;
	}  

	//return (e.pageX + 80);
	if(tempX > 800)
	{
		tempX = tempX-550;
	}
	
	var tempXY = new Array();
	tempXY[0]=tempX;
	tempXY[1]=tempY;
	return (tempXY);
}


$(document).ready (
	function()
	{
		// s. Ticket #42, #61
	
		$("a[@class='imagesnap']").hover(function(e)
		{
			trgt = $(e.target).is("a") ? $(e.target) : $(e.target).parents("a");
			
			all_attribute	= trgt.attr("rel");
			attribute_array = all_attribute.split('#');

			/*
			Zeige Jahresabopreis
			html	= "<div id='ttimagesnap' class='imagehover_style'>"
						+ "<img src='" + attribute_array[0] + "' border='0' />"
						+ "<table>"
							+ "<tr valign='top'><td colspan=\"2\"><strong>"+attribute_array[1]+"</strong></td></tr>"
							+ "<tr valign='top'><td>Erscheinungsweise:</td><td align=\"right\">"+attribute_array[2]+"</td></tr>";
			if ( attribute_array[3] != '' )
				html += "<tr valign='top'><td>Laufzeit:</td><td align=\"right\">"+attribute_array[3]+"</td></tr>"
			html += "<tr valign='top'><td>"+attribute_array[8]+"</td><td align=\"right\">"+attribute_array[7]+"<br />(inkl. Versandkosten)</td></tr>"
							+ "<!--<tr><td>Jahresbezugspreis:</td><td align=\"right\">"+attribute_array[4]+"</td></tr>-->"
							+ "<!--<tr><td>Ersparnis Kioskpreis:</td><td align=\"right\">"+attribute_array[5]+"</td></tr>-->"
							+ "<!--<tr><td>1 Monat gratis bei Bankeinzug:</td><td align=\"right\">"+attribute_array[6]+"</td></tr>-->"
							+ "<!--<tr><td colspan=\"2\"><hr>&nbsp;</hr></td></tr>-->"
							+ "<!--<tr><td><h2>Ihr Vorteilspreis:</h2></td><td align=\"right\"><h2>"+attribute_array[7]+"</h2></td></tr>-->"
						+ "</table>"
					+ "</div>";
			*/

			html	= "<div id='ttimagesnap' class='imagehover_style'>"
						+ "<img src='" + attribute_array[0] + "' border='0' />"
						+ "<table>"
						+ "<tr valign='top'><td colspan=\"2\"><strong>"+attribute_array[1]+"</strong></td></tr>"
						+ "<tr valign='top'><td>Erscheinungsweise:</td><td align=\"right\">"+attribute_array[2]+"</td></tr>";

			if (( attribute_array[9].length > 3 ) && ( attribute_array[9].length < 22 ))
				// Zeige Preis
				html	+= "<tr valign='top'><td>Abopreis:</td><td align=\"right\">"+attribute_array[9]+"<br />(inkl. Versandkosten)</td></tr>"
			else if ((attribute_array[10] != null) && (attribute_array[10] != ''))
				// Zeige Zuzahlung/Wertigkeit und Beschreibung
				html	+= "<tr valign='top'><td><strong>"+attribute_array[10]+"</strong>:</td><td align=\"right\"><strong>"+attribute_array[11]+"</strong></td></tr><tr valign='top'><td colspan=\"2\">"+attribute_array[9]+"</td></tr>"
			else
				// Zeige Beschreibung
				html	+= "<tr valign='top'><td colspan=\"2\">"+attribute_array[9]+"</td></tr>"

			html += "</table>"
					+ "</div>";
			$(html).appendTo("body");

			// XY-Position abfragen
			var xy = getMouseXY(e);

			$('#ttimagesnap').css(
				{
					left: xy[0] + 'px',
					top:  xy[1] + 'px'
				}
			);

			$('#ttimagesnap').show();
			
		},function(e) { $('#ttimagesnap').remove(); });

	}
);


/**
 * MouseOver-Layer für die Zeitschriften-Rubriken-Liste 
 */
$(document).ready(function(){
	$("div[@class='zeitschriften_layer']").mouseover(function(e){
		 $(this).css({"background":"url('../gfx/ci/zeitschriftenseiten/bg_zeitschriftenliste.gif') no-repeat"});
	});
});

/**
 * MouseOut-Layer für die Zeitschriften-Rubriken-Liste 
 */
$(document).ready(function(){
	$("div[@class='zeitschriften_layer']").mouseout(function(e){
		 $(this).css({"background":"#fff"});
	});
});
