	
	var bgImgPos = 1, bgImgMax = 5, prefix = 'bg';
		
	function bgPhotoChange( direction ){
		++bgImgPos;
		if( bgImgPos > bgImgMax ) bgImgPos = 1;
		$("#bgImg").attr("src", "images/bg/"+ prefix + bgImgPos +".jpg");
	}
	
	
	function bgPhotoChange_auto(){
		if( bgImgPos > bgImgMax ) bgImgPos = 1;
		bgPhotoChange('next');
	}
	
	
	var imgSel = 1;
	
	function changeImg( direction, max ){

		var curImg = 0;
		if( direction == 'next' && imgSel < max ){ curImg = imgSel + 1; }
		if( direction == 'prev' && imgSel > 1 ){ curImg = imgSel - 1; }
		
		if( curImg != 0 ){
			$("#photo" + imgSel).fadeOut( 2200 );
		    $("#photo" + curImg).fadeIn( 1000 );
			imgSel = curImg;
		}
	}
	
	
	// TOOLTIP
	
	this.tooltip = function(){	
		/* CONFIG */		
			xOffset = 5;
			yOffset = 15;			
		$("a.tooltip").hover(function(e){											  
			this.t = this.title;
			this.title = "";									  
			$("body").append("<p id='tooltip'>"+ this.t +"</p>");
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");		
	    },
		function(){
			this.title = this.t;		
			$("#tooltip").remove();
	    });	
		$("a.tooltip").mousemove(function(e){
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px");
		});			
	};



	// starting the script on page load
	$(document).ready(function(){
		tooltip();
	});
	
	
	function setCookie(c_name,value,expiredays){
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
	}
	
	
	function getCookie(c_name){
		if (document.cookie.length>0)
		  {
		  c_start=document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1)
		    {
		    c_start=c_start + c_name.length+1;
		    c_end=document.cookie.indexOf(";",c_start);
		    if (c_end==-1) c_end=document.cookie.length;
		    return unescape(document.cookie.substring(c_start,c_end));
		    }
		  }
		return "";
	}
	
