	
	$(document).ready(function() {
		if (navigator.userAgent.indexOf("1.0") > 0) {
		    document.getElementById("wrapper").style.position="static";
		}
		
	    $('.bestellenicon,.bestellenbutton,.top_bestellenicon').parents('form').ajaxForm(); 
		 			
		$('.bestellenicon,.bestellenbutton,.top_bestellenicon, a').mouseover(
			//function() { $(document).trigger('hideCluetip'); }
		);
				
		$('#content').scroll(
			function() { $(document).trigger('hideCluetip'); }
		);				
		
		$('.smallbook_top a.vorschau').cluetip({
			width: '200',
			sticky: false,
			mouseOutClose: true,
			splitTitle: '|',			
			showTitle: false,
			attribute: 'rel',
			titleAttribute:   'rel',
			topOffset: 20,
			cluetipClass: 'topbooks',
			leftOffset: -20,
			positionBy: 'bottomTop'
		});
		
	    $('.bestellenicon,.bestellenbutton,.top_bestellenicon').cluetip({
			activation: 'click',
			width: 210, 
			mouseOutClose: true,
			sticky: true,
			showTitle: false,
			attribute: 'rel',
			titleAttribute:   '',
			cluetipClass: 'default',
			closeText: '',
			/*
			fx: {
				open: 'fadeIn',
				openSpeed: 'fast'
			},
			*/			
			onActivate: function(e) { 
				$('.topbooks, button').css('cursor','wait'); 
				$('.smallbook, button').css('cursor','wait'); 
				return true;
			},			
			onShow: function(ct,c) {	
				$('#warenkorb_icon').attr('src', ROOT_URL + 'images/warenkorb_01.gif');
				var response = $(this).parents('form').ajaxSubmit({
					target: '#warenkorb_contents',
					url:    ROOT_URL + 'scripts/warenkorb/warenkorb_ajax.php'
				});
				var loc = "" + document.location;
				if (loc.indexOf("warenkorb") > 0) {
					setTimeout("document.location.reload()", 1000);
				}
				$('.smallbook, button').css('cursor','auto');				
			}
		});

		
		$('li.navitem').mouseenter( 
			function() {
				$(this).find('ul').css('display', 'block');
				$(this).mouseleave( 
					function() {
						$(this).find('ul').css('display', 'none');
					}
				);				
			}
		);
	});     

        function display(elt, display) {
            value = display == true ? 'block' : 'none';
            $(elt).find('ul:first').css('display', value);
            return false;
        }


	/**
	*
	*  Javascript cookies
	*  http://www.webtoolkit.info/
	*
	**/
	function CookieHandler() {
		this.setCookie = function(name, value, seconds) {
		    if (typeof(seconds) != 'undefined') {
				var date = new Date();
				date.setTime(date.getTime() + (seconds*1000));
				var expires = "; expires=" + date.toGMTString();
		    } else {
				var expires = "";
		    }
		    document.cookie = name+"="+value+expires+"; path=/";
		}

		this.getCookie = function(name) {
		    name = name + "=";
		    var carray = document.cookie.split(';');
		    for(var i=0;i < carray.length;i++) {
				var c = carray[i];
				while (c.charAt(0)==' ') c = c.substring(1, c.length);
				if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
				}
		    return null;
		}
		this.deleteCookie = function (name) {
		    this.setCookie(name, "", -1);
		}
	}

	var cookiehandler = new CookieHandler();
	function gotoReferrer() {
	    referrer = cookiehandler.getCookie("referrer");
	    document.location.href = referrer;
	}

	function openaudio(popup) {
	   var audiowindow = window.open(popup, "Hoerprobe", "width=350,height=400,left=100,top=200");
	   audiowindow.focus();
	}

	function openetext(popup) {
	   var etextwindow = window.open(popup, "E-Text", "width=760,height=700,left=50,top=20");
	   etextwindow.focus();
	}

	function openvideo(popup) {
	   var videowindow = window.open(popup, "Video", "width=420,height=500,left=100,top=200");
	   videowindow.focus();
	}   

		

