var rootUrl; rootUrl='http://menuk.ee'; var $j = jQuery.noConflict(); window.dhtmlHistory.create({ toJSON:function(o) { return JSON.stringify(o);}, fromJSON:function(o) { return JSON.parse;} }); /** Olulised abimuutujad */ var menu=1; var oldmenu=1; var noreload=false; var slideinit=false; var alttimer; var Pages=Array('','menuk_news','menuk_books','menuk_authors','menuk_publisher','menuk_ordering'); var pageLoaded=Array(); var menuUrls=Array(); var slideshowloaded=false; var slideshow2loaded=false; var imgSwap=Array(); var imgSwapBack=Array(); menuUrls['menuk_news']=rootUrl+'/'; menuUrls['menuk_books']=rootUrl+'/raamatud'; menuUrls['menuk_authors']=rootUrl+'/kliendilehed'; menuUrls['menuk_publisher']=rootUrl+'/kirjastus'; menuUrls['menuk_ordering']=rootUrl+'/telli'; //menuUrls['menuk_tv']=rootUrl+'/menutv'; function swapImg(obj) { if (imgSwap[obj.id]) obj.src=imgSwap[obj.id]; } function swapImgBack(obj) { if (imgSwapBack[obj.id]) obj.src=imgSwapBack[obj.id]; } function menukLoad() { dhtmlHistory.initialize(); dhtmlHistory.addListener(historyChange); dhtmlHistory.add('/','/'); menukAjaxUrl(window.location.href,0); return true; } function menukAjaxUrl(base,nohistory) { //alert('tere'); base=base.replace('#',''); base=base.replace('\/ajax',''); endurl=base.substr(rootUrl.length+1); //endurl=endurl.replace(/\//g, "_"); if (!nohistory) dhtmlHistory.add(endurl,base); url1=base+'?/ajaxpage'; $j.get( url1, function(data) { menu=data; //alert(base); //alert(menu); for(var x=1;x<8;x++) { if (x != menu) { $j("#content"+x).parent().addClass('closed'); //$j("#content"+x).css('display','none'); $j("#content"+x).html(''); } $j("#content"+x).parent().removeClass('prevopen'); } //IE hack if (menu==1) { $j('#screen2').css('visibility','visible').fadeIn(150); } else if (menu==3) { $j('#screen3').css('visibility','visible').fadeIn(150); var prevmenu=parseInt(menu)+1; $j("#content"+prevmenu).parent().addClass('prevopen'); } else { var prevmenu=parseInt(menu)+1; $j("#content"+prevmenu).parent().addClass('prevopen'); $j('#screen2').css('visibility','hidden'); $j('#screen3').css('visibility','hidden'); } $j( "#content"+menu ).parent().removeClass('closed'); if ( !slideinit ) { slideMenu.build( 'menuk_slider', 750, 10, 10, menu ); } //comes from backbutton, reopen other slide if needed, don't reload default data url else if( nohistory && oldmenu != menu ) { noreload=true; $j( "#content"+menu ).parent().find( "div:first-child" ).trigger( 'click' ); } url=base+'?/ajax'; //$j("#content"+menu).css('display','block'); $j( "#content"+menu).html('
'); $j("#content"+menu).load(url); if (!slideshow2loaded) { slideshow2loaded=true; loadSlideShow2(); } if (!slideshowloaded) { slideshowloaded=true; loadSlideShow(); } // Hetkel laeme uuesti lehe avamisel // pageLoaded[Pages[menu]]=true; oldmenu=menu; }); // alert( "Ohhoooo" ); } var old_cw = 0; // vajalik slider-i eelmise laiuse hoidmiseks var slideMenu=function(){ var sp, st, t, m, sa, l, w, sw, ot; return{ build:function( sm, sw, mt, s, sl, h ) { sp = s; st = sw; t = mt; slideinit = true; m = document.getElementById( sm ); sa=$j( '.slide' ); l = sa.length; w = m.offsetWidth; sw = w / l; ot = Math.floor( ( w - st ) / ( l - 1 ) ); var i = 0; for( i; i < l; i++ ) { s = sa[i]; s.style.width = sw +'px'; this.timer( s ); } if( sl!=null ){ m.timer = setInterval( function(){ slideMenu.slide( sa[ sl-1 ] ) }, t ) } }, timer:function(s){ //alert( s.id ); $j(s).find(".img").click(function(){ if (s.id=='menuk_ebooks') return true; if (s.id=='menuk_tv') return true; $j(s).children(".frame").removeClass('closed'); //Backbutton slidemise juhtudeks eri case if (!noreload && !pageLoaded[s.id]) { menukAjaxUrl(menuUrls[s.id],0); } else noreload=false; clearInterval(m.timer); m.timer=setInterval(function(){slideMenu.slide(s)},t) }); }, slide:function( s ){ var cw = parseInt( s.style.width, '10' ); if( old_cw != cw ){ // kui vana laius ei= praegune laius var owt = 0; var i = 0; //alert( sa[5].id + " ### " + sa[5].style.width ); for( i; i < l; i++ ) { if( sa[i] != s ) { var o, ow; var oi = 0; o = sa[i]; ow = parseInt( o.style.width,'10' ); switch( i ){ case 0: // "uus" ot = 28; break; case 1: // "raamatud" ot = 34; break; case 2: // "eriprojektid" ot = 54; break; case 3: // "kirjastus" ot = 30; break; case 4: // "kuidas tellida" ot = 42; break; case 5: // "eRaamatud" ot = 36; break; case 6: // "menutv" ot = 27; break; default: // vaikimisi on suletud slider'i laiuseks 54 px ot = 54; break; } if( ow > ot ) { oi = Math.floor( ( ow-ot ) / sp ); oi = ( oi > 0 ) ? oi : 1; o.style.width = ( ow - oi ) + 'px' } owt = owt + ( ow - oi ) } } old_cw = cw; // omistame vanale laiusele väärtuse enne uue arvutamist s.style.width = ( w - owt ) + 'px'; } else { clearInterval(m.timer); clearInterval(alttimer); old_cw = 0; } } }; }(); function slideDiv( s ) { // $j( '#menuk_news_frame' ).addClass( 'closed' ); $j( '# '+ s.id + '_frame' ).removeClass( 'closed' ); clearInterval( alttimer ); alttimer = setInterval( function(){ slideMenu.slide( s ) }, 5 ); } function historyChange(newLocation, historyData) { menukAjaxUrl(historyData,1); } /*opacity*/ function SetOpacity(elem, opacityAsInt) { var opacityAsDecimal = opacityAsInt; if (opacityAsInt > 100) opacityAsInt = opacityAsDecimal = 100; else if (opacityAsInt < 0) opacityAsInt = opacityAsDecimal = 0; opacityAsDecimal /= 100; if (opacityAsInt < 1) opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0 elem.style.opacity = (opacityAsDecimal); elem.style.filter = "alpha(opacity=" + opacityAsInt + ")"; } /** Slideshow asjad */ function loadSlideShow() { $j('#slideshow').serialScroll({ items:'li', prev:'#slideprevbutton', next:'#slidenextbutton', offset:0, //when scrolling to photo, stop 230 before reaching it (from the left) start:0, //as we are centering it, start at the 2nd duration:500, force:true, step:3, stop:true, exclude: 5, lock:false, cycle:null, //don't pull back once you reach the end //easing:'easeOutQuart', //use this easing equation for a funny effect jump: null //click on the images to scroll to them }); $j('#screen2').css('visibility','visible'); } function loadSlideShow2() { $j('#slideshow2').serialScroll({ items:'li', prev:'#slideprev', next:'#slidenext', offset:0, //when scrolling to photo, stop 230 before reaching it (from the left) start:0, //as we are centering it, start at the 2nd duration:500, force:true, step:3, stop:true, exclude: 5, lock:false, cycle:null, //don't pull back once you reach the end //easing:'easeOutQuart', //use this easing equation for a funny effect jump: null //click on the images to scroll to them }); $j('#screen3').css('visibility','visible'); } var player; var firstoverlay=true; function showVideo(video) { //first hack, twice first time, otherwise not loading if (firstoverlay) { firstoverlay=false; showVideo(video); } $j('#player').attr('href',video); player = $f("player", rootUrl+"/flowplayer.unlimited-3.1.5.swf"); var ol=$j("#overlay").overlay({ expose: '#fff', effect: 'apple', onLoad: function() { player.load(); }, onClose: function() { if (player.unload()) { $j('#player').attr('href','#'); } player = undefined; } }); ol.load(); } function showUrl(url) { //horrible hack - do it twice first time, otherwise not working if (firstoverlay) { firstoverlay=false; showUrl(url); } if ($j("#overlay_url .contentWrap").load(url)) { $j("#overlay_url").overlay({ expose: '#FFF', effect: 'apple', onClose: function() { // grab wrapper element inside content var wrap = this.getContent().find(".contentWrap"); // load the page specified in the trigger wrap.innerHTML=''; } }).load(); } }