/*
	created by: Klaus Hoermann <klaus@3b-solutions.net>
	created for: Messerer Fahrzeug- und Karosseriebau
	Client: Messerer
	Description: Main Menu JavaScript file
	Copyright: (C) 3B-Solutions Klaus Hoermann 2010
*/

/* uncrypt email adress function*/
function UnCryptMailto(s, shift) 
{
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) 
	{
		n=s.charCodeAt(i); 
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(shift)); 
	}
	return r;
}

/* link to email adress */
function linkTo_UnCryptMailto(s, shift)
{
	location.href=UnCryptMailto(s, shift);
}

// jQuery's noConflict mode is used instead of the $
var J = jQuery.noConflict();

/* when the document is ready */
jQuery(document).ready(function()
{	
	//-----------------------------------------------------------------
	// QTIP
	// set qtip jquery plugin for all titles of links
	//------------------------------------------------------------------
	// REPLACE LINK TITLE TOOLTIPS WITH STYLISH ONES
	J('a[title]').qtip(
	{
		style:
		{
			background: "white",
			color:"#ff0000",
			"font-weight":"bold",
			"font-family":"Verdana, Geneva, sans-serif",
			"font-size":13,
			"text-align":"center",
			border:
			{
				width:2,
				radius:0,
				color:"#0000ff"
			},
			tip: true
		},
		position:
		{
			target: "mouse",
			corner:
			{
				target: "topMiddle",
				tooltip: "bottomMiddle"
			}
		}
	})
	
	//-----------------------------------------------------------------
	// MAIN MENU
	// on hover over a link in a mainmenu list item
	J("ul.mainmenu li a").hover
	(
	 	function() 
		{ 
			// drop down the subnav on click
			J(this).parent().find("ul.subnav").stop().slideDown("3000").show("2500", function()
			{
				J(this).height("auto");
			}); 

			// when the mouse hovers out of the subnav, move it back up
			J(this).parent().hover
			(
			 	// over
		 		function() {}, 
				// out
				function()
				{	
					J(this).parent().find("ul.subnav").stop().slideUp("2500")
				}
			);

		// following events are applied to the trigger (hover events for the trigger)
		}
	)
	.hover
	(
	 	// over
	 	function() { J(this).stop().addClass("subhover"); }, 
		// out
		function() { J(this).stop().removeClass("subhover"); }
	);
	
	//-----------------------------------------------------------------
	// FOOTER IMAGES
	// switch opacity when over or out of the images in the footer
	J(".fadelink img").hover
	(
	 	// over
	 	function() { J(this).animate({opacity: "1"}, "fast"); },
		// out
		function() { J(this).animate({opacity: ".4"}, "fast"); }
	 );
	
	//-----------------------------------------------------------------	
	// SHADOWBOX
	Shadowbox.init({
		handleOversize: "drag",
		modal: false
	});
	
	//-----------------------------------------------------------------	
	// LIGHTBOX 
	/*J("a.lightbox").lightBox(
	{
		txtImage: "Bild",
		txtOf: "von",
		imageLoading: "images/lightbox/lightbox-ico-loading.gif",
		imageBtnClose: "images/lightbox/lightbox-btn-close.gif",
		imageBtnPrev: "images/lightbox/lightbox-btn-prev.gif",
		imageBtnNext: "images/lightbox/lightbox-btn-next.gif",
		imageBlank: "images/lightbox/lightbox-blank.gif"
	}	
	);*/
});
