﻿
/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var trailimage = ["test.gif",480,480]
var offsetfrommouse=[-50,0] //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0 //duration in seconds image should remain visible. 0 for always.
var compwidth = 480
var compheight = 480
var isbigcomp = 1


// initialize global variables
var detectableWithVB = false;
var pluginFound = false;

function detectPlugin() {
  // allow for multiple checks in a single pass
  var daPlugins = detectPlugin.arguments;
  // consider pluginFound to be false until proven true
  var pluginFound = false;
  // if plugins array is there and not fake
  if (navigator.plugins && navigator.plugins.length > 0) {
  	var pluginsArrayLength = navigator.plugins.length;
  	// for each plugin...
  	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
  	    // loop through all desired names and check each against the current plugin name
    var numFound = 0;
  	    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
      		// if desired plugin name is found in either plugin name or description
      		if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
      		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
      		    // this name was found
      		    numFound++;
      		}
    	  } // end of for
        // now that we have checked all the required names against this one plugin,
        // if the number we found matches the total number provided then we were successful
        if(numFound == daPlugins.length) {
      		pluginFound = true;
      		// if we've found the plugin, we can stop looking through at the rest of the plugins
      		break;
    	  }
    } // end of for
  } //end of if
  return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}

function loadQT()
{
  if (document.getElementById || document.all) {
  	document.write('<div id="showzoomid"><img src="images/spacer.gif" width="0" height="0"></div>');
  	gettrailobj().width=0;
  	gettrailobj().height=0;
    gettrailobj().left="-1000px";
    gettrailobj().top="10px";
  	gettrailobj().visibility="hidden";
    gettrailobj().display="";
  }

}

loadQT()


function loadQTV()
{
  if (document.getElementById || document.all) {
  	document.write('<div id="showzoomid"><img src="/images/spacer.gif">');
  	document.write('</div>');
  	pluginFound = detectPlugin('QuickTime');
  	// if not found, try to detect with VisualBasic
  	if(!pluginFound && detectableWithVB) {
  		pluginFound = detectQuickTimeActiveXControl();
    }
  	if (pluginFound) {
    	document.getElementById("showzoomid").innerHTML = '<div style="width:0px;height:0px;padding:4px;background-color:#fff;border:1px solid #888;"><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="0" height="0" align="middle"> <param name="src" value="/images/spacer.mov"> <param name="autoplay" value="true"> <param name="bgcolor" value="#ffffff"> <embed width="0" height="0" src="/images/spacer.mov" bgcolor="#ffffff" pluginspage="http://www.apple.com/quicktime/download/"></embed></object></div>'
  	}
  	gettrailobj().width=0;
  	gettrailobj().height=0;
    gettrailobj().left="-1000px";
    gettrailobj().top="0px";
  	gettrailobj().visibility="visible";
    gettrailobj().display="";
  }

}

function gettrailobj(){
  if (document.getElementById)
    return document.getElementById("showzoomid").style
  else if (document.all)
    return document.all.trailimagid.style
}

function truebody(){
  return (!window.opera && document.compatMode && document.compatMode!="BackCompat")?   document.documentElement : document.body
}

function showtrail(comppath,iwidth,iheight,linkpage){

//if (document.form_nav.quickview.checked) {

var maxsize = 0
var f = 0.0
var max_comp = 130
var max_bigcomp = 480
var strimagename = ""
//var srcobj = document.getElementById(objown);

  maxsize = max_bigcomp //max_comp
  compwidth = 480
  compheight = 480

  if (iwidth == null || iheight == null || iwidth == 0 || iheight == 0) {
    iwidth = 480
    iheight = 480
  }
  if (iwidth > iheight) {
    f = maxsize/iwidth
    compheight = iheight * f
  } else {
    f = maxsize/iheight
    compwidth = iwidth * f
  }

  //document.onmousemove=followmouse;

  if (comppath.indexOf("mov") > 0) {
    //video preview
    compheight = 200
    compwidth = 240
    strimagename = comppath.substring(comppath.lastIndexOf("/")+1,comppath.toLowerCase().lastIndexOf(".mov")).toUpperCase()
    document.getElementById("showzoomid").innerHTML = '<div style="width:240px;height:212px;padding:4px;background-color:#fff;border:1px solid #888;"><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="'+compwidth+'" height="'+compheight+'" align="middle"> <param name="src" value="'+comppath+'"> <param name="autoplay" value="true"> <param name="controller" value="true"> <param name="bgcolor" value="#ffffff"> <embed width="'+compwidth+'" height="'+compheight+'" src="'+comppath+'" bgcolor="#ffffff" pluginspage="http://www.apple.com/quicktime/download/" controller="true"></embed></object><br><b>'+strimagename+'</b></div>'

  } else if (comppath.indexOf("mp3") > 0) {
    //audio preview
    compheight = 30
    compwidth = 160
    strimagename = comppath.substring(comppath.lastIndexOf("/")+1,comppath.toLowerCase().lastIndexOf(".mp3")).toUpperCase()
    document.getElementById("showzoomid").innerHTML = '<div style="width:160px;height:42px;padding:4px;background-color:#fff;border:1px solid #888;"><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="'+compwidth+'" height="'+compheight+'" align="middle"> <param name="src" value="'+comppath+'"> <param name="autoplay" value="true"> <param name="controller" value="true"> <param name="bgcolor" value="#ffffff"> <embed width="'+compwidth+'" height="'+compheight+'" src="'+comppath+'" bgcolor="#ffffff" pluginspage="http://www.apple.com/quicktime/download/" controller="true"></embed></object><br><b>'+strimagename+'</b></div>'

  } else {
    //image preview
    compheight = compheight + 12  // to display image name
    if (comppath.toLowerCase().lastIndexOf(".jpg") > 0)
       strimagename = comppath.substring(comppath.lastIndexOf("/")+1,comppath.toLowerCase().lastIndexOf(".jpg")).toUpperCase()
    else
       strimagename = comppath.substring(comppath.lastIndexOf("/")+1,comppath.toLowerCase().lastIndexOf(".gif")).toUpperCase()

    document.getElementById("showzoomid").innerHTML = '<div style="width:'+compwidth+'px;height:'+compheight+'px;padding:4px;background-color:#777777;border:1px solid #888;cursor: hand;" onClick="'+linkpage+'" align="center" valign="middle"><img src="'+comppath+'" onClick="'+linkpage+'" border="0" style="filter:alpha(opacity=70)" onmouseover="high(this)"><font size=2> click picture to close window</font></div>'

  }

  if (iwidth != 0 && iheight != 0){
    //gettrailobj().width=iwidth;
    //gettrailobj().height=iheight;}
    gettrailobj().width=compwidth;
    gettrailobj().height=compheight;
  }
  
  followmouse_1();
  gettrailobj().visibility="visible";

//}

}

function hidetrail(){
  //document.getElementById("showzoomid").innerHTML = ''
  gettrailobj().visibility="hidden";
  gettrailobj().left="-1000px";
  document.onmousemove="";
}

function hidetrail_v(){
  compheight = 30;
  compwidth = 160;
  document.getElementById("showzoomid").innerHTML = '<div style="width:160px;height:42px;padding:4px;background-color:#fff;border:1px solid #888;"><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" width="0" height="0" align="middle"> <param name="src" value="/images/spacer.mov"> <param name="autoplay" value="true"> <param name="controller" value="true"> <param name="bgcolor" value="#ffffff"> <embed width="0" height="0" src="/images/spacer.mov" bgcolor="#ffffff" pluginspage="http://www.apple.com/quicktime/download/" controller="true"></embed></object><br></div>'
  gettrailobj().visibility="hidden";
  gettrailobj().left="-1000px";
  document.onmousemove="";
}

function followmouse_1(e){
  var xcoord=offsetfrommouse[0];
  var ycoord=offsetfrommouse[1];
  if (isbigcomp == 1) {
     trailimage[1] = 480;
     trailimage[0] = 480;
  }
  var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
  var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)

  //if (docwidth < xcoord+trailimage[1] || docheight < truebody.scrollTop+trailimage[1]) {
    //gettrailobj().visible="none"
  //}
  //} else {
  
  var middocwidth = docwidth / 2;
  var middocheight= docheight / 2;
  var midimgwidth = compwidth / 2;
  var midimgheight= compheight / 2;
  
    if (typeof e != "undefined") {
      // Mozilla
      xcoord+=e.pageX
      ycoord+=e.pageY
      if (xcoord+trailimage[1] >docwidth)
        xcoord = e.pageX - compwidth - offsetfrommouse[0];
      if (ycoord+trailimage[1]+27> docheight + truebody().scrollTop)
        ycoord = (truebody().scrollTop+docheight) - compheight - 35;

    	//always show big-comp even if it doesn't quite fit
    	if (ycoord <= 0 && isbigcomp == 1)
    	   ycoord = truebody().scrollTop;
    	if (xcoord <= 0 && isbigcomp == 1)
    	   xcoord = e.pageX+trailimage[1];

      // this is to move the .top up if it is too far down from the mouse pointer
      if (ycoord > (truebody().scrollTop+e.pageY) + 10)
         ycoord  = ycoord  - (ycoord - (truebody().scrollTop+e.pageY))
         
      //xcoord=truebody().scrollLeft+e.pageX - 70;
      //ycoord=truebody().scrollTop+e.pageY - 70;

    }
    else if (typeof window.event !="undefined") {
      // IE browser
      xcoord+=middocwidth - midimgwidth + truebody().scrollLeft;
      ycoord+=middocheight - midimgheight + truebody().scrollTop;

      if (xcoord+trailimage[1] > docwidth) 
        xcoord = docwidth - compwidth;
      if (ycoord+trailimage[1]+27 > docheight + truebody().scrollTop) 
        ycoord = (truebody().scrollTop+docheight) - compheight - 27;

      //xcoord=truebody().scrollLeft+100;
      //ycoord=event.clientY;

    }


  //}

  if (xcoord < 0 || ycoord < 0) {
    gettrailobj().visible="none"
    gettrailobj().display=""
  } else {
    gettrailobj().display=""
    gettrailobj().left= xcoord+"px"
    gettrailobj().top= ycoord+"px"
  }  
}

function followmouse(e){
  var xcoord=offsetfrommouse[0];
  var ycoord=offsetfrommouse[1];
  if (isbigcomp == 1) {
     trailimage[1] = 480;
     trailimage[0] = 480;
  }
  var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
  var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)

  //if (docwidth < xcoord+trailimage[1] || docheight < truebody.scrollTop+trailimage[1]) {
    //gettrailobj().visible="none"
  //}
  //} else {
  
    if (typeof e != "undefined") {
      // Mozilla
      xcoord+=e.pageX
      ycoord+=e.pageY
      if (xcoord+trailimage[1] >docwidth)
        xcoord = e.pageX - compwidth - offsetfrommouse[0];
      if (ycoord+trailimage[1]+27> docheight + truebody().scrollTop)
        ycoord = (truebody().scrollTop+docheight) - compheight - 35;

    	//always show big-comp even if it doesn't quite fit
    	if (ycoord <= 0 && isbigcomp == 1)
    	   ycoord = truebody().scrollTop;
    	if (xcoord <= 0 && isbigcomp == 1)
    	   xcoord = e.pageX+trailimage[1];

      // this is to move the .top up if it is too far down from the mouse pointer
      if (ycoord > (truebody().scrollTop+e.pageY) + 10)
         ycoord  = ycoord  - (ycoord - (truebody().scrollTop+e.pageY))
         
      //xcoord=truebody().scrollLeft+e.pageX - 70;
      //ycoord=truebody().scrollTop+e.pageY - 70;

    }
    else if (typeof window.event !="undefined") {
      // IE browser
      xcoord+=truebody().scrollLeft+event.clientX;
      ycoord+=truebody().scrollTop+event.clientY;

      if (xcoord+trailimage[1] > docwidth) 
        xcoord = (truebody().scrollLeft+event.clientX) - compwidth - offsetfrommouse[0];
      if (ycoord+trailimage[1]+27 > docheight + truebody().scrollTop) 
        ycoord = (truebody().scrollTop+docheight) - compheight - 27;

    	//always show big-comp even if it doesn't quite fit
    	if (ycoord <= 0 && isbigcomp == 1)
    	   ycoord = (truebody().scrollTop)
    	if (xcoord <= 0 && isbigcomp == 1)
    	   xcoord = (truebody().scrollLeft+event.clientX)+offsetfrommouse[0]

      // this is to move the .top up if it is too far down from the mouse pointer
      if (ycoord > (truebody().scrollTop+event.clientY) + 10)
         ycoord  = ycoord  - (ycoord - (truebody().scrollTop+event.clientY))

      //xcoord=truebody().scrollLeft+100;
      //ycoord=event.clientY;

    }


  //}

  if (xcoord < 0 || ycoord < 0) {
    gettrailobj().visible="none"
    gettrailobj().display=""
  } else {
    gettrailobj().display=""
    gettrailobj().left= xcoord+"px"
    gettrailobj().top= ycoord+"px"
  }  
}

function high(which2){
  theobject=which2
  highlighting=setInterval("highlightit(theobject)",70)
}

function low(which2){
  clearInterval(highlighting)
  which2.filters.alpha.opacity=20
}

function highlightit(cur2){
  if (cur2.filters.alpha.opacity<100)
    cur2.filters.alpha.opacity+=5
  else if (window.highlighting)
    clearInterval(highlighting)
}

function quickview_onClick()
{
   var dt = new Date();
   //default to 1 year
   dt.setTime(dt.getTime()+(365*24*3600*1000))
   if (document.form_nav.quickview.checked) {
	setCookie("quickview","yes",dt,"/","","");
   } else {
	setCookie("quickview","no",dt,"/","","");
   }
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}