var nw,nh;
function resizeFullImage()
{
	var size = getPageSize();
	var objHead = document.getElementById('headmenuBG');
	objHead.style.height = size[3] + "px";
	
	var bw = 0;
	var obj = document.getElementById('fullImage');
	var buttonFrame = document.getElementById('buttonFrame');
	//if (!buttonFrame) alert("noButton");
	if (obj)
	{	
		var pos = { x: 260, y: 82 };
		obj.style.width = eval(size[0] - pos.x - bw) + "px";
		obj.style.height = eval(size[3] - pos.y - bw) + "px";
		
		//buttonFrame.style.width = eval(size[0] - pos.x - bw) + "px";
		if (buttonFrame) buttonFrame.style.height = eval(size[3] - pos.y - bw) + "px";
		
		//var pos = getAbsolutePosition(obj);
		var w = eval( size[2] - pos.x - bw ),
				h = eval( size[3] - pos.y - bw );
				
		obj.style.width = eval( w ) + "px";
		obj.style.height = eval( h ) + "px";
		
		//buttonFrame.style.width = eval( w ) + "px";
		if (buttonFrame) buttonFrame.style.height = eval( h ) + "px";
		
		var imgObj = obj.getElementsByTagName('img')[0];
		if (imgObj)
		{			
			
			var iw = imgObj.getAttribute('width'),
				  ih = imgObj.getAttribute('height');
			iw = iw ? iw : orgW;
			ih = ih ? ih : orgH;
			
			
			
			var rw = iw / ih;
	    var rh = ih / iw;
	    var sc = h * rw;
	    if (sc >= w) {
	        nh = h;
	        nw = sc;
	    } else {
	        sc = w * rh;
	        nh = sc;
	        nw = w;
	    }
	    
	    
	    //if ((nw + pos.y) > size[2])
	    if ((nw + pos.x) > size[2])
	    {	    	
	    	nw = size[2] - pos.x - bw;
	    	nh = Math.round(ih * nw / iw);
	    	//nh = size[3] - pos.x - bw;	    	
	    	//nw = Math.round(ih * w / iw);
	    	//nw = size[2] - pos.y - bw;
	    	//nh = Math.round(iw * h / ih);
	    	//alert("Width 2 Big");
	    }
	    
	    if ((nh + pos.y) > size[3])
	    {	    	
	    	nh = size[3] - pos.y - bw;	    	
	    	nw = Math.round(iw * nh / ih);
	    	//nw = size[2] - pos.y - bw;
	    	//nh = Math.round(iw * h / ih);
	    	//alert("Height 2 Big");
	    }
	    
	    //alert(size);
			//alert(h + "x" + w + "\n" + iw + "x" + ih + "\n" + nw + "x" + nh );
	    
	    if ( imgObj.style.display != 'none' )
	    {
	    	imgObj.style.height = eval( nh ) + "px";
				imgObj.style.width = eval( nw ) + "px";
				if (buttonFrame) buttonFrame.style.width = eval( nw ) + "px";
	    }
	    else
	    {	    					
								
				imgObj.style.height = eval( nh ) + "px";
				imgObj.style.width = eval( nw ) + "px";
				if (buttonFrame) buttonFrame.style.width = eval( nw ) + "px";
				
				new Effect.Appear(imgObj.id,{
					afterFinish:function()
					{						
						obj.style.display = "";
						imgObj.style.display = "";
					}
				});
	    }
			
		}
	}
}


Event.observe(window, 'load', resizeFullImage, false);
Event.observe(window, 'resize', resizeFullImage, false);

var mp3FileName;
var mp3IsPlaying = false;

var myListener = new Object();


myListener.onInit = function()
{
    this.position = 0;
};

myListener.onUpdate = function()
{

};

function getFlashObject()
{
    return document.getElementById("myFlash");
}
function playMP3()
{
    getFlashObject().SetVariable("method:setUrl", mp3FileName.value);
    getFlashObject().SetVariable("method:play", "");
    getFlashObject().SetVariable("enabled", "true");
}

function stopMP3()
{
    getFlashObject().SetVariable("method:stop", "");
}

function setPosition()
{
    var position = document.getElementById("inputPosition").value;
    getFlashObject().SetVariable("method:setPosition", position);
}

function setVolume()
{
    getFlashObject().SetVariable("method:setVolume", 100);
}

function switchMP3()
{
	mp3FileName = document.getElementById('mp3_file_name');
	if (mp3FileName)
	{
		getFlashObject().SetVariable("method:setVolume", 100);
		if (mp3IsPlaying)
		{
			stopMP3();
		}
		else
		{
			playMP3();
		}
		mp3IsPlaying = !mp3IsPlaying;
	}
}

Event.observe(window, 'load', switchMP3, false);

/*
function resizeFullImage()
{
	var size = getPageSize();
	var objHead = document.getElementById('headmenuBG');
	objHead.style.height = size[3] + "px";
	
	var bw = 0;
	var obj = document.getElementById('fullImage');
	if (obj)
	{	
		var pos = { x: 260, y: 82 };
		obj.style.width = eval(size[0] - pos.x - bw) + "px";
		obj.style.height = eval(size[3] - pos.y - bw) + "px";
		
		//var pos = getAbsolutePosition(obj);
		var w = eval( size[2] - pos.x - bw ),
				h = eval( size[3] - pos.y - bw );
				
		obj.style.width = eval( w ) + "px";
		obj.style.height = eval( h ) + "px";
		
		var imgObj = obj.getElementsByTagName('img')[0];
		if (imgObj)
		{			
			var iw = imgObj.getAttribute('width'),
				  ih = imgObj.getAttribute('height');
			iw = iw ? iw : orgW;
			ih = ih ? ih : orgH;
			
			var rw = iw / ih;
	    var rh = ih / iw;
	    var sc = h * rw;
	    if (sc >= w) {
	        nh = h;
	        nw = sc;
	    } else {
	        sc = w * rh;
	        nh = sc;
	        nw = w;
	    }
	    
	    //if ((nw + pos.y) > size[3])
	    if ((nw + pos.y) > size[2])
	    {	    	
	    	nh = size[3] - pos.x - bw;	    	
	    	nw = Math.round(ih * w / iw);
	    	//nw = size[2] - pos.y - bw;
	    	//nh = Math.round(iw * h / ih);
	    }

	    if ( imgObj.style.display != 'none' )
	    {
	    	imgObj.style.height = eval( nh ) + "px";
				imgObj.style.width = eval( nw ) + "px";
	    }
	    else
	    {	    					
								
				imgObj.style.height = eval( nh ) + "px";
				imgObj.style.width = eval( nw ) + "px";
				
				new Effect.Appear(imgObj.id,{
					afterFinish:function()
					{						
						obj.style.display = "";
						imgObj.style.display = "";
					}
				});
	    }
			
		}
	}
}
*/
