$.clrCore.hooks.add('editor-created', 'item.clrWebsiteUpload(\'init\');');function clrUploaded(id, status, data){var item=$('#clr-editor-'+parseInt(id));item.clrWebsiteUpload('complete', status, data);};$.fn.clrWebsiteUpload=function(){function init(){data=item.data('clr');var url=data.urlBookmark+'&uploadframe=true';if(typeof(data.params.simpleUpload)=='undefined')return false;row=item.find('#'+data.id+'-bottom');if(!row.length)return false;row.append('<div class="clr-editor-header"><span class="clr-left"></span><span class="clr-right"></span><span class="clr-editor-header-content">Upload File</span></div>'+'<div id="'+data.id+'-simple-upload" class="clr-download"></div>');_reset();return true;};function focus(){data=item.data('clr');var empty=true,url=data.params.bookmark;for(var i=0;i<data.editors.items.length;i++){if(data.editors.items[i].data.urlShort.length>0){empty=false;}var setURL=data.editors.items[i].data.urlShort;eval("url=url.replace(/{set"+i+"}/, setURL);");}if(empty){_reset();alert('Nothing to colorize. You cannot upload files if there are no color changes.');return false;}url+='&uploadframe=1';row=item.find('#'+data.id+'-simple-upload');row.html('<iframe src="'+url+'" style="width: 100%;height: 40px;border-width: 0;"></iframe>');return false;};function inputChanged(input){if(!input.value.length)return false;data=item.data('clr');row=item.find('#'+data.id+'-simple-upload');var empty=true,url=data.params.bookmark;for(var i=0;i<data.editors.items.length;i++){if(data.editors.items[i].data.urlShort.length>0){empty=false;}var setURL=data.editors.items[i].data.urlShort;eval("url=url.replace(/{set"+i+"}/, setURL);");}if(empty){_reset();row.clrMessage('error', 'Nothing to colorize. You cannot upload files if there are no color changes.');return false;}url+='&uploadframe='+data.number;var form=row.find('form'),number=$.clrCore.nextCounter('iframe', 'clr-iframe-', 'clr-iframe'),id='clr-iframe-'+number,message='';if(!form.length)return false;form.attr('target', 'clr_iframe_'+number).attr('action', url);text='Upload is in progress. Please wait...';text+='<iframe name="clr_iframe_'+number+'" id="'+id+'" class="clr-iframe" style="width: 0;height: 0;border: none;"></iframe>';row.clrMessage('show', text, 'Cancel');form.submit();return true;};function complete(status, text){data=item.data('clr');row=item.find('#'+data.id+'-simple-upload');_reset();if(status=='error'){row.clrMessage('error', text);return false;}if(status=='complete'){var url=text,html='';iframe='colorizeit_iframe.php?url='+encodeURIComponent(url);if($.clrCore.browser.ie7||$.clrCore.browser.ie8){html+='Your file is ready, <a href="'+url+'">click here</a> to download it.';}else{html+='Your file is ready, download will begin in a few seconds. If download fails to start, <a href="'+url+'">click here</a> to download file.';html+='<iframe src="'+iframe+'" width="10" height="10" style="border-width: 0;padding: 0;margin: 0;"></iframe>';}row.clrMessage('show', html);return true;}row.clrMessage('error', 'Invalid responsed from server.');};function _reset(){row=item.find('#'+data.id+'-simple-upload');row.html('<p class="clr-option-note">If you would like to apply same color changes to another color scheme, use form below.</p><p class="clr-option-note">You can upload a zip file that contains files in format that ColorizeIt can process or one file in format that ColorizeIt can process: gif, png, jpg, html, css, js, vBulletin xml.</p><dl class="clr-option clr-rename"><dt>Upload File:</dt><dd><form action="" target="" method="post" onsubmit="void(0);" enctype="multipart/form-data"><input type="file" class="clr-rename-upload" onchange="$(\'#'+data.id+'\').clrWebsiteUpload(\'input-changed\', this);" name="clr_upload" /></form></dd></dl>');};var action=arguments[0],item=this, row, data;switch(action){case 'init': return init();case 'input-changed': return inputChanged(arguments[1]);case 'focus': return focus();case 'complete': return complete(arguments[1], arguments[2]);}};$.clrWebsite={parseWebsite: function(root){root.find('div.columns').each(function(){var items=$(this).children();if(items.length>1){items.wrapAll('<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr></tr></table>').wrap('<td valign="top"'+(($(this).hasClass('equal'))?' width="'+(Math.floor(100 / items.length))+'%"': '')+'></td>');}});root.find('div.welcome').find('p:last').addClass('last-row');root.find('div.block').each(function(){$(this).clrSection({'keepHTML': true, 'parseHeaders': true, 'type': 2});});}};$(document).ready(function(){var div=$('body');div.html('<table height="100%" border="0" cellspacing="0" cellpadding="0" id="global"><tr><td valign="top">'+div.html()+'</td></tr><tr><td id="website-footer" valign="bottom">'+$('#footer').html()+'</td></tr></table>');div=$('#header');div.replaceWith('<div id="website-header"><div class="clr-left"><div class="clr-right">'+div.html()+'</div></div></div>');$('#logo').empty();$('#footer').remove();$.clrWebsite.parseWebsite($('body'));});
