﻿/**
*   Browser
*
*   Class offers all utility functions with regard to the browser & its functionality
*
*   @usage    Used by all pages to return the navigation view based upon passed specifics
*   @author   Daniel Ivanovic dan@anti-blanks.co.uk
*/
var Browser = Class.extend(
	{
		init: function() 
		{
			this.binfo = new Object();
		},
		
		/**
		*   getBrowser
		*
		*   Returns the relevant browser info
		*/
		getBrowser: function()
		{
			var ua;
			var b = '';
			var i = 0;
			
			ua = navigator.userAgent;
			
			b = "Opera";
			if ( ( i = ua.indexOf(b) ) >= 0 ) 
			{
				this.binfo = {
					type: "Opera",
					version: parseFloat( ua.substr(i + b.length) )
				};
			}
			
			b = "Netscape6/";
			if ( (i = ua.indexOf(b)) >= 0 ) 
			{
				this.binfo = {
					type: "Netscape6",
					version: parseFloat( ua.substr(i + b.length) )
				};
			}
			
			b = "Gecko";
			if ( (i = ua.indexOf(b)) >= 0 ) 
			{
				this.binfo = {
					type: "Netscape",
					version: 6.1
				};
			}
			
			b = "MSIE";
			if ( (i = ua.indexOf(b)) ) 
			{
				this.binfo = {
					type: "IE",
					version: parseFloat( ua.substr(i + b.length) )
				};
			}
			
			return this.binfo;
		},
		
		/**
		*	getUrlVars
		*	
		*	Returns an array of url vars
		*/
		getUrlVars: function()
		{
			var vars = [], hash;
			var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
			
			for(var i = 0; i < hashes.length; i++)
			{
				hash = hashes[i].split('=');
				vars.push(hash[0]);
				vars[hash[0]] = hash[1];
			}
		
			return vars;
		}
	}
);