var img_pre = new Array();
var fade_ok = 1;
var last_id = 1;
var preload_ok = 1;
var is_netscape = (navigator.appName == "Netscape");

function switch_content(iid)
{
	if(iid > 0 && fade_ok == 1 && last_id != iid)
	{
		fade_ok=0;
		timer=50;
		fade('out','window_content_img',0);
		setTimeout("switch_string('window_content_img','2',"+iid+")",(timer * 2));
		setTimeout("fade('in','window_content_img',"+(timer)+")",(timer * 3));
		setTimeout("switch_string('window_content_img2','2',"+iid+")",(timer * 14));
		last_id=iid;
	}
}

function preload_image(pid,amount)
{
	preload_ok=0;
	for(i=1;i<=amount;i++)
	{
		img_pre[i] = new Image();
		img_pre[i].src = "user/portfolio/img_"+pid+"_"+i+".jpg";
	}
}

function switch_string(sname,stype,newstring)
{
	if(stype == 1)
	{
		document.getElementById(sname).innerHTML=newstring;
	}
	else if(stype == 2)
	{
		document.getElementById(sname).src = img_pre[newstring].src;
	}
}

function fade(fader,sname,timer)
{
	timer_c=0;
	for(((fader=='in')?(i=1):(i=9));((fader=='in')?(i<=10):(i>=0));((fader=='in')?(i++):(i--)))
	{
		setTimeout("opac("+i+",'"+sname+"');",timer_c*timer);
		timer_c++;
	}
}

function opac(i,sname)
{
	var object = document.getElementById(sname).style;
	object.opacity = (i / 10);
	object.MozOpacity = (i / 10);
	object.KhtmlOpacity = (i / 10);
	object.filter = "alpha(opacity="+(i * 10)+")";
	if(i == 10)
	{
		fade_ok=1;
	}
}