<!--
function onYouTubePlayerReady(playerId) {ytplayer = document.getElementById("ytapiplayer");}
function play() {if (ytplayer) {ytplayer.playVideo();}}

$(document).ready(function() {

var randomvid = "20";

$.ajax({
type: "GET",
url: "/NR/rdonlyres/3382EE47-7F68-422A-A2AB-B59D0FBD9665/0/wpp_videolibrary.xml",
dataType: "xml",
success: function(xml) {
var cid = $.jqURL.get('v');

if(cid!=null){
var totalrow = $(xml).find('item').length;
} else {
var totalrow = "1";
}

$(xml).find('item').slice(0,totalrow).each(function(){

var id = $(this).attr('id')
var img = $(this).find('image').text()
var imgw = $(this).find('image').attr('width')
var imgh = $(this).find('image').attr('height')
var title = $(this).find('title').text()
var link = $(this).find('link').text()
var cat = $(this).find('category').text()
var catid = $(this).find('category').attr('id')
var author = $(this).find('author').text()
var authorl = $(this).find('authorl').text()
var desc = $(this).find('desc').text()
var date = $(this).find('pubDate').text()
var dur = $(this).find('duration').text()
var via = $(this).find('via').text()
var embd = $(this).find('embd').text()
var ccid = $.jqURL.get('c');

if(cid!=null && cid!=""){

if(id==cid){

if(embd=="0"){
$('<div class="rr_video_playimg">').html('<img src="' + img + '" width="' + imgw + '" height="' + imgh + '" alt="' + title + '">').appendTo('#rr_output');
$('<div class="rr_video_detail_lrg">').html('<a href="' + link + '" target="external">' + title + '<\/a>').appendTo('#rr_output');
} else if(embd=="2"){
var imgWHttp=img;
var imgWTHttp=imgWHttp.replace('http://www.wpp.com/', '/');
$('<div id="mediaspace">').html('<div id="mediaspace_v"></div>').appendTo('#rr_output');
var params = {allowScriptAccess:'always',allowFullScreen:'true'};
var atts = { id: 'ytapiplayer' };
swfobject.embedSWF('/NR/rdonlyres/E5F1C23F-9E2E-41E0-9898-F39315544436/0/vidplayer.swf?file=' + link + '&image=' + imgWTHttp + '&autostart=false', 'mediaspace_v', '300', '218', '8', null, null, params, atts);
$('<div class="rr_video_detail_lrg">').html('<a href="' + authorl + '" target="external">' + title + '<\/a>').appendTo('#rr_output');
} else {
$('<div id="mediaspace">').html('<div id="mediaspace_v"></div>').appendTo('#rr_output');
var params = {allowScriptAccess:'always',allowFullScreen:'true'};
var atts = { id: 'ytapiplayer' };
swfobject.embedSWF('http://www.youtube.com/v/' + link + '&amp;border=0&amp;enablejsapi=1&amp;playerapiid=ytplayer&amp;showinfo=0&amp;color1=0xd8eaef&amp;color2=0xe5f3f8&amp;fs=1&amp;egm=0&amp;rel=0', 'mediaspace_v', '300', '218', '8', null, null, params, atts);
$('<div class="rr_video_detail_lrg">').html('<a href="http://www.youtube.com/watch?v=' + link + '">' + title + '<\/a>').appendTo('#rr_output');
}

$('<div class="rr_video_detail_sml">').html('Category:&nbsp;&nbsp;' + cat + '<br>').appendTo('#rr_output');
if(authorl!=''){
$('<div class="rr_video_detail_sml">').html('Company:&nbsp;&nbsp;<a href="' + authorl + '">' + author + '</a><br>').appendTo('#rr_output');
} else {
$('<div class="rr_video_detail_sml">').html('Company:&nbsp;&nbsp;' + author + '<br>').appendTo('#rr_output');
}
$('<div class="rr_video_detail_sml">').html('Added:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + date + '<br>').appendTo('#rr_output');
$('<div class="rr_video_detail_sml">').html('Source:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + via + '<br>').appendTo('#rr_output');
$('<div class="rr_video_detail_sml">').html('Length:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + dur + '<br>').appendTo('#rr_output');
$('<div>').html('<br>' + desc).appendTo('#rr_output');

if(embd=="0"){
$('<div class="rr_videoplay">').html('<a href="javascript:void(0);" onclick="window.open(\''+link+'\');" class="rr_video_playbutton">&nbsp;</a> (via ' + via + ')').appendTo('#rr_output');
} else if(embd=="2"){
$('<div class="rr_videoplay">').html('<a href="javascript:void(0);" onclick="window.open(\''+authorl+'\');" class="rr_video_detailbutton">&nbsp;</a>').appendTo('#rr_output');
} else {
$('<div class="rr_videoplay">').html('<a href="javascript:void(0);" onclick="play();" class="rr_video_playbutton">&nbsp;</a> or watch via <a href="http://www.youtube.com/watch?v=' + link + '" target="_blank">' + via + '</a>').appendTo('#rr_output');
}

$('<div style="float:right;margin-top:-35px;">').html('<iframe src="http://www.facebook.com/plugins/like.php?app_id=162433470496481&amp;href=http%3A%2F%2Fwww.wpp.com%2Fwpp%2Fmarketing%2Fonscreen.htm%3Fv%3D'+id+'&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe>').appendTo('#rr_output');

whatcat = cat.replace(/ /g,'');
$("#cat_"+catid).addClass("active");
	if(catid=="1" || ccid=="1") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/B86DD335-FB13-4ED1-A891-8F785D01DD1E/0/videolist_advertising.html?vc=1");}
	if(catid=="2" || ccid=="2") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/787937AF-8FF4-45B8-8077-EF895EA5C3F0/0/videolist_consumerinsights.html?vc=2");}
	if(catid=="3" || ccid=="3") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/266635CF-31D7-4F8D-94CB-FBE0644CC386/0/videolist_design.html?vc=3");}
	if(catid=="4" || ccid=="4") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/EA41F9CA-2EB7-43D2-9F32-1664BECF0D44/0/videolist_digital.html?vc=4");}
	if(catid=="5" || ccid=="5") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/C75C4325-4BB8-4FE2-8273-1103A20D7A66/0/videolist_hottopics.html?vc=5");}
	if(catid=="6" || ccid=="6") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/07CD4197-EBF0-4EEF-BAA4-35B6DCA2D586/0/videolist_marketing.html?vc=6");}
	if(catid=="7" || ccid=="7") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/1D0F0348-5840-4733-BF94-2C8FEE2B07FB/0/videolist_media.html?vc=7");}
	if(catid=="8" || ccid=="8") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/CE42093C-5C7A-4428-BB07-FABCC210E34B/0/videolist_publicrelations.html?vc=8");}
	if(catid=="9" || ccid=="9") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/D40194D2-8399-457D-AF38-F67E68ABE24F/0/videolist_wpp.html?vc=9");}
}

} else {

//if(id==randomvid){

if(embd=="0"){
$('<div class="rr_video_playimg">').html('<img src="' + img + '" width="' + imgw + '" height="' + imgh + '" alt="' + title + '">').appendTo('#rr_output');
$('<div class="rr_video_detail_lrg">').html('<a href="' + link + '" target="external">' + title + '<\/a>').appendTo('#rr_output');
} else if(embd=="2"){
var imgWHttp=img;
var imgWTHttp=imgWHttp.replace('http://www.wpp.com/', '/');
$('<div id="mediaspace">').html('<div id="mediaspace_v"></div>').appendTo('#rr_output');
var params = {allowScriptAccess:'always',allowFullScreen:'true'};
var atts = { id:'ytapiplayer' };
swfobject.embedSWF('/NR/rdonlyres/E5F1C23F-9E2E-41E0-9898-F39315544436/0/vidplayer.swf?file=' + link + '&image=' + imgWTHttp + '&autostart=false', 'mediaspace_v', '300', '218', '8', null, null, params, atts);
$('<div class="rr_video_detail_lrg">').html('<a href="' + authorl + '" target="external">' + title + '<\/a>').appendTo('#rr_output');
} else {
$('<div id="mediaspace">').html('<div id="mediaspace_v"></div>').appendTo('#rr_output');
var params = {allowScriptAccess:'always',allowFullScreen:'true'};
var atts = { id: 'ytapiplayer' };
swfobject.embedSWF('http://www.youtube.com/v/' + link + '&amp;border=0&amp;enablejsapi=1&amp;playerapiid=ytplayer&amp;showinfo=0&amp;color1=0xd8eaef&amp;color2=0xe5f3f8&amp;fs=1&amp;egm=0&amp;rel=0', 'mediaspace_v', '300', '218', '8', null, null, params, atts);
$('<div class="rr_video_detail_lrg">').html('<a href="http://www.youtube.com/watch?v=' + link + '">' + title + '<\/a>').appendTo('#rr_output');
}

$('<div class="rr_video_detail_sml">').html('Category:&nbsp;&nbsp;' + cat + '<br>').appendTo('#rr_output');
if(authorl!=''){
$('<div class="rr_video_detail_sml">').html('Company:&nbsp;&nbsp;<a href="' + authorl + '">' + author + '</a><br>').appendTo('#rr_output');
} else {
$('<div class="rr_video_detail_sml">').html('Company:&nbsp;&nbsp;' + author + '<br>').appendTo('#rr_output');
}
$('<div class="rr_video_detail_sml">').html('Added:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + date + '<br>').appendTo('#rr_output');
$('<div class="rr_video_detail_sml">').html('Source:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + via + '<br>').appendTo('#rr_output');
$('<div class="rr_video_detail_sml">').html('Length:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + dur + '<br>').appendTo('#rr_output');
$('<div>').html('<br>' + desc).appendTo('#rr_output');

if(embd=="0"){
$('<div class="rr_videoplay">').html('<a href="javascript:void(0);" onclick="window.open(\''+link+'\');" class="rr_video_playbutton">&nbsp;</a> (via ' + via + ')').appendTo('#rr_output');
} else if(embd=="2"){
$('<div class="rr_videoplay">').html('<a href="javascript:void(0);" onclick="window.open(\''+authorl+'\');" class="rr_video_detailbutton">&nbsp;</a>').appendTo('#rr_output');
} else {
$('<div class="rr_videoplay">').html('<a href="javascript:void(0);" onclick="play();" class="rr_video_playbutton">&nbsp;</a> or watch via <a href="http://www.youtube.com/watch?v=' + link + '" target="_blank">' + via + '</a>').appendTo('#rr_output');
}

$('<div style="float:right;margin-top:-35px;">').html('<iframe src="http://www.facebook.com/plugins/like.php?app_id=162433470496481&amp;href=http%3A%2F%2Fwww.wpp.com%2Fwpp%2Fmarketing%2Fonscreen.htm%3Fv%3D'+id+'&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe>').appendTo('#rr_output');

whatcat = cat.replace(/ /g,'');
$("#cat_"+ccid).addClass("active");
	if(ccid=="1") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/B86DD335-FB13-4ED1-A891-8F785D01DD1E/0/videolist_advertising.html?vc=1");}
	if(ccid=="2") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/787937AF-8FF4-45B8-8077-EF895EA5C3F0/0/videolist_consumerinsights.html?vc=2");}
	if(ccid=="3") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/266635CF-31D7-4F8D-94CB-FBE0644CC386/0/videolist_design.html?vc=3");}
	if(ccid=="4") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/EA41F9CA-2EB7-43D2-9F32-1664BECF0D44/0/videolist_digital.html?vc=4");}
	if(ccid=="5") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/C75C4325-4BB8-4FE2-8273-1103A20D7A66/0/videolist_hottopics.html?vc=5");}
	if(ccid=="6") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/07CD4197-EBF0-4EEF-BAA4-35B6DCA2D586/0/videolist_marketing.html?vc=6");}
	if(ccid=="7") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/1D0F0348-5840-4733-BF94-2C8FEE2B07FB/0/videolist_media.html?vc=7");}
	if(ccid=="8") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/CE42093C-5C7A-4428-BB07-FABCC210E34B/0/videolist_publicrelations.html?vc=8");}
	if(ccid=="9") {$('#rr_iframe_cat').attr("src","/NR/rdonlyres/D40194D2-8399-457D-AF38-F67E68ABE24F/0/videolist_wpp.html?vc=9");}
//}

}

});
}
});
})
//-->
