Thanks first for the help. I don't do javascript syntax too well.

What I' need to do is to take a piece of photopost code that embeds videos and replace the url to the video and insert some javascript from ValueClick. This will then put in pre/post roll ads.

Here is the photopost template:
HTML Code:
                

<?php

$imgdisp = <<<IMGDISP
 <!-- BEGIN TEMPLATE: embed-ms.tmpl -->
     <table border='0' cellpadding='0' align="center">
      <tr><td>
      <OBJECT id='mediaPlayer' width="320" height="285" 
      classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' 
      codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
      standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
      <param name='fileName' value="{$Globals['origdir']}/$storecat/$bigimage">
      <param name='animationatStart' value='true'>
      <param name='transparentatStart' value='true'>
      <param name='autoStart' value="true">
      <param name='showControls' value="true">
      <param name='loop' value="false">
      <EMBED type='application/x-mplayer2'
        pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
        id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1' 
        bgcolor='darkblue' showcontrols="true" showtracker='-1' 
        showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="320" height="285"
        src="{$Globals['origdir']}/$storecat/$bigimage" autostart="true" designtimesp='5311' loop="false">
      </EMBED>
      </OBJECT>
      </td></tr>
        <tr><td align='center'>
        <a href="{$Globals['origdir']}/$storecat/$bigimage" style='font-size: 85%;' target='_blank'>{$Globals['pp_lang']['video']}</a>
        </td></tr>
      </table>
<!-- END TEMPLATE: embed-ms.tmpl -->
IMGDISP;

?>
I need to replace the embed src with this:

HTML Code:
<!-- ValueClick Media 320x240 In-stream Video CODE for powwows.com -->
<script type="text/javascript">
<!--                                 
var contentURL='http://www.powwows.com/galleries/<? echo $storecat; ?>/<? echo $bigimage; ?>';
var defaultAdURL='';                
var posterURL='';
var defaultAdLP = '';
var contentDuration=30;
var contentType='wmv';
var ctp=0;
var ct=contentType ? contentType.substr(0,1) : 'a';
var dc=document; var pre=0,post=0;
var contentWidth=320, contentHeight=240;
dc.cookie='h2=o; path=/;';
if (dc.cookie.indexOf('pr=e') < 0 && 300000 > 0) {
   var date_ob=new Date();
   date_ob.setTime(date_ob.getTime()+300000);
   dc.cookie='pr=e; path=/; expires='+ date_ob.toGMTString();
} else if (300000 > 0) { pre=1; }
if (dc.cookie.indexOf('po=st') < 0 && 300000 > 0) {
   var date_ob=new Date();
   date_ob.setTime(date_ob.getTime()+300000);
   dc.cookie='po=st; path=/; expires='+ date_ob.toGMTString();
} else if (300000 > 0) { post=1; }
var adSrc='http://media.fastclick.net/w/get.media?sid=1552&m=11&postfc='+post+'&prefc='+pre;
dc.writeln('<scr' + 'ipt src="' + adSrc + '&ct=' + ct + '"></scr' + 'ipt>');
// -->
</script>
<!-- ValueClick Media 320x240 In-stream Video CODE for powwows.com -->
Can anyone help!

Thanks!