var Base = {

	base_path: 'http://www.digitaltherapist.co.uk/builds/',
	
	numberFormat: function(n,places){
	
		var a = Base.roundTo(n,places); 
		var s = a.toString(); 
		
		var decimalIndex = s.indexOf("."); 
		
		if (places > 0 && decimalIndex < 0){ 
		
			decimalIndex = s.length; 
			s += '.';
			 
		}
		
		while (decimalIndex + places + 1 > s.length){
		
			s += '0';
		
		}
		
		return s;
	   
	},
	
	roundTo: function(n,places){
	
  		var m = Math.pow(10, places); 
  		var a = Math.round(n * m) / m;
  		
  		return a;
  		
  	},
	
	validateEmail: function(email){
	
		// get reg exp code from somewhere
	
	},
	
	hyphenSplit: function(value){

		var split = value.indexOf("-");
		var ID = value.substr(split + 1,value.length);
		
		return ID;
	
	},
	
	spaceSplit: function(value){

		var split = value.indexOf(" ");
		var ID = value.substr(split + 1,value.length);
		
		return ID;
	
	},
	
	checkAll: function(){
	
		var cl = this.title;
	
		var classCheckboxes = $("." + cl);
		
		for(var x = 0; x < classCheckboxes.length; x++){
		
			classCheckboxes[x].checked = true;
		
		}
	
	},
	
	unCheckAll: function(){
	
		var cl = this.title;
	
		var classCheckboxes = $("." + cl);
		
		for(var x = 0; x < classCheckboxes.length; x++){
		
			classCheckboxes[x].checked = false;
		
		}
	
	},
	
	cursorPosition: function(event){ 

		if (typeof event == "undefined"){ 
			event = window.event; 
		} 
		
		var scrollingPosition = Base.getScrollingPosition(); 
		var cursorPosition = [0, 0]; 
		
		if (typeof event.pageX != "undefined" && typeof event.x != "undefined"){ 
		
			cursorPosition[0] = event.pageX; 
			cursorPosition[1] = event.pageY; 
			
		}else{ 
		
			cursorPosition[0] = event.clientX + scrollingPosition[0]; 
			cursorPosition[1] = event.clientY + scrollingPosition[1];
			
		} 
		
		return cursorPosition;
	  
	},
	
	
	scrollPosition: function(){
 
		var position = [0, 0];
		
		if(typeof window.pageYOffset != 'undefined'){
		
			position = [ 
				window.pageXOffset, 
				window.pageYOffset 
			];
		
		}else if(typeof document.documentElement.scrollTop != 'undefined' && document.documentElement.scrollTop > 0 || document.documentElement.scrollLeft > 0){ 
		
			position = [ 
				document.documentElement.scrollLeft, 
				document.documentElement.scrollTop 
			]; 
		
		}else if(typeof document.body.scrollTop != 'undefined'){
		
			position = [ 
				document.body.scrollLeft, 
				document.body.scrollTop 
			];
		
		} 
		
		return position; 
	  
	}

}
