
/*
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",300,300]
var offsetfrommouse=[15,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 = 300
var compheight = 300
var isbigcomp = 0
var isimageoftheday = 0
var isfocusclip = 0
var isinternalip = 0

// 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++;
		}   
	    }
	    // 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;
	    }
	}
    }
    return pluginFound;
} // detectPlugin






function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").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){

//if (document.form_nav.quickview.checked) {

var maxsize = 500
var f = 0.0

var strimagename = ""


   compwidth = 500
   compheight = 500




if (iwidth > iheight) {
  f = maxsize/iwidth
  compheight = iheight * f
} else {
  f = maxsize/iheight
  compwidth = iwidth * f
}

document.onmousemove=followmouse;



  //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();
  }
  var imglen = strimagename.length;
  strimagename = '<br><b>' + strimagename + '</b>'



  document.getElementById("trailimageid").innerHTML = '<div style="width:'+compwidth+'px;height:'+compheight+'px;padding:4px;background-color:#fff;border:1px solid #888;"><img src="'+comppath+'" border="0">'+strimagename+'</div>'



if (iwidth != 0 && iheight != 0){
//gettrailobj().width=iwidth;
//gettrailobj().height=iheight;}
gettrailobj().width=compwidth;
gettrailobj().height=compheight;}
gettrailobj().visibility="visible";

//}

}

function hidetrail(){
//document.getElementById("trailimageid").innerHTML = ''
gettrailobj().visibility="hidden"
gettrailobj().left="-1000px"
document.onmousemove=""
}



function followmouse(e){
  var xcoord=offsetfrommouse[0]
  var ycoord=offsetfrommouse[1]
  if (isbigcomp == 1) {
     trailimage[1] = 500;
     trailimage[0] = 500;
  }
  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)
	   ycoord = truebody().scrollTop
	if (xcoord <= 0)
	   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))


      // center all clips from the homepage link to the focus video page
      if (isfocusclip == 1)
	 ycoord = ycoord - 100

    }
    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))

      // center all clips from the homepage link to the focus video page
      if (isfocusclip == 1)
	 ycoord = ycoord - 100
    }


  //}

  if (xcoord < 0 || ycoord < 0) {
    gettrailobj().visible="none"
    gettrailobj().display=""
  } else {
    gettrailobj().display=""
    gettrailobj().left=xcoord+"px"
    gettrailobj().top=ycoord+"px"
  }  
}




