//Detect browser
var agt		= navigator.userAgent.toLowerCase();
var version = navigator.appVersion 
var MSIE	= agt.indexOf("msie")
var IE		= ( MSIE!= -1);

//array holding the pictures
var homepic = new Array;

//all these pictures must be the same in size :
var pwd		= 350;	//art pictures width
var phg		= 350;	//art pictures height
var pint	= 20;	//number of seconds between art pictures
var pspd	= 10;	//speed of the IE animations
var pani	= false;//switch IE animations
var picdesc	= null;
var pich, pdiff, anima, pnxt, pmod, artx;

//function for the art
function swap_art_images() {

    for (var i=0; i<parent.frames.length; i++) {
        if (parent.frames[i].name == "homemain") artx = parent.homemain.setInterval("next_pic(1,false)",pint*1000);
    }
}

function next_pic(pstp,set) {

	if (picdesc) if (picdesc!=null) if (!picdesc.closed) return true;
	clearInterval(anima);
	if (set) {
		clearInterval(artx);
		artx = parent.homemain.setInterval("next_pic(1,false)",pint*1000);
	}
	if (typeof(pnxt)=="undefined") pnxt = -1;
	if (typeof(pstp)=="undefined") pstp = 1;
	get_pictures();
	panz = homepic.length
	pnxt = pnxt+pstp;
	if (pnxt>homepic.length-1) pnxt = 0;
	if (pnxt<0) pnxt=homepic.length-1;
	if (parent.artpics.document.loaded.loadpic.value.indexOf("#"+pnxt+"P")>-1) {
		if (IE && pani) {
			pdiff = -pspd;
			pich  = parent.homemain.document.homepic.height;
			if (typeof(pmod)=="undefined") pmod = -1;
			clearInterval(anima);
			pmod  = 0;
			anima = parent.homemain.setInterval("shrink("+pstp+")",1);
		}
		else { //in Netscape no change of image size possible or animation disabled
			parent.homemain.document.homepic.src = parent.artpics.document.images["hidpic"+pnxt].src;
		}
	}
	return true;
}


function shrink(pstp) {
	var p = parent.homemain.document.homepic
	var a;
	if (pmod==1) {pich=p.height;}
	else {pich=p.width;}
	pich = pich + pdiff;
	if (pich<=-Math.abs(pdiff)) {
		p.src = parent.artpics.document.images["hidpic"+pnxt].src
		pich  = pich+pdiff;
		pdiff = pspd;
		pich  = pich+pdiff;
	}
	if (pmod==1) a=phg;
	else a = pwd;
	if (pich>=a) {
		clearInterval(anima);
	}
	set_pic_size(p);
}


function set_pic_size(p) {
	if (pmod==0) {p.height=phg;p.width=pich;}
	if (pmod==1) {p.height=pich;p.width=pwd;}
	if (pmod==2) {p.height=pich;p.width=pich;}
}

function get_pictures() {
	var p = parent.artpics.document.homepics.pics;
	if (p) {
		var str = p.value;
		var x   = -1;
		var i   = -1;
		var y,pic;
		do {
			x = str.indexOf("[",x+1);
			y = str.indexOf("]",x+1);
			if (x != -1 && y>x) {
				pic = str.substring(x+1,y);
				if (pic != "") {
					i++;
					homepic[i] = pic;
				}
			}
		} while (x!=-1);
	}
}


function art_info() {
	clearInterval(anima);
	clearInterval(artx);
	artx = parent.homemain.setInterval("next_pic(1,false)",pint*1000);   
	show_art_window();
}


function show_art_window() {
	var name,htm;
	var p = parent.homemain.document.homepic;
	if (IE) {
		p.height = phg;
		p.width  = pwd;
	}
	name	= p.src;
	var low = name.toLowerCase();	
	
	var pos1, pos2, strArtName, strArtID;
	pos1 = name.lastIndexOf("/") + 1;
	pos2 = name.lastIndexOf(".");
	strArtName = name.substring(pos1,pos2);
	
	if(strArtName == "home")
	    strArtID = "0"
	else
		strArtID = strArtName.substring(0,strArtName.indexOf("350"))
		
	//htm = "http://localhost/wwwnet/graphics/art/ArtworkDetails.aspx?artPID=" + strArtID
	
	htm = "http://www.starkmann.com/graphics/art/ArtworkDetails.aspx?artPID=" + strArtID
	
	
		
	//htm		= name.substring(0,low.indexOf(".jpg"))+".htm";	
	//picdesc = window.open(htm,"pic_desc","scrollbars,height="+p.height+",width="+p.width+",resizable, titlebar=no, top=200, left=500");
	//if (htm=="http://localhost/wwwnet/graphics/art/01350.htm") picdesc = window.open(htm,"pic_desc","scrollbars,height=837,width=650,resizable, titlebar=no, top=200, left=500");
    //if (htm=="http://localhost/wwwnet/graphics/art/07350.htm") picdesc = window.open(htm,"pic_desc","scrollbars,height=837,width=650,resizable, titlebar=no, top=200, left=500");
    //if (htm=="http://localhost/wwwnet/graphics/art/05350.htm") picdesc = window.open(htm,"pic_desc","scrollbars,height=837,width=630,resizable, titlebar=no, top=200, left=500");
 
    picdesc = window.open(htm,"pic_desc","scrollbars,height=400,width=650,resizable, titlebar=no, top=200, left=600");
	picdesc.focus();
	
}

   
function close_art_window() {
	if (picdesc) if (picdesc.open && picdesc!=null) picdesc.close();
}