var ns4=(document.layers)?true:false;
var ie4up=(document.all)?true:false;
var ns5up=(document.getElementById && !ie4up)?true:false;

//  the first parameter passed must be the full image path up to and including the last '/'
//  after that list all images with extension (.gif, .jpg) and they will be cached
function cacheImgs(){
	cached = new Array();
	for (var i=1;i<arguments.length;i++){
		cached[i]=new Image();
		cached[i].src = arguments[0] + arguments[i];
	}
}
	

//  for rollovers - the first parameter passed should be the name of the image followed by the rollover image with extension (.gif, .jpg)   
function imgSwap(nom,pik){
	var end_path;
	var image_path;
	end_path=document[nom].src.lastIndexOf('/') + 1;
	image_path=document[nom].src.substring(0,end_path);
	document[nom].src = image_path + pik;
}

//Function to open LotFinder. Just pass it sale number and lot number.
//to add LotFinder link to page; use this example: href="javascript:goLotFinder('saleNumber','lotNumber')"
var lotFinderWin;
var promoSaleID;
function goLotFinder(saleNum,lotNum){
	if(arguments.length == 0){return}
	if (arguments.length == 1){
		parseInt(saleNum);
		if(saleNum == null || saleNum == "" || isNaN(saleNum)){return}
		else{
			if(!lotFinderWin || lotFinderWin.closed){
				lotFinderWin = window.open('http://www.christies.com/LotFinder/search/searchresults.asp?SN='+saleNum+'','LotFinder','location=yes,menubar=yes,status=yes,toolbar=yes,scrollbars=yes,resizable=yes')}
			else{
				lotFinderWin.location='http://www.christies.com/LotFinder/search/searchresults.asp?SN='+saleNum; lotFinderWin.focus();
			}
		}	
	}
	else if(lotNum == null || lotNum == ""){return}
	else{
		parseInt(lotNum)
		if(isNaN(lotNum)){return}
		ilot = lotNum.toString();
		if(ilot.length==1){ilot = '000'+ilot};
		if(ilot.length==2){ilot = '00'+ilot};
		if(ilot.length==3){ilot = '0'+ilot};
		if(!lotFinderWin || lotFinderWin.closed){
			lotFinderWin = window.open('http://www.christies.com/LotFinder/search/searchresults.asp?SN='+saleNum+'&LN='+ilot+'','LotFinder','location=yes,menubar=yes,status=yes,toolbar=yes,scrollbars=yes,resizable=yes')}
		else{
			lotFinderWin.location='http://www.christies.com/LotFinder/search/searchresults.asp?SN='+saleNum+'&LN='+ilot; lotFinderWin.focus();
		}
	}
}

function runSlideShow() {
	if (document.all) {
		document.images.SlideShow.style.filter="blendTrans(duration=2)";
		document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}
	document.images.SlideShow.src = preLoad[j].src;
	if (document.all) {
		document.images.SlideShow.filters.blendTrans.Play();
	}
	j = j + 1;
	if (j == p) j = 0; 
	t = setTimeout('runSlideShow()', slideShowSpeed); 
}

//cacheImgs('images/','startImage.gif','stopImage.gif');
var iPause = 1
var stop = true;
var start = false;
var pausePic_btn = new Array('images/startImage.gif','images/stopImage.gif')
function pausePic(){
	objPause = document['pauseImg'];
	if(iPause == 1){
		start = true;
		stop = false;
		pauseMe();
		objPause.src=pausePic_btn[0];
		iPause = iPause + 1;}
	else if(iPause == 2){
		start = false;
		stop = true;
		runSlideShow();
		objPause.src=pausePic_btn[1];
		iPause = 1;}
}
function pauseMe(){clearTimeout(t);}

// function for showMe

if (ns4) {var visible='show'; var hidden='hide';}
if (ie4up) {var visible='visible'; var hidden='hidden';}
if (ns5up) {var visible='visible'; var hidden='hidden';}

function showMe(){
	hideRule();
	if (!(ie4up || ns5up || ns4)) {return }
	if (ie4up) {var daRef=document.all['catSub'].style;
				var otherRef=document.all['specialistSub'].style;}
	if (ns5up) {var daRef=document.getElementById('catSub').style;
				var otherRef=document.getElementById('specialistSub').style;}
	if (ns4) {var daRef=document.layers['catSub'];
			  var otherRef=document.layers['specialistSub'];}
	otherRef.visibility=hidden;
	if (daRef.visibility==hidden || daRef.visibility=='') {daRef.visibility=visible;showRule("catSub");}
	else {daRef.visibility=hidden;hideRule();}
	}
	
function showMe2(){
	hideRule();
	if (!(ie4up || ns5up || ns4)) {return }
	if (ie4up) {var daRef2=document.all['specialistSub'].style;
				var otherRef2=document.all['catSub'].style;}
	if (ns5up) {var daRef2=document.getElementById('specialistSub').style;
				var otherRef2=document.getElementById('catSub').style;}
	if (ns4) {var daRef2=document.layers['specialistSub'];
			  var otherRef2=document.layers['catSub'];}
	otherRef2.visibility=hidden;
	if (daRef2.visibility==hidden || daRef2.visibility=='') {daRef2.visibility=visible;showRule("specialistSub");}
	else {daRef2.visibility=hidden;hideRule();}
	}

function showRule(showDiv){
	if (showDiv == "catSub"){
		imgSwap("nav_rule","nav_rule_catalogue.gif")
	}
	else {imgSwap("nav_rule","nav_rule_specialist.gif")}
}

function hideRule(){
	imgSwap("nav_rule","clear.gif")
}
	
//Flash Detector
var flash3Installed = false;		// boolean. true if flash 3 is installed
var flash4Installed = false;		// boolean. true if flash 4 is installed
var flash5Installed = false;		// boolean. true if flash 5 is installed

// write vbscript detection if we're on ie win

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;	// true for ie
var isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false; // true for mac
var isIEMac4 = (navigator.userAgent.charAt(navigator.userAgent.indexOf('MSIE')+5)<5)?true:false;
if(isIE && !isMac){ // only write vbscript on ie win
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
	document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');	
	document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

//now we will test for flash in netscape

if (navigator.plugins){								// does navigator.plugins exist?
	if (navigator.plugins["Shockwave Flash 2.0"] 	// if yes then is Flash 2 installed?
	|| navigator.plugins["Shockwave Flash"]){		// or is flash 3+ installed?
		// set convenient references to flash 2 and the plugin description and version
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		flash3Installed = (flashVersion == 3)?true:false;
		flash4Installed = (flashVersion == 4)?true:false;
		flash5Installed = (flashVersion == 5)?true:false;}}	

if(isIEMac4){flash5Installed = true;}

//if (!(flash3Installed || flash4Installed || flash5Installed)){ // if no flash

//Shockwave Detection function
if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)){	
		//This script needs to go on the page itself for the Shockwave detection to work
		document.writeln('<script language="VBScript">')
		document.writeln('<!-- // You need this visual basic helper to detect ActiveX control')
		document.writeln('Function VBGetShockwaveVer(i)')
		document.writeln('  on error resume next')
		document.writeln('  Dim swControl, swVersion')
		document.writeln('  swVersion = "0.0"')
		document.writeln('  set swControl = CreateObject("SWCtl.SWCtl." + CStr(i))')
		document.writeln('  if (IsObject(swControl)) then')
		document.writeln('    swVersion = CStr(i) + ".0"')
		document.writeln('    swVersion = CStr(swControl.ShockwaveVersion(""))')
		document.writeln('  end if')
		document.writeln('  VBGetShockwaveVer = swVersion')
		document.writeln('End Function')
		document.writeln('// -->')
		document.writeln('</script>')
}
function shockwaveDetectAxVer(reqVer) {
// For detecting the ActiveX for ie win.
// Requires vbscript function above.
// Returns version found or 0.0.
// This function can return a boolean or a floating point value.
// If you supply a reqVer value (number) it will return true or false
// depending on if that version or higher was found.
// If you don't supply a parameter it will return the found version number.
	
	  // this function returns a floating point value which should be the version of the Shockwave control or 0.0
	  // this function should only be called from Internet Explorer for Windows
	  if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && !(((navigator.appVersion.charAt( navigator.appVersion.indexOf("MSIE")+5 )) <= 4 ) && isMac) && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)){
	   	// loop backwards through the versions until we get a bite
	    for (i=8;i>0;i--) {
	      versionString = VBGetShockwaveVer(i);
	      if (versionString != "0.0") {
	        // if we get 1.0 we assume it is actually 6.0
	        versionNum = (versionString == "1.0" ? 6.0 : parseFloat(versionString));
			return (reqVer ? versionNum >= reqVer : versionNum);
	      }
	    }
	  }
	  //cannot detect IE 4 or less on the Mac, so return true or version number and let the user figure it out.
	  else if( ( navigator.userAgent.indexOf("MSIE") >=0 ) && ( navigator.appVersion.charAt(navigator.appVersion.indexOf("MSIE")+5) <= 4 ) && (isMac) ){
	  	return (reqVer ? true : reqVer)
	  }
	  else if(navigator.mimeTypes && navigator.mimeTypes["application/x-director"] && navigator.mimeTypes["application/x-director"].enabledPlugin) {
		if(navigator.plugins && navigator.plugins["Shockwave for Director"] && (versionIndex = navigator.plugins["Shockwave for Director"].description.indexOf(".")) != - 1){
	    	var versionString = navigator.plugins["Shockwave for Director"].description.substring(versionIndex-1,versionIndex);
	    	var subVersionString = navigator.plugins["Shockwave for Director"].description.substring(versionIndex+1,versionIndex+2);
	    	versionIndex = parseInt( versionString );
			subVersionIndex = parseInt(subVersionString);
			versionNum = versionIndex+'.'+subVersionIndex;
			return (reqVer ? versionNum >=reqVer : versionNum);
	    }
	  }
	return (reqVer ? false : 0.0);
}

function nsCssFix() {document.location=document.location;}
if ((ns4) && (parseInt(navigator.appVersion)==4)){window.onresize=nsCssFix;}

function findLeft() {
	if(ie4up){
		var x=0;
		//var y=0;
		var ref=document.all.lefty;
		if(!ref){return}
		else {
			while (ref.offsetParent){
				x+=ref.offsetLeft;
				//y+=ref.offsetTop;
				ref=ref.offsetParent;
			}
			document.all['catSub'].style.pixelLeft=x;
			document.all['specialistSub'].style.pixelLeft=x;
		}
	}
	if(ns4){
	var daLeft = document.images['lefty'].x;
				document.catSub.left = daLeft;
				document.specialistSub.left=daLeft;
	}
	if(ns5up){
	var daLeft = document.images['lefty'].offsetLeft;
	document.getElementById('catSub').style.left=daLeft + 'px';
	document.getElementById('specialistSub').style.left=daLeft + 'px';
	}
}

onresize = findLeft
