var BrowserDetect={
init:function(){
this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";}, searchString:function(data){
for(var i=0;i<data.length;i++){
var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){
if(dataString.indexOf(data[i].subString)!=-1)return data[i].identity;}
else if(dataProp)return data[i].identity;}
return null;}, searchVersion:function(dataString){
var index=dataString.indexOf(this.versionSearchString);if(index==-1)return null;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));}, dataBrowser:[
{string:navigator.userAgent, subString:"OmniWeb", versionSearch:"OmniWeb/", identity:"OmniWeb"
},{
string:navigator.vendor, subString:"Apple", identity:"Safari"
},{
prop:window.opera, identity:"Opera"
},{
string:navigator.vendor, subString:"iCab", identity:"iCab"
},{
string:navigator.vendor, subString:"KDE", identity:"Konqueror"
},{
string:navigator.userAgent, subString:"Firefox", identity:"Firefox"
},{
string:navigator.vendor, subString:"Camino", identity:"Camino"
},{
string:navigator.userAgent, subString:"Netscape", identity:"Netscape"
},{
string:navigator.userAgent, subString:"MSIE", identity:"Explorer", versionSearch:"MSIE"
},{
string:navigator.userAgent, subString:"Gecko", identity:"Mozilla", versionSearch:"rv"
},{
string:navigator.userAgent, subString:"Mozilla", identity:"Netscape", versionSearch:"Mozilla"
}
], dataOS:[
{
string:navigator.platform, subString:"Win", identity:"Windows"
},{
string:navigator.platform, subString:"Mac", identity:"Mac"
},{
string:navigator.platform, subString:"Linux", identity:"Linux"
}
]
};BrowserDetect.init();var Url={
redirect:function(qstrKey){
var r=getQstrVar(qstrKey);if(r)r=this.decode(r);else r='/';top.location.href=r;}, encode:function(s){
return escape(this._utf8_encode(s));}, decode:function(s){
return this._utf8_decode(unescape(s));}, _utf8_encode:function(s){
s=s.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<s.length;n++){
var c=s.charCodeAt(n);if(c<128)utftext+=String.fromCharCode(c);else if((c>127)&&(c<2048)){
utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}
else{
utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}
return utftext;}, _utf8_decode:function(utftext){
var s="";var i=0;var c=c1=c2=0;while(i<utftext.length){
c=utftext.charCodeAt(i);if(c<128){
s+=String.fromCharCode(c);i++;}
else if((c>191)&&(c<224)){
c2=utftext.charCodeAt(i+1);s+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}
else{
c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);s+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
return s;}}
var ajax=new Object();ajax.READY_STATE_UNINITIALIZED=0;ajax.READY_STATE_OPEN=1;ajax.READY_STATE_SENT=2;ajax.READY_STATE_RECEIVING=3;ajax.READY_STATE_LOADED=4;ajax.ieajax=new Object();ajax.ieajax.instances=0;ajax.ieajax.objects=[];ajax.ieajax.isInstance=function(obj){
return typeof obj.id=='number'&&ajax.ieajax.objects[obj.id]==obj;}
ajax.ieajax.XMLHttpRequest=function(){
if(!document.createElement||!document.getElementById)throw new Error('User-Agent does not support required methods');this.id=++ajax.ieajax.instances;ajax.ieajax.objects[this.id]=this;}
ajax.ieajax.XMLHttpRequest.prototype={
id:0, iframe:null, iframe_doc:null, responseText:'', responseXML:null, status:0, readyState:ajax.READY_STATE_UNINITIALIZED, onreadystatechange:function(){}, setRequestHeader:function(){}, abort:function(){
if(this.iframe&&this.iframe.parentNode)this.iframe.parentNode.removeChild(this.iframe);this.iframe=null;this.iframe_doc=null;this.readyState=ajax.READY_STATE_UNINITIALIZED;}, open:function(unused_method, uri){
this.responseText='';this.responseXML=null;this.status=0;this.readyState=ajax.READY_STATE_OPEN;var div=document.createElement('div');div.innerHTML='<iframe onload="ajax.ieajax.objects[' +
this.id + '].checkState(0)" id="ieajax_iframe_' + this.id + '" style="display:none;" src="about:blank"></iframe>';this.iframe=div.getElementsByTagName('iframe').item(0);this.iframe.requestURI=uri;}, send:function(unused_postdata){
this.readyState=ajax.READY_STATE_SENT;this.iframe.src=this.iframe.requestURI;document.body.appendChild(this.iframe);setTimeout('ajax.ieajax.objects[' + this.id + '].checkState(2)', 500);}, checkState:function(delay){
if(arguments.callee.complete)return;if(!this.iframe)return;if(document.frames)this.iframe_doc=document.frames['ieajax_iframe_' + this.id].document;else this.iframe_doc=this.iframe.contentDocument;if(delay==0||!this.iframe_doc.readyState)arguments.callee.complete=true;else{
this.readyState=ajax.READY_STATE_RECEIVING;arguments.callee.complete=this.iframe_doc.readyState=='complete';}
if(arguments.callee.complete){
this.readyState=ajax.READY_STATE_LOADED;var responseText=this.iframe_doc.body.innerText;if(responseText.match(/^\s*<\?xml/i))responseText=responseText.replace(/^-/gm, '');var responseXML=null;try{
var xmlDoc=new ActiveXObject('Microsoft.XMLDOM');xmlDoc.async='false';xmlDoc.loadXML(responseText);if(xmlDoc.parseError.errorCode==0)responseXML=xmlDoc;}
catch(e){
}
this.abort();arguments.callee.complete=false;this.responseText=responseText;this.responseXML=responseXML;this.readyState=ajax.READY_STATE_LOADED;this.status=200;this.onreadystatechange.call(this);}
else{
delay*=1.5;setTimeout('ajax.ieajax.objects[' + this.id + '].check_state(' + delay + ')', delay);}}
}
ajax.Request=function(){}
ajax.Request.prototype={
debugMode:false, autoKeyFormat:[ 'xmlhttp_arg', '' ], xmlhttp:null, onError:function(msg){}, onComplete:function(responseText, responseXML){}, debug:function(msg){
if(this.debugMode)alert(msg);}, enableDebug:function(enabled){
if(typeof enabled=='undefined')enabled=true;this.debugMode=enabled;}, createXMLHttpObject:function(){
this.debug('Function called:ajax.createXMLHttpObject()');var xmlhttp=null;if(typeof XMLHttpRequest!='undefined')xmlhttp=new XMLHttpRequest();else{
try{
xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');}
catch(e){
try{
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}
catch(e){
try{
xmlhttp=new ajax.ieajax.XMLHttpRequest();}
catch(e){
}}
}}
if(!xmlhttp){
this.debug('Unable to initialize XML-HTTP object');this.onError.call(this, 'Unable to initialize XML-HTTP object');}
return xmlhttp;}, setAutoKeyFormat:function(formatString){
if(typeof formatString!='string')return;if(formatString=='')this.autoKeyFormat=[ 'xmlhttp_arg', '' ];else{
formatString=formatString.replace(/%[dins]/, '%%');if(formatString.indexOf('%%')==-1)this.autoKeyFormat=[ formatString, '' ];else{
var sep=formatString.indexOf('%%');this.autoKeyFormat=[ formatString.substring(0, sep), formatString.substring(sep + 2)];}}
}, urlEncode:function(str){
return encodeURIComponent(str);}, sendRequest:function(method, uri){
try{
this.debug('Function called:sendRequest("' + method + '", "' + uri + '")');if(!this.xmlhttp)this.xmlhttp=this.createXMLHttpObject();if(!this.xmlhttp)return false;if(this.xmlhttp.readyState!=ajax.READY_STATE_UNINITIALIZED){
this.onError.call(this, 'Previous request still in progress');return false;}
if(typeof method=='string'&&method.toUpperCase()=='POST')method='POST';else method='GET';this.debug('Processing request:' + method + '->' + uri);var qstr='';var date=new Date();var time=date.getTime();delete date;uri+=uri.indexOf('?')==-1?'?':'&';uri+='__dnc_rnd=' + time;qstr='__rs=' + time;var auto_index=0;for(var i=2;i<arguments.length;++i){
arguments[i]=arguments[i].toString();var equal=arguments[i].indexOf('=');var key, val;if(equal==-1){
if(this.autoKeyFormat[0].indexOf('[]')>-1)key=this.autoKeyFormat[0];else key=this.autoKeyFormat[0] + auto_index++ + this.autoKeyFormat[1];val=arguments[i];}
else{
key=arguments[i].substring(0, equal);val=arguments[i].substring(equal + 1);}
key=this.urlEncode(key);val=this.urlEncode(val);qstr+='&' + key + '=' + val;}
var obj=this;this.xmlhttp.onreadystatechange=function(){
if(!obj.xmlhttp){
obj.debug('XML-HTTP object is no longer valid-state change ignored');return;}
if(obj.abort_requested){
if(obj.xmlhttp){
obj.xmlhttp.abort();delete obj.xmlhttp;obj.xmlhttp=null;}
obj.debug('Request aborted-XML-HTTP object has been destroyed');obj.abort_requested=null;return;}
obj.debug('Request state changed:readyState=' + obj.xmlhttp.readyState);if(obj.xmlhttp.readyState==ajax.READY_STATE_LOADED){
var responseText=obj.xmlhttp.responseText;var responseXML=obj.xmlhttp.responseXML;var status=obj.xmlhttp.status;delete obj.xmlhttp;obj.xmlhttp=null;obj.abort_requested=null;if(status==200||status==0)obj.onComplete.call(obj, responseText, responseXML);else obj.onError.call(obj, 'XML-HTTP request completed, but status=' + status);}}
if(method=='POST'&&!ajax.ieajax.isInstance(this.xmlhttp)&&qstr.length>0){
this.xmlhttp.open('POST', uri, true);this.xmlhttp.setRequestHeader('Method', 'POST ' + uri + ' HTTP/1.1');this.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');this.xmlhttp.setRequestHeader('Content-Length', qstr.length);this.xmlhttp.setRequestHeader('Connection', 'Close');this.debug('Sending the following request:\r\nmethod=POST\r\nuri=' + uri + '\r\npostdata=' + qstr);this.xmlhttp.send(qstr);}
else{
uri=uri + '&' + qstr;this.xmlhttp.open('GET', uri, true);this.xmlhttp.setRequestHeader('Content-Type', 'charset=UTF-8');this.xmlhttp.setRequestHeader('Connection', 'Close');this.debug('Sending the following request:\r\nmethod=GET\r\nuri=' + uri);this.xmlhttp.send(null);}
return true;}
catch(err){
this.onError.call(this, typeof err.description=='undefined'?(typeof err.message=='undefined'?err:err.message):err.description);return false;}}, abortRequest:function(){
if(this.xmlhttp&&this.xmlhttp.readyState!=ajax.READY_STATE_UNINITIALIZED)this.abort_requested=true;this.debug('Function called:abortRequest()-XML-HTTP object:' +
(this.xmlhttp?('VALID, readyState:' + this.xmlhttp.readyState):'INVALID'));}}
var ajaxml=new Object();ajaxml.RESULT_TAG='result';ajaxml.ERROR_TAG='error';ajaxml.LABEL_TAG='label';ajaxml.RETURNURL='return';ajaxml.SUCCESS='success';ajaxml.FAILURE='failure';ajaxml.Reply=function(){}
ajaxml.Reply.clearErrors=function(field){
setInnerById(field + '_error', '');setInnerById(field + '_errors', '');var label=getLabelFor(field);if(label)removeClass(label, ajaxml.ERROR_TAG);};ajaxml.Reply.prototype={
result:'', returnurl:'', error:'', errors:[], fields:[], labels:[], removeWhiteSpace:function(root){
var child=root.firstChild;while(child){
if(child.nodeType==3){
var next=child.nextSibling;root.removeChild(child);child=next;}
else child=child.nextSibling;}}, isScalar:function(el){
return !el.getAttribute('r');}, isArray:function(el){
return el.getAttribute('r')=='true';}, process:function(responseXML){
this.errors=new Array();this.fields=new Array();this.labels=new Array();var root=responseXML.documentElement;this.removeWhiteSpace(root);var el=root.firstChild;while(el){
if(el.tagName==ajaxml.RESULT_TAG){
if(el.firstChild)this.result=el.firstChild.nodeValue;}
else if(el.tagName==ajaxml.RETURNURL){
if(el.firstChild)this.returnurl=el.firstChild.nodeValue;}
else if(el.tagName==ajaxml.ERROR_TAG){
if(this.isScalar(el))this.error=!el.firstChild?'':el.firstChild.nodeValue;else{
this.removeWhiteSpace(el);var child=el.firstChild;while(child){
var field=child.tagName;if(this.isArray(child)){
this.removeWhiteSpace(child);if(typeof this.errors[field]=='undefined')this.errors[field]=new Array();var oneErr=child.firstChild;while(oneErr){
this.errors[field].append(oneErr.firstChild.nodeValue);oneErr=oneErr.nextSibling;}}
else this.errors[field]=child.firstChild.nodeValue;child=child.nextSibling;}}
}
else if(el.tagName==ajaxml.LABEL_TAG){
if(this.isArray(el)){
this.removeWhiteSpace(el);var child=el.firstChild;while(child){
var field=child.tagName;this.labels[field]=child.firstChild?child.firstChild.nodeValue:'';child=child.nextSibling
}}
}
else if(this.isScalar(el))this.fields[el.tagName]=!el.firstChild?'':el.firstChild.nodeValue;el=el.nextSibling;}
return this.didSucceed();}, displayArrayErrors:function(field){
var errors=this.getErrorsFor(field);if(errors){
var errstr='<ul>';for(var i=0;i<errors.length;++i)errstr+='<li>' + errors[i] + '</li>';errstr+='</ul>';var labelClass=this.getLabel(field);if(labelClass){
var label=getLabelFor(field);if(label)addClass(label, labelClass);}
setInnerById(field + '_errors', errstr);}}, getResult:function(){
return this.result;}, getReturnUrl:function(){
return this.returnurl;}, didSucceed:function(){
return this.result==ajaxml.SUCCESS;}, getStringError:function(){
return this.error;}, getArrayErrors:function(){
return this.errors;}, getErrorsFor:function(name){
return this.errors[name];}, getAllFields:function(){
return this.fields;}, getField:function(name){
return this.fields[name];}, getAllLabels:function(){
return this.labels;}, getLabel:function(name){
return this.labels[name];}}
String.prototype.ltrim=function(){
var s=this.replace(/^\s+|$/, '');while(s.charCodeAt(0)==160||s.charCodeAt(0)==32)s=s.substring(1, s.length);return s;}
String.prototype.rtrim=function(){
var s=this.replace(/^|\s+$/, '');var l=s.length;while(s.charCodeAt(l-1)==160||s.charCodeAt(l-1)==32)s=s.substring(0,--l);return s;}
String.prototype.trim=function(){
return this.rtrim().ltrim();}
String.prototype.ucfirst=function(){
return this.substr(0,1).toUpperCase()+ this.substr(1);}
Array.prototype.indexOf=function(obj){
for(var i=0;i<this.length;++i)if(this[i]==obj)return i;return-1;}
Array.prototype.hasKey=function(obj){
for(var k in this)if(k==obj)return true;return false;}
Array.prototype.contains=function(obj){
return this.indexOf(obj)>=0;}
Array.prototype.append=function(obj, nodup){
if(!(nodup&&this.contains(obj)))this[this.length]=obj;return this.length;}
Array.prototype.remove=function(obj){
var i=this.indexOf(obj);if(i>=0)this.splice(i, 1);}
var eventRouter=function(el, eventType){
if(el){
this.handlers=new Array();this.el=el;el.router=this;if(typeof el[eventType]=='function'){
this.el.oldfunc=el[eventType];el[eventType]=function(e){
this.oldfunc.call(this, e);eventRouter.callback(e);}}
else el[eventType]=eventRouter.callback;}}
eventRouter.prototype={
addHandler:function(handler){
this.handlers.append(handler, true);}, removeHandler:function(handler){
this.handlers.remove(handler);}, notify:function(e){
var handlers=this.handlers;for(var i=0;i<handlers.length;++i)handlers[i].call(this, e);}}
eventRouter.callback=function(event){
var e=event||window.event;this.router.notify(e);}
var msiepre7=BrowserDetect.browser=='Explorer'&&BrowserDetect.version<7;var modalpage=new Object();modalpage.overlay=null;modalpage.underlay=null;modalpage.body=null;modalpage.children=new Array();modalpage.init=function(){
if(!this.body)this.body=gebtn('body')[0];if(this.body&&!this.overlay){
var w=this.body.offsetWidth;var h=this.body.offsetHeight;var ul=document.createElement('iframe');ul.src='about:blank';ul.frameBorder='0';ul.scrolling='no';ul.width=w+'px';ul.height=h+'px';ul.style.zIndex='200000';ul.style.position='absolute';ul.style.top=ul.style.left='0';ul.style.display='none';setOpacity(ul, 0);this.underlay=ul;var ol=document.createElement('div');ol.style.display='none';ol.style.zIndex='300000';ol.style.backgroundColor='#000';ol.style.position='absolute';ol.style.top=ol.style.left='0';ol.style.width=w+'px';ol.style.height=h+'px';setOpacity(ol, 0);this.overlay=ol;this.body.insertBefore(ol, this.body.firstChild);this.body.insertBefore(ul, this.body.firstChild);var r=new eventRouter(window, 'onresize');r.addHandler(
function(){
var w=gebi('header').offsetWidth;var h=modalpage.body.offsetHeight;var ol=modalpage.overlay;var ul=modalpage.underlay;ol.style.width=w+'px';ol.style.height=h+'px';ul.style.width=w+'px';ul.style.height=h+'px';for(var i=0;i<modalpage.children.length;++i)modalpage.children[i].recenter();}
);}}
modalpage.fadeIn=function(next, end, interval){
if(!this.overlay)return;setOpacity(this.overlay, end);{
this.fading=false;this.showEmbeds(false);if(this.obj)this.obj.onopen();}}
modalpage.fadeOut=function(next, end, interval){
if(!this.overlay)return;setOpacity(this.overlay, end);{
this.overlay.style.display='none';this.underlay.style.display='none';this.fading=false;if(this.obj)this.obj.onclose();}}
modalpage.showEmbeds=function(show){
var e=gebtn('embed');for(var i=0;i<e.length;++i)e[i].style.visibility=show?'visible':'hidden';var e=gebtn('object');for(var i=0;i<e.length;++i)e[i].style.visibility=show?'visible':'hidden';}
modalpage.show=function(visible, obj){
if(!this.overlay)return;if(this.fading)return;this.fading=true;if(obj)this.obj=obj;if(visible){
this.underlay.style.display='block';this.overlay.style.display='block';this.fadeIn(1, 5, 10);}
else{
this.showEmbeds(true);this.fadeOut(4, 0, 10);}}
modalpage.addChild=function(obj){
this.children.append(obj, true);}
modalpage.removeChild=function(obj){
this.children.remove(obj);}
modalpage.Box=function(width, height, top){
modalpage.init();if(width)this.width=width;if(height)this.height=height;if(top)this.top=top;}
modalpage.Box.DEF_TOP=50;modalpage.Box.DEF_WIDTH=500;modalpage.Box.DEF_HEIGHT=300;modalpage.Box.EC_CANCEL=1;modalpage.Box.prototype={
init:null, cancel:null, wnd:null, body:null, top:modalpage.Box.DEF_TOP, width:modalpage.Box.DEF_WIDTH, height:modalpage.Box.DEF_HEIGHT, endcode:null, setInitFunc:function(init){
this.init=init;}, setCancelFunc:function(cancel){
this.cancel=cancel;}, open:function(){
modalpage.show(true, this);}, close:function(endcode){
this.endcode=endcode;this.setLoading(false);if(this.shadow)this.shadow.style.display='none';if(this.wnd)this.wnd.style.display='none';modalpage.show(false);}, recenter:function(){
if(!this.wnd)return;var mid=modalpage.body.offsetWidth/2;var half=Math.round(this.width/2);this.shadow.style.left=(mid-half+10)+'px';this.wnd.style.left=(mid-half)+'px';this.loading.style.left=parseInt((mid-half)+(this.width/2)-8)+'px';}, resize:function(w,h){
this.width=w;this.height=h;if(!this.wnd)return;this.wnd.style.width=this.width+'px';this.wnd.style.height=this.height+'px';this.shadow.style.width=this.width+'px';this.shadow.style.height=this.height+'px';this.recenter();}, setLoading:function(loading){
this.body.style.display=!loading?'block':'none';if(this.loading)this.loading.style.display=loading?'inline':'none';}, onopen:function(){
if(!this.wnd){
var w=document.createElement('div');w.style.zIndex='400000';w.style.fontSize='1.25em';w.style.border='2px solid #444';w.style.backgroundColor='#fff';w.style.top=this.top+'px';w.style.width=this.width+'px';w.style.height=this.height+'px';if(msiepre7)w.style.position='absolute';else w.style.position='fixed';this.wnd=w;var s=document.createElement('div');s.style.zIndex='310000';s.style.backgroundColor='#444';s.style.top=(this.top+15)+'px';s.style.width=this.width+'px';s.style.height=this.height+'px';if(msiepre7)s.style.position='absolute';else s.style.position='fixed';setOpacity(s, 6);this.shadow=s;var a=document.createElement('a');a.href='#';a.innerHTML='X';a.setAttribute('style','float:right');a.style.styleFloat='right';a.style.fontSize='0.6em';a.style.fontWeight='bold';a.style.fontFamily='Arial,Verdana,Tahoma,sans-serif';a.style.margin='2px 2px 0 0';a.style.padding='0 2px';a.style.border='1px solid #600';a.style.color='#fff';a.style.backgroundColor='#E46446';a.box=this;a.onclick=function(){this.box.close(modalpage.Box.EC_CANCEL);return false;}
a.onmouseover=function(){this.style.cursor='default';this.style.backgroundColor='#FF8663';}
a.onmousedown=function(){this.style.backgroundColor='#900';}
a.onmouseout=function(){this.style.backgroundColor='#E46446';}
this.wnd.appendChild(a);var l=document.createElement('img');l.alt=l.title='Loading...';l.src='/teevirus/i/loading.gif';l.style.zIndex='410000';l.style.width='16px';l.style.height='16px';l.style.top=parseInt(parseInt(this.wnd.style.top)+(this.height/2)-8)+'px';if(msiepre7)l.style.position='absolute';else l.style.position='fixed';this.loading=l;this.recenter();var b=modalpage.body,fc=b.firstChild;b.insertBefore(this.loading, fc);b.insertBefore(this.wnd, fc);b.insertBefore(this.shadow, fc);this.body=document.createElement('div');this.body.style.fontSize='0.75em';this.body.style.fontFamily='Lucida Sans,Helvetica,Geneva,Sans-serif';this.body.style.margin='3px';this.wnd.appendChild(this.body);modalpage.addChild(this);if(this.init)this.init.call(this);}
else{
if(this.shadow)this.shadow.style.display='block';if(this.wnd)this.wnd.style.display='block';}}, onclose:function(){
switch(this.endcode){
case modalpage.Box.EC_CANCEL:if(this.cancel)this.cancel.call(this);break;}}
}
function voteCallback(text, xml){
showInfoMsg();this.link.busy=document.busy_voting=false;var post=this.link.post;var xr=new ajaxml.Reply();xr.process(xml);if(xr.didSucceed()){
var val=xr.getField('value');var dval=xr.getField('delval');if(dval){
var i=gebi('votelink-'+post+'-'+dval);if(i)i.className='';}
if(val!=dval){
var i=gebi('votelink-'+post+'-'+val);if(i)i.className='cast';}
var r=xr.getField('ratio');var v=xr.getField('votes');gebi('voteratio-'+post).innerHTML=r+'%';gebi('votecount-'+post).innerHTML=v+' '+(v==1?'vote':'votes');}
else alert(xr.getStringError());}
function prepAllVoteBtns(div){
var post=div.id.split('-')[1];var links=gebtn('a', div);for(var j=0;j<links.length;++j)prepVoteBtn(links[j], post);}
function prepVoteBtn(l,p){
l.post=p;l.onclick=function(){
if(l.className=='mine'){
alert('You cannot vote for your own designs');return false;}
if(this.busy||document.busy_voting){
alert('Still busy casting your vote. Please wait...');return false;}
var vars=getHrefArr(this.href, 'vote');var token=vars[0];var target=vars[1];vars=getQstrMap(this.href);var ret_url=vars['return'];if(token==''||target=='')return true;this.busy=document.busy_voting=true;showInfoMsg('Please wait...');var request=new ajax.Request();request.link=this;request.onComplete=voteCallback;request.sendRequest('GET', '/vote.php', 'token=' + token, 'target=' + target, 'return=' + ret_url
);return false;}}
function thumbvoteCallback(responseText, responseXML){
showInfoMsg();var comment=this.link.comment;var a=gebi('thumbup-' + comment);if(a)a.busy=false;a=gebi('thumbdown-' + comment);if(a)a.busy=false;a=gebi('thumbspam-' + comment);if(a)a.busy=false;var xmlreply=new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
if(xmlreply.getField('deleted'))gebi('comment-' + comment).style.display='none';else{
if(xmlreply.getField('haspoint')!=0)gebi('commentstar-' + comment).innerHTML='&#9733;';var u=xmlreply.getField('thumbsup'),d=xmlreply.getField('thumbsdown');var s=gebi('thumbup-'+comment).parentNode;s.innerHTML='&#9650;';s.title=xmlreply.getField('thumbsup_title');if(s=gebi('thumbdown-'+comment)){
s=s.parentNode;s.innerHTML='&#9660;';s.title=xmlreply.getField('thumbsdown_title');}
s=gebi('commentvotes-'+comment);s.innerHTML=u-d;s.title=u+' up:'+d+' down';s=gebi('thumbspamouter-' + comment);s.innerHTML='flag spam(' + xmlreply.getField('spamvotes')+ ')';s.title=xmlreply.getField('spam_title');}}
else alert(xmlreply.getStringError());}
function prepThumbVoteLink(link){
link.onclick=function(){
if(/^thumbdown/.test(this.id)){
if(!confirm('Are you sure you really want to down vote this comment?'))return false;}
else if(/^thumbspam/.test(this.id)){
if(!confirm('Are you sure you really want to flag this comment as spam?'))return false;}
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
var vars=getHrefArr(this.href, 'thumbvote');var comment=vars[0];var vote=vars[1];vars=getQstrMap(this.href);var ret_url=vars['return'];if(comment==''||vote=='')return true;showInfoMsg('Please wait...');var a=gebi('thumbup-' + comment);if(a)a.busy=true;a=gebi('thumbdown-' + comment);if(a)a.busy=true;a=gebi('thumbspam-' + comment);if(a)a.busy=true;this.comment=comment;var request=new ajax.Request();request.link=this;request.onComplete=thumbvoteCallback;request.sendRequest('GET', '/rs/thumbvote.php', 'comment=' + comment, 'vote=' + vote, 'return=' + ret_url
);return false;}}
function favoriteCallback(responseText, responseXML){
showInfoMsg();this.link.busy=false;var xmlreply=new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
this.link.title=xmlreply.getField('linktitle');this.link.innerHTML=xmlreply.getField('linktext');}
else alert(xmlreply.getStringError());}
function prepFavLink(link){
link.onclick=function(){
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
var vars=getHrefArr(this.href, 'favorite');var loctype=vars[0];var url_title=vars[1];vars=getQstrMap(this.href);var ret_url=vars['return'];if(url_title=='')return true;this.busy=true;showInfoMsg('Please wait...');var request=new ajax.Request();request.link=this;request.onComplete=favoriteCallback;request.sendRequest('GET', '/rs/favorite.php', 'type=' + loctype, 'title=' + url_title, 'return=' + ret_url
);return false;}}
function reWsCB(text, xml){
showInfoMsg();this.link.busy=false;var xr=new ajaxml.Reply();xr.process(xml);if(xr.didSucceed()){
var p=this.link.parentNode;p.className+=' success';p.innerHTML=xr.getField('msg');}
else alert(xr.getStringError());}
function prepReWsLink(link){
link.onclick=function(){
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
var vars=getHrefArr(this.href, 'reworkshop');var url_title=vars[0];vars=getQstrMap(this.href);var ret_url=vars['return'];if(url_title=='')return true;this.busy=true;showInfoMsg('Please wait...');var rq=new ajax.Request();rq.link=this;rq.onComplete=reWsCB;rq.sendRequest('GET', '/rs/reworkshop.php', 'title='+url_title, 'return='+ret_url
);return false;}}
function prepWsDiscard(link){
link.onclick=function(){
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
if(!confirm('Are you sure you really want to discard this post?'))return false;var vars=getHrefArr(this.href, 'wsdiscard');var url_title=vars[0];vars=getQstrMap(this.href);var ret_url=vars['return'];if(url_title=='')return true;this.busy=true;showInfoMsg('Please wait...');var rq=new ajax.Request();rq.link=this;rq.onComplete=function(text,xml){
showInfoMsg();this.link.busy=false;var xr=new ajaxml.Reply();xr.process(xml);if(xr.didSucceed()){
var p=this.link.parentNode;p.className+=' success';p.innerHTML=xr.getField('msg');}
else alert(xr.getStringError());}
rq.sendRequest('GET', '/rs/wsdiscard.php', 'title='+url_title, 'return='+ret_url
);return false;}}
function emailSuccess(xmlreply){
var m=xmlreply.getField('message');if(m.length>0){
this.box.resize(550, 100);this.box.body.innerHTML=m;}}
function emailformCallback(responseText, responseXML){
var box=this.box;var link=box.link;box.setLoading(false);var xr=new ajaxml.Reply();xr.process(responseXML);if(xr.didSucceed()){
var d=document.createElement('div');d.style.margin='10px';d.innerHTML=xr.getField('emailbody');box.body.appendChild(d);initTextFocus(d);selectDefaultInput(d);gebi('email_newhtimg').href='#';var form=gebtn('form',d)[0];form.onsuccess=emailSuccess;form.box=box;prepareLabelClickFocus();prepareFormValidation();}
else alert(xr.getStringError());}
function modalShowEmail(){
var rq=new ajax.Request();rq.box=this;rq.onComplete=emailformCallback;rq.sendRequest('GET', '/rs/modal/email.php', 'title='+this.link.thetitle
);}
function prepEmailLink(l){
l.onclick=function(){
var vars=getHrefArr(this.href, 'email');this.thetitle=vars[0];var modalbox=new modalpage.Box(640,450);modalbox.setInitFunc(modalShowEmail);modalbox.setCancelFunc(function(){delete this.box;});modalbox.link=this;modalbox.open();return false;}}
function contactSuccess(xmlreply){
var m=xmlreply.getField('message');if(m.length>0){
this.box.resize(550, 100);this.box.body.innerHTML=m;}}
function contactformCallback(responseText, responseXML){
var box=this.box;var link=box.link;box.setLoading(false);var xr=new ajaxml.Reply();xr.process(responseXML);if(xr.didSucceed()){
var d=document.createElement('div');d.style.margin='10px';d.innerHTML=xr.getField('contactbody');box.body.appendChild(d);initTextFocus(d);selectDefaultInput(d);gebi('contact_newhtimg').href='#';var form=gebtn('form',d)[0];form.onsuccess=contactSuccess;form.box=box;prepareLabelClickFocus();prepareFormValidation();}
else alert(xr.getStringError());}
function modalShowContact(){
var vars=getQstrMap(this.link.href);var oid=vars['oid'];var rq=new ajax.Request();rq.box=this;rq.onComplete=contactformCallback;rq.sendRequest('GET', '/rs/modal/contact.php', 'oid='+oid
);}
function prepContactLink(l){
if(/\/contact(\.php)?/.test(l.href)){
l.onclick=function(){
var modalbox=new modalpage.Box(700,475);modalbox.setInitFunc(modalShowContact);modalbox.setCancelFunc(function(){delete this.box;});modalbox.link=this;modalbox.open();return false;}}
}
initVoteStars = function(){
vsxOffset = -120;vsyOffset = 10;$(".ws-votebox .buttons div a").hover(
function(e){
this.valid=false;if($(this).hasClass('mine'))return;this.valid=true;this.t=this.title;this.title='';var n=this.parentNode.className.split('-')[1];$("body").append("<p id='votestars'><img src='http://static1.videosift.com/teevirus.com/teevirus/i/wsvote/"+n+"of5.gif' alt=''/></p>");$("#votestars").css("background-color","#fff").css("position","absolute").css("border","1px solid #000").css("top",(e.pageY - vsyOffset)+ "px").css("left",(e.pageX + vsxOffset)+ "px").fadeIn("fast");}, function(){
if(!this.valid)return;this.title=this.t;$("#votestars").remove();}
);$(".ws-votebox .buttons div a").mousemove(function(e){
if(!this.valid)return;$("#votestars").css("top",(e.pageY - vsyOffset)+ "px").css("left",(e.pageX + vsxOffset)+ "px");});};addLoadEvent(function(){
initVoteStars();});function vpembedCB(responseText, responseXML){
var div=this.div;div.busy=false;showInfoMsg();var xmlreply=new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
div.embedcode=xmlreply.getField('vidembed');var l=document.createElement('a');l.href='#';l.div=div;l.innerHTML='minimize video&#9660;';l.className='tiny';l.onclick=function(){
this.div.spacer.style.display='block';this.div.embed.style.display='none';this.div.expanded=false;gebtn('div',this.div.embed).item(0).innerHTML='';this.div.vidthumb.style.display='block';return false;}
var ed=gebi('embedcode-' + div.vidthumb.vid);ed.innerHTML='<div>'+div.embedcode+'</div>';ed.insertBefore(l, ed.firstChild);div.spacer=gebi('lbspacer-' + div.vidthumb.vid);div.spacer.style.display='none';div.embed=ed;div.vidthumb.style.display='none';div.embed.style.display='block';div.expanded=true;}
else div.vidthumb.onclick=function(){return true;}}
document.video_divs=new Array();function prepVidPreview(div){
var c=div.firstChild;div.expanded=false;div.vidthumb=c;c.div=div;document.video_divs.append(div);var parts=div.id.split('-');c.vid=parts[1];var d=document.createElement('span');d.className='tiny';d.innerHTML='<br/>show video&#9650;';insertAfter(d, c.lastChild);c.onclick=function(){
if(this.div.embed){
this.div.spacer.style.display='none';this.style.display='none';this.div.embed.style.display='block';this.div.expanded=true;gebtn('div',this.div.embed).item(0).innerHTML=this.div.embedcode;return false;}
if(this.div.busy){
alert('Still busy processing your request. Please wait...');return false;}
this.div.busy=true;showInfoMsg('Please wait...');var request=new ajax.Request();request.div=this.div;request.onComplete=vpembedCB;request.sendRequest('GET', '/rs/vidpreview.php', 'vid=' + this.vid
);return false;}}
addLoadEvent(initTextFocus);addLoadEvent(selectDefaultInput);addLoadEvent(prepareLabelClickFocus);addLoadEvent(prepareFormValidation);
