// VILLANI EDITIONS Javascript file

var len = 0
// elm = 12 // restricted
var art_list = ''
var reorder = new Array()
var done    = 'no'
var trace   = 'reord:'
var col     =4
siz = 130


    function popSeries(page) {
 	size = 'width=650,height=760' + ',resizable,scrollbars=yes'
 	popWnd = window.open(page,'series',size)
 	popWnd.document.close()
 	popWnd.focus()
    }

    function popWork(page) {
 	size = 'width=650,height=760' + ',resizable'
 	popWnd = window.open(page,'work',size)
 	popWnd.document.close()
 	popWnd.focus()
    }

    function showTit(typ,tit) { 
	var TEXTobj = document.getElementById(typ);
        var tit = '<SPAN class=tit>' + tit + '</SPAN>'
	TEXTobj.innerHTML = tit;
    }

    function resetTit(typ,tit) { 
	var TEXTobj = document.getElementById(typ);
        var tit = '<SPAN class=tit>' + tit + '</SPAN>'
	TEXTobj.innerHTML = tit;
    }

    function scramble() {
	var sel = 1
	for (var k=1;k<=len;k++ ) { reorder[k] = k}
        for (var i=1;i<=len;i++ ) { 
	     sel = 1 + Math.floor( (Math.random()* (len )) )
	     temp = reorder[i]
	     reorder[i] = reorder[sel]
	     reorder[sel] = temp
	}
    }

    function getSel(col,elm,sz,ln) {
	var i=0
	len = worklist.length -2
	if(done == 'no') {
		scramble()
		done = 'yes'
	}
	if(sz > 0) { siz = sz }
        for (var n=1;n<=len;n++ ) { 
	    img  = getArtist(reorder[n])
 	    if(img == '') { continue }
	    if(i++ >=elm)  { return(0) }
	    if((i%col)==1) {
	    	document.write('<tr valign=top colspan=' + col + ' >')
	    }
	    document.write('<td width=' + ln + ' align=left><SPAN class=img>')
	    document.write(img)
	    document.write('</SPAN></td>')

	    if((i%col)==0) {
	    	document.write('</tr>')
	    }

	}
    }

 function getArtist(num) {
	var txt = worklist[num]
	info    = txt.split('|')
	art_cd = info[2]
        image = info[3]
	pic   = image.split('.')

// document.write(art_cd,"- ",image,"- ",pic,"<br>")

	if( (art_list.indexOf(art_cd)>=0) ) { return('') }  // exclude picked artists
        art_list = art_list + art_cd + ','
	if(image=='') { img = '<img src="images/thumb/no_image.jpg" ' }
	else 		{ img = '<img src="http://www.villanieditions.com/work/' + art_cd + '_' + pic[0] + '_s.' + pic[1] + '" '}
 	img = img + 'alt="' + info[5] + ", " + info[6] + '" height=' + siz +  ' border=1>' 
	lnk = '<a HREF="http://www.villanieditions.com/cgi/VIL_artist.pl?artist='  + art_cd + '" >' + img + '<br>' + info[4] + '<br></a>'
	return(lnk)
    }


    function maili() {
      document.write("<P><a HREF=" + "Mailto:info")
      document.write("\@" + "villanieditions.")
      document.write("com>")
      document.write("</a></nobr></P>")
    }

    function foot() {
      document.write("<table border=0 width=800><tr>")
      document.write("<td><SPAN  class=foot><nobr>DIANE VILLANI | editions &nbsp; 285 Lafayette Street, &nbsp; NEW YORK, NY 10012</nobr></SPAN></td>")
      document.write("<td align=center><a class=mail HREF='Mailto:info@villanieditions.com'>info@VillaniEditions.com</td>")
      document.write("<td align=right><SPAN class=foot><nobr> +1 (212) 925-1075 | T &nbsp; +1 (212) 966-8411 | F</SPAN></nobr>")
      document.write("</td></tr><tr><td colspan=3><img src='http://www.villanieditions.com/images/1x1_trans.gif' border=0 width=800 height=30><br>")
      document.write("</tr></td></table>")
    }

    function popup_foot() {
      document.write("<table border=0 width=380><tr>")
      document.write("<td align=center><SPAN class=white><nobr>&copy DIANE VILLANI | editions &nbsp;&nbsp; 285 Lafayette Street, &nbsp;&nbsp; NEW YORK, NY 10012</nobr>")
      document.write("<br>+1 (212) 925-1075 | T &nbsp;&nbsp;&nbsp; +1 (212) 966-8411 | F")
      document.write(" &nbsp;&nbsp;&nbsp; info@VillaniEditions.com</SPAN>")
      document.write("</td></table>")
    }

    function mail() {
      document.write("<a class=assoc HREF='Mailto:info@villanieditions.com'>info@villanieditions.com</a>")
    }

