﻿window.size = function()
	{
	var w = 0;
	var h = 0;
	
	//IE
	if(!window.innerWidth)
		{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
			{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
			}
			//quirks mode
			else	{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
			}
		}
		//w3c
		else {
		w = window.innerWidth;
		h = window.innerHeight;
		}

	return {width:w,height:h};
	}

window.center = function()
	{
	var hWnd = (arguments[0] != null) ? arguments[0] : {width:0,height:0};

	var _x = 0;
	var _y = 0;
	var offsetX = 0;
	var offsetY = 0;

	//IE
	if(!window.pageYOffset)
		{
		//strict mode
		if(!(document.documentElement.scrollTop == 0))
			{
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
			}
			//quirks mode
			else
			{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
			}
		}
	//w3c
		else	{
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
		}
	
	_x = ((this.size().width-hWnd.width)/2)+offsetX;
	_y = ((this.size().height-hWnd.height)/2)+offsetY;
	
	return{x:_x,y:_y};
}

////


function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
////
function isIE()
	{
	return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
	}
////
function addLoadEvent(func) 
	{ 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') 
		{  
		window.onload = func;  
		} else {  
		window.onload = function() 
			{  
			if (oldonload) 
				{  
				oldonload();  
				}  
			func();  
			}  
		}  
	}
	
	
////
function fadeIn(objId,opacity, increment) 
	{
	if (opacity <= 100) 
		{
		obj = document.getElementById(objId);
		setOpacity(obj, opacity);
		opacity += increment;
		if (opacity > 100) opacity = 100; 
		window.setTimeout("fadeIn('"+objId+"',"+opacity+", " + increment + ")", 20);
		}
	}

////
function fadeOut(objId,opacity, increment) 
	{
	if (opacity >= 0) 
		{
		obj = document.getElementById(objId);
		setOpacity(obj, opacity);
		opacity -= increment;
		if (opacity<0) opacity = 0; 
		window.setTimeout("fadeOut('"+objId+"',"+opacity+", '" + increment + "')", 20);
		}
	}


////
function getY(oElement)
	{
	var iReturnValue = 0;
	while( oElement != null ) 
		{
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
		}
	return iReturnValue;
	}
////
function getX(oElement)
	{
	var iReturnValue = 0;
	while( oElement != null ) 
		{
		iReturnValue += oElement.offsetLeft;
		oElement = oElement.offsetParent;
		}
	return iReturnValue;
	}


////
function setOpacity(obj, opacity) 
	{

	opacity = (opacity == 100)?99.999:opacity;
	
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
	}
////
function getOpacity(obj)
	{
	return;
		// Safari<1.2, Konqueror
		obj.style.KHTMLOpacity = opacity/100;
		
		// Older Mozilla and Firefox
		obj.style.MozOpacity = opacity/100;
		
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = opacity/100;
	}
////
function moveElementById(id, x, y) 
	{
	var elm = document.getElementById(id);
	elm.style.left = x + "px";
	elm.style.top = y + "px";
	}	
////
function getPosition(e) 
	{
	e = e || window.event;
	var cursor = {x:0, y:0};
	if (e.pageX || e.pageY) 
		{
		cursor.x = e.pageX;
		cursor.y = e.pageY;
		} else {
		var de = document.documentElement;
		var b = document.body;
		cursor.x = e.clientX +  (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
		cursor.y = e.clientY +  (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
		}
	return cursor;
	}	
////
function pause( iMilliseconds )
	{
    var sDialogScript = 'window.setTimeout( function () { window.close(); }, ' + iMilliseconds + ');';
    window.showModalDialog('javascript:document.writeln ("<script>' + sDialogScript + '<' + '/script>")');
	}
	