/*
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">');
        document.write('</div>');
}

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

function gettrailobjnostyle(){
if (document.getElementById)
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
}
var playerMouseOffset = 0;



function showtrail(imagename,type,title,description,ratingaverage,ratingnumber,showthumb,height,downloads,format,width,height,catid,loopable,mouseOffset,subcat1,subcat2,subcat3,keywords,category,copyright,audiocat,loprice,hiprice){
        if (typeof catid == 'undefined' ) {
                catid = 0;
        }
        if (typeof loopable == 'undefined' ) {
                loopable = 0;
        }
        if (typeof mouseOffset == 'undefined' ) {
                mouseOffset = 0;
        }
        playerMouseOffset = mouseOffset;
	if (typeof subcat1 == 'undefined' ) {
                subcat1 = 0;
        }
        if (typeof subcat2 == 'undefined' ) {
                subcat2 = 0;
        }
        if (typeof subcat3 == 'undefined' ) {
                subcat3 = 0;
        }
        if (typeof keywords == 'undefined' ) {
                keywords = '';
        }
        if (typeof category == 'undefined' ) {
                category = '';
        }
        if (typeof copyright == 'undefined' ) {
                copyright = '';
        }

        if (typeof themePath == 'undefined' ) {
                themePath = '';
        }

        if (height > 0){
                currentimageheight = height;
        }
        playerMouseOffset = mouseOffset;
        document.onmousemove=followmouse;

        cameraHTML = '';

        if (ratingnumber == 0){
                ratingaverage = 0;
        }

        for(x = 1; x <= 5; x++){

                if (ratingaverage >= 1){
                        cameraHTML = cameraHTML + '<img src="' + themePath + '/images/camera_1.gif">';
                } else if (ratingaverage >= 0.5){
                        cameraHTML = cameraHTML + '<img src="' + themePath + '/images/camera_05.gif">';
                } else {
                        cameraHTML = cameraHTML + '<img src="' + themePath + '/images/camera_0.gif">';
                }

                ratingaverage = ratingaverage - 1;

        }

        cameraHTML = cameraHTML + ' (' + ratingnumber + ' Review';
        if ( ratingnumber != 1 ) cameraHTML += 's';
        cameraHTML = cameraHTML + ')';
	
	if(ratingnumber == 'info') {
		// change the display based on what was passed to us
			var newHTML = '<table border="0" width="500" cellpadding="3" cellspacing="3" bgcolor="#666666"><tr><td width="50%" valign="top">';

      		newHTML = newHTML + '<table class="thin" width="222">';
        	newHTML = newHTML + '<tr><td width="100%">';
          newHTML = newHTML + '<p align="center">';

        	if (showthumb > 0){
                	if(type=='photo')
		        	newHTML = newHTML + '<div align="center" style="padding: 0px 0px 0px 0px;"><img src="' + imagename + '" border="0"></div>';
                	if(type=='video' || type=='ae') {
				temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: black;">'
                        + '<a class=player href="' + imagename + '" style="display:block;width:266px;height:' + height + 'px;"></a>'
                        + '</div>'; }
		if(type=='audio') {
				temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: white;width:266px;height:177px;" class="player">'
                        + '</div>';
}


                   		newHTML += temp;

				  newHTML = newHTML + '</td></tr>';
        	newHTML = newHTML + '</table>';
  				newHTML = newHTML + '</td><td width="50%" height="100%" align="left" valign="top">';
  				newHTML = newHTML + '<font color="#F0F0F0">';
  				newHTML = newHTML + '<b>DESCRIPTION:</b><br>';
  				if (description != ''){
  				newHTML = newHTML + '' +description+ '';
  				} else {
          newHTML = newHTML + 'You have not added a description for this file.  Please click the EDIT icon to add one.';
          }
  				newHTML = newHTML + '<br><br>';
  			  newHTML = newHTML + '<b>KEYWORDS:</b><br>';
  				if (keywords != ''){
  				newHTML = newHTML + '' +keywords+ '';
  				} else {
          newHTML = newHTML + 'You have not added any keywords for this file.  Please click the EDIT icon to add some keywords.';
          }
  				newHTML = newHTML + '<br><br>';
  						  newHTML = newHTML + '<b>CATEGORIES:</b><br>';
  				if (format != ''){
  				newHTML = newHTML + 'Main: ' +category+ '';
  				} else {
          newHTML = newHTML + 'IMPORTANT:  The primary category missing!  Click EDIT to repair.';
          }
  				newHTML = newHTML + '<br>';
 		 
  				if (subcat1 != '' || subcat2 != '' || subcat3 !=''){
  				newHTML = newHTML + 'Sub Category 1: ' +subcat1+ '<br>';
  				if (subcat2 != ''){
          newHTML = newHTML + 'Sub Category 2: ' +subcat2+ '<br>';
          } 
          if (subcat3 != ''){
  				newHTML = newHTML + 'Sub Category 3: ' +subcat3+ '';
  				 } 
  				newHTML = newHTML + '';
  				
  				} else {
          newHTML = newHTML + 'You have not added any sub-categories for this file. Please click the edit icon to add some sub-categories.';
          }
  				newHTML = newHTML + '<br><br>';
  				newHTML = newHTML + '</font>';
  				newHTML = newHTML + '</td></tr></table>';
  				
  				
  				
  				
  				
                	}
			
  				
  				}
  				


else if(ratingnumber == 'infolarge') {
		// change the display based on what was passed to us
			var newHTML = '<table border="0" width="678" cellpadding="3" cellspacing="3" bgcolor="#666666"><tr><td width="50%" valign="top">';

      		newHTML = newHTML + '<table class="thin" width="400">';
        	newHTML = newHTML + '<tr><td width="100%">';
          newHTML = newHTML + '<p align="center">';

        	if (showthumb > 0){
                	if(type=='photo')
		        	newHTML = newHTML + '<div align="center" style="padding: 0px 0px 0px 0px;"><img src="' + imagename + '" border="0"></div>';
                	if(type=='video' || type=='ae') {
				temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: black;">'
                        + '<a class="player" href="' + imagename + '" style="display:block;width:400px;height:' + height + 'px;"></a>'
                        + '</div>'; }
		if(type=='audio') {
				temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: white;width:400px;height:248px;" class="player">'
                        + '</div>';
}


                   		newHTML += temp;

				  newHTML = newHTML + '</td></tr>';
        	newHTML = newHTML + '</table>';
  				newHTML = newHTML + '</td><td width="50%" height="100%" align="left" valign="top">';
  				newHTML = newHTML + '<font color="#F0F0F0">';
  				newHTML = newHTML + '<b>DESCRIPTION:</b><br>';
  				if (description != ''){
  				newHTML = newHTML + '' +description+ '';
  				} else {
          newHTML = newHTML + 'You have not added a description for this file.  Please click the EDIT icon to add one.';
          }
  				newHTML = newHTML + '<br><br>';
  			  newHTML = newHTML + '<b>KEYWORDS:</b><br>';
  				if (keywords != ''){
  				newHTML = newHTML + '' +keywords+ '';
  				} else {
          newHTML = newHTML + 'You have not added any keywords for this file.  Please click the EDIT icon to add some keywords.';
          }
  				newHTML = newHTML + '<br><br>';
  						  newHTML = newHTML + '<b>CATEGORIES:</b><br>';
  				if (format != ''){
  				newHTML = newHTML + 'Main: ' +category+ '';
  				} else {
          newHTML = newHTML + 'IMPORTANT:  The primary category missing!  Click EDIT to repair.';
          }
  				newHTML = newHTML + '<br>';
 		 
  				if (subcat1 != '' || subcat2 != '' || subcat3 !=''){
  				newHTML = newHTML + 'Sub Category 1: ' +subcat1+ '<br>';
  				if (subcat2 != ''){
          newHTML = newHTML + 'Sub Category 2: ' +subcat2+ '<br>';
          } 
          if (subcat3 != ''){
  				newHTML = newHTML + 'Sub Category 3: ' +subcat3+ '';
  				 } 
  				newHTML = newHTML + '';
  				
  				} else {
          newHTML = newHTML + 'You have not added any sub-categories for this file. Please click the edit icon to add some sub-categories.';
          }
  				newHTML = newHTML + '<br><br>';
  				newHTML = newHTML + '</font>';
  				newHTML = newHTML + '</td></tr></table>';
  				
  				
  				
  				
  				
                	}
			
  				
  				}



	
  	else if(ratingnumber == 'notes') {
		// change the display based on what was passed to us
			var newHTML = '<table border="0" width="200" cellpadding="3" cellspacing="3" bgcolor="#666666"><tr><td width="100%" valign="top">';

      		newHTML = newHTML + '<table class="thin" width="222">';
        	newHTML = newHTML + '<tr><td width="100%">';
          newHTML = newHTML + '<p align="left"><b>REVIEWER NOTES:</b><br>' + description + '</p>';



				  newHTML = newHTML + '</td></tr>';
        	newHTML = newHTML + '</table>';
  				newHTML = newHTML + '</td>';
  				newHTML = newHTML + '</tr></table>';
  				
  				
  				
  				
  				
                	}              	
                	

	
	else if(copyright != '' || category != '') {  
		if(type == 'video' || type == 'ae') {
	                if(width <= 0) {
       	                	width = 266;
       	         	}
                	if(height > 0) {
                        	var factor = width / 266;
                        	if(factor != 0) {
                                	var new_height = height / factor;
                                	if(new_height > 100) {
                                        	height = new_height;
                                	}
                                	else {
                                        	height = 150;
                                	}
                        	}
                        	else {
                                	width = 266;
                                	height = 150;
                        	}
                	}
                	else {
                        	height = 150;
                	}
                	width = 266;
        	}
		if (height > 0){
                	currentimageheight = height;
        	}
		var newHTML = '<table border="0" width="240" cellpadding="3" cellspacing="3" bgcolor="#666666">';
  		newHTML = newHTML + '<tr><td width="100%" valign="top">';
      		newHTML = newHTML + '<table class="thin" width="222">';
        	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 (showthumb > 0){
                	if(type=='photo')
		        	newHTML = newHTML + '<div align="center" style="padding: 0px 0px 0px 0px;"><img src="' + imagename + '" border="0"></div>';
                	if(type=='video') {
				temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: black;">'
                        + '<a class="player" href="' + imagename + '" style="display:block;width:266px;height:' + height + 'px;"></a>'
                        + '</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="Tahoma" size="1">'+title+'</font>';
	                      	newHTML = newHTML + '<br><font face="Tahoma" size="1">&#169;' +copyright+ '</font></td></tr>';
        		      	newHTML = newHTML + '</table></td></tr>';
            			newHTML = newHTML + '</table></td></tr></table></td></tr>';
  				newHTML = newHTML + '<tr><td width="100%" valign="top"><table width="100%"><tr><td align="left" width="70%"><font face="Tahoma" size="1">' +category+ '<br> Native Format:'+format+'</font></td>';
  				newHTML = newHTML + '<td align="right" width="30%" valign="top"><font face="Tahoma" size="1">' +loprice+ '</td></tr></table></td>';
  				newHTML = newHTML + '</tr></table>';
                	}
			if(type=='audio') {
				temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: white;width:266px;height:177px;" class="player">'
                        + '</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="Tahoma" size="1">'+title+'</font>';
                     		newHTML = newHTML + '<br><font face="Tahoma" size="1">&#169;' +copyright+ '</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="Tahoma" size="1">Stock Audio<br></font></td>';
  				newHTML = newHTML + '</tr></table>';

                	}
        	}
	}
	else {
        	newHTML = '<table bgcolor="white" width="222" cellpadding="0" cellspacing="0" border="0" style="border:0px solid #000000;"><tr><td width="0%">';
		if (showthumb > 0){
                	if(type=='photo')
                	newHTML = newHTML + '<div align="center" style="padding: 0px 0px 0px 0px;"><img src="' + imagename + '" border="0"></div>';
                	if(type=='video' || type=='ae') {
				 temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: black;">'
                        + '<a class="player" href="' + imagename + '" style="display:block;width:266px;height:' + height + 'px;"></a>'
                        + '</div>';

                   		newHTML += temp;

				newHTML = newHTML + '</td><td width="100%" valign="top" style="font-family:Verdana; font-size:12px;">';
        			newHTML = newHTML + '<div style="padding: 0px; background-color: #000000;">';


                	}

                	if(type=='audio') {
				 temp = '<div align="center" style="padding: 0px 0px 0px 0px; background-color: white;width:266px;height:177px;" class="player">'
                        + '</div>';

                   		newHTML += temp;
        			newHTML = newHTML + '<div style="padding: 0px; background-color: #000000;">';

                	}
        	}




        	newHTML = newHTML + '</div></td></tr></table>';
	}

        gettrailobjnostyle().innerHTML = newHTML;

        if(type=='audio') {
		
$f("div.player", "/flowplayer.commercial-3.2.2.swf", {
           		key: '#$91a49734961719e9aff',

    // first entry in the playlist works as splash and second entry is the audio file
    playlist: ['http://www.revostock.com/themes/indiefootage/images/' + catid + 'medium.jpg', imagename],

    			// fullscreen button not needed here
    			plugins: {
 
    			
    			
        			controls: null
    			},
    			clip: {
        			autoPlay: true
       

       
       
    			}

		});
	}
	else {
flowplayer("a.player", "/flowplayer.commercial-3.2.2.swf", {
           		key: '#$91a49734961719e9aff',

        		clip: {
            			autoPlay: true,
            			autoBuffering: true,
            			onBeforeFinish: function() {
                			// returning false prevents the default
                			// behavior associated with this event --->
                			// it will loop instead of stop at finish
                			return false;
            			}
          		},
        		logo: {
            			opacity: 0
        		},

        		canvas: {backgroundColor: "#48494b"},

			plugins: {
 				controls: null
			}
        	});
	}



        gettrailobj().visibility="visible";

}



function watermark(watermark){

        mouseOffset = 0;
        playerMouseOffset = mouseOffset;
        document.onmousemove=followmouse;



		// change the display based on what was passed to us
	


   var newHTML = '<div align="left">';
   newHTML = newHTML + '<p><img src="'+ watermark + '" width="800"></p>';
newHTML = newHTML + '</div>';


	

        gettrailobjnostyle().innerHTML = newHTML;

        gettrailobj().visibility="visible";

}









function showtrailhelp(helpnotes){

        mouseOffset = 0;
        playerMouseOffset = mouseOffset;
        document.onmousemove=followmouse2;

      

		// change the display based on what was passed to us
	


   var newHTML = '<div align="left">';
   newHTML = newHTML + '<table border="0" width="287" cellspacing="0" cellpadding="0" height="46">';
    newHTML = newHTML + '<tr>';
    newHTML = newHTML + '<td width="100%" height="4"><img border="0" src="http://www.revostock.com/themes/indiefootage/images/bubbletop.png" width="287" height="35"></td>';
    newHTML = newHTML + '</tr>';
    newHTML = newHTML + '<tr>';
      newHTML = newHTML + '<td width="100%" height="21"  style="padding: 0px 13px 0px 16px; word-wrap: break-word; overflow: hidden;" background="http://www.revostock.com/themes/indiefootage/images/bubblemiddle.png"><font face="Tahoma" size="1">' + helpnotes + '</font></td>';
    newHTML = newHTML + '</tr>';
    newHTML = newHTML + '<tr>';
      newHTML = newHTML + '<td width="100%" height="19"><img border="0" src="http://www.revostock.com/themes/indiefootage/images/bubblebottom.png" width="287" height="19"></td>';
    newHTML = newHTML + '</tr>';
  newHTML = newHTML + '</table>';
newHTML = newHTML + '</div>';


	

        gettrailobjnostyle().innerHTML = newHTML;

        gettrailobj().visibility="visible";

}


function showtrailencode(image){

        mouseOffset = 0;
        playerMouseOffset = mouseOffset;
        document.onmousemove=followmouse2;

      

		// change the display based on what was passed to us
	


   var newHTML = '<div align="center">';
   newHTML = newHTML + '<div style="padding: 10px; background-color: #ffffff; border: solid 1px #E4E4E4;"';
    newHTML = newHTML + '<img src="/themes/indiefootage/images/' + image + '">';
newHTML = newHTML + '</div>';


	

        gettrailobjnostyle().innerHTML = newHTML;

        gettrailobj().visibility="visible";

}



function hidetrail(){
	var foo = gettrailobj();
	if(foo) {
		foo.visibility = "hidden";
	}
	//gettrailobj().visibility="hidden";
	foo = gettrailobjnostyle();
	if(foo) {
		foo.innerHTML = "";
	}
	//gettrailobjnostyle().innerHTML=""
	document.onmousemove=""
	foo = gettrailobj();
	if(foo) {
		foo.left="-500px";
	}
	//gettrailobj().left="-500px"

}
function followmouse(e){

        if (typeof playerMouseOffset == 'undefined' ) {
                playerMouseOffset = 0;
        }

        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 + 110)){
			// bug fix by Marc Swanson.  Safari would show the popup off the screen on widescreen pages.
			// removed the e.PageY from the subtraction in the calc.
                        //ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
                        ycoord += e.pageY - Math.max(0,(110 + currentimageheight - 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 + 110)){
                        ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + 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)
        ycoord -= playerMouseOffset;

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

}

function followmouse2(e){
	if (typeof playerMouseOffset == 'undefined' ) {
                playerMouseOffset = 0;
        }

        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.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(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 - 0; // Move to the left side of the cursor
                } else {
                        xcoord += e.pageX;
                }
		if (docheight - e.pageY < (currentimageheight + 110)){
                        // bug fix by Marc Swanson.  Safari would show the popup off the screen on widescreen pages.
                        // removed the e.PageY from the subtraction in the calc.
                        //ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
                        ycoord += e.pageY - Math.max(0,(110 + currentimageheight - docheight - truebody().scrollTop));
                } else {
                        ycoord += e.pageY;
                }

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


        ycoord -= playerMouseOffset;

        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();
