$.ifixpng.pixel = '/script/jquery.ifixpng/pixel.gif'
$(function() {


	// Moved from inline in base.mako to here
    $('#search input').liveSearch({
        ajaxURL: '/livesearch?q=',
        width: 300,
        offset_top: 5,
        offset_left: 38,
        onhide: function() {
            $('#eos_menu').removeClass('hide_swf')
            $('#eos_model').removeClass('hide_swf')
        },
        onshow: function() {
            $('#eos_menu').addClass('hide_swf')
            $('#eos_model').addClass('hide_swf')
        },
        html: '<ul><li><span class="text">Skriv för att söka</span></li></ul>'
    })
    
    $('#slideImages a').lightBox({
        overlayOpacity: 0.1,
        imageLoading: '/img/jquery.lightbox-0.5/lightbox-ico-loading.gif',
        imageBtnClose: '/img/jquery.lightbox-0.5/lightbox-btn-close.gif',
        imageBtnNext: '/img/jquery.lightbox-0.5/lightbox-btn-next.gif',
        imageBtnPrev: '/img/jquery.lightbox-0.5/lightbox-btn-prev.gif',
        imageBlank: '/img/jquery.lightbox-0.5/lightbox-blank.gif',
        txtOf: '/',
        txtImage: ''                    
    });
    // $('#slideImages').mouseover(function() {
    //     $('#eos_menu').height(70)
    // })
    $('#eos_menu').mouseover(function() {
        $('#eos_menu').height(350)
    })
    $('#eos_menu').mouseout(function() {
        $('#eos_menu').height(70)
    })                              

    $('#main').setupHyp();            

	// End - Moved from inline in base.mako to here



    // htmlbox
    $('a.case_popup').htmlbox({
        width: null,
        height: null,            
        overlayOpacity: 0.1,
        top: 90,
        navigation: 'text'
    });
    
    // $(function() {
    //     $('.link_to a.eos_function_popup').htmlbox({
    //         width: 990,  // 990
    //         height: 535, // 500            
    //         overlayOpacity: 1,
    //         overlayColor: '#cccccc',
    //         top: 0,
    //         crossfade: '#htmlbox_content .image',
    //         navigation: 'text',
    //         onComplete: function() {
    //             try {
    //                 $('.popup.eos_function .shadow').ifixpng()
    //             } catch(e) {}
    //         }                
    //     });
    //     $('.link_to a.case_popup').htmlbox({
    //         width: null,
    //         height: null,            
    //         overlayOpacity: 0.1,
    //         top: 90,
    //         navigation: 'text'
    //     });
    //     
    // })    
    
    //slideshow
    // if slideshow object found in document
    if ($('.slideShow')[0]) {
        
	
        $('#slideImages').cycle({
            delay: 2000,
    		timeout: 20000,
            speed: 1000,
            prev: '#previous',
            next: '#next',
            before: changeTitle
        });

        // 
        // $('#slideImages a').lightBox({
        //     overlayOpacity: 0.1,
        //     imageLoading: '/img/jquery.lightbox-0.5/lightbox-ico-loading.gif',
        //     imageBtnClose: '/img/jquery.lightbox-0.5/lightbox-btn-close.gif',
        //     imageBtnNext: '/img/jquery.lightbox-0.5/lightbox-btn-next.gif',
        //     imageBtnPrev: '/img/jquery.lightbox-0.5/lightbox-btn-prev.gif',
        //     imageBlank: '/img/jquery.lightbox-0.5/lightbox-blank.gif',
        // });

    }
    
    function changeTitle() {
		var title = this.title;
		// fade out text

		//$('#slideTitle').fadeOut(300);
		$('#slideTitle').hide();
		

		// toggle background

		// update title
		$('#slideTitle').html(title);
		// set new height
		//$('#slideTitleBack').height($('#slideTitle').outerHeight());
		// fade in text
		//$('#slideTitle').fadeIn(800);
		$('#slideTitle').show();
		// toggle background
		$('#slideTitleBack').toggle("slow");
	
    }
    //slideshow end
    
    // swf
    var swfparams = {
    	menu: "false",
    	wmode: "transparent",
    	scale: "noscale",
    	quality: 'high',
    	align: 'middle',
    	play: 'true',
    	loop: 'true',
    	devicefont: 'false',
    	allowFullScreen: 'false',
    	allowScriptAccess: 'sameDomain',
    	movie: 'image',
    	salign: 'lt'
    };    

    
    var loc = window.location.href
    var uri = loc.substr(loc.indexOf('/', loc.indexOf('//') + 2))
    
    // if hypergene_logo object found in document
	if ($('#hypergene_logo')[0]){
	    $.swfobject.embedSWF("/logoanimation.swf", "hypergene_logo", "620", "100", "9.0.0", "", {}, swfparams);
	}
	
    if ($('#eos_model')[0]){
    
        $.swfobject.embedSWF("/EOSBoth.swf", "eos_model", "639", "400", "9.0.0", "", {xmlsrc: '/prod_xml2?uri='+uri, link: uri}, swfparams);
    }   
	if ($('#eos_menu')[0]){
	    swfparams.width = 210
	    swfparams.height = 70
	    $.swfobject.embedSWF("/EOSMenu.swf", "eos_menu", "210", "70", "9.0.0", "", {xmlsrc: '/prod_xml2?uri='+uri, link: uri}, swfparams);
	}  
    // swf end
    
    
    
    
});



$(document).ready(
	function() {
		$("#menu").hypergeneMenu();
	}
);
