var current=0; var changeEvery = 4; function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } function nstest(){ // Hiding all the testimonials, except for the first one. $('#testimonials li').hide().eq(0).show(); // A self executing function that loops through the testimonials: (function showNextTestimonial(){ // Wait for 7.5 seconds and hide the currently visible testimonial: $('#testimonials li:visible').delay(7500).fadeOut('slow',function(){ // Move it to the back: $(this).appendTo('#testimonials ul'); // Show the next testimonial: $('#testimonials li:first').fadeIn('slow',function(){ // Call the function again: showNextTestimonial(); }); }); })(); } $(document).ready(function(){ createSound(); createPage(); nstest(); }); function createPage(){ checkURL(); $('ul li a').click(function (e){ checkURL(this.hash); }); //filling in the default content default_content = $('#pageContent').html(); setInterval("checkURL()",250); } var lasturl=""; function checkURL(hash) { if(!hash) hash=window.location.hash; if(hash != lasturl) { lasturl=hash; // FIX - if we've used the history buttons to return to the homepage, // fill the pageContent with the default_content if(hash=="") $('#pageContent').html(default_content); else loadPage(hash); } } function loadPage(url) { url=url.replace('#',''); $('#loading').css('visibility','visible'); $.ajax({ type: "POST", url: "load_page.php", data: 'page='+url, dataType: "html", success: function(msg){ if(parseInt(msg)!=0) { $('#pageContent').fadeOut('slow', function(){ $('#pageContent').html(msg); $('#pageContent').fadeIn('slow', function(){ current=0; nsGal(); autoAdvance(); $('#menu ul li.menuItem:first').addClass('act').siblings().addClass('inact'); clearInterval(itvl); itvl = setInterval(function(){autoAdvance()},changeEvery*1000); /* Start the sliding animation */ nstest(); }); }); $('#loading').css('visibility','hidden'); //check if the page contains a testimonial or gallery and execute it nstest(); nsGal(); } } }); } function nsGal (){ /* This code is executed after the DOM has been completely loaded */ var totWidth=0; var positions = new Array(); $('#slides .slide').each(function(i){ /* Traverse through all the slides and store their accumulative widths in totWidth */ positions[i]= totWidth; totWidth += $(this).width(); /* The positions array contains each slide's commulutative offset from the left part of the container */ if(!$(this).width()) { alert("Please, fill in width & height for all your images!"); return false; } }); $('#slides').width(totWidth); /* Change the cotnainer div's width to the exact width of all the slides combined */ $('#menu ul li a').click(function(e,keepScroll){ /* On a thumbnail click */ $('li.menuItem').removeClass('act').addClass('inact'); $(this).parent().addClass('act'); var pos = $(this).parent().prevAll('.menuItem').length; $('#slides').stop().animate({marginLeft:-positions[pos]+'px'},450); /* Start the sliding animation */ e.preventDefault(); /* Prevent the default action of the link */ // Stopping the auto-advance if an icon has been clicked: if(!keepScroll) { clearInterval(itvl); } }); $('#menu ul li.menuItem:first').addClass('act').siblings().addClass('inact'); /* On page load, mark the first thumbnail as active */ /***** * * Enabling auto-advance. * ****/ } var itvl = setInterval(function(){autoAdvance()},changeEvery*1000); function autoAdvance() { if(current==-1) return false; $('#menu ul li a').eq(current%$('#menu ul li a').length).trigger('click',[true]); // [true] will be passed as the keepScroll parameter of the click function on line 28 current++; } function createSound(){ $('.item .delete').click(function(){ var elem = $(this).closest('.item'); $.confirm({ 'title' : 'Sound Confirmation', 'message' : 'Do you want to enable background music.
It cannot be restored at a later time! Continue?', 'buttons' : { 'Yes' : { 'class' : 'blue', 'action': function(){ elem.slideUp(); alert("1"); } }, 'No' : { 'class' : 'gray', 'action': function(){} // Nothing to do in this case. You can as well omit the action property. } } }); }); var x = readCookie('nassersound'); if (x) { if (x == "on"){ nsFlash('sound.swf','nsound','90','280','on'); } if (x == "off"){ nsFlash('nosound.swf','nsound','0','0','off'); } }else{ var elem = $(this).closest('.item'); $.confirm({ 'title' : 'Background Music Confirmation', 'message' : 'Do you want to enable background music?', 'buttons' : { 'Yes' : { 'class' : 'blue', 'action': function(){ createCookie('nassersound','on',0); nsFlash('sound.swf','nsound','90','280','on'); } }, 'No' : { 'class' : 'gray', 'action': function(){ nsFlash('nosound.swf','nsound','0','0','off'); createCookie('nassersound','off',0); } // Nothing to do in this case. You can as well omit the action property. } } }); } } function nsFlash(currSWF,curDisplay,curHeight,curWidth,status){ var nsMovie = currSWF; var nsDisplay = curDisplay; var nsWidth = curWidth; var nsHeight = curHeight; var flashObjStr = ''+ ''+ ''+ ''+ ''+ ''+ ''; document.getElementById(nsDisplay).innerHTML = flashObjStr; }