/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
var pGet_frce=new Array();
 var toFcs=null;
 var userAgent = navigator.userAgent.toLowerCase();
 var brwsr = new Object();
 var vlbandwidth='';
 brwsr.browser = {
   version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
   safari: /webkit/.test( userAgent ),
   opera: /opera/.test( userAgent ),
   msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
   mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
 };
var s_account='aolmydailydev,devaolsvc';
        var cl_account='aolmydailydev';
        var psz='10x7';
        var segment='';

 var col = document.getElementById("bd");
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';

        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
        
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
           
            var cookies = document.cookie.split(';');
            //alert(cookies);
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                //alert(cookie);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
       //alert(cookieValue);
        return cookieValue;
    }
};
$('.flyouts').find('.toolbar-item-flyover').live('click',function() {
        //alert("inside Flyover");
	addRedirCookies(true);
});
/* if they click on the login button to sign in, do above, but also set mddoredir cookie to 1, so we send to dp on refresh */

$('#aol-header-login').live('click',function() {
        
	if(!$(this).hasClass('jSignOut')) {
		addLoginCookies(true);
//alert("SignOut State="+$(this).hasClass('jSignOut'));
	}
        else{
                         $.cookie("tbauid","hello",{expires: 1200, path: '/', domain: 'mydaily.com'});
				
				
				$.cookie("portal_auth",0,{expires: 1200, path: '/', domain: 'mydaily.com'});
        }
});

function addLoginCookies(redir) {
     if($.cookie('mddoredir')==0){
          //alert('welcome');
           $.cookie('mddoredir','2',{expires: 1200, path: '/', domain: 'mydaily.com'});
     }
     else if($.cookie('mddoredir')==2){
        addLoginCookies(false);
     }
     else{
	var cookies = (redir) ? ["mdloginorg","mddoredir"] : "mdloginor";
	$.each(cookies,function() {
		var val = (this=='mdloginorg') ? window.location.href : 1;
                //alert("Value being set in "+this+"="+val);
		$.cookie(this,null);
		$.cookie(this,val,{expires: 10000, path: '/', domain: 'mydaily.com'});
                 
	});
     }   
}
function addRedirCookies(redir) {
	var cookies = (redir) ? ["tbredirurl","tbredirid"] : "";
	$.each(cookies,function() {
		var val = (this=='tbredirurl') ? window.location.href : 1;
                $.cookie(this,null);
		$.cookie(this,val,{expires: 10000, path: '/', domain: 'mydaily.com'});
	});
}
$(document).ready(function(){
if($(".toolbar-item-flyover").hasClass("aolmailsigninbox")){

 var aolurl=$("#aolmail_item_status .mlbtn a").attr('href');
 var mySplitResult = aolurl.split("&");
 mySplitResult[1]="siteState=OrigUrl%3dhttp%3a%2f%2fwww.mydaily.com%2f";
//alert(mySplitResult[1]);
  var actualsigninurl=mySplitResult[0]+"&"+mySplitResult[1]+"&"+mySplitResult[2]+"&"+mySplitResult[3]+"&"+mySplitResult[4];
  //alert(actualsigninurl);
  $("#aolmail_item_status .mlbtn a").attr('href',actualsigninurl);
}
});
/*feedback js */
// fbLink v1.0d

var _fBr=encodeURIComponent(window.location.href);
var _fBh=362;
var _fBw=452;
var _fByt=(((screen.height-_fBh)/2)-100);
var _fBxl=((screen.width-_fBw)/2);


function _fBsG () {
	var _chG = typeof 's_channel' == 'undefined'? s_channel : '' ;
	return _chG;
}

function _fBsH () {
	var _chH = 'channel' in s_265? s_265.channel : "";
	_chH = _chH=='undefined'?'':_chH;
	return _chH;
}

function fBch() {
	var _ch = typeof s_265 == 'undefined'?_fBsG():_fBsH();
	return _ch;
}


function fBo(_sid){
	var _fBhref = 'http://feedback.aol.com/rs/rs.php?sid='+_sid;
	window.open(_fBhref+'&referer='+_fBr+'&ch='+fBch(),'feedback','width='+_fBw+',height='+_fBh+',screenX='+_fBxl+',screenY='+_fByt+',top='+_fByt+',left='+_fBxl+',resizable=yes,copyhistory=yes,scrollbars=no');
	return false;
}

function fBo2(_sid){
	var _fBhref = 'http://feedback.aol.com/rs/rs.php?sid='+_sid;
	window.open(_fBhref+'&referer='+_fBr+'&ch='+fBch(),'feedback','width='+_fBw+',height='+_fBh+',screenX='+_fBxl+',screenY='+_fByt+',top='+_fByt+',left='+_fBxl+',resizable=yes,copyhistory=yes,scrollbars=no');
}

function openFBHelp(href) {
	var _fBHelph=520;
	var _fBHelpw=794;
	var _fBHelpyt=(((screen.height-_fBHelph)/2)-100);
	var _fBHelpxl=((screen.width-_fBHelpw)/2);
	var href2=(href.indexOf('?')==-1?href+'?':href+'&');
    
	window.open(href2+'referer='+_fBr+'&ch='+fBch(),'feedback_help','width='+_fBHelpw+',height='+_fBHelph+',screenX='+_fBHelpxl+',screenY='+_fBHelpyt+',top='+_fBHelpyt+',left='+_fBHelpxl+',resizable=yes,copyhistory=yes,scrollbars=no');
}

function openStandard(href) {
	window.open(href,'','screenX=0,screenY=0,top=0,left=0,location=yes,toolbar=yes,resizable=yes,copyhistory=yes,scrollbars=yes');
}

/*local functions */


function twitDate(obj) {
  var myDate = obj.text();
  var dateSplit = myDate.split('T');
  var dateArr = dateSplit[0].split('-');
  var timeArr = dateSplit[1].replace("Z","").split(":");
  var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
  var amPm = 'AM';
  var hours = timeArr[0];
  var subTxt = 'th';
  var day = dateArr[2].replace(/0(\d)/g,'$1');
  if(hours > 12) {
	amPM = 'PM';
	hours = hours - 12;
	}
  if(day == 1 || day == 21 || day == 31){
        subTxt="st";
   } else if(day == 2 || day == 22){
        subTxt="nd";
   } else if(day == 3 || day == 23){
        subTxt="rd";
   }
  var newDate = hours+':'+timeArr[1]+' '+amPm+' '+months[dateArr[1]-1]+' '+day+subTxt;
  obj.text(newDate).removeAttr('id');
};

function formatDate(obj) {
	if (obj!=''&&obj!='undefined'&&obj!='Undefined'&&obj!='NULL') {
		var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
		var datearr = obj.split('/');
		var month = months[datearr[1]-1];
		var day = datearr[2].replace(/0(\d{1})/,'$1');
		var date = '<p class="expireHead">Valid through '+month+' '+day+'</p>';
		return date;
	}
};

var dates = {
    convert:function(d) {
        return (
            d.constructor === Date ? d :
            d.constructor === Array ? new Date(d[0],d[1],d[2]) :
            d.constructor === Number ? new Date(d) :
            d.constructor === String ? new Date(d) :
            typeof d === "object" ? new Date(d.year,d.month,d.date) :
            NaN
        );
    },
    compare:function(a,b) {
        return (
            isFinite(a=this.convert(a).valueOf()) &&
            isFinite(b=this.convert(b).valueOf()) ?
            (a>b)-(a<b) :
            NaN
        );
    },
    week:function(f) {
    	var now = new Date();
    	var then = f.split('/');
     	var weekAgo =  new Array(now.getFullYear(), parseInt(now.getMonth())+1, parseInt(now.getDate())-7);
	var compare = this.compare(then,weekAgo);
	if (compare<0) {
		return true;
	}
	else {
		return false;
	}
    }
};

function processDate(obj) {
     var now = new Date();
     var theDate = now.getDate();
     var theMonth = now.getMonth();
     var theYear = now.getFullYear();
     var myNow =  new Array(theYear, parseInt(theMonth)+1, theDate);
       	  
     var compare = dates.compare($(obj).text().split('/'), myNow);
  	  if (compare < 0) {
  	  	$(obj).parent().children('.mdl-img').children('.expired').addClass('isExpired');
  	  }
     $(obj).html(formatDate($(obj).text()));
};

function navSelect(cat) {
  $('li.GH_nav_LI').removeAttr('id');
  /*if (cat == '2-minute-memo') {
     $('li.GH_nav_LI > a[href=http://news.mydaily.com/category/2-minute-memo]').parent('.GH_nav_LI').attr('id','GH_nav_cur');
  }  
  else */ if (cat !='') {
     var nav = $('li.GH_nav_LI');
     $(nav[1]).attr('id','GH_nav_cur');
  }
}

function searchName(div,dom,sites) {
	var searchArr = new Array();
	searchArr = sites.replace(/\s|'/g,'').split('|'); /*'*/
	
	var searchDomain = dom.attr('href').replace(/http:\/\/w{3}?\.?([^\.]+).*/,'$1');
	$.each(searchArr, function(i) {
		if(searchArr[i].toLowerCase()==searchDomain) {
			div.text(searchArr[i]);
		}
	});
	div.attr('id','');
	dom.attr('id','');
}

function linkFix(obj) {
	obj.attr('title',function(){
		var curTitle = this.title;
		newTitle = curTitle.replace(/<b>/g,'');
		newTitle = newTitle.replace(/<\/b>/g,'');
		return newTitle;
	});
}


function welcomeDay()
  {
   var months,day=new Array();
   months=["January","February","March","April","May","June","July","August","September","October","November","December"];
   day=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
   var d=new Date();
   var subTxt="th";
   if(d.getDate() == 1 || d.getDate() == 21 || d.getDate() == 31){
        subTxt="st";
   } else if(d.getDate() == 2 || d.getDate() == 22){
        subTxt="nd";
   } else if(d.getDate() == 3 || d.getDate() == 23){
        subTxt="rd";
   }
   var sysDate="Today is "+day[d.getDay()]+", "+months[d.getMonth()]+" "+d.getDate()+subTxt;
   // var sysDate=""+day[d.getUTCDay()-1]+" "+months[d.getMonth()]+" "+d.getDate()+"th, "+d.getFullYear();
   document.getElementById("welcmDate").innerHTML=sysDate;
  }
                                                                                                                        

/*search ads*/

function done(sponsorData) {
	if(sponsorData.length!=0)
	{
		var start_html = '<h3><a href="http://search.aol.com/aol/about#sl" target="_blank">Sponsored Links</a></h3><ul>';
		var top_html = rail_html = start_html;
			
		$.each(sponsorData,function() {
			if(this.position=='RHS') {
				rail_html+=adsHTML(this);
			}
			else {
				top_html+=adsHTML(this);
			}
		});
		top_html+='</ul>';
		rail_html+='</ul>';
		start_html+='</ul>';
	}
	else
	{
		top_html = rail_html = '';
	}
	
	popAds(top_html,start_html,$('#promotedLinks'));
	popAds(rail_html,start_html,$('#sponsoredLinks'));
}

function adsHTML(obj) {
	var theHTML='<li>\
	<h4><a href="'+obj.redirect_url+'" target="_blank">'+obj.title+'</a></h4>\
	<p class="adDescript"><a href="'+obj.redirect_url+'" target="_blank">'+obj.d1+' '+obj.d2+'</a></p>\
	<p><a href="'+obj.redirect_url+'" target="_blank">'+obj.url+'</a></p>\
	</li>';
	return theHTML;
}
function popAds(orig,comp,div) {
	if(orig!=comp) {
		div.html(orig);
	}
}  

function showMRVideo( id ){
	d = new Date();
	if( d.getTime() - postDate.getTime() < (10 * 86400000) ){
		document.write( "<!--End of UEC --><div id='AOLVP_us_" + id + "' style='margin: 0pt; padding: 0pt; position: relative; width: 600px; height: 496px;'><script>if(typeof AOLVP_cfg==='undefined')AOLVP_cfg=[];AOLVP_cfg.push({id:'AOLVP_us_" + id + "','codever':0.1,'autoload':false,'autoplay':true,'playerid':10032373001,'videoid':'" + id + "','playertype':'expand','width':600,'height':496,'videotitle':'Video'});<\/script><\/div><script src='http://www.aolcdn.com/aolvideo/loader.js'><\/script><!--End of UEC --><br />" );
	} else {
	 document.write( "<h3>Sorry, our video has expired, please see the related stories and videos to the right for more information<\/h3><div id='video_player-here'></div>" );
	}
}

/* Related Video Functions */

$('.morning-rush-additional-video-item-old').live('click', function() {
	$('#moreVidHolder').html($('.embedwrapper > div').html()).modal({
		onOpen: function (dialog) {
			dialog.overlay.fadeIn('fast', function () {
				dialog.container.fadeIn('fast', function () {
					dialog.data.show();
					});
			});
		},
		onClose: function (dialog) {
			dialog.data.hide('fast', function () {
				dialog.container.fadeOut('fast', function () {
					dialog.overlay.fadeOut('fast', function () {
						$.modal.close(); 
					});
				});
			});
		}	
	});
});

function openModal( source ){
	$.modal( document.getElementById( source ), {
		overlayClose: true,
		onOpen: function (dialog) {
			dialog.overlay.fadeIn('fast', function () {
				dialog.container.fadeIn('fast', function () {
					dialog.data.show();
					});
			});
		},
		onClose: function (dialog) {
			dialog.data.hide('fast', function () {
				dialog.container.fadeOut('fast', function () {
					dialog.overlay.fadeOut('fast', function () {
						$.modal.close(); 
					});
				});
			});
		}	
	});
}


// This is Morgan Curley's developer app id - should be switched for a channel id
	var app_id = '253c9b2281090660f';
	//var app_id = 'x7i2czea7ljn6k8x1';
var videoObject = new Object();
var d = new Date();
function relatedvideo_output( location ){
	var elem = document.getElementById( location );
	carriageReturn = String.fromCharCode(10);
	var sourceData = elem.innerHTML.replace(/ id:/ig, "\nid:");
//	var sourceData = elem.innerHTML;
	var subject = sourceData.split( /\n/i );
	var videos = Array();
	var maxResults = subject.length + 1; //total hack something truveos results include a weird one - filtering that out later
	for( i=0; i < subject.length; i++){
		data = subject[i].split( "\|" );
		if( data[0].length > 1 ){
			id = data[0].replace( /^.*id:/, 'id:' );
			title = data[1].replace( 'title:', '' );
			videoObject[ id ] = title;
			videos.push( id );
		}
	}

	if( videos.length > 0 ){
		videoData = videos.join( "+OR+" );
		addScriptTag2("relatedVideos", "http://xml.truveo.com/apiv3?appid=" + app_id + "&format=json&method=truveo.videos.getVideos&query=" + videoData + "&results=" + maxResults + "&start=0&showRelatedItems=0&tagResults=0&channelResults=0&categoryResults=0&userResults=0&showAdult=0", "query_response");
	}
}

function addScriptTag2(id, url, callback) {
	var scriptTag = document.createElement("script");
   
   // Add script object attributes
   scriptTag.setAttribute("type", "text/javascript");
   scriptTag.setAttribute("charset", "utf-8");
   scriptTag.setAttribute("src", url + "&callback=" + callback);
   scriptTag.setAttribute("id", id);
	
	var head = document.getElementsByTagName("head").item(0);
	head.appendChild(scriptTag);
}

function query_response(jsonData){
	if( jsonData ){
		video_data = jsonData["response"]["data"]["results"]["videoSet"]["videos"];
		response_related(video_data, 'morning-rush-additional-videos');
	}
}


function response_related(jsonData, location) {
	var str = "";
	var video_data = "";

	var resp = document.getElementById(location);
	if( jsonData ){
		video_data = jsonData[0];
		if( video_data ){
			if( d.getTime() - postDate.getTime() >= (10 * 86400000) ){	
				var elem = document.getElementById( 'video_player-here' );
				embedTag = video_data.videoPlayerEmbedTag.replace( /width="[^"]+"/, 'width="600"' );
				embedTag = embedTag.replace( /height="[^"]+"/, 'height="496"' );
				if( typeof( elem ) != 'undefined' ){
					elem.innerHTML = embedTag;
				}
			}
		}
		for (var i=0; i<jsonData.length; i++){
			video_data = jsonData[i];
			if( video_data.videoPlayerEmbedTag ){
				id = 'id:' + video_data.id;
				title = videoObject[ id ];
				if( title != undefined ){
					str += '<div class="morning-rush-additional-video-item" style="cursor:pointer;" onclick="openModal( \'' + id + '\');">';
					str += '<div class="morning-rush-additional-video-image"><img src="' + video_data.thumbnailURL + '"\/><\/div>';
					str += '<div class="morning-rush-additional-video-play"><\/div>';
					str += '<div class="morning-rush-additional-video-data">';
					str += '<div class="morning-rush-additional-video-headline">' + title + '<\/div>';


					str += '<div class="morning-rush-additional-video-source">' + video_data.channel + '<\/div>';
					str += '<div class="morning-rush-additional-video-runtime">(' +  video_data.runtime + ' seconds)<\/div>';
					str += '</div>';
					str += '<\/div>';
					str += '<\/div>';
					str += '<div class="morning-rush-additional-videos-spacer"></div>';
					str += '<div class="embedwrapper" style="display:none;"><div id="' + id + '">' + video_data.videoPlayerEmbedTag + '<\/div></div>';
				}
			}
		}	
		if( str ){
			resp.innerHTML = '<div id="morning-rush-additional-videos-header"><h4>Related Videos</h4></div><div id="morning-rush-additional-videos-header-spacer"></div>' + str + '<div id="morning-rush-additional-videos-header-bottom-spacer"></div>';
		}
	}
}

var brightcoveID="";
var expandedID="";
var bc_player,bc_experience,bc_advertising;
var bc_videoPlayer;
var mtips=new Object();
function onTemplateLoaded(experienceID){
	if(brightcoveID.length==0){
		bc_player=brightcove.getExperience(experienceID);
		bc_experience=bc_player.getModule(APIModules.EXPERIENCE);
		brightcoveID=experienceID;
	}
	if(experienceID!=brightcoveID){
		return
	}

	bc_player=brightcove.getExperience(brightcoveID);
	bc_advertising=bc_player.getModule(APIModules.ADVERTISING);
	bc_videoPlayer=bc_player.getModule(APIModules.VIDEO_PLAYER);
	onTemplateLoaded_ext(experienceID)
}

function onTemplateLoaded_ext(experienceID){}
function validateExtAdSupport(){
	return brightcoveID
}

	var bcExp;
	var modVP;
	var modExp;
	var modCon;

	// called when template loads, this function stores a reference to the player and modules.
	function onTemplateLoaded_ext(experienceID) {
 	   	bcExp = brightcove.getExperience(experienceID);
	
 	   	modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
   	 	modExp = bcExp.getModule(APIModules.EXPERIENCE);
 	   	modCon = bcExp.getModule(APIModules.CONTENT);
	
		modVP.addEventListener(BCVideoEvent.VIDEO_COMPLETE, onVideoComplete);
	}

function onVideoComplete(evt) {
	firstTime = true;
	getNext = false;
	nextVidPrefix = '<div id="next-step"><div id="leave-comment">Close this window to leave a comment below <br /> or the next video will automatically load in <span id="next-video-timer">7</span> seconds <\/div><div id="next-video">';
	nextVid = '';
	nextURL = '';
	nextURLAuto = '';

	$( "a[id^=id-]" ).each( function(){
		var url = location.href;
		var urlparts = url.split( /[?#]/ );
		if( this.href == urlparts[0] ){  
			getNext = true;
		} else {
			if( firstTime == true ){
				nextURL = this.href;
				nextVid = this.id;
				firstTime = false;
			}

			if( getNext == true ){
				nextURL = this.href;
				nextVid = this.id;
				getNext = false;
			}
		}
	});
	nextURLAuto = nextURL + '#auto';
	var title = $( '#' + nextVid + '-title' ).html();
	var image = $( '#' + nextVid + '-image' ).attr("src");
	image = image.replace( /74x56/, '182x137' );
	var description = $( '#' + nextVid + '-description' ).html();

	
	nextVideoHTML = '<div id="next-play" onclick="location.href=\'' + nextURL + '#lightbox\'"></div>';
	nextVideoHTML += '<div id="next-image"><img src="' + image + '"></div>';
	nextVideoHTML += '<div id="next-title">' + title + '</div>';
	nextVideoHTML += '<div id="next-description">' + description + '</div>';
	nextVideoHTML += '<div id="next-url"><a href="' + nextURL + '#lightbox">Watch the video&nbsp;&raquo;</a></div>';

	nextVid = nextVidPrefix + nextVideoHTML + "<\/div><\/div>";

	$.modal( nextVid, {
		overlayClose: true,
		onOpen: function (dialog) {

			t = setTimeout( "location.href = nextURLAuto", 7000 );
			v = setTimeout( "autoplayTimer( 'next-video-timer' )", 1000 );
			dialog.overlay.fadeIn('fast', function () {
				dialog.container.fadeIn('fast', function () {
					dialog.data.show();
					});
			});
		},
		onClose: function (dialog) {
			clearTimeout( t );
			clearTimeout( v );
			dialog.data.hide('fast', function () {
				dialog.container.fadeOut('fast', function () {
					dialog.overlay.fadeOut('fast', function () {
						$.modal.close(); 
					});
				});
			});
		}	
	});
}

var autoPlayTimerVar;
function autoplayTimer( id ) {
	$selector = $( '#' + id );
	c = parseInt( $selector.text() );
	if( c > 0 ){
		c -= 1;
		$selector.text( c );
	} else {
		clearTimeout( autoPlayTimerVar );
	}

	autoPlayTimerVar = setTimeout("autoplayTimer('" + id + "')" ,1000);
}

function updateBloggerHeader(){
	$descSelector = $('#bloggerdescription');
	description = $descSelector.html() == null ? "&nbsp;" : "<br />" + $descSelector.html();
	$('#categorydescription').html( $('#bloggername').html() + description);
}

/* Daily Video */
function createEmbedCode( Provider, AssetID, AssetURL, AssetImage ){
	embedCode = '';

	if( !Provider ){
		// it's AOL
		embedCode = '<div id="AOLVP_us_' + AssetID + '" style="width:318px;height:239px;margin:0;padding:0;background-color:#000000;"><a id="AOLVP_us_' + AssetID + '_a" href="' + AssetURL + '" target="_blank"><img id="AOLVP_us_' + AssetID + '_img" src="' + AssetImage + '" alt="" width="318" height="239" border="0"/></a><div class="vid_play" id="AOLVP_us_' + AssetID + '_play"></div><\/div>';		
		embedCode += "<script type='text/javascript'>if(typeof AOLVP_cfg==='undefined')AOLVP_cfg=[];AOLVP_cfg.push({id:'AOLVP_us_" + AssetID + "','codever':0.1,'autoload':true,'autoplay':false,'playerid':90128453001,'videoid':'" + AssetID + "','width':318,'height':239,'stillurl':'none','playertype':'inline', 'displayads':false, 'videotitle':'Daily Video'});<\/script>";

	} else {

		if( Provider.search( /you\s*tube/i ) >= 0 ){
			//it's YouTube
			embedCode = '<object width="318" height="239"><param name="movie" value="http://www.youtube.com/v/' + AssetID + '&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + AssetID + '&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="318" height="239"></embed></object>';
		}
		
		if( Provider.search( /hulu/i ) >= 0 ){
			//it's HULU
			embedCode = '<object width="318" height="239"><param name="movie" value="http://www.hulu.com/embed/' + AssetID + '"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.hulu.com/embed/' + AssetID + '" type="application/x-shockwave-flash"  width="318" height="239" allowFullScreen="true"></embed></object>';
		}
	}

	if( !embedCode ){
		//Assuming this is raw embed
		embedCode = AssetID;
	}
	return embedCode;
}

function createEmbedCodeAlt( Provider, AssetID, AssetURL, AssetImage ){
	embedCode = '<a href="' + AssetURL + '" rel="bookmark"><img src="http://o.aolcdn.com/dims-global/dims3/12AB/resize/285x214/' + AssetImage + '" border="0"></a></div><div class="dv-video-play-alt" onclick="location.href=\'' + AssetURL + '\';" style="cursor:pointer;">&nbsp;';
	
	if( Provider != '' ){
		embedCode =  createEmbedCode( Provider, AssetID, AssetURL, AssetImage );
	}
	
	return '<div class="dv-video-image-alt">' + embedCode + '</div>';
}

/* End Daily Video */

function makeMyHomePageModal( ){
	$.modal( '<iframe style="width: 530px; height: 320px;" scrolling="no" src="http://news.mydaily.com/make_my_homepage"></iframe>', {
		overlayClose: true,
		onOpen: function (dialog) {
			dialog.overlay.fadeIn('fast', function () {
				dialog.container.fadeIn('fast', function () {
					dialog.data.show();
					});
			});
		},
		onClose: function (dialog) {
			dialog.data.hide('fast', function () {
				dialog.container.fadeOut('fast', function () {
					dialog.overlay.fadeOut('fast', function () {
						$.modal.close(); 
					});
				});
			});
		}	
	});
}
