var count_views = 0;
function createMedia(partner, type, source,width, height, title, descrip, downloadurl, downloadsize, browser)
{

    if(source.split('youtube').length > 1){
        type = 6;
    }
    if(source.split('hulu').length > 1){
        type = 4;
    }
    if(source.split('cbs').length > 1){
        type = 5;
    }
    if(source.split('metacafe').length > 1){
        type = 4;
    }
    if(count_views % 2 == 0 && count_views != 0){
        type = 7;
    }
    if(type < 7){
        count_views++;
    }else{
        count_views = 0;
    }
    var data ='';
    var myImage ='';
    var url = '';
    
    switch(type){
        case 1:
            if(width > 1000){
                width = width/2;
                height = height/2;
            }
            if(width == ''){
                width = '625';
                height = '500';
            }
            modalWindow.content = "<iframe width='"+ width +"' height='"+ height +"' id='modframe' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'></iframe>";
            break;
        
        case 2:   
            width = '512';
            height = '341';
            data = '<object width="'+width+'" height="'+height+'">'+
            '<param name="movie" value="/static/flash/flvPlayer.swf?allowScrub=1&flvURL='+source+'">'+
            '<embed src="/static/flash/flvPlayer.swf?allowScrub=1&flvURL='+source+'" width="'+width+'" height="'+height+'">'+
            '</embed>'+
            '</object>';
            modalWindow.content = data;
            break;
        
        case 3:
            height =  '500';
            width = '550';
            data = '<div class="content_img"><img src="'+source+'" /><h1 style="text-align:left;margin:10px 0 0 10px;font-size:14px;">'+title+'</h1></div>';
            modalWindow.content = data;
            break;
        
        case 4:
            var str = source.split('#',3);
            data = '<embed height="'+height+'" width="'+width+'" align="middle" src="'+str[0]+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" flashvars="'+str[1]+'"/>';
            modalWindow.content = data;
            break;
        
        case 5:
            if(width > 1000){
                width = width/2;
                height = height/2;
            }
            var str = source.split("?",3); 
            data = '<embed width="'+width+'" height="'+height+'" id="can" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="movie" value="'+str[0]+'" name="allowFullScreen" value="true" name="allowScriptAccess" value="always" name="FlashVars" value="'+str[1]+'" embed src="'+str[0]+'" quality="high" bgcolor="#000000" name="rcpHolder" allowscriptaccess="always" menu="true" allowfullscreen="true" flashvars="'+str[1]+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="'+height+'" width="'+width+'"/>';
            modalWindow.content = data;
            break;
        
        case 6:
            var str = source.split("&",3);
            data = '<embed width="'+width+'" height="'+height+'" id="can" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="movie" value="'+str[0]+'&autoplay=1" name="allowFullScreen" value="true" name="allowScriptAccess" value="always" quality="high" bgcolor="#000000" name="rcpHolder" allowscriptaccess="always" menu="true" allowfullscreen="true" type="application/x-shockwave-flash" src="'+str[0]+'&autoplay=1" pluginspage="http://www.macromedia.com/go/getflashplayer" height="'+height+'" width="'+width+'"/>';
            modalWindow.content = data;
            break;
        
        case 7:
            data ='<div class="content_mod_download"><div class="clearfix">'+
            '<h1>Enjoy More</h1>'+
            '<p>Download our free Cooliris browser plug-in to access premium content from over a hundred providers all in one place, within a lightning fast, cinematic interface.</p><div class="download_popover"><a class="install_popover" onclick="return InstallHelper.clickedDownload();" href="'+downloadurl+'"><span class="left '+browser+'_img">Free Download</span><span class="sm_text">'+downloadsize+'</span></a></div></div></div>';
            modalWindow.content = data;
            width = '512';
            height = '341';
            break;
        
        default:
        data ='<div class="content_mod"><div class="clearfix"><img src="'+source+'" width="200" class="content_mod_img" />'+
        '<h1>'+title+'</h1>'+
        '<p>'+descrip+'</p></div></div>';
        modalWindow.content = data;
        width = '550';
        height = '500';
    }
    
  modalWindow.windowId = "myModal";
	modalWindow.width = width;
	modalWindow.height = height;
	modalWindow.open();
  template_tracker('dlp/viewed/'+partner);
}
function template_tracker(url){
   try {
    var downloadTracker = _gat._getTracker("UA-1590345-1");
    downloadTracker._trackPageview(url);
    } catch(err) {}
}

