function gup(name){
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null) 
        return "";
    else 
        return results[1];
}

$(document).ready(function(){

	/* UPDATE - Lurchi Steckbrief - 19.05.2011 */		
	$("div.steckbrief-list").unwrap("div#scrollarea");
	$("div.steckbrief-list").unwrap("div.jScrollPaneContainer");
	/* UPDATE - Ende */


    var $lastImg = 0;
    var $uid = gup('uid');
    $uid = parseInt($uid);
    $start = $uid - 2;
    if ($start < 1) {
        $start = 1
    };
    
    jQuery('#gallery_slide').jcarousel({
        scroll: 1,
        wrap: 'circular',
        visible: '4',
        start: $start
    });
    
    //Detailseite per AJAX laden
    $('img.collection_thumb_detailview').css('visibility', 'visible').each(function(){
        $(this).css('cursor', 'pointer').click(function(e){
        
            var $thisImg = $(this).attr('shoe');
            if ($thisImg != $lastImg) {
                $lastImg = $thisImg;
                $('div.#ajax-content').fadeOut();
                $.post("getAJAXContents.php", {
                    uid: $(this).attr('shoe')
                }, function(data){
					
				    $xpos = e.pageX; 
					if ($xpos > 830 && $xpos < 970){
						$right='190px';
					}else if ($xpos > 640 && $xpos < 790){
						$right='382px';
					}else if ($xpos > 450 && $xpos < 610){
						$right='574px';
					}else if ($xpos > 260 && $xpos < 420){
						$right='756px';
					}else{
						$right = '190px';
					}
						
				  
					$('.footer-kleine-maus').animate({right:$right},1000);
                    $('div.#ajax-content').html(data).fadeIn();
					$('#fade-start-shoes, #fade-start-text').innerfade({
				        animationtype: 'fade',
				        speed: 1200,
						timeout: 4000,
						type: 'sequence'
				    });
					$("a.detail").fancybox({
						hideOnContentClick: true,
						verlayOpacity	: 0.5,
						overlayColor	: '#fffd66'
					});
                });
            }
            
            
        });
    });
    
	//Innerfade Startseite Bilder
    
	$('#fade-start-img').innerfade({
        animationtype: 'fade',
        speed: 1200,
		timeout: 4000,
		containerheight: '460px',
        type: 'sequence'
    });
	/*
	$('#fade-start-shoes').innerfade({
        animationtype: 'fade',
        speed: 1200,
		timeout: 4000,
		type: 'sequence'
    });
    */
	$test = $('#fade-start-text').innerfade({
        animationtype: 'fade',
        speed: 1200,
		timeout: 16000,
		type: 'sequence'
	});
	
	$('#tipp-right').click(function(){
		$('#fade-start-text').innerfade.next;
		
	});
    
	//PDF-Download Malvorlagen
	
	$('img.pdf-malen').each(function(){
		$(this).bind('click',function(){
			window.open($(this).attr('file'));
		}).css('cursor','pointer');
	});
	
	//Lurchi-Heft nachladen
	$('img.img-loading').each(function(){
		$(this).attr('src',$(this).attr('tmp'));
	});
	
	
	
    
});


