var prev_active = false ;
var fadeVal=0;

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function resPrint()
{
	var scrWidth = screen.width ;
	var scrHeight = screen.height ;	
	var scrRatio = roundNumber(scrWidth / scrHeight,2) ;
	
	var resPrint = "<span id='respri';>Your display features</span><span>Aspect Ratio: <strong>";
	if(scrRatio == 1.25 || scrRatio == 1.33)
	{
		resPrint += "Standard";
	}			
	else if(scrRatio == 1.6 || scrRatio == 1.67)
	{
		resPrint += "Wide";
	}
	else if(scrRatio == 1.78)
	{
		resPrint += "HD";
	}
	else if(scrRatio == 1.76)
	{
		resPrint += "Mobile PSP";
	}
	else if(scrRatio == 0.75 || (scrRatio == 1.33 && scrWidth <= 640))
	{
		resPrint += "Mobile VGA";
	}
	else if(scrRatio == 0.6 || (scrRatio == 1.67 && scrWidth <= 800))
	{
		resPrint += "Mobile WVGA";
	}
	else if(scrRatio == 0.67 || (scrRatio == 1.5 && scrWidth == 480))
	{
		resPrint += "Mobile iPhone";
	}		
	else if(scrRatio == 0.8)
	{
		resPrint += "Mobile Phone";
	}			
	else
	{
		resPrint = "Unknown";
	}
	resPrint += "</strong></span><span>Resolution: <strong>"+scrWidth+" x "+scrHeight+"</strong></span>";
	document.write(resPrint);
}

function linkHighlight()
{
	var scrWidth = screen.width ;
	var scrHeight = screen.height ;
	
  for (i=0; i<document.links.length; i++) 
  {
	 if(document.links[i].href.search('/download/')>0 && document.links[i].href.search(scrWidth+'x'+scrHeight+'.html')>0)
	 {
		document.links[i].style.backgroundColor="#BBBBBB";
		document.links[i].style.MozBorderRadius="6px";
		document.links[i].style.webkitBorderRadius="6px";
		document.links[i].style.paddingLeft="5px";
		document.links[i].style.paddingRight="5px";
	 }
  }
}

function hidediv(id) {if (document.getElementById){document.getElementById(id).style.display = 'none';}else{if(document.layers){document.id.display = 'none';}else{document.all.id.style.display = 'none';}}}
function showdiv(id) {if (document.getElementById){document.getElementById(id).style.display = 'block';}else{if (document.layers){document.id.display = 'block';}else{document.all.id.style.display = 'block';}}}

function showhidediv(id)
{
	if (document.getElementById)
	{
		if(document.getElementById(id).style.display == 'block')
		{
			document.getElementById(id).style.display = 'none';
		}
		else if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}
	}
	else
	{
		if (document.layers)
		{
			if(document.id.display == 'block')
			{
				document.id.display = 'none';
			}
			else if(document.id.display == 'none')
			{
				document.id.display = 'block';
			}
		}
		else
		{
			if(document.all.id.style.display == 'block')
			{
				document.all.id.style.display = 'none';
			}
			else if(document.all.id.style.display == 'none')
			{
				document.all.id.style.display = 'block';
			}
		}
	}
}

function prevframe_show(wurl)
{
	if (document.getElementById)
	{
		document.getElementById("notifyFrame").src = wurl;
	}
	else
	{
		if (document.layers)
		{
			document.notifyFrame.src = wurl;
		}
		else
		{
			document.all.notifyFrame.src = wurl;
		}
	}
	prev_active = true ;
	frameLoad();
	showdiv("notifyBox2");
	showdiv("notifyBox3");
}

function prevframe_close()
{
	if (document.getElementById)
	{
		document.getElementById("notifyFrame").src = "";
	}
	else
	{
		if (document.layers)
		{
			document.notifyFrame.src = "";
		}
		else
		{
			document.all.notifyFrame.src = "";
		}
	}
	prev_active = false ;
	hidediv("notifyBox2");
	hidediv("notifyBox3");
}

function winHeight(frameHeight) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  var margingHeight = Math.round((myHeight-frameHeight)/2);
  if (margingHeight<0) { margingHeight = 0 ;}
	if (document.getElementById)
	{
		document.getElementById('notifyBox3').style.marginTop = margingHeight+"px";
	}
	else
	{
		if (document.layers)
		{
			document.notifyBox3.style.marginTop = margingHeight+"px";
		}
		else
		{
			document.all.notifyBox3.style.marginTop = margingHeight+"px";
		}
	}
	frameLoaded();
}

function frameHeight()
{
	if (prev_active)
	{
		if (document.getElementById)
		{
			//document.getElementById('notifyFrame').height=20;
			var the_height=document.getElementById('notifyFrame').contentWindow.document.body.scrollHeight;
			document.getElementById('notifyFrame').height= the_height;
		}
		else
		{
			if (document.layers)
			{
				//document.notifyFrame.height=20;
				var the_height=document.notifyFrame.contentWindow.document.body.scrollHeight;
				document.notifyFrame.height= the_height;
			}
			else
			{
				//document.all.notifyFrame.height=20;
				var the_height=document.all.notifyFrame.contentWindow.document.body.scrollHeight;
				document.all.notifyFrame.height= the_height;
			}
		}
		winHeight(the_height);
	}
}

function frameLoad()
{
	if (document.getElementById)
	{
		document.getElementById('notifyBox3').style.opacity = 0;
		document.getElementById('notifyBox3').style.filter = "alpha(opacity=0)";
	}
	else
	{
		if (document.layers)
		{
			document.notifyBox3.style.opacity = 0;
			document.notifyBox3.style.filter = "alpha(opacity=0)";
		}
		else
		{
			document.all.notifyBox3.style.opacity = 0;
			document.all.notifyBox3.style.filter = "alpha(opacity=0)";
		}
	}
	showdiv("notifyBoxLoad");
}

function frameLoaded()
{
	hidediv("notifyBoxLoad");
	
	fadeVal=0;
	frameFadeIn();	
}

function frameFadeIn()
{
	fadeVal+=100;
	if (document.getElementById)
	{
		document.getElementById('notifyBox3').style.opacity = fadeVal/100;
		document.getElementById('notifyBox3').style.filter = "alpha(opacity="+fadeVal+")";
	}
	else
	{
		if (document.layers)
		{
			document.notifyBox3.style.opacity = fadeVal/100;
			document.notifyBox3.style.filter = "alpha(opacity="+fadeVal+")";
		}
		else
		{
			document.all.notifyBox3.style.opacity = fadeVal/100;
			document.all.notifyBox3.style.filter = "alpha(opacity="+fadeVal+")";
		}
	}
	if(fadeVal < 100) setTimeout("frameFadeIn()",50);
}

function slide_advert(){ window.setTimeout(function() {showdiv("wall_advert")},7000); }