/* usemedia.com . joes koppers . 08.2006 */
/* thnx for reading this code */


//bliin panes class

ii_panes = new Object() //global associative array holds all panes

function iiPane(name,x,y,w,h)
{
	//this.obj = id; //name of object
	this.name = name;
	
//	this.id = id;
	this.x = x;
	this.y = y;
	this.w = w;
	this.h = h;
	this.visible = false;
	
	/* build */

	var pane = document.createElement('div');
	pane.style.visibility = 'hidden';
	pane.style.display = 'none';
	document.body.appendChild(pane);	

	pane.id = 'pane_'+this.name;
	pane.className = 'pane';
	pane.style.left = this.x +"px";
	pane.style.top = this.y +"px";
	pane.style.width = w+15 +"px";
	pane.style.height = h+15 +"px";

	w-=30;
	h-=30;
	
	//background
	var pane_bg = document.createElement('div');
	document.getElementById(pane.id).appendChild(pane_bg);
	pane_bg.className = 'pane_bg';
	var str = '<span style="left:0px; top:0px; width:20px; height:20px; '+iiPNGbgImage('pane_w_nw.png')+'"><\/span>';
		str+= '<span style="left:20px; top:0px; width:'+(w)+'px; height:20px; '+iiPNGbgImage('pane_w_n.png')+'"><\/span>';
		str+= '<span style="left:'+(w+20)+'px; top:0px; width:25px; height:20px; '+iiPNGbgImage('pane_w_ne.png')+'"><\/span>';
		str+= '<span style="left:0px; top:20px; width:20px; height:'+h+'px; '+iiPNGbgImage('pane_w_w.png')+'"><\/span>';
		str+= '<span style="left:20px; top:20px; width:'+(w)+'px; height:'+(h)+'px; '+iiPNGbgImage('pane_w_c.png')+'"><\/span>';
		str+= '<span style="left:'+(w+20)+'px; top:20px; width:25px; height:'+(h)+'px; '+iiPNGbgImage('pane_w_e.png')+'"><\/span>';
		str+= '<span style="left:0px; top:'+(h+20)+'px; width:20px; height:25px; '+iiPNGbgImage('pane_w_sw.png')+'"><\/span>';
		str+= '<span style="left:20px; top:'+(h+20)+'px; width:'+(w)+'px; height:25px; '+iiPNGbgImage('pane_w_s.png')+'"><\/span>';
		str+= '<span style="left:'+(w+20)+'px; top:'+(h+20)+'px; width:25px; height:25px; '+iiPNGbgImage('pane_w_se.png')+'"><\/span>';
	pane_bg.innerHTML = str;
	//content		
	var pane_content = document.createElement('div');
	document.getElementById(pane.id).appendChild(pane_content);
	pane_content.className = 'content';
	pane_content.style.width = w+30 +"px";
	pane_content.style.height = h+30 +"px";
	
	if (ii_use_PNGfilter) pane_content.style.filter = 'Alpha(opacity=100)'; //IE display bug

	//ref to content div
	this.content = pane_content;
	this.div = pane;
	
	//add to associative 'array'
	ii_panes[this.name] = this;
}

iiPane.prototype.fade = function(mode)
{
	this.visible = (mode=='in')? true:false;
	//attach an iiFade obj
	var fade_begin = (mode=='out')? 100:0;
	var fade_end = (mode=='out')? 0:100;
	var fade_step = (mode=='in')? 20:25;
	var obj = this;
	this.do_fade = new iiFade('ii_panes[\''+this.name+'\'].do_fade',[this.div],fade_begin,fade_end,false,fade_step,35);
	//start fading
	this.do_fade.start();
}

iiPane.prototype.open = function()
{
	this.fade('in');
}

iiPane.prototype.hide = function()
{
	this.div.style.display = 'none';
}

iiPane.prototype.dispose = function()
{
	document.body.removeChild(document.getElementById('pane_'+this.name));
}

iiPane.prototype.addCloseButton = function()
{
	//closebutton
	var x = document.createElement('img');
	x.style.visibility = 'hidden';
	this.content.appendChild(x);
	x.src = siteUrl+'gm/gmmedia/close.gif';
	x.className = 'pane_x';
 	x.style.left = this.w-20 +"px";
 	
	var obj = this;
	x.onmouseup = function () { x.src = siteUrl+'gm/gmmedia/close.gif'; obj.close(obj) };
	x.onmouseover = function() { x.src = siteUrl+'gm/gmmedia/closeX.gif' };
	x.onmouseout = function() { x.src = siteUrl+'gm/gmmedia/close.gif' };
	
	x.style.visibility = 'visible';
}	

iiPane.prototype.close = function(obj)
{
	//default: this pane only
	this.fade('out');
	//others
	this.closeMore();	
}

iiPane.prototype.closeMore = function()
{
	//default empty, called on close(), 
	//define object specific if needed
}

iiPane.prototype.addSlider = function(name,x,y,min,max,value,func)
{
	
	//Slider.create(x,y,this.content,min,max,value,func);
	eval('this.'+name+' = new Slider.Slider(x,y,this.content,min,max,value,func)');
	
	//return new Slider.Slider(x,y,this.content,min,max,value,func);
}

