/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/

var offsetfrommouse=[15,15]; //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 currentimageheight = 270;	// maximum image size.

if (document.getElementById || document.all){
document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:200px;top:200px">');document.write('<img src="http://www.skyhousemedia.com"> </div>');
}

function gettrailobj(){
if (document.getElementById && document.getElementById("trailimageid"))
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById && document.getElementById("trailimageid"))
return document.getElementById("trailimageid")
else if (document.all)
return document.all.trailimagid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showtrail(imagename,type,client,campaign,width,height,format,length){
	if(type == 'video') {
		if(width <= 0) {
			width = 200;
		}
		if(height > 0) {
			var factor = width / 200;
			if(factor != 0) {
				var new_height = height / factor;
				if(new_height > 100) {
					height = new_height;
				}
				else {
					height = 240;
				}
			}
			else {
				width = 200;
				height = 240;
			}
		}
		else {
			height = 240;
		}
		width = 200;
	}

	if (height > 0){
		currentimageheight = height;
	}


	document.onmousemove=followmouse;

	var newHTML = '<table border="0" width="200" cellpadding="4" cellspacing="3" bgcolor="#FFFFFF">';
  newHTML = newHTML + '<tr><td width="100%" valign="top">';
      newHTML = newHTML + '<table class="thin" width="200">';
        newHTML = newHTML + '<tr><td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">';
              newHTML = newHTML + '<tr><td width="100%"><p align="center">';

                if(type=='photo') {
                newHTML = newHTML + '<div align="center" style="padding: 0px 0px 0px 0px;"><img src="' + imagename + '" border="0"></div>';
				newHTML = newHTML + '</td></tr><tr><td width="100%" bgcolor="#000000">';
                  newHTML = newHTML + '<table border="0" width="100%" cellpadding="2"><tr>';
                      newHTML = newHTML + '<td width="100%"><font face="Arial" size="1">'+client+'</font>';
                      newHTML = newHTML + '<br><font face="Arial" size="1">' +campaign+ '</font>';
					   newHTML = newHTML + '<br><font face="Arial" size="1">' +format+ '</font>';
                  newHTML = newHTML + '</table></td></tr>';
            newHTML = newHTML + '</table></td></tr></table></td></tr>';
				
				  }
				  
                if(type=='video') {
                        temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: black;">'
                                 +'     <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" id="myplayer" align="middle">'
                                 +'     <param name="allowScriptAccess" value="sameDomain" />'
                                 +'     <param name="movie" value="player.swf" />'
                                 +'     <param name="quality" value="high" />'
                                 +'     <param name="bgcolor" value="#000000" />'
                                 +'      <param name="FlashVars" value=file='+imagename+'&autostart=true&displayclick=none&repeat=always&controlbar=over"='+imagename+'" />'
                                 +'     <embed FlashVars=file='+imagename+'&autostart=true&displayclick=none&repeat=always&controlbar=over"='+imagename+'" src="player.swf" LOOP="true" quality="high" bgcolor="#000000" width="'+width+'" height="'+height+'" name="player" align="middle"allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
                                 +'     </object>'
                                 +'</div>';

                   newHTML += temp;

newHTML = newHTML + '</td></tr><tr><td width="100%" bgcolor="#000000">';
                  newHTML = newHTML + '<table border="0" width="100%" cellpadding="2"><tr>';
                      newHTML = newHTML + '<td width="100%"><font face="Arial" size="1">'+client+'</font>';
                      newHTML = newHTML + '<br><font face="Arial" size="1">' +campaign+ '</font>';
					   newHTML = newHTML + '<br><font face="Arial" size="1">' +format+ '</font>';
					   newHTML = newHTML + '<br><font face="Arial" size="1">' +length+ '</font></td></tr>';
                  newHTML = newHTML + '</table></td></tr>';
            newHTML = newHTML + '</table></td></tr></table></td></tr>';


                }

                if(type=='audio') {
                        temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: white;">'
                                 +'     <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="0" height="0" id="myplayer" align="middle">'
                                 +'     <param name="allowScriptAccess" value="sameDomain" />'
                                 +'     <param name="movie" value="player.swf" />'
                                 +'     <param name="quality" value="high" />'
                                 +'     <param name="bgcolor" value="#000000" />'
                                 +' <param name="FlashVars" value="file='+imagename+'" /> '
                                 +'     <embed FlashVars="file='+imagename+'" src="player.swf" quality="high" bgcolor="#000000" width="0" height="0" name="myplayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
                                 +'     </object>'
                                 +'</div>';

                   newHTML += temp;

    newHTML = newHTML + '</td></tr><tr><td width="100%" bgcolor="#FFFFFF">';
                  newHTML = newHTML + '<table border="0" width="100%" cellpadding="2"><tr>';
                      newHTML = newHTML + '<td width="100%"><font face="Arial" size="1">'+client+'</font>';
                      newHTML = newHTML + '<br><font face="Arial" size="1">&#169;' +campaign+ '</font></td></tr>';
                  newHTML = newHTML + '</table></td></tr>';
            newHTML = newHTML + '</table></td></tr></table></td></tr>';
  newHTML = newHTML + '<tr><td width="100%" valign="top"><font face="Arial" size="1" color="#FFFFFF"><br></font></td>';
  newHTML = newHTML + '</tr></table>';

                }


        gettrailobjnostyle().innerHTML = newHTML;

        gettrailobj().visibility="visible";

}


function hidetrail(){
	gettrailobj().visibility="hidden"
	gettrailobjnostyle().innerHTML=""
	document.onmousemove=""
	gettrailobj().left="-500px"

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	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 (document.all){
	//	gettrailobjnostyle().innerHTML = 'A = ' + truebody().scrollHeight + '<br>B = ' + truebody().clientHeight;
	//} else {
	//	gettrailobjnostyle().innerHTML = 'C = ' + document.body.offsetHeight + '<br>D = ' + window.innerHeight;
	//}

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < 300){
			xcoord = e.pageX - xcoord - 286; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 75)){
			ycoord += e.pageY - Math.max(0,(75 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < 300){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - 286; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 200)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(75 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}



// call hidetrail once just to init things
// this prevents the first video from showing in the upper left momentarily in IE
hidetrail();