var Base = {

	base_path: '',
	
	init: function(){
	
		
	
	},
	
	blurThis: function(){
	
		this.blur();
	
	},
	
	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;
	
	},
	
	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);

var colour;

var MainPics = {

	init: function(){
	
		var mainPicSwapLinks = $(".mainPicSwapLink");
		
		if( mainPicSwapLinks.length > 0 )
		{
			colour = $("#isl-1").attr('class').split(' ')[0];
		
			for(var x = 0; x < mainPicSwapLinks.length; x++){
		
				$(mainPicSwapLinks[x]).click(MainPics.swap);
		
			}
		}
	},
	
	swap: function(){

		MainPics.unPink(colour);
	
		$(this).addClass(colour);
	
		var swapID = Base.hyphenSplit(this.id);
		
		MainPics.hideAll();
		
		MainPics.showPic(swapID);
	
	},
	
	hideAll: function(){
	
		var main_pics = $(".main_pic");
		
		for(var x = 0; x < main_pics.length; x++){
		
			$(main_pics[x]).hide();
		
		}
	
	},
	
	showPic: function(id){
	
		var picRef = "#mp-" + id;
		
		num = id - 1;
		
		if( document.getElementById( 'mpa-' + num ).href.length == 0 )
		   document.getElementById( 'mpa-' + num ).href = "http://www.whowithwhat.com/company/Login.php?keepThis=true&TB_iframe=true&height=350&width=191";
		
		document.getElementById( 'mpa-main' ).href = document.getElementById( 'mpa-' + num ).href;
		document.getElementById( 'mpa-main' ).title = document.getElementById( 'mpa-' + num ).title;
		$(picRef).show();
	
	},
	
	unPink: function(){
	
		var mainPicSwapLinks = $(".mainPicSwapLink");
		
		for(var x = 0; x < mainPicSwapLinks.length; x++){
		
			if($(mainPicSwapLinks[x]).hasClass(colour)){
		
				$(mainPicSwapLinks[x]).removeClass(colour);
			
			}	
		
		}
	
	}

}

$(document).ready(MainPics.init);



var IE = {

	init: function(){
	
		$("#page").css("padding-top","5px");
	
	}

}

if($.browser.msie){
	$(document).ready(IE.init);
}


