//detects window inner resolution

function findLiveHeight(){
	if(window.innerHeight != null)
		return window.innerHeight;
	if (document.body.clientHeight != null)
		return document.body.clientHeight;
	return (null);
}
function findLiveWidth(){
	if(window.innerWidth != null)
		return window.innerWidth;
	if (document.body.clientWidth != null)
		return document.body.clientWidth;
	return (null);
}

//this builds the individual layers

function build(){
makeLayer('loading','absolute','0','0','1024','640','visible', "0001");
makeLayer('top','absolute','0','0','1024','171','visible', "0001");
makeLayer('corner','absolute','0','0','210','210','visible', "0011");
makeLayer('topmenu','absolute','250','120','650','25','visible',"1111");
makeLayer('side','absolute','0','0','176','640','visible', "0010");
makeLayer('content-bg','absolute','160','160','865','480','visible', "1100");
makeLayer('sidemenu','absolute','10','250', '140','390', 'visible', "1111");
makeLayer('logo','absolute','10','5', '102', '142', 'visible', "1100");
makeLayer('slideshow','absolute','50','10','790','120','visible',"1111");
makeLayer('display1','absolute','15','182','135','50','visible', "1111");
makeLayer('display2','absolute','12','193','140','30','visible', "1111");
makeLayer('arrow','absolute','155','180','39','51','visible', "1100");
}

//makes dynamic layer
function makeLayer(id, position, left, top, width, height, visibility, c_effect) {
	this.obj = document.getElementById(id).style;
	this.obj.position = position;
	this.obj.left = parseInt(left*x_scale);
	this.obj.top = parseInt(top*y_scale);
	this.obj.width = parseInt(width*x_scale);
	this.obj.height = parseInt(height*y_scale);
	this.obj.visibility = visibility;
	
	if (constraint)
	{
		if (c_effect.charAt(0)=="1")
			this.obj.left = parseInt(left*constraint);
		if (c_effect.charAt(1)=="1")
			this.obj.top = parseInt(top*constraint);
		if (c_effect.charAt(2)=="1")
			this.obj.width = parseInt(width*constraint);
		if (c_effect.charAt(3)=="1")
			this.obj.height = parseInt(height*constraint);
	}	
	
	if (id=='content-bg' && constraint)
	{
		if (constraint)
		{
			sp_left = left*constraint;
			sp_top = top*constraint;
		}
		else
		{
			sp_left = left*x_scale;
			sp_top = top*y_scale;
		}
		this.obj.width = parseInt(pageWidth-sp_left);
		this.obj.height = parseInt(pageHeight-sp_top);
	}
	return this.obj;
}

// fit a graphic within the current window or frame

function showGraphic(src, w, h, alt, aln) {
	if (src==null) return;
	if (w==null) w=100; 			// width
	if(h==null)  h=100;				// height
	if(alt==null) alt="Picture";		// alt text
	if(aln==null) aln="left";			// alignment
	pageHeight = findLiveHeight();
	pageWidth = findLiveWidth();
	x_scale = pageWidth/1024
	y_scale = pageHeight/640
	scale = (x_scale<=y_scale)?x_scale:y_scale;
	var sw=Math.round(w*scale);
	var sh=Math.round(h*scale);
	document.write('<img src="'+src+'" alt="'+alt+'" width="'+sw+'" height="'+sh+'" align="'+aln+'">');
	}