// (c) RTL Nederland Interactief
function RTLUpload(id,pollHandler,metadataHandler,uploadHandler,guidServer,profile,mp_channel){this.jsID=id;this.objectID=id+'_object';this.embedID=id+'_embed';var mpstatus=this.getCookie('mediapaspoort_loggedin');var mpname=this.getCookie('mediapaspoort_loginid');this.userEmail=mpname.trim();this.loggedIn=(mpstatus=='yes');this.pollHandler=pollHandler;this.metadataHandler=metadataHandler;this.uploadHandler=uploadHandler;this.guidServer=guidServer;this.profile=profile;this.mpChannel=mp_channel;this.server='';this.GUID='';this.GUIDAttempts=0;this.stage=0;this.stages={flashTest:1,readyForGUID:2,getGUID:3,receivedGUID:4,readyForUploading:5,uploading:6,encoding:7,uploadingEncodingError:8,thumbsReceived:9,sendMetadata:10,completed:11};this.interfaceStage=1;this.thumbnails=null;this.thumbnailsImg=null;this.thumbnailsLoaded=null;this.thumbnailsInterval=null;this.startThumb=0;this.errorState=false;this.IE55=(window.createPopup&&window.ActiveXObject);this.fields=['title','description','keywords','location','videodate','videocategory','file']};RTLUpload.prototype={start:function(){(this.loggedIn)?this.getObj('rtlupload_starter_button').style.display='block':this.getObj('rtlupload_login_button').style.display='block'},restart:function(){var mpstatus=this.getCookie('mediapaspoort_loggedin');var mpname=this.getCookie('mediapaspoort_loginid');var logged_in=(mpstatus=='yes');var user_email=mpname.trim();if(logged_in!=this.loggedIn||user_email!=this.userEmail){this.showUI(this.getObj('rtlupload_starter_button'))}},pollMP:function(){var mpstatus=this.getCookie('mediapaspoort_loggedin');var mpname=this.getCookie('mediapaspoort_loginid');var logged_in=(mpstatus=='yes');var user_email=mpname.trim();if(logged_in!=this.loggedIn||user_email!=this.userEmail){location.replace(location.href)}},flashDetect:function(){var flash_version=-1;if(typeof window.ActiveXObject!='undefined'&&navigator.platform.indexOf('Win')!=-1){try{var flash_obj=new ActiveXObject('ShockwaveFlash.ShockwaveFlash.8');flash_version=8}catch(e){flash_version=-1}flash_obj=null}else if(navigator.plugins){var flash_obj=navigator.plugins['Shockwave Flash'];if(flash_obj&&typeof flash_obj.description=='string'){var version_nr=flash_obj.description.match(/\d+\.\d/);flash_version=version_nr?parseInt(version_nr[0]):flash_version}}return flash_version},testInterfacePassive:function(string){if(string!='CallFromFlash'){this.handleUI({stage:this.stages.flashTest,errorString:'flash-javascript communicatie niet mogelijk'})}else{var id=this.jsID;setTimeout(function(){window[id].testInterfaceActive()},500);return'ResponseFromJS'}},testInterfaceActive:function(){var result=this.flashCall('testInterfacePassive');if(result!='ResponseFromFlash'){this.handleUI({stage:this.stages.flashTest,errorString:'flash-js communicatie niet mogelijk'})}else{this.stage=this.stages.readyForGUID;this.handleUI({stage:this.stages.readyForGUID,errorString:''})}},getGUID:function(){this.GUIDAttempts++;this.stage=this.stages.getGUID;var result=this.flashCall('getGUID');if(result=='Error'){this.handleUI({stage:this.stages.getGUID,errorString:'geen guid ontvangen'})}},receiveGUID:function(string){if(string=='Error'){if(this.GUIDAttempts<2){this.getGUID()}else{this.handleUI({stage:this.stages.getGUID,errorString:'geen guid ontvangen'})}}else{var list=string.split('<|>');this.server=list[0];this.GUID=list[1];this.stage=this.stage.readyForUploading;this.handleUI({stage:this.stages.receivedGUID,errorString:''})}},startPolling:function(){this.stage=this.stages.uploading;this.flashCall('startPolling')},receivePollResult:function(obj){var errorstrings={n1:'geen video bestand',n2:'slechts 1 frame aangetroffen',n3:'verzoek geannuleerd',n4:'speelduur te lang',n6:'speelduur te kort',n7:'bestand te groot',n99:'niet nader gespecificeerd'};if(obj.errorCode!=0){var description_text=(errorstrings['n'+obj.errorCode]||'niet nader gespecificeerd');this.stage=this.stages.readyForGUID;this.handleUI({stage:this.stages.uploadingEncodingError,errorString:description_text})}else if(typeof obj.thumbnails!='undefined'){this.stage=this.stages.thumbsReceived;this.handleUI({stage:this.stages.thumbsReceived,errorString:'',thumbnails:obj.thumbnails})}else if(obj.stage=='uploading'){this.stage=this.stages.uploading;this.handleUI({stage:this.stage,uploadperc:obj.uploadperc,errorString:''})}else if(obj.stage=='encoding'){this.stage=this.stages.encoding;this.handleUI({stage:this.stage,encodingperc:obj.encodingperc,errorString:''})}},sendMetaData:function(string){this.stage=this.stages.sendMetadata;var result=this.flashCall('sendMetaData',string);if(result=='Error'){this.handleUI({stage:this.stages.sendingMetadata,errorString:'fout bij js-flash communicatie'})}},receiveMetaDataResult:function(string){if(string=='Error'){this.handleUI({stage:this.stages.sendMetadata,errorString:'fout bij opslaan metadata'})}else{this.handleUI({stage:this.stages.completed});this.stage=this.stages.readyForGUID}},showMP:function(source){show_mp_iframe(false,'close_and_notify',this.mpChannel,true)},showUI:function(source){if(source.className.indexOf('disabled')!=-1){return}if(!document.createElement||window.opera||(window.ActiveXObject&&!window.createPopup)){alert('Deze toepassing werkt niet in de door u gebruikte webbrowser.');return}source.className='rtlupload_starter_disabled';var object_els=document.getElementsByTagName('object');var flash_objects=[];for(var i=0;i<object_els.length;i++){var w=(object_els[i].offsetWidth)?object_els[i].offsetWidth:0;flash_objects.push(object_els[i]);object_els[i].style.visibility='hidden'}this.flashObjects=flash_objects;var top_container=this.getObj('rtlupload_topcontainer');var overlay=this.getObj('pic_view_overlay');document.body.appendChild(top_container);top_container.style.display='block';this.placeOverlay();this.addEvent(window,'resize',function(){rtlupload.placeOverlay()});if(this.IE55){var fake_container=this.getObj('rtlupload_fake_file_container');var real_file_form=this.getObj('rtlupload_file_form');var real_file_input=this.getObj('rtlupload_step1_file');fake_container.style.top=fake_container.parentNode.offsetHeight-real_file_input.offsetHeight;fake_container.style.display='block';real_file_form.style.position='relative';real_file_form.style.zIndex=2;real_file_input.style.filter='alpha(opacity=0)';real_file_input.onmousemove=function(){rtlupload.fileInputMouseOver(true)};real_file_input.onmouseout=function(){rtlupload.fileInputMouseOver(false)};real_file_input.onkeydown=function(){return false};real_file_input.onpaste=function(){return false};real_file_input.oncontextmenu=function(){return false}}this.stage=this.stages.flashTest;if(this.flashDetect()>=8){this.writeFlash()}else{this.handleUI({stage:this.stages.flashTest,errorString:'er is geen flash 8 ondersteuning aangetroffen'})}},closeUI:function(source){if(source.className.indexOf('disabled')!=-1){return}if(source.getAttribute('id')=='rtlupload_closebutton'&&(this.interfaceStage>2&&this.interfaceStage<8)&&!this.errorState){if(!confirm('Het opslaan van de gegevens is niet voltooid.\nWeet je zeker dat je wilt afsluiten?')){return}}this.getObj('pic_view_overlay').style.display='none';this.getObj('pic_view_overlay').className='hidden';this.getObj('rtlupload_topcontainer').style.display='none';location.replace(location.href)},handleUI:function(obj){var stages=this.stages;var error_txt='Er is een fout opgetreden.';switch(obj.stage){case stages.flashTest:this.showMessage('html',error_txt+'<br />('+obj.errorString+')',true);break;case stages.readyForGUID:this.getGUID();break;case stages.getGUID:this.showMessage('html',error_txt+'<br />('+obj.errorString+')',true);break;case stages.receivedGUID:this.getObj('rtlupload_file_form').action=this.server+this.uploadHandler+'?PostID='+this.GUID+'&profile='+this.profile;for(var i=0;i<this.fields.length;i++){var field=this.getObj('rtlupload_step1_'+this.fields[i]);field.disabled=false}this.getObj('rtlupload_step1_'+this.fields[0]).focus();break;case stages.readyForUploading:break;case stages.uploading:this.getObj('rtlupload_upload_perclabel').firstChild.nodeValue=Math.round(obj.uploadperc)+'%';this.getObj('rtlupload_upload_bar').style.width=Math.round(obj.uploadperc)+'%';break;case stages.encoding:if(this.interfaceStage==3){this.goToStep(4)}this.getObj('rtlupload_encoding_perclabel').firstChild.nodeValue=Math.round(obj.encodingperc)+'%';this.getObj('rtlupload_encoding_bar').style.width=Math.round(obj.encodingperc)+'%';break;case stages.uploadingEncodingError:this.showMessage('html',error_txt+'<br />('+obj.errorString+')',true);break;case stages.thumbsReceived:this.thumbnails=obj.thumbnails;this.goToStep(5);break;case stages.sendMetadata:this.showMessage('html',error_txt+'<br />('+obj.errorString+')',true);break;case stages.completed:this.goToStep(8);break}},goToStep:function(nr){if(nr==this.interfaceStage){return}switch(nr){case 1:this.getObj('rtlupload_step1_logo').style.display='block';this.getObj('rtlupload_step1_intro').style.display='block';this.getObj('rtlupload_step2_logo').style.display='none';this.getObj('rtlupload_step2_intro').style.display='none';this.getObj('rtlupload_step2_upload').className='rtlupload_upload_button_disabled';this.interfaceStage=1;break;case 2:this.getObj('rtlupload_step1_logo').style.display='none';this.getObj('rtlupload_step1_intro').style.display='none';this.getObj('rtlupload_step2_logo').style.display='block';this.getObj('rtlupload_step2_intro').style.display='block';this.getObj('rtlupload_step2_upload').className='rtlupload_upload_button';this.interfaceStage=2;break;case 3:for(var i=0;i<this.fields.length;i++){var max_length=(this.fields[i]=='description'?250:50);this.getObj('rtlupload_step3_'+this.fields[i]).firstChild.nodeValue=this.getObj('rtlupload_step1_'+this.fields[i]).value.insertSpaces(32,30).truncate(max_length,' ..')}this.getObj('rtlupload_step1_container').style.visibility='hidden';this.getObj('rtlupload_pb_step4_container').style.visibility='hidden';this.getObj('rtlupload_step3_container').style.visibility='visible';var h=this.getObj('rtlupload_step3_container').offsetHeight+110;this.getObj('rtlupload_topcontainer').style.height='450px';this.getObj('rtlupload_body').style.height='403px';this.getObj('rtlupload_closebutton').className='rtlupload_sluitknop_disabled';this.getObj('rtlupload_upload_bar').style.width='1%';this.getObj('rtlupload_encoding_bar').style.width='1%';this.interfaceStage=3;break;case 4:this.getObj('rtlupload_step3_logo').style.display='none';this.getObj('rtlupload_step4_logo').style.display='block';this.getObj('rtlupload_step3_intro').style.display='none';this.getObj('rtlupload_step4_intro').style.display='block';this.getObj('rtlupload_upload_perclabel').firstChild.nodeValue='100%';this.getObj('rtlupload_upload_bar').style.width='100%';this.getObj('rtlupload_pb_step4_container').style.visibility='visible';this.interfaceStage=4;break;case 5:this.getObj('rtlupload_encoding_perclabel').firstChild.nodeValue='100%';this.getObj('rtlupload_encoding_bar').style.width='100%';this.getObj('rtlupload_topcontainer').style.height='577px';this.getObj('rtlupload_body').style.height='530px';this.thumbnailsImg=[];this.thumbnailsLoaded=[];var instance=this;for(var i=0;i<this.thumbnails.length;i++){var img=document.createElement('img');img.setAttribute('rel',i+':'+this.thumbnails[i]);img.onload=function(){this.setAttribute('width',this.width);this.setAttribute('height',this.height);instance.thumbnailsLoaded[Number(this.getAttribute('rel').split(':')[0])]=1;this.onload=null;this.onerror=null};img.onerror=function(){instance.thumbnailsLoaded[Number(this.getAttribute('rel').split(':')[0])]=-1;this.onload=null;this.onerror=null};this.getObj('carrousel_thumbs_container').appendChild(img);img.setAttribute('src',this.server+this.thumbnails[i]);this.thumbnailsImg.push(img);this.thumbnailsLoaded.push(0)}this.thumbnailsInterval=setInterval(function(){instance.checkThumbsLoading()},1000);for(var i=0;i<this.fields.length;i++){var field_5=this.getObj('rtlupload_step5_'+this.fields[i]);var field_6=this.getObj('rtlupload_step6_'+this.fields[i]);var max_length=(this.fields[i]=='description'?250:50);if(field_5){field_5.firstChild.nodeValue=this.getObj('rtlupload_step1_'+this.fields[i]).value.insertSpaces(32,30).truncate(max_length,' ..')}if(field_6){if(field_6.nodeName.toLowerCase()!='select'){field_6.value=this.getObj('rtlupload_step1_'+this.fields[i]).value}else{var val=this.getObj('rtlupload_step1_'+this.fields[i]).value;for(var j=0;j<field_6.options.length;j++){if(field_6.options[j].value==val){field_6.selectedIndex=j;break}}}}}this.interfaceStage=5;break;case 6:if(this.interfaceStage==5){this.getObj('rtlupload_step5_intro').style.display='none';this.getObj('rtlupload_step6_intro').style.display='block';this.getObj('rtlupload_step5_meta_container').style.visibility='hidden';this.getObj('rtlupload_step6_meta_container').style.visibility='visible'}else{this.getObj('rtlupload_step6_send').className='rtlupload_send_button'}this.interfaceStage=6;break;case 7:this.getObj('rtlupload_step6_send').className='rtlupload_send_button_disabled';this.interfaceStage=7;break;case 8:this.getObj('rtlupload_step8_intro').innerHTML=this.getObj('rtlupload_thankyou_text').innerHTML;var els=['rtlupload_step5_headercontainer','carrousel_top_container','rtlupload_step5_meta_container','rtlupload_step6_meta_container'];for(var i=0;i<els.length;i++){this.getObj(els[i]).style.display='none'}this.getObj('rtlupload_step8_container').style.visibility='visible';this.getObj('rtlupload_body').style.height='130';this.getObj('rtlupload_topcontainer').style.height='177';this.interfaceStage=8;break}},checkThumbsLoading:function(){if(this.thumbnailsLoaded.indexOf(0)!=-1){return}clearInterval(this.thumbnailsInterval);var top_container=this.getObj('rtlupload_topcontainer');var header_container=this.getObj('rtlupload_step5_headercontainer');var thumbs_container=this.getObj('carrousel_top_container');var meta_container=this.getObj('rtlupload_step5_meta_container');var meta6_container=this.getObj('rtlupload_step6_meta_container');var thumbs=[];for(var i=0;i<this.thumbnailsLoaded.length;i++){if(this.thumbnailsLoaded[i]==1){thumbs.push(this.thumbnailsImg[i])}}if(thumbs.length==0){this.showMessage('html','Er is een fout opgetreden<br />(geen thumbs ingeladen).',true);return}rtlcarrousel.start(thumbs,this.startThumb);thumbs_container.style.top=(parseInt(header_container.style.height)+35)+'px';meta_container.style.top=meta6_container.style.top=(parseInt(thumbs_container.style.height)+parseInt(thumbs_container.style.top))+'px';var meta_height=(meta_container.offsetHeight>meta6_container.offsetHeight)?meta_container.offsetHeight:meta6_container.offsetHeight;var total_height=(parseInt(meta_container.style.top)+meta_height+40);total_height=(total_height>600?total_height:600);header_container.style.visibility='visible';thumbs_container.style.visibility='visible';meta_container.style.visibility='visible';this.getObj('rtlupload_step3_container').style.display='none';this.getObj('rtlupload_closebutton').className='rtlupload_sluitknop'},showMessage:function(type,message_string,error_state){if(type=='html'){this.getObj('rtlupload_error_subcontainer').innerHTML=message_string;this.getObj('rtlupload_invalid_closebutton').style.display=(error_state)?'none':'block';this.getObj('rtlupload_error_closebutton').style.display=(error_state)?'block':'none';this.getObj('rtlupload_error_container').style.visibility='visible'}else{alert(message_string)}if(error_state){this.errorState=true}},handleKeyUp:function(current_step,step_non_valid,step_valid){this.goToStep((this.validateFields(current_step).length==0?step_valid:step_non_valid));if(this.IE55&&event.type=='change'){this.getObj('rtlupload_fake_file_input').value=this.getObj('rtlupload_step1_file').value}},handleSubmit:function(frm){return false},handleClick:function(evt){var source=(window.event)?event.srcElement:evt.target;source=(source.nodeType==3)?source.parentNode:source;if(source.className.indexOf('disabled')!=-1){return}var rel=source.getAttribute('rel');if(!rel||rel.indexOf('click:')!=0){return}this[rel.split(':')[1]](source)},startUpload:function(source){if(this.validateFields(1).length>0){this.showMessage('html','Vul eerst alle verplichte<br /> velden op correcte wijze in.',false)}else{document.getElementById('rtlupload_file_form').submit();this.goToStep(3);this.startPolling()}},editMetaData:function(source){this.goToStep(6)},prepareMetaData:function(source){var fields=[
rtlcarrousel.activeThumb.getAttribute('rel').replace(/^\d+:/,''),this.getObj('rtlupload_step6_title').value.trim(),this.getObj('rtlupload_step6_description').value.trim(),this.getObj('rtlupload_step6_keywords').value.trim(),this.getObj('rtlupload_step6_location').value.trim(),this.getObj('rtlupload_step6_videodate').value.trim(),this.getObj('rtlupload_step6_videocategory').value
];if(fields.indexOf('')!=-1){this.showMessage('html','Vul eerst alle verplichte<br /> velden op correcte wijze in.',false);return}else{source.className='rtlupload_send_button_disabled';this.getObj('rtlupload_step5_edit').className='rtlupload_edit_button_disabled'}var xml_string='<fi'+'elds>\n';xml_string+='<ima'+'ge>'+fields[0].escapeXML(127)+'<\/im'+'age>\n';xml_string+='<ti'+'tle>'+fields[1].escapeXML(127)+'<\/ti'+'tle>\n';xml_string+='<descr'+'iption>'+fields[2].escapeXML(127)+'<\/descri'+'ption>\n';xml_string+='<key'+'words>'+fields[3].escapeXML(127)+'<\/keywords>\n';xml_string+='<cus'+'tom>\n';xml_string+='<loca'+'tion>'+fields[4].escapeXML(127)+'<\/loca'+'tion>\n';xml_string+='<vide'+'odate>'+fields[5].escapeXML(127)+'<\/vide'+'odate>\n';xml_string+='<rubr'+'iek>'+fields[6].escapeXML(127)+'<\/rubr'+'iek>\n';xml_string+='<\/cu'+'stom>\n';xml_string+='<\/fi'+'elds>';this.sendMetaData(xml_string)},resetForms:function(){this.getObj('rtlupload_step1_form').reset();this.getObj('rtlupload_file_form').reset();this.getObj('rtlupload_step2_upload').className='rtlupload_upload_button_disabled';this.goToStep(1);this.getObj('rtlupload_fake_file_input').value=''},fileInputMouseOver:function(over){if(!this.IE55){return}var fake_button=this.getObj('rtlupload_fake_file_button');var real_file_input=this.getObj('rtlupload_step1_file');if(!over){fake_button.className='rtlupload_fake_file';real_file_input.style.cursor='default'}else{var el=rtlcarrousel.getXY(fake_button);var mouse=rtlcarrousel.getMouseXY(event);var over_button=((mouse.x>el.x&&mouse.x<el.x+el.w)&&(mouse.y>el.y&&mouse.y<el.y+el.h));if(over_button){if(fake_button.className=='rtlupload_fake_file'){fake_button.className='rtlupload_fake_file_on'}}else{if(fake_button.className=='rtlupload_fake_file_on'){fake_button.className='rtlupload_fake_file'}}real_file_input.style.cursor=over_button?'hand':'default'}},validateFields:function(current_step){var invalid_fields=[];for(var i=0;i<this.fields.length;i++){var input=this.getObj('rtlupload_step'+current_step+'_'+this.fields[i]);if(!input){continue}var rel=input.getAttribute('rel');var val=input.value;if(rel&&rel.indexOf('req')==0){var function_name=rel.split(':')[1];if(!this[function_name](val)){invalid_fields.push(this.fields[i])}}}return invalid_fields},validDate:function(string){var input=string.trim();if(!/^\d{1,2}\-\d{1,2}\-\d{4}$/.test(input)){return false}var list=string.split('-');list.walk(Number);if(list[2]<1896||list[2]>(new Date()).getFullYear()){return false}if(list[1]>12){return false}if(list[0]>[31,(list[2] % 4==0?29:28),31,30,31,30,31,31,30,31,30,31][list[1]-1]){return false}return true},notEmpty:function(string){return(string.trim()!='')},preloadImages:function(urls){for(var i=0;i<urls.length;i++){var img=new Image();img.src=urls[i]}},placeOverlay:function(){var overlay_el=this.getObj('pic_view_overlay');overlay_el.style.display='none';var page_size=this.determinePageDimensions();overlay_el.className='pic_view_overlay';with(overlay_el.style){width=page_size.x+'px';height=page_size.y+'px';display='block';zIndex=599}document.body.scrollTop=0},determinePageDimensions:function(){var test1=document.body.scrollHeight;var test2=document.body.offsetHeight
return(test1>test2)?{x:document.body.scrollWidth,y:document.body.scrollHeight}:{x:document.body.offsetWidth,y:document.body.offsetHeight}},determineWindowDimensions:function(){return{x:(window.innerWidth?window.innerWidth-15:document.body.clientWidth),y:(window.innerHeight?window.innerHeight-15:document.body.clientHeight)}},flashCall:function(method_name,arg){var embs=document.embeds;var flash_el=(embs&&embs[this.embedID]&&embs[this.embedID][method_name])?embs[this.embedID]:document.getElementById(this.objectID);var result;try{result=(typeof arg=='undefined')?flash_el[method_name]():flash_el[method_name](arg)}catch(e){result='Error'}return result},getCookie:function(name){var rx=new RegExp(name+"=([^;]+)");var value=rx.exec(document.cookie);return(value!=null)?unescape(value[1]):''},getObj:function(id){return document.getElementById(id)},addEvent:function(object,eventstring,func){if(typeof window.addEventListener=='function'){object.addEventListener(eventstring,func,false)}else{object.attachEvent('on'+eventstring,func)}}};function RTLCarrousel(id,topContainer,maxThumbWidth,thumbMargin,showBorder){this.id=id;this.topContainer=topContainer;this.maxThumbWidth=maxThumbWidth;this.thumbMargin=thumbMargin;this.showBorder=showBorder;this.thumbs=null;this.activeThumb=null;this.thumbWidth=0;this.thumbHeight=0;this.firstStart=true;this.dragging=false;this.dragOffset=0;this.IE=(typeof ActiveXObject=='function');this.noPNG=(typeof ActiveXObject=='function'&&typeof XMLHttpRequest=='undefined')};RTLCarrousel.prototype={start:function(thumbs,start_at){if(this.firstStart){var els=['carrousel_top_container','carrousel_thumbs_container','carrousel_prev_button','carrousel_next_button','carrousel_number','carrousel_overlay_left','carrousel_overlay_right','carrousel_border','carrousel_border_white','carrousel_slider_top_container','carrousel_slider_container','carrousel_slider_button'];for(var i=0;i<els.length;i++){this[els[i]]=document.getElementById(els[i])}var instance=this;this.addEvent(document,'mousemove',function(evt){instance.handleMouseMove(evt)});this.addEvent(document,'mouseup',function(evt){instance.stopDrag(evt)});this.firstStart=false}if(this.noPNG){this.carrousel_overlay_left.style.backgroundImage='none';this.carrousel_overlay_left.style.backgroundColor='#FFFFFF';this.carrousel_overlay_left.style.filter='alpha(opacity=60)';this.carrousel_overlay_right.style.backgroundImage='none';this.carrousel_overlay_right.style.backgroundColor='#FFFFFF';this.carrousel_overlay_right.style.filter='alpha(opacity=60)'}this.thumbs=thumbs;while(this.carrousel_thumbs_container.hasChildNodes()){this.carrousel_thumbs_container.removeChild(this.carrousel_thumbs_container.lastChild)}for(var i=0;i<this.thumbs.length;i++){this.thumbs[i].style.visibility='hidden';this.carrousel_thumbs_container.appendChild(this.thumbs[i])}var startpos=(start_at>thumbs.length-1)?thumbs.length-1:start_at;var w=Number(this.thumbs[0].getAttribute('width'));var h=Number(this.thumbs[0].getAttribute('height'));var thumb_w=this.maxThumbWidth;var thumb_h=(thumb_w/w)*h;var container_w=(3*this.maxThumbWidth)+(2*this.thumbMargin);var container_h=thumb_h;this.thumbPositions=[0,this.maxThumbWidth+this.thumbMargin,2*(this.maxThumbWidth+this.thumbMargin)];this.thumbWidth=thumb_w;this.thumbHeight=thumb_h;with(this.carrousel_border.style){left=(this.thumbPositions[1]-6)+'px';top='-4px';width=(this.thumbWidth+10)+'px';height=(this.thumbHeight+28)+'px';visibility=(this.showBorder)?'visible':'hidden'}with(this.carrousel_border_white.style){left=(this.thumbPositions[1]-1)+'px';top='18px';width=(this.thumbWidth+2)+'px';height=(this.thumbHeight+1)+'px';visibility=(this.showBorder)?'visible':'hidden'}with(this.carrousel_thumbs_container.style){width=container_w+'px';height=container_h+'px'}with(this.carrousel_top_container.style){width=container_w+'px';height=(this.thumbHeight+4+38)+'px'}with(this.carrousel_number.style){left=((container_w/2)-(this.carrousel_number.offsetWidth/2))+'px'}this.carrousel_prev_button.style.top=(this.thumbHeight+10+19)+'px';this.carrousel_next_button.style.top=(this.thumbHeight+10+19)+'px';with(this.carrousel_slider_top_container.style){left='44px';top=(this.thumbHeight+4+19)+'px';width=(container_w-88)+'px'}this.carrousel_slider_container.style.width=(container_w-92)+'px';this.scrollSpace=(this.carrousel_slider_container.offsetWidth-this.carrousel_slider_button.offsetWidth);this.sliderStep=this.scrollSpace/(this.thumbs.length-1);this.placeThumbs(startpos);this.placeSliderButton(startpos)},placeThumbs:function(startpos){for(var i=0;i<this.thumbs.length;i++){this.thumbs[i].style.visibility='hidden'}var left_img=(startpos>0)?this.thumbs[startpos-1]:null;var center_img=this.thumbs[startpos];var right_img=(startpos<this.thumbs.length-1)?this.thumbs[startpos+1]:null;if(left_img!=null){left_img.setAttribute('width',this.thumbWidth);left_img.setAttribute('height',this.thumbHeight);with(left_img.style){left=this.thumbPositions[0]+'px';top='0px';visibility='visible'}with(this.carrousel_overlay_left.style){left=this.thumbPositions[0]+'px';width=this.thumbWidth+'px';height=this.thumbHeight+'px';visibility='visible'}}else{this.carrousel_overlay_left.style.visibility='hidden'}center_img.setAttribute('width',this.thumbWidth);center_img.setAttribute('height',this.thumbHeight);with(center_img.style){left=this.thumbPositions[1]+'px';top='0px';visibility='visible'}if(right_img!=null){right_img.setAttribute('width',this.thumbWidth);right_img.setAttribute('height',this.thumbHeight);with(right_img.style){left=this.thumbPositions[2]+'px';top='0px';visibility='visible'}with(this.carrousel_overlay_right.style){left=this.thumbPositions[2]+'px';width=this.thumbWidth+'px';height=this.thumbHeight+'px';visibility='visible'}}else{this.carrousel_overlay_right.style.visibility='hidden'}var prev_class=this.carrousel_prev_button.className;var next_class=this.carrousel_next_button.className;if(startpos==0&&prev_class.indexOf('disabled')==-1){this.carrousel_prev_button.className='carrousel_prev_disabled'}else if(prev_class.indexOf('disabled')!=-1){this.carrousel_prev_button.className='carrousel_prev'}if(startpos==this.thumbs.length-1&&next_class.indexOf('disabled')==-1){this.carrousel_next_button.className='carrousel_next_disabled'}else if(next_class.indexOf('disabled')!=-1){this.carrousel_next_button.className='carrousel_next'}this.carrousel_number.firstChild.nodeValue='Screenshot '+(startpos+1)+' van '+this.thumbs.length;this.activePos=startpos;this.activeThumb=center_img},placeSliderButton:function(new_pos){var pos=(new_pos*this.sliderStep);pos=(pos<2)?2:pos;pos=(pos>this.scrollSpace-2)?this.scrollSpace-2:pos;this.carrousel_slider_button.style.left=pos+'px'},handleMouseMove:function(evt){if(!this.dragging){return}var source=(window.event)?event.srcElement:evt.target;source=(source.nodeType==3)?source.parentNode:source;var el=source;var in_top_container=false;while(el){if(el==this.topContainer){in_top_container=true;break}el=el.parentNode}(!in_top_container)?this.stopDrag(evt):this.doDrag(evt)},handlePrevNextClick:function(dir){var new_pos=this.activePos+dir;if(new_pos<0||new_pos>this.thumbs.length-1){return}this.placeThumbs(new_pos);this.placeSliderButton(new_pos)},handlePrevNextMouse:function(obj,inside){if(obj.className.indexOf('disabled')!=-1){return}var which=obj.getAttribute('rel').split(':')[1];obj.className='carrousel_'+which+(inside?'_on':'')},startDrag:function(evt){var mouse_xy=this.getMouseXY(evt);var button_xy=this.getXY(this.carrousel_slider_button);this.dragOffset=mouse_xy.x-button_xy.x;this.dragging=true;return false},doDrag:function(evt){var mouse_xy=this.getMouseXY(evt);var container_xy=this.getXY(this.carrousel_slider_container);var button_width=this.carrousel_slider_button.offsetWidth;var x_pos=mouse_xy.x-container_xy.x-this.dragOffset;x_pos=(x_pos<2)?2:x_pos;x_pos=(x_pos>container_xy.w-button_width-2)?container_xy.w-button_width-2:x_pos;this.carrousel_slider_button.style.left=x_pos+'px';var startpos=Math.round(x_pos/this.sliderStep);if(startpos!=this.activePos){this.placeThumbs(startpos)}},stopDrag:function(evt){this.dragging=false},addEvent:function(object,eventstring,func){if(typeof window.addEventListener=='function'){object.addEventListener(eventstring,func,false)}else{object.attachEvent('on'+eventstring,func)}},getXY:function(element){var el=element;var x_offset=0;var y_offset=0;while(el.offsetParent){x_offset+=el.offsetLeft;y_offset+=el.offsetTop;el=el.offsetParent}var w=(element.offsetWidth)?element.offsetWidth:0;var h=(element.offsetHeight)?element.offsetHeight:0;return{x:x_offset,y:y_offset,w:w,h:h}},getMouseXY:function(e){if(window.event){mouse_x=(window.ActiveXObject||window.opera)?event.clientX+document.body.scrollLeft:event.clientX;mouse_y=(window.ActiveXObject||window.opera)?event.clientY+document.body.scrollTop:event.clientY}else{mouse_x=e.pageX;mouse_y=e.pageY}return{x:mouse_x,y:mouse_y}}};String.prototype.insertSpaces=function(code_point,max_length){var words=this.split(/\s| /);for(var i=0;i<words.length;i++){if(words[i].length>max_length){words[i]=words[i].chunkSplit(max_length).join(String.fromCharCode(code_point))}}return words.join(' ')};String.prototype.chunkSplit=function(nr){var return_array=[];for(var i=0;i<this.length;i+=nr){return_array[return_array.length]=this.substring(i,i+nr)}return return_array};String.prototype.truncate=function(max_length,add_string){return(this.length>max_length)?this.substr(0,max_length-add_string.length)+add_string:this};Array.prototype.walk=function(func){for(var i=0;i<this.length;i++){this[i]=func(this[i])}};Array.prototype.indexOf=Array.prototype.indexOf||function(val){for(var i=0;i<this.length;i++){if(this[i]===val){return i}}return-1};String.prototype.trim=function(){return this.replace(/^\s+/g,'').replace(/\s+$/g,'')};String.prototype.escapeXML=function(encode_above){var xml_special='<>\'"&';var tmp='';var i=0;var c,cc,c2,cc2;while(i<this.length){c=this.charAt(i);cc=c.charCodeAt(0);if(xml_special.indexOf(c)!=-1||cc>encode_above){if(cc<0xD800||cc>0xDFFF){tmp+='&#'+cc+';';i++}else{c2=this.charAt(i+1);cc2=(c2!='')?c2.charCodeAt(0):NaN;if(cc>=0xD800&&cc<=0xDBFF&&!isNaN(cc2)&&cc2>=0xDC00&&cc2<=0xDFFF){cc=(((cc & 1023)<<10)|(cc2 & 1023))+0x10000;tmp+='&#'+cc+';';i+=2}else{i++}}}else{tmp+=c;i++}}return tmp};RTLUpload.prototype.writeFlash=function(){var flashvars='jsID='+this.jsID+'&guidServer='+this.guidServer+'&pollHandler='+this.pollHandler+'&metadataHandler='+this.metadataHandler;var html_string='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" id="'+this.objectID+'" align="middle">'+'<param name="flashvars" value="'+flashvars+'" />'+'<param name="wmode" value="transparent" />'+'<param name="allowScriptAccess" value="sameDomain" />'+'<param name="movie" value="/system/videoupload/videoupload2.swf" />'+'<param name="quality" value="high" />'+'<param name="bgcolor" value="#ffffff" />'+'<embed src="/system/videoupload/videoupload2.swf" wmode="transparent" flashvars="'+flashvars+'"quality="high" bgcolor="#ffffff" width="1" height="1" name="'+this.embedID+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';'<\/object>';this.getObj('rtlupload_flash_container').innerHTML=html_string};