var xpPanel_slideActive=true;	// Slide down/up active?
var xpPanel_slideSpeed=20;	// Speed of slide

var tm_Pane;
var tm_paneIndex=0;
var tm_Paneset=0;

var savedActivePane=false;
var savedActiveSub=false;

var xpPanel_currentDirection=false;

var cookieNames=new Array(new Array(),new Array());

var opacity=100;

function Get_Cookie(name) { 
	var start=document.cookie.indexOf(name+"=");
	var len=start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end=document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
	expires = expires * 60*60*24*1000;
	var today=new Date();
	var expires_date = new Date( today.getTime() + (expires) );
	var cookieString = name + "=" +escape(value) + 
       ( (expires) ? ";expires=" + expires_date.toGMTString() : "") + 
       ( (path) ? ";path=" + path : "") + 
       ( (domain) ? ";domain=" + domain : "") + 
       ( (secure) ? ";secure" : ""); 
	document.cookie=cookieString;
}

function cancelXpWidgetEvent()
{
	return false;	
}

function showHidePaneContent()
{
	var img=this.getElementsByTagName('IMG')[0];
	var numSet=img.id.replace(/Button(\S+)[.](\S+)/g,"$1");
	var numId=img.id.replace(/(\S+)[.](\S+)/g,"$2");
	var obj=document.getElementById('Content' + img.id.replace(/[^.0-9]/g,''));
	if(img.src.toLowerCase().indexOf('up')>=0){
		img.src=img.src.replace('up','down');
		if(xpPanel_slideActive){
			obj.style.display='block';
			xpPanel_currentDirection=(xpPanel_slideSpeed*-1);
			slidePane((xpPanel_slideSpeed*-1), obj.id);
		}else{
			obj.style.display='none';
		}
		if(cookieNames[numSet][numId])Set_Cookie(cookieNames[numSet][numId],'0',100000);
	}else{
		img.src=img.src.replace('down','up');
		if(xpPanel_slideActive){
			if(document.all){
				obj.style.display='block';
			}
			xpPanel_currentDirection=xpPanel_slideSpeed;
			slidePane(xpPanel_slideSpeed,obj.id);
		}else{
			obj.style.display='block';
			subDiv=obj.getElementsByTagName('DIV')[0];
			obj.style.height=subDiv.offsetHeight+'px';
		}
		if(cookieNames[numSet][numId])Set_Cookie(cookieNames[numSet][numId],'1',100000);
	}
	return true;
}

function slidePane(slideValue,id)
{
	if(slideValue!=xpPanel_currentDirection){
		return false;
	}
	var activePane=document.getElementById(id);
	if(activePane==savedActivePane){
		var subDiv=savedActiveSub;
	}else{
		var subDiv=activePane.getElementsByTagName('DIV')[0];
	}
	savedActivePane=activePane;
	savedActiveSub=subDiv;

	var height=activePane.offsetHeight;
	var innerHeight=subDiv.offsetHeight;
	height+=slideValue;
	if(height<0)height=0;
	if(height>innerHeight) height=innerHeight;

	if(document.all){
		activePane.style.filter = 'alpha(opacity=' + (10 + (Math.round((height / subDiv.offsetHeight)*90))) + ')';
	}else{
		var opacity=(height/subDiv.offsetHeight);
		if(opacity==0)opacity=0.01;
		if(opacity==1)opacity=0.99;
		activePane.style.opacity=opacity;
	}

	if(slideValue<0){
		activePane.style.height=height+'px';
		subDiv.style.top=height-subDiv.offsetHeight+'px';
		if(height>0){
			setTimeout('slidePane(' + slideValue + ',"' + id + '")',10);
		}else{
			if(document.all)activePane.style.display='none';
		}
	}else{
		subDiv.style.top=height-subDiv.offsetHeight+'px';
		activePane.style.height=height+'px';
		if(height<innerHeight){
			setTimeout('slidePane(' + slideValue + ',"' + id + '")',10);
		}
	}
}

function mouseoverTopbar()
{
	var img=this.getElementsByTagName('IMG')[0];
	var src=img.src;
	img.src=img.src.replace('.gif','_over.gif');

	var span=this.getElementsByTagName('SPAN')[0];
	span.style.color='#428EFF';
}
function mouseoutTopbar()
{
	var img=this.getElementsByTagName('IMG')[0];
	var src=img.src;
	img.src=img.src.replace('_over.gif','.gif');

	var span=this.getElementsByTagName('SPAN')[0];
	span.style.color='';
}

function initTM_Pane(PaneID,panelTitles,panelDisplayed,cookieArray)
{
	tm_Pane=document.getElementById(PaneID);
	var divs=tm_Pane.getElementsByTagName('DIV');
	tm_paneIndex=0;
	tm_Paneset++;
	cookieNames[tm_Paneset]=cookieArray;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='tm_panel'){
			var outerContentDiv=document.createElement('DIV');	
			var contentDiv=divs[no].getElementsByTagName('DIV')[0];
			outerContentDiv.appendChild(contentDiv);

			outerContentDiv.id='Content' + tm_Paneset + '.' + tm_paneIndex;
			outerContentDiv.className='panelContent';
			var topBar=document.createElement('DIV');
			topBar.onselectstart=cancelXpWidgetEvent;
			var span=document.createElement('SPAN');
			span.innerHTML=panelTitles[tm_paneIndex];
			topBar.appendChild(span);
			topBar.onclick=showHidePaneContent;
			if(document.all)topBar.ondblclick=showHidePaneContent;
			topBar.onmouseover=mouseoverTopbar;
			topBar.onmouseout=mouseoutTopbar;
			topBar.style.position='relative';

			var img=document.createElement('IMG');
			img.id='Button' + tm_Paneset + '.' + tm_paneIndex;
			img.src='img/arrow_up.gif';
			topBar.appendChild(img);

			if(cookieArray[tm_paneIndex]){
				cookieValue=Get_Cookie(cookieArray[tm_paneIndex]);
				if(cookieValue)panelDisplayed[tm_paneIndex]=cookieValue==1?true:false;
			}

			if(!panelDisplayed[tm_paneIndex]){
				outerContentDiv.style.height='0px';
				contentDiv.style.top=0-contentDiv.offsetHeight+'px';
				if(document.all)outerContentDiv.style.display='none';
				img.src='img/arrow_down.gif';
			}

			topBar.className='topBar';
			divs[no].appendChild(topBar);
			divs[no].appendChild(outerContentDiv);
			tm_paneIndex++;
		}
	}
}

// Fisheye Menu

k=document;v=Date;x=false;z=Array;af=Math.floor;ag=RegExp;b=new z(5);s=new z("null","chat","myweb","ecard","signup");aa=new z(4);ab=10;t=0;u=0;n=0;o=new v();h=5;m=200;c=0;w=x;var title;var firstHoverOccurred=x;m=200;p=0;function d(ac){c=ac;o=new v();setTimeout("gidle()",30);}function e(ac){c=0;w=x;o=new v();setTimeout("gidle()",30);}function ae(){for(var j=1;j<b.length;j++){b[j]=50}title=k.getElementById('imageTitle');for(i=0;i<b.length-1;i++){aa[i]=new Image();aa[i].src="/img/"+s[i+1]+".gif"}setTimeout("gidle()",30);}function gidle(){var l=0;for(var i=1;i<b.length;i++){var imagename="image"+i;var imageElem=k.getElementById(imagename);if(c!=i){if(b[i]>50){b[i]-=h;if(b[i]<=50){b[i]=50;imageElem.src="/img/"+s[i]+"-sm.gif"}imageElem.width=b[i];imageElem.height=b[i];if(c==0){var g=af(255-255*(b[i]-50)/50);title.style.color="rgb("+g+","+g+","+g+")";if(g==255)title.innerHTML=' '}p=1}l+=b[i]}}if(c!=0&&b[c]<90){imagename="image"+c;imageElem=k.getElementById(imagename);if(w==x){w=true;if(c<3){var y=150-(c-1)*95;title.innerHTML=k.getElementById(imagename).alt+'<img src="/img/dot.gif" width="'+y+'" height="5"/>'}else{var y=(c-2)*95-30;title.innerHTML='<img src="/img/dot.gif" width="'+y+'" height="1"/>'+k.getElementById(imagename).alt}}b[c]+=h;p=1;if(b[c]>90){b[c]=90}l+=b[c];if(l<m){b[c]+=m-l;if(b[c]>90){b[c]=90}l=m}var g=af(255-255*(b[c]-50)/50);title.style.color="rgb("+g+","+g+","+g+")";imageElem.width=b[c];imageElem.height=b[c];k.getElementById(imagename).src="/img/"+s[c]+".gif"}m=l;var ad=new v();ab=ad.getTime()-o.getTime();o=ad;t+=ab;u++;n=t/u;h=5;if(u>4){if(n>30){h=10}if(n>60){h=15}if(n>90){h=20}}if(p){setTimeout("gidle()",30);p=0}}

function fadeIn(id,duration,run)
{
	var activePane=document.getElementById(id);
	var delay=Math.round(duration/10);
	if(run!=1) opacity=0;
	opacity=opacity+10;
	if(opacity>100) opacity=100;
	activePane.style.filter='alpha(opacity='+opacity+')';
	activePane.style.opacity=opacity/100;
	if(opacity<100) setTimeout("fadeIn('"+id+"',"+duration+",1)",delay);
}

function fadeOut(id,duration,run)
{
        var activePane=document.getElementById(id);
	var delay=Math.round(duration/10);
	if(run!=1) opacity=100;
        opacity=opacity-10;
        if(opacity<0) opacity=0;
        activePane.style.filter='alpha(opacity='+opacity+')';
        activePane.style.opacity=opacity/100;
        if(opacity>0) setTimeout("fadeOut('"+id+"',"+duration+",1)",delay);
}

function slideTo(id,duration,pos,step)
{
	var activePane=document.getElementById(id);
	var delay=Math.round(duration/20);
	if(typeof(step)=='undefined') step=Math.round((pos-activePane.offsetLeft)/20);
	newleft=activePane.offsetLeft+step;
	if(Math.abs(newleft-pos)<Math.abs(step)) newleft=pos;
	activePane.style.left=newleft;
	if(Math.abs(newleft-pos)>=Math.abs(step))setTimeout("slideTo('"+id+"',"+duration+","+pos+","+step+")",delay);
}
