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")
}
	
//New Flash Detection
//this is a function which should be used instead of the old way below
var flashVersion = 0;
function getFlashVersion() {
	var agent = navigator.userAgent.toLowerCase(); 
	
   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }
   
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			if (flashPlugin.description.indexOf('7.') != -1) flashVersion = 7;
			else if (flashPlugin.description.indexOf('6.') != -1) flashVersion = 6;
			else if (flashPlugin.description.indexOf('5.') != -1) flashVersion = 5;
			else if (flashPlugin.description.indexOf('4.') != -1) flashVersion = 4;
			else if (flashPlugin.description.indexOf('3.') != -1) flashVersion = 3;
		}
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   document.write('<scr' + 'ipt language="VBScript"\> \n');
		document.write('on error resume next \n');
		document.write('dim obFlash \n');
		document.write('set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.7") \n');
		document.write('if IsObject(obFlash) then \n');
		document.write('flashVersion = 7 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.6") end if \n');
		document.write('if flashVersion < 7 and IsObject(obFlash) then \n');
		document.write('flashVersion = 6 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.5") end if \n');
		document.write('if flashVersion < 6 and IsObject(obFlash) then \n');
		document.write('flashVersion = 5 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.4") end if \n');
		document.write('if flashVersion < 5 and IsObject(obFlash) then \n');
		document.write('flashVersion = 4 \n');
		document.write('else set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash.3") end if \n');
		document.write('if flashVersion < 4 and IsObject(obFlash) then \n');
		document.write('flashVersion = 3 \n');
		document.write('end if');
		document.write('</scr' + 'ipt\> \n');
  }
		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	// Can't detect in all other cases
	else {
		flashVersion = flashVersion_DONTKNOW;
	}

	return flashVersion;
}

flashVersion_DONTKNOW = -1;

//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['catCover'].style.pixelLeft=x;
		}
	}
	if(ns4){
	var daLeft = document.images['lefty'].x;
				document.catCover.left = daLeft;
				//document.specialistSub.left=daLeft;
	}
	if(ns5up){
	var daLeft = document.images['lefty'].x;
	document.getElementById('catCover').style.left=daLeft + 'px';
	//document.getElementById('specialistSub').style.left=daLeft + 'px';
	}
	document['browse'].src = "images/browse_off.gif";
	document['buy'].src = "images/buy_off.gif";
}

var isShown="no"

function showMe3(){
	if(isShown=="yes"){
	hideMe3();
	return;
	}
	if (!(ie4up || ns5up || ns4)) {return }
	if (ie4up) {var daRef2=document.all['catCover'].style;}
	if (ns5up) {var daRef2=document.getElementById('catCover').style;}
	if (ns4) {var daRef2=document.layers['catCover'];}

	if(ie4up){daRef2.pixelTop=0;}
	if(ns5up){daRef2.top=0;}
	if(ns4){daRef2.top=0;}
	
	daRef2.visibility = hidden;
	isShown="yes"
}

function hideMe3(){
	isShown="no"
	if (!(ie4up || ns5up || ns4)) {return }
	if (ie4up) {var daRef2=document.all['catCover'].style;}
	if (ns5up) {var daRef2=document.getElementById('catCover').style;}
	if (ns4) {var daRef2=document.layers['catCover'];}

	daRef2.visibility = visible;
	if(ie4up){daRef2.pixelTop=123;}
	if(ns5up){daRef2.top=123;}
	if(ns4){daRef2.top=123;}
}

onresize = findLeft

//onresize = findLeft
