/**
 * Copyright 2007 SK Communications. All rights reserved
 * @author okjungsoo
 * @since 2007.01.12
 * 
 * Browser와 관련된 정보를 리턴합니다. 
 */
var BrowserInfo = {
	initialize: function(){
		this.isWin = this.hasString("win", navigator.appVersion.toLowerCase());
		this.isMac = this.hasString("Mac", navigator.platform);

		this.isIE = this.hasString("MSIE");
				
		this.handleVersion(this.isIE);
		this.handleNotIE(this.isIE);
		this.handleIE(this.isIE);
		
		this.isNotSupportIFrame = (this.isOpera && !this.isOpera9) || this.isSafari || (this.isMac && this.isIE50);
	}, 
	
	hasString: function(searchString, fromString){
		fromString = fromString ? fromString: navigator.userAgent;
		return (fromString.indexOf(searchString) != -1);
	}, 
	
	handleNotIE: function(ie) {
		this.isMozilla = false;
		this.isFirefox = false;
		this.isNetscape = false;
		
		this.isChrome = false;
		this.isSafari = false;
		this.isWebKit = false;
		
		this.isOpera = false;
		this.isOpera8 = false;
		this.isOpera9 = false;
		
		if(!ie) {
			this.isSafari = this.hasString("Safari");
			if(this.isSafari) {
				this.isWebKit = this.hasString("AppleWebKit");		
			}
			this.isChrome = this.hasString("Chrome");
			if(this.isChrome) {
				this.isSafari = false;
			}
			
			this.isMozilla = !this.isSafari && this.hasString('Mozilla');
			if(this.isMozilla) {
				this.isFirefox = this.hasString("Firefox");		
			}
			
			this.isOpera = this.hasString("Opera");
			if(this.isOpera) {
				this.isOpera8 = (this.verMajor >= 8 && this.verMajor < 9);
				this.isOpera9 = (this.verMajor >= 9);		
			}
			
			this.isNetscape = (navigator.appName == "Netscape");
		}
	},
	
	/**
	 * isIE4 : IE 4.x
	 * isIE50 : IE 5.0~ 5.5미만
	 * isIE55 : IE 5.5~ 6 미만
	 * isIE7 : IE 7.x
	 */	
	handleIE: function(ie) {
		this.isIE4 = false;
		this.isIE50 = false;
		this.isIE55 = false;
		this.isIE6 = false;		
		this.isIE7 = false;			
		
		if(ie) {
			if(this.verMajor >= 4 && this.verMajor <5) {
				this.isIE4 = true;
			}else if((this.verMajor >=5 && this.verMajor < 6) 
					&& (this.verMinor >= 0 && this.verMinor <5)) {
				this.isIE50 = true;		
			}else if((this.verMajor >=5 && this.verMajor < 6) 
					&& (this.verMinor >= 5)) {
				this.isIE55 = true;
			}else if(this.verMajor == 6 && this.verMajor < 7) {
				this.isIE6 = true;
			}else if(this.verMajor >=7 && this.verMajor < 8) {
				this.isIE7 = true;
			} 
		}
	}, 
	
	handleVersion: function(ie) {
		if(ie){
			this.verMajor = navigator.appVersion.match(/MSIE (.)/)[1];
			this.verMinor = navigator.appVersion.match(/MSIE .\.(.)/)[1];
		}else {
			this.verMajor = parseInt(navigator.appVersion);
			this.verMinor = parseFloat(navigator.appVersion);
		}		
	}, 
	
	/**
	 * ie55 이상, ns4이상, opera 9이상, mac이 아닌 경우만 지원
	 */
	isSupportFlash: function() {
		if(((this.isIEAbove55()) 
				|| (this.isNetscape && this.verMajor >= 4) 
				|| (this.isOpera && this.verMajor >= 9))
				&& !this.isMac) {
			return true;
		}else {
			return false;	
		}
	}, 
	
	isIEAbove55: function() {
		if(this.isIE && (this.verMajor > 5 || this.isIE55)){
			return true;
		}else {
			return false;
		}
	}, 
	
	isIEAbove4: function() {
		if(this.isIE && (this.verMajor > 4)){
			return true;
		}else {
			return false;
		}
	}
};

// initiate BrowserInfo
BrowserInfo.initialize();