// JavaScript Document
$(document).ready(function(){
						   
	var safari = $.browser_detect('safari');
	var firefox = $.browser_detect('firefox');
	var firefox3 = $.browser_detect('firefox',3);
	var chrome = $.browser_detect('chrome');
	var ie = $.browser_detect('ie');
	var ie6 = $.browser_detect('ie',6);
	var ie7 = $.browser_detect('ie',7);
	var ie8 = $.browser_detect('ie',8);
	
	//	 set styles for different browsers
	
	if(firefox){
		
	}
	
	//	Go to top of page
	
	$('#to_top').click(
					   
				function(){
						to_top('#top');
						return false;
	});
	
	
	// Insert email to protect against spam botties !!!
	
	var emailE = ('info@' + 'yogabirthsheffield.co.uk');
	var emailTo = ('info@' + 'olivialester.com');	//	yogabirthsheffield.co.uk  info@olivialester.co.uk
	$('#insert_email').html('<a href="mailto:' + emailE + '">' + emailE + '</a>');
	
						   
						   
});






//	Mouse over event

function over(event){
	$(this).find('a').css({'color':'#F30'});
}

//	Mouse out event

function out(event){
	$(this).find('a').css({'color':'#999'});
}


// function to move to top of page


function to_top(el){
	  var target_offset = $(el).offset();
      var target_top = target_offset.top;
	  $('html, body').animate({scrollTop:target_top}, 500);
}

//	Go to new address

function nav(el,href){
		$(el).addClass("hidden");
		location.href = href;
	}







// function to detecy different browsers

(function($) {
	
	$.browser_detect = function() {
    
    var userAgent = navigator.userAgent.toLowerCase();
    $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    
    // Is this a version of IE?
    if($.browser.msie){        
        
        $('body').addClass('ie ' + $.browser.version.substring(0,1));	// Add the version number
    }
       
    // Is this a version of Chrome?
    if($.browser.chrome){
    
        //$('body').addClass('browserChrome');
        
        //Add the version number
        userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
        userAgent = userAgent.substring(0,1);
        $('body').addClass('chrome ' + userAgent);
        
        
        $.browser.safari = false;	// If it is chrome then jQuery thinks it's safari so we have to tell it it isn't
    }
    
    // Is this a version of Safari?
    if($.browser.safari){
                
        userAgent = userAgent.substring(userAgent.indexOf('version/') +8)	// Add the version number;
        userAgent = userAgent.substring(0,1);
        $('body').addClass('safari ' + userAgent);
    }
    
    // Is this a version of Mozilla?
    if($.browser.mozilla){
               
        if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1){	 //Is it Firefox?
            
            // Add the version number
            userAgent = userAgent.substring(userAgent.indexOf('firefox/') +8);
            userAgent = userAgent.substring(0,1);
            $('body').addClass('firefox ' + userAgent);
        }        
        else{
            $('body').addClass('mozilla ');	// If not then it must be another Mozilla
        }
    }
    
    // Is this a version of Opera?
    if($.browser.opera){
        $('body').addClass('opera ');
    }
	
	
	var argLgth = arguments.length;
	
	if(argLgth==1){
		var browser = arguments[0];
		ver = false;
		var arg = false;
	}
	else if(argLgth==2){
		var browser = arguments[0];
		var ver = arguments[1];
		var arg = true;
	}
	
	var body_class = $('body').attr('class');
	var browserTest = body_class.indexOf(browser);
	
	
	
	if(arg){
	var version = browser.indexOf(ver);
	}
		
	if(browserTest>=0){
		if(arg){
			if(version>=0){
				return true;
			}
			else{
				return false;
			}
		}
		else{
			return true;
		}
	}
	else{
		return false;
	}
    
    
};
	
	
})(jQuery);


// Preload images

(function($) {
		  
  	var cache = [];
  	// Arguments are image paths relative to the current page.
  	$.preLoadImages = function() {
		$('img').addClass("hidden");
    	var args_len = arguments.length;
    	for (var i = args_len; i--;) {
     		 var cacheImage = document.createElement('img');
      		cacheImage.src = arguments[i];
			//var somevariable = $('').attr('src',arguments[i]);
      		cache.push(cacheImage);
    		}
		//$('img').fadeIn(2500,function(){$(this).removeClass("hidden");});
	
  	}
})(jQuery)



