var Base = {

	show_commands: false,
	base_path: 'http://www.dtne.org.uk/',
	email_filter: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
	
	init: function(){
	
		
	
	},
	
	blurThis: function(){
	
		this.blur();
	
	},
	
	test: function(){
	
		alert('base test');
	
	},
	
	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;
	
	},
	
	hyphenSplit2: function(value){

		var split = value.indexOf("-");
		
		var values = new Array();
		values[0] = value.substr(0,split);
		values[1] = value.substr(split + 1,value.length);
		
		return values;
	
	},
	
	spaceSplit: function(value){

		var split = value.indexOf(" ");
		var ID = value.substr(split + 1,value.length);
		
		return ID;
	
	},
	
	spaceSplit2: function(value){

		var split = value.indexOf(" ");
		
		var values = new Array();
		values[0] = value.substr(0,split);
		values[1] = value.substr(split + 1,value.length);
		
		return values;
	
	},
	
	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; 
	  
	}

}

$(document).ready(Base.init);
