//  GLOBAL SCRIPTS

  var ie4 = document.all
  var ns6 = document.getElementById&&!document.all
  var ns  = navigator.userAgent.indexOf('Netscape') != -1 && navigator.userAgent.indexOf('Gecko') != -1
  var opr = navigator.userAgent.indexOf('Opera/') != -1 | navigator.userAgent.indexOf('Opera ') != -1;   // Opera identifying Opera or Other
  var moz = navigator.userAgent.indexOf('Gecko') != -1

if (self != top) top.location = self.location;

	// PRELOAD ICONS
icon0 = new Image();icon0.src = "images/icon_info.gif"
icon1 = new Image();icon1.src = "images/icon_info2.gif"
icon2 = new Image();icon2.src = "images/icon_zoom.gif"
icon3 = new Image();icon3.src = "images/icon_zoom2.gif"
icon4 = new Image();icon4.src = "images/icon_zoom_out.gif"
icon5 = new Image();icon5.src = "images/icon_zoom_out2.gif"
icon6 = new Image();icon6.src = "images/type_icon_print.gif"
icon7 = new Image();icon7.src = "images/type_icon_orig.gif"
icon8 = new Image();icon8.src = "images/type_icon_cards.gif"
icon9 = new Image();icon9.src = "images/type_icon_cards_small.gif"
icon10= new Image();icon10.src = "images/type_icon_keyfob.gif"

	//  IMAGE ROLLOVERS
function swapBg(mo,ab) {
 if (ab=='a'){
        mo.style.backgroundColor = '#f1ddba'
                 mo.style.cursor = 'pointer';}
 if (ab=='b'){
	mo.style.backgroundColor = '#ffffff'
	mo.style.cursor          = '';}
 if (ab=='a2'){
        mo.style.backgroundColor = '#fffff0'
                 mo.style.cursor = 'pointer';}
 if (ab=='b2'){
	mo.style.backgroundColor = '#f9edd7'
	mo.style.cursor          = '';}
 if (ab=='a3'){
        mo.style.backgroundColor = '#fffff0'
        mo.style.color           = '#7a3a02'
        mo.style.cursor          = 'pointer';}
 if (ab=='b3'){
	mo.style.backgroundColor = '#f9edd7'
        mo.style.color           = '#c58513'
	mo.style.cursor          = '';}
}

	//  DROPDOWN MENUS
//Adapted from SuckerTree Horizontal Menu - Dynamic Drive: http://www.dynamicdrive.com/style/

var menuids= new Array('menu1')       //Enter id(s) of UL menus separated by commas
var adj ='';  adj=-2; if(ns){adj=199}

function submenus(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
   for (var t=0; t<ultags.length; t++){
    if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
        ultags[t].style.top=ultags[t].parentNode.offsetHeight+adj+"px" //dynamically position first level submenus to be height of main menu item
//        ultags[t].parentNode.getElementsByTagName("a")[0].className="mainicon"
	}
	else{ //else if this is a sub level menu (ul)
        ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
        ultags[t].parentNode.getElementsByTagName("a")[0].className="subicon"
	}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
   }
  }
}

if (window.addEventListener)
window.addEventListener("load",submenus,false)
else if (window.attachEvent)
window.attachEvent("onload",submenus)

	// COPYRIGHT UPDATE
function copyright() {
	cr      = new Date().getFullYear()+""
	cryear  = cr
	cpright = 'All content <span style="font-size:12pt">&copy;</span> David Carlile 2006-' + cryear + '&nbsp;&#151;&nbsp;Site design <span style="font-size:12pt">&copy;</span> <a class="web2" target="_blank" href="http://www.sibleyfineart.com">MSFA</a> 2006-' + cryear + ' &#151;&nbsp;<script type="text/javascript">document.write(webmaster())</script>'
   return cpright
}

	// OPEN GALLERY IMAGE from LINK
	// Fires "viewThis()" from link + feeds LinkGenerator

function gotoImage() {
       var idx = document.URL.indexOf('?')
  if (idx != -1) {
     imgId = document.URL.substring(idx+1,document.URL.length)
        post = document.getElementById(imgId).innerHTML
      params = post.substring(post.indexOf('viewThis'),post.indexOf(';return'))
eval(params)
	}
}

	// EXTERNAL LINK GENERATOR
  var copy = 1
function linkGen() {
	imgId = imgId
	btn = document.getElementById('linkG')
	genD= document.getElementById('linkData')
	genD.style.border = '1pt solid grey'
	genD.style.background = 'white'
	genD.value = 'www.DCArtwork.co.uk/' +category +gallery+ '.htm?' +imgId
  if(copy==0) {
	btn.innerHTML = '<a href="#" onClick="linkClr();return false">clear</a>'
	genD.focus()
	genD.select()
	}else{
	btn.innerHTML = '<a href="#" onClick="linkCopy();return false">copy</a>'
	} 
}
function linkCopy() {
	btn = document.getElementById('linkG')
	genD= document.getElementById('linkData')
	genD.focus()
	genD.select()
  if(ie4){
window.clipboardData.clearData()
window.clipboardData.setData('Text',genD.value)
  if(window.clipboardData.setData != -1) {
	genD.value = 'Link succesfully copied to CLIPBOARD'
	btn.innerHTML = '<a href="#" onClick="linkClr();return false">clear</a>'
	copy = 1  }
  if(window.clipboardData.setData == -1) {
	genD.value = 'COPY FAILED - click button to restore link - right-click link to copy manually - click button to clear'
	btn.innerHTML = '<a href="#" onClick="linkGen();return false">link</a>'
	copy = 0	}
    }
  if(!ie4){
	btn.innerHTML = '<a href="#" onClick="linkClr();return false">clear</a>'
	copy = 1 
     }
}
function linkClr() {
	btn = document.getElementById('linkG')
	genD= document.getElementById('linkData')
	genD.style.border = 'none'
	genD.style.background = 'none'
	genD.value = ''
	btn.innerHTML = '<a href="#" onClick="linkGen();return false">link</a>' 
	copy = 1
}



