var isIE = (navigator.userAgent.indexOf('MSIE') != -1);

//------------------------------------------------------------------------------
function getWindowSize()
{
	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};
}

//------------------------------------------------------------------------------
function getImageSize(image)
{
//	alert(image.naturalWidth + ', ' + image.clientWidth + ', ' + image.offsetWidth + ', ' + image.scrollWidth);

	if(image.naturalWidth)
		return {width:image.naturalWidth, height:image.naturalHeight};

	return {width:image.width, height:image.height};
}

//------------------------------------------------------------------------------
function assert(message, condition)
{
	if(!condition)
		alert('assertion failed: ' + message);
}

//------------------------------------------------------------------------------
function getMilliseconds()
{
	var date = new Date();
	return date.getTime();
}

//------------------------------------------------------------------------------
function setOpacity(element, opacity)
{
	element.style.opacity = opacity;
   	if(isIE)
   		element.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
}

//------------------------------------------------------------------------------
function getURLParam(strParamName)
{ 
    var strReturn = ""; 
    var strHref = window.location.href; 
    if(strHref.indexOf("?") > -1)
    { 
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase(); 
        var aQueryString = strQueryString.split("&"); 
        for(var iParam = 0; iParam < aQueryString.length; iParam++)
        { 
            if(aQueryString[iParam].indexOf(strParamName + "=") > -1)
            { 
                var aParam = aQueryString[iParam].split("="); 
                strReturn = aParam[1]; 
                break; 
            } 
        } 
    } 

    return strReturn; 
}
