function splashscreen(area, settings, repeat) {
	$(document).ready(function(){
		var a = document.cookie;
		var cookiename = a.substr(0,a.search('='));
		if(cookiename != "splash") {
			// Calling our splashScreen plugin and
			// passing an array with images to be shown
			$('#' + area).splashScreen(settings, new Boolean(true));
			document.cookie = 'splash=true;';
		}
		document.getElementById(area).style.visibility = 'hidden';
		document.getElementById(area).style.height = 0;
		document.getElementById(area).style.width = 0;
	});
}

function boarding(area, settings) {	
			$(document).ready(function(){
				$('#' + area).airport(settings);
			});	
}

function initCollapsingMenu(menuId) {
  $(document).ready(function() {
	$('#' + menuId + ' ul').hide();
	$('#' + menuId + ' li a').click(
		function() {
			$(this).next().slideToggle('normal');	
		});
  });
}

function canimateAnimation(area, totalframes, prefix, fps, preload) {
$(document).ready(function(){
		
			$('.' + area).canimate({
				totalFrames: totalframes,
				imagePrefix: prefix,
				fps: fps,
				preload:preload
			});
			
});
}

function initAccordionMenu(menuId) {
	$(document).ready(function() {
		$('#' + menuId + ' ul').hide();
		$('#' + menuId + ' ul:first').show();
		$('#' + menuId + ' li a').click(
		function() {
			var checkElement = $(this).next();
			if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
				return false;
			}
			if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
				$('#' + menuId + ' ul:visible').slideUp('normal');
				checkElement.slideDown('normal');
				return false;
			}
		});
	});
 }
 
 function bubbleInfo() {
	$(function () {
        $('.bubbleInfo').each(function () {
            var distance = 10;
            var time = 250;
            var hideDelay = 500;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger', this);
            var info = $('.popup', this).css('opacity', 0);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;

                    info.css({
                        top: -90,
                        left: -33,
                        display: 'block'
                    }).animate({
                        top: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        top: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
        });
    });
}

function clock() {
        $(document).ready(function() {
              setInterval( function() {
              var seconds = new Date().getSeconds();
              var sdegree = seconds * 6;
              var srotate = "rotate(" + sdegree + "deg)";
              
              $("#sec").css({"-moz-transform" : srotate, "-webkit-transform" : srotate});
                  
              }, 1000 );
              
         
              setInterval( function() {
              var hours = new Date().getHours();
              var mins = new Date().getMinutes();
              var hdegree = hours * 30 + (mins / 2);
              var hrotate = "rotate(" + hdegree + "deg)";
              
              $("#hour").css({"-moz-transform" : hrotate, "-webkit-transform" : hrotate});
                  
              }, 1000 );
        
        
              setInterval( function() {
              var mins = new Date().getMinutes();
              var mdegree = mins * 6;
              var mrotate = "rotate(" + mdegree + "deg)";
              
              $("#min").css({"-moz-transform" : mrotate, "-webkit-transform" : mrotate});
                  
              }, 1000 );
         
        }); 
}

function movingText(container, marginLeft, interval) {
$(document).ready(function(){

	$('.' + container + ' .flying-text').css({opacity:0});
	$('.' + container + ' .active-text').animate({opacity:0.6, marginLeft: marginLeft}, 4000);

	var int = setInterval(changeText, interval);	


function changeText(){

	var jQueryactiveText = $("." + container + " .active-text");	
	
	var jQuerynextText = jQueryactiveText.next(); 
	if(jQueryactiveText.next().length == 0) jQuerynextText = $('.' + container + ' .flying-text:first');
	
	jQueryactiveText.animate({opacity:0}, 1000);
	jQueryactiveText.animate({marginLeft: "-100px"});
		
	jQuerynextText.css({opacity: 0}).addClass('active-text').animate({opacity:0.6, marginLeft: marginLeft}, 4000, function(){
		
		jQueryactiveText.removeClass('active-text');
	});
}
});
}



function rotateImage(image, url) {
	drawCanvas(image, url);
}

function flipImages(element, bgcolor) {
	(function($){
      $(function(){
        $("#" + element).jFlip(300,300,{background:bgcolor,cornersTop:false}).
        bind("flip.jflip",function(event,index,total){
          $("#l1").html("Image "+(index+1)+" of "+total);
        });
        $("#g2").jFlip(300,300,{background:bgcolor,cornersTop:true,scale:"fit"});
        $("#g3").jFlip(300,300,{background:bgcolor,cornersTop:true,scale:"fill"});
      });
  })($);
}

function thumbhover() {
	$(function(){
		$("img[src*='_s.jpg']").thumbPopup({
			imgSmallFlag: "_s",
			imgLargeFlag: "_l"
		});
	});
}
