window.addEvent('domready', function() {  

   // var myMenu = new MenuMatic({ orientation:'horizontal' });			


	 new SmoothScroll({ duration:1500 }, window); //700 milliseconds to get there 
 
	//store titles and text
	$$('a.tipz').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip:title', content[0]);
		element.store('tip:text', content[1]);
	});  
	
	
   
	
	

	//create the tooltips
	var tipz = new Tips('.tipz',{
		className: 'tipz',
		fixed: true,
		offset: {'x':10, 'y':20},
		hideDelay: 50,
		showDelay: 50
	}); 
	  
	tipz.addEvents({
		'show': function(tip) {
			tip.fade('in');
			//tip.setStyle("opacity",".7")
		},
		'hide': function(tip) {
			tip.fade('out');
		}
	});
	
});	
function in_array (needle, haystack, argStrict) { 
	    var key = '', strict = !!argStrict;
	    if (strict) {
	        for (key in haystack) {
	            if (haystack[key] === needle) {
	                return true;
	            }
	        }
	    } else {
	        for (key in haystack) {
	            if (haystack[key] == needle) {
	                return true;
	            }
	        }
	    }

	    return false;
	}     


 //class is in
	var dwProgressBar = new Class({

		//implements
		Implements: [Options],

		//options
		options: {
			container: $$('body')[0],
			boxID:'',
			percentageID:'',
			displayID:'',
			startPercentage: 0,
			displayText: false,
			speed:10
		},

		//initialization
		initialize: function(options) {
			//set options
			this.setOptions(options);
			//create elements
			this.createElements();
		},

		//creates the box and percentage elements
		createElements: function() {
			var box = new Element('div', { id:this.options.boxID });
			var perc = new Element('div', { id:this.options.percentageID, 'style':'width:0px;' });
			perc.inject(box);
			box.inject(this.options.container);
			if(this.options.displayText) { 
				var text = new Element('div', { id:this.options.displayID });
				text.inject(this.options.container);
			}
			this.set(this.options.startPercentage);
		},

		//calculates width in pixels from percentage
		calculate: function(percentage) {
			return ($(this.options.boxID).getStyle('width').replace('px','') * (percentage / 100)).toInt();
		},

		//animates the change in percentage
		animate: function(to) {
			$(this.options.percentageID).set('morph', { duration: this.options.speed, link:'cancel' }).morph({width:this.calculate(to.toInt())});
			if(this.options.displayText) { 
				$(this.options.displayID).set('text', to.toInt() + '%'); 
			}
		},

		//sets the percentage from its current state to desired percentage
		set: function(to) {
			this.animate(to);
		}

	});
	
	
function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

 
	
