function setBrowserDimensions(width, height)
{	
	window.resizeTo(width, height);
		
	var diffWidth = width - getBrowserWidth();
	var diffHeight = height - getBrowserHeight();
	
	window.resizeTo(width + diffWidth, height + diffHeight);
}

function getBrowserWidth()
{
    var width = 0;
    if (self.innerWidth)
    {
    	width = self.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
    	width = document.documentElement.clientWidth;
    }
    else if (document.body)
    {
    	width = document.body.clientWidth;
    }
    return width;
}

function getBrowserHeight()
{
	var height = 0;
    if (self.innerHeight)
    {
    	height = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
    	height = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
    	height = document.body.clientHeight;
    }
    return height;
}

function applyFadeInEffectToImageControl(imageId, step)
{
	var image = document.getElementById(imageId);
	
	setOpacityToObjectControl(image, 0);	
	fadeInEffectToControl(image.id, 0, step);
}

function fadeInEffectToControl(objectId, opacity, step)
{
	if (opacity <= 100) 
	{
		var object = document.getElementById(objectId);
		object.style.display="";
		setOpacityToObjectControl(object, opacity);
		opacity += step;
		
		window.setTimeout("fadeInEffectToControl('"+objectId+"'," + opacity + "," + step + ")", 100);
	}
	else
	{
		var object = document.getElementById(objectId);
		setOpacityToObjectControl(object, 100);
	}
}

function applyFadeOutEffectToImageControl(imageId, step)
{
	var image = document.getElementById(imageId);
	
	setOpacityToObjectControl(image, 100);	
	fadeOutEffectToControl(image.id, 100, step);
}

function fadeOutEffectToControl(objectId, opacity, step)
{
	var object = document.getElementById(objectId);
	
	if (opacity >= 0) 
	{		
		setOpacityToObjectControl(object, opacity);
		opacity -= step;
				
		window.setTimeout("fadeOutEffectToControl('"+objectId+"',"+opacity+"," + step + ")", 100);
	}
	else
	{
		object.style.display="none";
	}
}

function setOpacityToObjectControl(object, opacity) 
{
  if (opacity < 0)
  {
	opacity=0;
  }
	
  if (opacity >= 100)
  {
	object.style.filter = "";
  	opacity = 99.999;
  }
  else
  {
	object.style.filter = "alpha(opacity:"+opacity+")";
  }

  // IE/Win
  //object.style.filter = "alpha(opacity:"+opacity+")";
  //object.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ")";
  
  // Safari<1.2, Konqueror
  object.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  object.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  object.style.opacity = opacity/100;
}

function applyAnimationXToObject(objectId, xStart, xEnd, step)
{
	var object = document.getElementById(objectId);

	animationXToObject(objectId, xStart, xEnd, step);
}

function animationXToObject(objectId, xStart, xEnd, step)
{
	var object = document.getElementById(objectId);
		
	if (xStart > xEnd) // Left
	{
		if (convertPxToNumber(object.style.left) < xEnd) 
		{
			return ;
		}
		
		object.style.left = (convertPxToNumber(object.style.left) - step) + "px";
	}	
	else if (xStart < xEnd) // Right
	{
		if (convertPxToNumber(object.style.left) > xEnd) 
		{
			return ;
		}

		object.style.left = (convertPxToNumber(object.style.left) + step) + "px";
	}
	else
	{
		alert(convertPxToNumber(object.style.left) - step);
		return ;
	}
	
	window.setTimeout("animationXToObject('"+objectId+"',"+xStart+","+xEnd+","+ step + ")", 1);
}

function applyAnimationYToObject(objectId, yStart, yEnd, step)
{
	var object = document.getElementById(objectId);

	animationYToObject(objectId, yStart, yEnd, step);
}

function animationYToObject(objectId, yStart, yEnd, step)
{
	var object = document.getElementById(objectId);
		
	if (yStart > yEnd) // Left
	{
		if (convertPxToNumber(object.style.top) < yEnd) 
		{
			return ;
		}
		
		object.style.top = (convertPxToNumber(object.style.top) - step) + "px";
	}	
	else if (yStart < yEnd) // Right
	{
		if (convertPxToNumber(object.style.top) > yEnd) 
		{
			return ;
		}

		object.style.top = (convertPxToNumber(object.style.top) + step) + "px";
	}
	else
	{
		return ;
	}
	
	window.setTimeout("animationYToObject('"+objectId+"',"+yStart+","+yEnd+","+ step + ")", 1);
}

function openWindowFullscreen (url) 
{ 
	width = screen.availWidth;
	height = screen.availHeight;
                                
	return window.open(url,null,"width="+width+",height="+height+",scrollbars=yes,top=0,left=0,toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes");
}

function convertPxToNumber(numberpx)
{
	return parseInt(numberpx.replace('px',''),10);
}

