//Chrome Drop Down Menu- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated: June 14th, 06' v2.0

var cssdropdown={
disappeardelay: 500, //set delay in miliseconds before menu disappears onmouseout
disablemenuclick: false, //when user clicks on a menu item with a drop down menu, disable menu item's link?
enableswipe: 1, //enable swipe effect? 1 for yes, 0 for no

//No need to edit beyond here////////////////////////
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,

getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10) //unclip drop down menu visibility gradually
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}
else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},

showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)" //hide menu via clipping
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}
else if (e.type=="click")
obj.visibility="hidden"
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null) //hide previous menu
this.dropmenuobj.style.visibility="hidden" //hide menu
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
obj.onclick=function(){return !cssdropdown.disablemenuclick} //disable main menu item link onclick?
this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e)
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
}
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'",this.disappeardelay) //hide menu
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},

startchrome:function(){
for (var ids=0; ids<arguments.length; ids++){
var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
var relvalue=menuitems[i].getAttribute("rel")
menuitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}
}
}
}
}

}



var cloud1Moved = false;
var cloud2Moved = false;
var cloud3Moved = false;
var cloud4Moved = false;
var balloonMoved = false;
var birdMoved = false;
var bird1Moved = false;
var bird2Moved = false;
$(init);

function init()
{
	cloud1Move();
	cloud2Move();
	cloud3Move();
	cloud4Move();
	balloonMove();
	birdMove();
	bird1Move();
	bird2Move();
}

function cloud1Move()
{
	if (!cloud1Moved)
	{
		$("#cloud1")
			.css("left", $("#cloud1").offset().left)
	}
	
	$("#cloud1")
		.animate(
			{
				left: $("#sky").width()
			},
			cloud1Moved ? 180000 : 150000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				
				cloud1Moved = true;
				
				cloud1Move();
			}
		)
}

function cloud2Move()
{
	if (!cloud2Moved)
	{
		$("#cloud2")
			.css("left", $("#cloud2").offset().left)
	}
	
	$("#cloud2")
		.animate(
			{
				left: $("#sky").width()
			},
			cloud2Moved ? 120000 : 60000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				
				cloud2Moved = true;
				
				cloud2Move();
			}
		)
}

function cloud3Move()
{
	if (!cloud3Moved)
	{
		$("#cloud3")
			.css("left", $("#cloud3").offset().left)
	}
	
	$("#cloud3")
		.animate(
			{
				left: $("#sky").width()
			},
			cloud3Moved ? 250000 : 50000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				
				cloud3Moved = true;
				
				cloud3Move();
			}
		)
}

function cloud4Move()
{
	if (!cloud4Moved)
	{
		$("#cloud4")
			.css("left", $("#cloud4").offset().left)
	}
	
	$("#cloud4")
		.animate(
			{
				left: $("#sky").width()
			},
			cloud4Moved ? 300000 : 100000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				
				cloud4Moved = true;
				
				cloud4Move();
			}
		)
}
function balloonMove()
{
	if (!balloonMoved)
	{
		$("#balloon")
			.css("left", $("#balloon").offset().left)
	}
	
	$("#balloon")
		.animate(
			{
				left: $("#sky").width()
			},
			balloonMoved ? 80000 : 200000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				
				balloonMoved = true;
				
				balloonMove();
			}
		)
}

function birdMove()
{
	if (!birdMoved)
	{
		$("#bird")
			.css("left", $("#bird").offset().left)
	}
	
	$("#bird")
		.animate(
			{
				left: $("#sky").width()
			},
			birdMoved ? 80000 : 10000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				
				birdMoved = true;
				
				birdMove();
			}
		)
}

function bird1Move()
{
	if (!bird1Moved)
	{
		$("#bird1")
			.css("left", $("#bird1").offset().left)
	}
	
	$("#bird1")
		.animate(
			{
				left: $("#sky").width()
			},
			bird1Moved ? 50000 : 12000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				
				bird1Moved = true;
				
				bird1Move();
			}
		)
}

function bird2Move()
{
	if (!bird2Moved)
	{
		$("#bird2")
			.css("left", $("#bird2").offset().left)
	}
	
	$("#bird2")
		.animate(
			{
				left: $("#sky").width()
			},
			bird2Moved ? 100000 : 9000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				
				bird2Moved = true;
				
				bird2Move();
			}
		)
}



jQuery(function(){
	   
jQuery("#tab a")
	.css( {backgroundPosition: "right 0"} )
	.mouseover(function(){
		jQuery(this).stop().animate({backgroundPosition:"(right -85px)"}, {duration:400})
	})
	.mouseout(function(){
		jQuery(this).stop().animate({backgroundPosition:"(right 0)"}, {duration:400})
	})
	
				jQuery("#tab a span")
	.css( {backgroundPosition: "left 0"} )
	.mouseover(function(){
		jQuery(this).stop().animate({backgroundPosition:"(0 -85px)"}, {duration:400})
	})
	.mouseout(function(){
		jQuery(this).stop().animate({backgroundPosition:"(left 0)"}, {duration:400})
	})

});



/**
 * @author Alexander Farkas
 * v. 1.02
 */
(function(jQuery) {
	jQuery.extend(jQuery.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = jQuery.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);


/* ------------------------------------------------------------------------
	s3Slider
	
	Developped By: Boban Karišik -> http://www.serie3.info/
        CSS Help: Mészáros Róbert -> http://www.perspectived.com/
	Version: 1.0
	
	Copyright: Feel free to redistribute the script/modify it, as
			   long as you leave my infos at the top.
------------------------------------------------------------------------- */


(function($){  

    $.fn.s3Slider = function(vars) {       
        
        var element     = this;
        var timeOut     = (vars.timeOut != undefined) ? vars.timeOut : 4000;
        var current     = null;
        var timeOutFn   = null;
        var faderStat   = true;
        var mOver       = false;
        var items       = $("#" + element[0].id + "Content ." + element[0].id + "Image");
        var itemsSpan   = $("#" + element[0].id + "Content ." + element[0].id + "Image span");
            
        items.each(function(i) {
    
            $(items[i]).mouseover(function() {
               mOver = true;
            });
            
            $(items[i]).mouseout(function() {
                mOver   = false;
                fadeElement(true);
            });
            
        });
        
        var fadeElement = function(isMouseOut) {
            var thisTimeOut = (isMouseOut) ? (timeOut/2) : timeOut;
            thisTimeOut = (faderStat) ? 10 : thisTimeOut;
            if(items.length > 0) {
                timeOutFn = setTimeout(makeSlider, thisTimeOut);
            } else {
                console.log("Poof..");
            }
        }
        
        var makeSlider = function() {
            current = (current != null) ? current : items[(items.length-1)];
            var currNo      = jQuery.inArray(current, items) + 1
            currNo = (currNo == items.length) ? 0 : (currNo - 1);
            var newMargin   = $(element).width() * currNo;
            if(faderStat == true) {
                if(!mOver) {
                    $(items[currNo]).fadeIn((timeOut/6), function() {
                        if($(itemsSpan[currNo]).css('bottom') == 0) {
                            $(itemsSpan[currNo]).slideUp((timeOut/6), function() {
                                faderStat = false;
                                current = items[currNo];
                                if(!mOver) {
                                    fadeElement(false);
                                }
                            });
                        } else {
                            $(itemsSpan[currNo]).slideDown((timeOut/6), function() {
                                faderStat = false;
                                current = items[currNo];
                                if(!mOver) {
                                    fadeElement(false);
                                }
                            });
                        }
                    });
                }
            } else {
                if(!mOver) {
                    if($(itemsSpan[currNo]).css('bottom') == 0) {
                        $(itemsSpan[currNo]).slideDown((timeOut/6), function() {
                            $(items[currNo]).fadeOut((timeOut/6), function() {
                                faderStat = true;
                                current = items[(currNo+1)];
                                if(!mOver) {
                                    fadeElement(false);
                                }
                            });
                        });
                    } else {
                        $(itemsSpan[currNo]).slideUp((timeOut/6), function() {
                        $(items[currNo]).fadeOut((timeOut/6), function() {
                                faderStat = true;
                                current = items[(currNo+1)];
                                if(!mOver) {
                                    fadeElement(false);
                                }
                            });
                        });
                    }
                }
            }
        }
        
        makeSlider();

    };  

})(jQuery);  
