var Browser = {

    availWidth: screen.availWidth,
    availHeight: screen.availHeight,
    upWin: null,
    
	type: {
		IE:     !!(window.attachEvent && !window.opera),
		Opera:  !!window.opera,
		WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
		Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
				MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
	},
        
    trim: function(str) {

		if (typeof str != "string") {
			return str;
		}

		var ret = str.replace(/^\s*([\S\s]*)$/,'$1');
		ret = str.replace(/\s+$/,'');
		ret = str.replace(/\s\s+/g,' ');

		return ret;
    },
    
	trimUScore: function (str) {
		var ret = Browser.trim(str);
		ret = ret.replace(/\s/g,'_');
		return ret;
	},

    openWindow : function(url, name, w_width, w_height, args, placeWindow) {

		name = Browser.trim(Browser.trimUScore(name));
		args = Browser.trim(args);


		if(args !== ''){
			args = args + ',';
		}
		
		if (!Browser.upWin || Browser.upWin.closed) {
			var center_of_screen_X = Math.floor(Browser.availWidth/2)-Math.floor(w_width/2);
			var center_of_screen_Y = Math.floor(Browser.availHeight/2)-Math.floor(w_height/2);
			placeWindow = (Browser.type.Opera) ? "" : ",left=" + center_of_screen_X + ",top=" + center_of_screen_Y;
		}
		
		Browser.upWin = window.open(url,name, args + 'width='+w_width+',height='+w_height + placeWindow);

		if(Browser.upWin){
			Browser.upWin.focus();
		} else {
			alert("The Street View mode is launched in a new window that was blocked by your popup-blocker. Please review your browser settings.");
		}
	
    },
	
	getViewportHeight: function()
	{
		var myHeight = 0;
		if( typeof( window.innerHeight ) == 'number' )
		{
			//Non-IE
			myHeight = window.innerHeight;
		}
		else if( document.documentElement && document.documentElement.clientHeight )
		{
			//IE 6+ in 'standards compliant mode'
			myHeight = document.documentElement.clientHeight;
		} else if ( document.body && document.body.clientHeight )
		{
			//IE 4 compatible
			myHeight = document.body.clientHeight;
		}
		return myHeight;
	},
	
	getViewportWidth: function()
	{
		var myWidth = 0;
		if( typeof( window.innerWidth ) == 'number' )
		{
			//Non-IE
			myWidth = window.innerWidth;
		}
		else if( document.documentElement && document.documentElement.clientWidth )
		{
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
		} else if ( document.body && document.body.clientWidth )
		{
			//IE 4 compatible
			myWidth = document.body.clientWidth;
		}
		return myWidth;
	},
	
	getWindowSize: function()
	{
		var myHeight = 0;
		if( typeof( window.outerHeight ) == 'number' )
		{
			//Non-IE
			myWidth = window.innerWidth;
		}
		else 
		{

		}

	},
	
	
	setViewportSize: function(width,height)
	{
		var size = Browser.getWindowSize();
		//alert("W:" + size.width +" H:" + size.height);
	}
	
	
};