/*
-------------------------------------------------------------------------------------------
	ORANGE CIRCLE
	Library      : extension.js
	version      : 1.5.2
	revision     : 200704222
------------------------------------------------------------------------------------------ */

/* get_environment_variable
------------------------------------------------------------------------------------------ */
EXTENSION.GET_ENVIRONMENT = function(){
	this.ua = navigator.userAgent.toUpperCase();
}

EXTENSION.GET_ENVIRONMENT.prototype = {
	isOS : function(){
		if     (this.ua.match(/WIN(DOWS)?/)){return 'win';}
		else if(this.ua.match(/MAC/))       {return 'mac';}
		else if(this.ua.match(/X11/))       {return 'unix';}
		else if(this.ua.match(/LINUX/))     {return 'linux';}
		else {return false;};
	},
	isUA : function(){
		var os = this.isOS();
		if     (os=='win' && this.ua.match(/MSIE/)){return 'ie';}
		else if(os=='mac' && this.ua.match(/MSIE/)){return 'mie';}
		else if(this.ua.match(/FIREFOX/)) {return 'ff';}
		else if(this.ua.match(/NETSCAPE/)){return 'ns';}
		else if(this.ua.match(/OPERA/))   {return 'op';}
		else if(this.ua.match(/SAFARI/))  {return 'sf';}
		else {return false;};
	},
	isNAVIGATOR : function(){
		var os = this.isOS();
		var ua = this.ua;
		return {
			win : function(){if(os=='win') return true;},
			w95 : function(){if(os=='win' && ua.match(/95/)) return true;},
			w98 : function(){if(os=='win' && ua.match(/98/)) return true;},
			me  : function(){if(os=='win' && ua.match(/9x 4\.90/)) return true;},
			nt  : function(){if(os=='win' && ua.match(/NT 4\.0/)) return true;},
			w2k : function(){if(os=='win' && ua.match(/NT 5\.0/)) return true;},
			xp  : function(){if(os=='win' && ua.match(/NT 5\.1/)) return true;},
			vst : function(){if(os=='win' && ua.match(/NT 6\.0/)) return true;},
			mac : function(){if(os=='mac') return true;},
			osx : function(){if(os=='mac' && ua.match(/OS X/) || ua.match(/MSIE 5\.23/)) return true;},
			os9 : function(){if(os=='mac' && !this.osx()) return true;},
			unx : function(){if(os=='unix') return true;},
			lnx : function(){if(os=='linux') return true;},
			ie  : function(){if(ua.match(/MSIE/)) return true;},
			ie4 : function(){if(ua.match(/MSIE 4/)) return true;},
			ie5 : function(){if(ua.match(/MSIE 5/)) return true;},
			ie6 : function(){if(ua.match(/MSIE 6/)) return true;},
			ie7 : function(){if(ua.match(/MSIE 7/)) return true;},
			ff  : function(){if(ua.match(/FIREFOX/)) return true;},
			ff1 : function(){if(ua.match(/FIREFOX\/1/)) return true;},
			ff2 : function(){if(ua.match(/FIREFOX\/2/)) return true;},
			ns  : function(){if(ua.match(/NETSCAPE/)) return true;},
			ns6 : function(){if(ua.match(/NETSCAPE\/6/)) return true;},
			ns7 : function(){if(ua.match(/NETSCAPE\/7/)) return true;},
			ns8 : function(){if(ua.match(/NETSCAPE\/8/)) return true;},
			op  : function(){if(ua.match(/OPERA/)) return true;},
			op8 : function(){if(ua.match(/OPERA\/8/)) return true;},
			op9 : function(){if(ua.match(/OPERA\/9/)) return true;},
			sf  : function(){if(ua.match(/SAFARI/)) return true;},
			sf0 : function(){if(ua.match(/SAFARI\/8/)) return true;},
			sf1 : function(){if(ua.match(/SAFARI\/1/) || ua.match(/SAFARI\/3/)) return true;},
			sf2 : function(){if(ua.match(/SAFARI\/4/)) return true;},
		  mie : function(){if(this.mac() && this.ie()) return true;},
			nn4 : function(){if(document.layers) return true;}
		};
	},
	FLASHPLAYER : function(){
		var shockwave = navigator.mimeTypes['application/x-shockwave-flash'];
		var getPlugin = (navigator.mimeTypes && shockwave) ? shockwave.enabledPlugin : 0;
		if(getPlugin){
			var getPlayer = navigator.plugins['Shockwave Flash'].description.split(' ');
			for (var i=0; i<getPlayer.length; i++){
				if (isNaN(parseInt(getPlayer[i]))) continue;
				var pluginVersion = parseInt(getPlayer[i],10);
			};
		} else if(navigator.userAgent.match(/MSIE/) && navigator.userAgent.match(/Windows/)){
			var pluginVersion = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').FlashVersion();
			    pluginVersion = Math.floor(pluginVersion / 0x10000);
		};
		return pluginVersion;
	}
}



EXTENSION.GET_PAGESIZE = function(){}
EXTENSION.GET_PAGESIZE.prototype = {
	sw : screen.width,
	sh : screen.height,
	aw : screen.availWidth,
	ah : screen.availHeight,
	sx : function(){return window.screenX || window.screenLeft;},
	sy : function(){return window.screenY || window.screenTop;},

	ww : function(){
		if(self.innerWidth){
			return self.innerWidth;
		} else if(document.documentElement && document.documentElement.clientWidth){
			return document.documentElement.clientWidth;
		} else if(document.body){
			return document.body.clientWidth;
		};
	},
	wh : function(){
		if(self.innerHeight){
			return self.innerHeight;
		} else if(document.documentElement && document.documentElement.clientHeight){
			return document.documentElement.clientHeight;
		} else if(document.body){
			return document.body.clientHeight;
		};
	},

	pw : function(){
		if(window.innerWidth && window.scrollMaxX){
			return window.innerWidth + window.scrollMaxX;
		} else if (document.body.scrollWidth > document.body.offsetWidth){
			return document.body.scrollWidth;
		} else {
			return document.body.offsetWidth;
		}
	},
	ph : function(){
		if(window.innerHeight && window.scrollMaxY){
			return window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){
			return document.body.scrollHeight;
		} else {
			return document.body.offsetHeight;
		}
	},

	dx : function(){
		if(document.documentElement.scrollLeft){
			return document.body.scrollLeft || document.documentElement.scrollLeft;
		} else {
			return document.body.scrollLeft;
		};
	},
	dy : function(){
		if(document.documentElement.scrollTop){
			return document.body.scrollTop || document.documentElement.scrollTop;
		} else {
			return document.body.scrollTop;
		};
	}
}



/* extension
------------------------------------------------------------------------------------------ */
function $(element){
	if(typeof(element) == 'string'){
		return document.getElementById(element);
	} else {
		return false;
	};
}


function $$(targetClass, element){
	if(!element) element = '*';
	var result = [];
	var elements = document.getElementsByTagName(element);
	var pattern = new RegExp(targetClass);
	for(var i=0, j=0; i<elements.length; i++){
		if(elements[i].className.match(pattern)){
			result[j++] = elements[i];
		}
	};
	return result;
}

function $pos(element){
	if(typeof(element)=='string') element = $(element);
	var result = {
		w : null,
		h : null,
		x : null,
		y : null
	};
	if(!element){
		return result;
	} else {
		result.w = element.offsetWidth;
		result.h = element.offsetHeight;
		result.x = element.offsetLeft;
		result.y = element.offsetTop;
		while(element.offsetParent) {
			element = element.offsetParent;
			result.x += element.offsetLeft;
			result.y += element.offsetTop;
		}
	};
	return result;
}


function addEvent(element, evtType, func){
	if(evtType == 'mousewheel' && navigator.userAgent.toUpperCase().indexOf('FIREFOX')>=0){
		evtType = 'DOMMouseScroll';
	};
	if(element.addEventListener){
		element.addEventListener(evtType, func, false);
	} else if(element.attachEvent){
		element.attachEvent('on'+ evtType, func);
	} else {
		var evtStorage = element['on' + evtType];
		element['on' + evtType] = evtStorage ? function (){ func() ; evtStorage() } : func;
	};
}



/* utility
------------------------------------------------------------------------------------------ */
addEvent(window, 'load', function(){
	var getSwpImage = $$('rov','img');
	var swpImages  = getSwpImage.length;
	var d = document;
	if(!d.preSetImage) d.preSetImage = new Array();
		for (var i=0, j=0; i<swpImages; i++, j++){
			var swpimg = getSwpImage[i];
			    swpimg.out = swpimg.src;
			    swpimg.ov  = swpimg.src.replace('_ot\.gif', '_ov\.gif').replace('_ot\.jpg', '_ov\.jpg');
			    swpimg.onmouseover = function(){ this.src = this.ov;  };
			    swpimg.onmouseout  = function(){ this.src = this.out; };
			d.preSetImage[j] = new Image;
			d.preSetImage[j].src = swpimg.ov;
	};
});