
latestMedia_offset=3;latestMedia_currentWidth=null;latestMedia_ul=null;latestMedia_isScrolling=false;function collectionsCallback(response)
{var media=response.xml.getElementsByTagName('media');for(var m=0;m<media.length;m+=1)
{var element=media[m];switch(element.getAttribute("type"))
{case'video':var li=document.createElement('li');var a_picture=document.createElement('a');a_picture.href=element.getAttribute("url");var img=document.createElement('img');img.src='img/videos/'+element.getAttribute("id")+'.jpg';img.title=element.firstChild.data;a_picture.appendChild(img);li.appendChild(a_picture);var div_title=document.createElement('div');div_title.className='title';var a_title=document.createElement('a');a_title.href=element.getAttribute("url");a_title.appendChild(document.createTextNode(element.firstChild.data));div_title.appendChild(a_title);li.appendChild(div_title);latestMedia_ul.appendChild(li);break;case'collection':var li=document.createElement('li');var a_picture=document.createElement('a');a_picture.href=element.getAttribute("url");var img=document.createElement('img');img.src='img/thumb.php?picture_id='+element.getAttribute("id");try
{img.title=element.firstChild.data;}
catch(e){}
a_picture.appendChild(img);li.appendChild(a_picture);var div_title=document.createElement('div');div_title.className='title';var a_title=document.createElement('a');a_title.href=element.getAttribute("url");try
{a_title.appendChild(document.createTextNode(element.firstChild.data));}
catch(e){}
div_title.appendChild(a_title);li.appendChild(div_title);latestMedia_ul.appendChild(li);break;}}}
function scrollCollectionsByType(type)
{var currentMarginLeft=latestMedia_ul.style.marginLeft;if(currentMarginLeft==='')
{currentMarginLeft=0;}
else
{currentMarginLeft=parseInt(currentMarginLeft.substr(0,currentMarginLeft.indexOf("px")));}
if(type==='+')
{currentMarginLeft-=141;latestMedia_isScrolling=true;window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft+45)+"px';",75);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft+25)+"px';",150);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft+15)+"px';",225);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft+10)+"px';",300);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft+5)+"px';",375);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft)+"px'; latestMedia_isScrolling = false;",450);}
else if(type==='-')
{currentMarginLeft+=141;latestMedia_isScrolling=true;window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft-45)+"px';",0);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft-25)+"px';",75);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft-15)+"px';",150);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft-10)+"px';",225);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft-5)+"px';",300);window.setTimeout("latestMedia_ul.style.marginLeft = '"+(currentMarginLeft)+"px'; latestMedia_isScrolling = false;",375);}}
function scrollLatestMedia(type)
{if(latestMedia_isScrolling)
return false;if(latestMedia_ul===null)
{latestMedia_ul=document.getElementById('lastmedia').getElementsByTagName("ul")[0];}
if(latestMedia_currentWidth===null)
{latestMedia_currentWidth=latestMedia_ul.offsetWidth;}
if(type==='+')
{latestMedia_offset+=1;latestMedia_currentWidth+=140;latestMedia_ul.style.width=latestMedia_currentWidth+'px';scrollCollectionsByType(type);var request=new ajaxRequest({url:'lib/ajax/latestmedia.php?offset='+latestMedia_offset,type:'GET',callback:collectionsCallback});request.startRequest();}
else
{if(latestMedia_offset<=3)
return;latestMedia_offset-=1;scrollCollectionsByType(type);}}