jQuery.cookie=function(name, value, options){
if(typeof value!='undefined'){
options=options||{};if(value===null){
value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){
var date;if(typeof options.expires=='number'){
date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{
date=options.expires;}
expires=';expires=' + date.toUTCString();}
var path=options.path?';path=' +(options.path):'';var domain=options.domain?';domain=' +(options.domain):'';var secure=options.secure?';secure':'';document.cookie=[name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');}else{
var cookieValue=null;if(document.cookie&&document.cookie!=''){
var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){
var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0, name.length + 1)==(name + '=')){
cookieValue=decodeURIComponent(cookie.substring(name.length + 1));break;}}
}
return cookieValue;}};var entered = false;var usermenuhide = false;var pointerColor;function findPos(obj){
var curtop = 0;var curleft = 0;if(obj.offsetParent){
while(obj.offsetParent){
curtop+=obj.offsetTop
curleft+=obj.offsetLeft
obj = obj.offsetParent;}}
return{left:curleft,top:curtop}}
function scrollPos(){
var scrollLeft = 0;var scrollTop = 0;if(typeof window.pageYOffset!='undefined'){
scrollTop = window.pageYOffset;scrollLeft = window.pageXOffset;}
else if(typeof document.compatMode!='undefined'&&
document.compatMode!='BackCompat'){
scrollTop = document.documentElement.scrollTop;scrollLeft = document.documentElement.scrollLeft;}
else if(typeof document.body!='undefined'){
scrollTop = document.body.scrollTop;scrollLeft = document.body.scrollLeft;}
return{left:scrollLeft,top:scrollTop}}
function changeStyle(e){
if($("#styleicon").attr("src").search("sun")!=-1){
newsrc = 'http://static1.videosift.com/cdm/moon.png';newcss = 'dark';}else{
newsrc = 'http://static1.videosift.com/cdm/sun.png';newcss = 'light';}
$(".search", $("#allcome")).css({marginRight:'116px'});posSun = findPos(document.getElementById("styleicon"));posAll = findPos(document.getElementById("allcome"));offLeft = posSun.left - posAll.left;$("#styleicon").css({position : 'absolute', marginLeft : offLeft});$("#styleicon").animate({marginTop: "40px"},{duration:600, easing:"swing", complete:function(e){
$(this).attr({src:newsrc})}}).animate({opacity: "1"}, 500).animate({marginTop: "0px"},{duration:600, easing:"swing", complete:function(e){
anchor = new RegExp(/[(#)][A-Za-z0-9-]{2,30}/);loc = window.location.toString().replace(anchor, "");if(loc.search("style=dark")!=-1){
loc = loc.replace('style=dark','style=' + newcss);window.location = loc;}else if(loc.search("style=light")!=-1){
loc = loc.replace('style=light','style=' + newcss);window.location = loc;}else if(loc.search("=")!=-1){
window.location = loc + '&style=' + newcss;}else window.location = loc + '?style=' + newcss;}});}
function fixLongTitles(){
$(".gallery_title a", $("#content_left")).each(
function(){
if($(this).attr("offsetHeight")> 85||$(this).attr("offsetWidth")> 130){
if(jQuery.browser.safari)$(this).css({"letter-spacing":"-1px"});else $(this).css({"letter-spacing":"-0.05em"});}}
);}
function showUserMenu(e){
usermenuhide = false;if($("#usermenu").css("display")!='block'){
position = findPos(e.target);posBox = findPos(document.getElementById("allcome"));mind =(window.innerWidth - 146);matter =(position.left - scrollPos().left + 5);if(mind < matter)leftpos = mind;else leftpos = matter;$("#usermenu").slideDown("normal");$("#usermenu").css({'top' :((position.top - scrollPos().top)+ 30)+ 'px', 'left' : leftpos + 'px'});$(window).scroll(function(){
$("#usermenu").css({'top' :(position.top - scrollPos().top + 30)+ 'px'});});}}
function hideUserMenu(e){
if(!($(e.relatedTarget).is('#usermenu a, #usermenu, #userlink'))&&(e.relatedTarget!=null)){
usermenuhide = true;window.setTimeout("hideUserMenuNow()", 800);}}
function hideUserMenuNow(){
if(usermenuhide){
$("#usermenu > div").fadeOut("normal");$("#usermenu").slideUp("normal");}}
function showQueuedVids(e){
if($("#queuebox").css("display")!='block'){
$("#usermenu > div").fadeOut("normal");$("#queuebox div").html("<br>Retrieving data...<br><br><br>");$("#queuebox").fadeIn("normal");$.getJSON("http://videosift.com/api.php?apikey=491f50292a3e79e0b651c132f257dc41&action=currentuserqueuedvids&callback=?", function(data){
var isEmpty = true;$("#queuebox div").html("");$.each(data, function(i){isEmpty = false;});if(isEmpty)$("#queuebox div").html("<br>You currently have no videos in your queue.<br><br><br>");else{
$("#queuebox div").append("<table><tr><th>votes</th><th>title</th><th>comments</th></tr></table>");$.each(data, function(i,item){
$("<tr>").html("<td style='padding: 6px 0'>" + item.votes + "</td><td><a title='posted "+item.age+"' href='"+item.link+"'>" + item.title + 
"</a></td><td style='padding: 6px 0'>" + item.comments + "</td>").appendTo("#queuebox #cont table");});$("#queuebox #cont").append('<div class="fright small padwide"><a href="'+$("#userlink").attr("href")+'/queued">show listing</a></div>');}});}
return false;}
function hideQueuedVids(e){
$("#queuebox").fadeOut("normal");return false;}
function showRecentVids(e){
if($("#recentbox").css("display")!='block'){
$("#usermenu > div").fadeOut("normal");$("#recentbox div").html("<br>Retrieving data...<br><br><br>");$("#recentbox").fadeIn("normal");$.getJSON("http://videosift.com/api.php?apikey=491f50292a3e79e0b651c132f257dc41&action=currentuserrecentvids&callback=?", function(data){
var isEmpty = true;$("#recentbox div").html("");$.each(data, function(i){isEmpty = false;});if(isEmpty)$("#recentbox div").html("<br>You haven't sifted any videos recently.<br><br><br>");else{
$("<table>").html("<tr><th>votes</th><th>title</th><th>comments</th></tr>").appendTo("#recentbox #cont");$.each(data, function(i,item){
$("<tr>").html("<td style='padding: 6px 0'>" + item.votes + "</td><td><a title='posted "+item.age+"' href='"+item.link+"'>" + item.title + 
"</a></td><td style='padding: 6px 0'>" + item.comments + "</td>").appendTo("#recentbox #cont table");});}});}
return false;}
function hideRecentVids(e){
$("#recentbox").fadeOut("normal");return false;}
function initGuestMenu(e){
$("#guestlink").click(function(e){
if($("#guestbox").css('display')!='block'){
$("#guestbox").fadeIn("def");}else{
$("#guestbox").fadeOut("def");}});}
function showFlags(e){
if($(e.target).parents(".sift, .gallery_sift, .gallery_promoted").data("prev")!="true"){
$(e.target).parent().parent().siblings(".video_flags_g").fadeIn("def");$(e.target).parents().siblings(".galleryblocked, .video_flags").fadeIn("def");$(e.target).parent().siblings(".badge, .gallerybadge").fadeIn("def");}}
function hideFlags(e){
$(e.target).parent().parent().siblings(".video_flags_g").fadeOut("def");$(e.target).parents().siblings(".galleryblocked, .video_flags").fadeOut("def");$(e.target).parent().siblings(".badge, .gallerybadge").fadeOut("def");}
function showGalleryPopup(e){
coords = findPos(e.target);hideFlags(e);idnum = e.target.parentNode.id.replace("vidthumb-", "");$("#gallery_popup").html($("#gallery_hidden-" + idnum).html());$("#gallery_popup").css({'left' :(coords.left - scrollPos().left + 131)+ 'px', 'top' :(coords.top - scrollPos().top - 1)+ 'px'});$("#gallery_popup").stop(1, 1);$("#gallery_popup").fadeIn("normal");$(window).scroll(function(){$("#gallery_popup").css({'left' :(coords.left - scrollPos().left + 131)+ 'px', 'top' :(coords.top - scrollPos().top)+ 'px'});});}
function hideGalleryPopup(e){
showFlags(e);if(!($(e.relatedTarget).is("#gallery_popup, #gallery_popup *"))){
$("#gallery_popup").fadeOut("normal");}}
function insertMenuPointer(menu){
if($(menu).find(".activesublink").length > 0){
if(jQuery.browser.safari||jQuery.browser.opera)mtop = "-4px";else if(jQuery.browser.msie){
if(jQuery.browser.version=='7.0')mtop = "22px";else mtop = "-3px";}
else mtop = "-5px";if((jQuery.browser.msie)&&(jQuery.browser.version=='7.0'))m_left = '-' +(Math.round($(menu).find(".activesublink").attr("offsetWidth")/ 2 + 8))+ 'px';else m_left = Math.round($(menu).find(".activesublink").attr("offsetWidth")/ 2 - 4)+ 'px';pointer = document.createElement("div");$("#pointer").remove();if(pointerColor=='')pointerColor = $("#footer").prev().css("background-color");$(pointer).appendTo($(menu).find(".activesublink").get(0)).html("&#9650;").css({"position":"absolute","color":pointerColor,"margin-top":mtop, "margin-left":m_left}).attr({"id":"pointer"});}}
function initMenu(){
insertMenuPointer($(".activesub", $("#submenu")).get(0));$("#activetab").addClass("active");$("#menu li a").each(function(){
$(this).mouseover(function(e){
if($("#sub_" + this.name).css("display")!='block'){
coords=findPos(e.target);$(".active").removeClass("active");$("#submenu ul").css({'display':'none'});$("#sub_" + this.name).css({'top': '-35px', 'display':'block'});$("#pointer", $("#submenu")).remove();$("#sub_" + this.name).animate({top: "-1px"}, 250, "linear", function(){
insertMenuPointer(this);});}}
);$(this).mouseout(function(e){
if($(e.relatedTarget).is("#submenu *, #submenu")){
$(e.target).addClass("active");}else if(!$(e.relatedTarget).is("#menu li a")){
resetMenu(true);}}
);}
);$("#submenu").mouseleave(function(e){
if($(e.relatedTarget).is("#menu *, #menu"))entered = true;else{
entered = false;window.setTimeout("resetMenu(false)", 1200);}}
);$("#submenu").mouseenter(function(e){
entered = true;}
);}
function initEmbedPop(){
$("#embedbox button").click(function(e){
$(this).attr({disabled:true});$("#embedbox div").html("");embedcode = $(this).siblings("textarea").val();if(embedcode!=''){
$.getJSON("http://videosift.com/api.php?apikey=491f50292a3e79e0b651c132f257dc41&action=findembedlink&callback=?",{embed: embedcode}, function(json){
$("#embedbox button").attr({disabled:false});if(json.url!=''){
if(json.error!='')errortext = json.error;else errortext = 'Dupe! Video has already been posted as:'
$("<div>").css({color: '#ff0000', fontWeight:'bold', margin:'4px 3px'}).html(errortext).appendTo("#embedbox > div");$(json.url).appendTo("#embedbox > div");}else{
embedcode=json.encodedembed;$("<div>").css({color: '#008800', fontWeight:'bold', margin:'4px 3px'}).html('This embed has not been posted yet!').appendTo("#embedbox > div");$("<a>").attr({href:'http://videosift.com/vidpost?vidtitle=&summary=&postcontent=' + embedcode}).html('Click here to submit it now').appendTo("#embedbox > div");}});}else{
alert("Please enter the embed code into the input box");$(this).attr({disabled:false});}});$("#embedbox textarea").click(function(e){
if($(this).val()=='Embed code')$(this).val("");});}
function showEmbedBox(){
if($("#embedbox").css("display")!='block'){
$("#usermenu > div").fadeOut("def");$("#embedbox").fadeIn("def");$("#embedbox textarea").focus();$("#embedbox textarea").select();$("#embedbox div").html("");}else $("#embedbox").fadeOut("def");return false;}
function resetMenu(bypass){
if(!entered||bypass){
$(".active").removeClass("active");$("#activetab").addClass("active");if($(".activesub").css("display")!='block'){
$("#submenu ul").css({'display':'none'});$(".activesub").css({'top': '-35px', 'display':'block'});$(".activesub").animate({top: "-1px"}, 250, "linear", function(){
insertMenuPointer(this);});}}
}
function setRes(e){
wrapper = document.getElementById("allcome");if(e.checked)wrapper.style.maxWidth = "1150px";else wrapper.style.maxWidth = "none";}
function prepPoll(divnum){
if((!$("#poll-" + divnum).hasClass("voteable"))||($("#pollshow-" + divnum).css("display")=='none')){
arrColors = new Array("http://i42.tinypic.com/wargj9.jpg","http://i44.tinypic.com/rksxav.jpg", "http://i42.tinypic.com/11i0d5k.jpg","http://i39.tinypic.com/e8pock.jpg", "http://i39.tinypic.com/xlikhf.jpg");total = parseInt($("#totalvotes-" + divnum).attr("name"));$("#polltbl-" + divnum).find(".pollbar, br").remove();$("#polltbl-" + divnum).find("label").each(function(i){
votes = parseInt($(this).attr("votes"));if(votes!=0){
percent = Math.round(votes / total * 100);}
bar = document.createElement("img");$(bar).addClass("pollbar");bar.src = arrColors[i];if(votes!=0)$(bar).css({width:'0%', height: '16px'});else $(bar).css({width:'3px', height: '16px'});this.parentNode.appendChild(document.createElement("br"));this.parentNode.appendChild(bar);if(votes!=0)$(bar).animate({'opacity':'1'}, 1000).animate({width: percent + "%"}, percent * 40, "swing");});}}
function initFixedWidthToggle(){
$("#chk_width").click(function(){
if($("#chk_width").attr("checked"))$("#allcome").css({maxWidth: '1150px'});else $("#allcome").css({maxWidth: ''});});}
function showAlertMsg(){
var flag = $(".alert").attr("name");if($.cookie("alert__" + flag)!='hide'){
window.setTimeout(function(){$(".alert").slideDown("def");pointerColor = $(".alert").css('background-color');$("#pointer").css({'color':pointerColor});}, 1000);$(".alert #alert_close").click(function(){
pointerColor = $("#footer").prev().css('background-color');$(this).parent().parent().slideUp("def", function(){$("#pointer").css({'color':pointerColor});});flag = $(this).parent().parent().attr("name");$.cookie("alert__" + flag, 'hide',{expires: 1, domain: '.videosift.com', path: '/'});});}}
function recalcEmbed2(embed, div){
if(embed.search(/width=\"([0-9]{2,4})\"/)!=-1){
em_w=embed.match(/width=\"([0-9]{2,4})\"/)[1];em_h=embed.match(/height=\"([0-9]{2,4})\"/)[1];ar=em_h/em_w;new_w=$("#content_left").attr("offsetWidth")-468;new_h=Math.round(new_w*ar);if((window.innerHeight!=0)&&(new_h>window.innerHeight)){
new_h=window.innerHeight-75;new_w=Math.round(new_h/ar);}
$(div).find("object, embed, div").attr({"height": new_h, "width" : new_w});$(div).find("object, embed").attr({"scale": "scale"});if(jQuery.browser.msie){
div.innerHTML=embed.replace(/height=\"[0-9]{2,4}\"/g,'height="'+new_h+'"');div.innerHTML=div.innerHTML.replace(/width=\"[0-9]{2,4}\"/g,'width="'+new_w+'"');}}
}
function resizeEmbed(){
if(!((jQuery.browser.msie)&&(jQuery.browser.version=='7.0'))){
$(".post-embed").each(function(){
recalcEmbed2(this.innerHTML, this);});}}
function resizeGallery(){
if(window.innerWidth < 1129&&$(".gallery_sift").length > 0){
$(".gallery", $("#content_left")).css({'width':'50px'});$(".post-sidebar", $("#content_left")).css({'margin':'0 6px 0 0', 'text-align':'right'});$(".gallery_sift", $("#content_left")).css({'margin':'10px 10px 45px 6px'});$(".content").filter(".main").css({'padding':'1px'});$(".galleryblocked", $("#content_left")).css({'margin-left':'57px'});}}
function initPqueued(){
$("#refreshAssorted").click(function(){
userid = $(this).attr("name");$(this).toggle();$("#rpq").html('<img src="http://static1.videosift.com/cdm/i/loading.gif" alt="loading" title="loading" style="margin-top:100px" />');$.getJSON("http://videosift.com/api.php?apikey=491f50292a3e79e0b651c132f257dc41&userid="+userid+"&action=currentuserrandpqueued&callback=?", function(json){
$("#rpq").html(json.container);$("#refreshAssorted").toggle();$("#rpq .gal_thumb").each(function(){
$(this).mouseenter(showGalleryPopup);$(this).mouseleave(hideGalleryPopup);});});});}
function commentIndent(){
$("#comments > div span").find("em").each(function(){
$(this).wrap("<div class='quoteComment box' style='border-color: rgb(51, 51, 51);margin: 4px 0px 0px 6px;padding: 10px;background-color: rgb(88, 98, 88);'></div>");});}
$(document).ready(function(){
fixLongTitles();pointerColor = $("#footer").prev().css("background-color");$("#styleicon").click(changeStyle);$("#gallery_popup").mouseleave(hideGalleryPopup);$("#userlink").mouseenter(showUserMenu);$("#embedlink").click(showEmbedBox);$("#userlink").mouseleave(hideUserMenu);$("#usermenu").mouseleave(hideUserMenu);$("#usermenu").mouseenter(function(e){
usermenuhide = false;});$("#queuelink").click(showQueuedVids);$("#queuebox").mouseleave(hideQueuedVids);$("#recentlink").click(showRecentVids);$("#recentbox").mouseleave(hideRecentVids);initMenu();showAlertMsg();initEmbedPop();initGuestMenu();initFixedWidthToggle();$(".gal_thumb").each(function(){
$(this).mouseenter(showGalleryPopup);$(this).mouseleave(hideGalleryPopup);}
);$(".thumbn").each(function(){
$(this).mouseenter(hideFlags);$(this).mouseleave(showFlags);}
);resizeGallery();});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];}}
function addLoadEvent(func){
if(typeof func!='function')return;if(window.calledloadevents)func();else{
var oldloadevents=window.loadevents;if(typeof window.loadevents=='function')window.loadevents=function(){oldloadevents();func();}
else window.loadevents=function(){window.calledloadevents=true;func();}}
}
function initEl(id,func){
var e=gebi(id);if(e&&typeof func=='function')func(e);}
function insertAfter(newEl,targEl){
var parent=targEl.parentNode;if(parent.lastChild==targEl)parent.appendChild(newEl);else parent.insertBefore(newEl,targEl.nextSibling);}
function getForAttrib(label){
var f=label.getAttribute('for');return f?f:label.htmlFor;}
function prepareLabelClickFocus(){
if(!document.getElementsByTagName)return;var l=gebtn('label');for(var i=0;i<l.length;++i){
if(!getForAttrib(l[i]))continue;l[i].onclick=function(){
var id=getForAttrib(this);if(!gebi(id))return false;var el=document.getElementById(id);el.focus();if(el.select)el.select();return true;}}
}
function parseLabelName(label){
var a=label.indexOf('*');var c=label.lastIndexOf(':');return label.substring(a + 1, c);}
function selectDefaultInput(root){
var is=gebtn('input', root);for(var i=0;i<is.length;++i){
if(is[i].className.indexOf('default')!=-1){
is[i].focus();is[i].select();break;}}
}
function initTextFocus(root){
var is=gebtn('input', root);for(var i=0;i<is.length;++i){
if(/^(text|password)$/.test(is[i].type)){
is[i].onfocus=function(){this.style.borderStyle='dotted';}
is[i].onblur=function(){this.style.borderStyle='solid';}}
}
var is=gebtn('textarea', root);for(var i=0;i<is.length;++i){
is[i].onfocus=function(){this.style.borderStyle='dotted';}
is[i].onblur=function(){this.style.borderStyle='solid';}}
}
function findLabelForInput(form, el){
var l=gebtn('label', form);for(var j=0;j<l.length;++j){
if(getForAttrib(l[j])==el.id)return parseLabelName(l[j].lastChild.nodeValue);}
return '';}
function validateForm(form){
if(form.novalidate)return true;for(var i=0;i<form.elements.length;++i){
var el=form.elements[i];if(el.className.indexOf('required')!=-1){
if(!isFilled(el)){
var t=findLabelForInput(form, el);alert('Please fill in the ' + t + ' field.');el.focus();if(el.select)el.select();return false;}}
if(el.className.indexOf('email')!=-1){
if(isFilled(el)&&!isEmail(el)){
var t=findLabelForInput(form, el);alert('The ' + t + ' field must be a valid email address.');el.focus();if(el.select)el.select();return false;}}
}
return true;}
function resetFields(form){
for(var i=0;i<form.elements.length;++i){
var el=form.elements[i];if(el.type=='submit')continue;if(!el.defaultValue)continue;if(el.type=='text')el.onfocus=function(){this.select();}}
}
function prepareFormValidation(){
for(var i=0;i<document.forms.length;++i){
var f=document.forms[i];if(typeof f.onsubmit=='function'){
f.p=f.onsubmit;f.onsubmit=function(){
if(!validateForm(this))return false;return this.p.call(this);}}
else{
f.onsubmit=function(){
return validateForm(this);}}
}}
function isFilled(fld){
return fld.value.length>=1;}
function isEmail(fld){
if(fld.value.indexOf('@')==-1||fld.value.indexOf('.')==-1)return false;if(fld.value.length<5)return false;return/^\s*[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{2,})+\s*$/.test(fld.value);}
function describeObject(obj, recurse){
var d='';for(var i in obj){
var v='';if(recurse&&typeof obj[i]=='object')v='\n{\n' + describeObject(obj[i])+ '}';else v=obj[i];d+=i + '=(' +(typeof obj[i])+ ')' + v + '\n';}
return d;}
document.infoMsg=null;function showInfoMsg(msg){
var im=document.infoMsg;if(!msg){
if(im)im.style.display='none';return;}
if(!im){
document.infoMsg=im=document.createElement('div');document.getElementsByTagName('body')[0].appendChild(im);var s=document.createElement('span');im.appendChild(s);$(s).addClass('msgbox');$(s).addClass('box');}
im.firstChild.innerHTML=msg;im.style.display='block';}
function setOpacity(el, valueOutOfTen){
el.style.opacity=valueOutOfTen/10;el.style.filter='alpha(opacity=' +(valueOutOfTen*10)+ ')';}
function gebi(id, root){
if(!document.getElementById)return null;if(!root)root=document;return root.getElementById(id);}
function gebtn(tagName, root){
if(!document.getElementsByTagName)return null;if(!root)root=document;return root.getElementsByTagName(tagName);}
function setInnerById(id, html){
var el=gebi(id);if(el)el.innerHTML=html;}
function getLabelFor(id){
var l=gebtn('label');for(var i=0;i<l.length;++i)if(getForAttrib(l[i])==id)return l[i];return null;}
function addClass(el, className){
var r=new RegExp('(^|)' + className + '(|$)');if(r.test(el.className))return;var n=[ el.className , className ];el.className=n.join(' ');}
function removeClass(el, className){
var p=el.className.split(className);el.className=p.join(' ');}
function disableButtons(form, disabled){
var is=form.getElementsByTagName('input');for(var i=0;i<is.length;++i){
var t=is[i].getAttribute('type').toLowerCase();if(t=='submit'||t=='reset')is[i].disabled=disabled;}}
function busifyForm(form, busy){
var p=typeof form.nonbusyOnSubmit;if(busy){
if(p=='undefined')form.nonbusyOnSubmit=form.onsubmit;form.onsubmit=function(){return false;}}
else if(p!='undefined')form.onsubmit=form.nonbusyOnSubmit;disableButtons(form, busy);}
function getQstrVar(key, query){
if(typeof query=='undefined')query=window.location.search.substring(1);var v=query.split('&');for(var i=0;i<v.length;++i){
var p=v[i].split('=', 2);if(p[0]==key)return p[1];}
return null;}
function getHrefArr(href, pagename){
var r=new Array();href=href.split('?').slice(0, 1).toString();var p=href.split('/').slice();var pi=p.indexOf(pagename);if(pi>=0)for(var i=pi + 1;i<p.length;++i)r.push(unescape(p[i]));return r;}
function getQstrMap(href){
var r=new Array();var q=href.split('?').slice(1).toString();if(q!=''){
var p=q.split('&');for(var i=0;i<p.length;++i){
var a=p[i].split('=', 2);r[a[0]]=unescape(a[1]);}}
return r;}
function getSuccessBox(m){
return '<div id="notification" class="success">SUCCESS<br/>' + m + '</div>';}
function getWarningBox(m){
return '<div id="notification" class="warning">WARNING<br/>' + m + '</div>';}
function getErrorBox(m){
return '<div id="notification" class="error">ERROR<br/>' + m + '</div>';}
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();}
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);}
function enableDefaultWidth(){
var l=null;var ls=document.getElementsByTagName('link');for(var i=0;l=ls[i];++i)if(l.getAttribute('name')=='width')l.disabled=/^alt/.test(l.rel);}
function switchWidth(width){
var l=null;var ls=document.getElementsByTagName('link');for(var i=0;l=ls[i];++i){
if(l.getAttribute('name')=='width'){
if(!l.disabled)l.disabled=true;else if(l.title==width)l.disabled=false;}}
var s=null;var ss=gebi('footer').getElementsByTagName('span');for(var i=0;s=ss[i];++i){
if(/^offwidth-[0-9]+$/.test(s.id)){
if(s.id==('offwidth-' + width))s.style.display='none';else s.style.display='inline';}
else if(/^onwidth-[0-9]+$/.test(s.id)){
if(s.id==('onwidth-' + width))s.style.display='inline';else s.style.display='none';}}
}
function resizeCallback(text, xml){
var xr=new ajaxml.Reply();xr.process(xml);if(xr.didSucceed())switchWidth(xr.getField('width'));else alert(xr.getStringError());this.anchor.resizing=false;}
function doResize(anchor, width){
if(anchor.resizing)return false;anchor.resizing=true;var vars=getHrefArr(anchor.href, 'resize');width=vars[0];vars=getQstrMap(anchor.href);var ret_url=vars['return'];var rq=new ajax.Request();rq.anchor=anchor;rq.onComplete=resizeCallback;rq.sendRequest('GET', '/resize.php', 'width=' + width, 'return=' + ret_url
);return false;}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-links').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=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.className='box';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='/cdm/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;}}
}
var niftyOk=(document.getElementById&&document.createElement&&Array.prototype.push);var niftyCss=false;String.prototype.find=function(what){
return(this.indexOf(what)>=0?true:false);}
function AddCss(){
niftyCss=true;}
function Nifty(selector,options){
if(niftyOk==false)return;if(niftyCss==false)AddCss();var i,v=selector.split(","),h=0;if(options==null)options="";if(options.find("fixed-height"))h=getElementsBySelector(v[0])[0].offsetHeight;for(i=0;i<v.length;i++)Rounded(v[i],options);if(options.find("height"))SameHeight(selector,h);}
function Rounded(selector,options){
var i,top="",bottom="",v=new Array();if(options!=""){
options=options.replace("left","tl bl");options=options.replace("right","tr br");options=options.replace("top","tr tl");options=options.replace("bottom","br bl");options=options.replace("transparent","alias");if(options.find("tl")){
top="both";if(!options.find("tr"))top="left";}
else if(options.find("tr"))top="right";if(options.find("bl")){
bottom="both";if(!options.find("br"))bottom="left";}
else if(options.find("br"))bottom="right";}
if(top==""&&bottom==""&&!options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);for(i=0;i<v.length;i++){
FixIE(v[i]);if(top!="")AddTop(v[i],top,options);if(bottom!="")AddBottom(v[i],bottom,options);}}
function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;d.style.marginLeft="-"+getPadding(el,"Left")+"px";d.style.marginRight="-"+getPadding(el,"Right")+"px";if(options.find("alias")||(color=getBk(el))=="transparent"){
color="transparent";bk="transparent";border=getParentBk(el);btype="t";}
else{
bk=getParentBk(el);border=Mix(color,bk);}
d.style.background=bk;d.className="niftycorners";p=getPadding(el,"Top");if(options.find("small")){
d.style.marginBottom=(p-2)+"px";btype+="s";lim=2;}
else if(options.find("big")){
d.style.marginBottom=(p-10)+"px";btype+="b";lim=8;}
else d.style.marginBottom=(p-5)+"px";for(i=1;i<=lim;i++)d.appendChild(CreateStrip(i,side,color,border,btype));el.style.paddingTop="0";el.insertBefore(d,el.firstChild);}
function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;d.style.marginLeft="-"+getPadding(el,"Left")+"px";d.style.marginRight="-"+getPadding(el,"Right")+"px";if(options.find("alias")||(color=getBk(el))=="transparent"){
color="transparent";bk="transparent";border=getParentBk(el);btype="t";}
else{
bk=getParentBk(el);border=Mix(color,bk);}
d.style.background=bk;d.className="niftycorners";p=getPadding(el,"Bottom");if(options.find("small")){
d.style.marginTop=(p-2)+"px";btype+="s";lim=2;}
else if(options.find("big")){
d.style.marginTop=(p-10)+"px";btype+="b";lim=8;}
else d.style.marginTop=(p-5)+"px";for(i=lim;i>0;i--)d.appendChild(CreateStrip(i,side,color,border,btype));el.style.paddingBottom=0;el.appendChild(d);}
function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");x.className=btype+index;x.style.backgroundColor=color;x.style.borderColor=border;if(side=="left"){
x.style.borderRightWidth="0";x.style.marginRight="0";}
else if(side=="right"){
x.style.borderLeftWidth="0";x.style.marginLeft="0";}
return(x);}
function CreateEl(x){
return(document.createElement(x));}
function FixIE(el){
if(el.currentStyle!=null&&el.currentStyle.hasLayout!=null&&el.currentStyle.hasLayout==false)el.style.display="inline-block";}
function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;for(i=0;i<v.length;i++){
t=getElementsBySelector(v[i]);els=els.concat(t);}
for(i=0;i<els.length;i++){
if(els[i].offsetHeight>maxh)maxh=els[i].offsetHeight;els[i].style.height="auto";}
for(i=0;i<els.length;i++){
gap=maxh-els[i].offsetHeight;if(gap>0){
t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";nc=els[i].lastChild;if(nc.className=="niftycorners")els[i].insertBefore(t,nc);else els[i].appendChild(t);}}
}
function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;if(selector.find("#")){//id selector like "tag#id"
if(selector.find(" ")){//descendant selector like "tag#id tag"
s=selector.split(" ");var fs=s[0].split("#");if(fs.length==1)return(objlist);f=document.getElementById(fs[1]);if(f){
v=f.getElementsByTagName(s[1]);for(i=0;i<v.length;i++)objlist.push(v[i]);}
return(objlist);}
else{
s=selector.split("#");tag=s[0];selid=s[1];if(selid!=""){
f=document.getElementById(selid);if(f)objlist.push(f);return(objlist);}}
}
if(selector.find(".")){//class selector like "tag.class"
s=selector.split(".");tag=s[0];selclass=s[1];if(selclass.find(" ")){
s=selclass.split(" ");selclass=s[0];tag2=s[1];}}
var v=document.getElementsByTagName(tag);//tag selector like "tag"
if(selclass==""){
for(i=0;i<v.length;i++)objlist.push(v[i]);return(objlist);}
for(i=0;i<v.length;i++){
c=v[i].className.split(" ");for(j=0;j<c.length;j++){
if(c[j]==selclass){
if(tag2=="")objlist.push(v[i]);else{
v2=v[i].getElementsByTagName(tag2);for(k=0;k<v2.length;k++)objlist.push(v2[k]);}}
}}
return(objlist);}
function getParentBk(x){
var el=x.parentNode,c;while(el.tagName.toUpperCase()!="HTML"&&(c=getBk(el))=="transparent")el=el.parentNode;if(c=="transparent")c="#FFFFFF";return(c);}
function getBk(x){
var c=getStyleProp(x,"backgroundColor");if(c==null||c=="transparent"||c.find("rgba(0, 0, 0, 0)"))return("transparent");if(c.find("rgb"))c=rgb2hex(c);return(c);}
function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);if(p==null||!p.find("px"))return(0);return(parseInt(p));}
function getStyleProp(x,prop){
if(x.currentStyle)return(x.currentStyle[prop]);if(document.defaultView.getComputedStyle)return(document.defaultView.getComputedStyle(x,'')[prop]);return(null);}
function rgb2hex(value){
var hex="",v,h,i;var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;var h=regexp.exec(value);for(i=1;i<4;i++){
v=parseInt(h[i]).toString(16);if(v.length==1)hex+="0"+v;else hex+=v;}
return("#"+hex);}
function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);if(c1.length==4)step1=1;else step1=2;if(c2.length==4)step2=1;else step2=2;for(i=0;i<3;i++){
x=parseInt(c1.substr(1+step1*i,step1),16);if(step1==1)x=16*x+x;y=parseInt(c2.substr(1+step2*i,step2),16);if(step2==1)y=16*y+y;r[i]=Math.floor((x*50+y*50)/100);r[i]=r[i].toString(16);if(r[i].length==1)r[i]="0"+r[i];}
return("#"+r[0]+r[1]+r[2]);}
function prepLinkbar(d){
var p=d.parentNode;var l=d.firstChild;l.p=p;l.d=d;var divs=gebtn('div',p);for(var j=0;j<divs.length;++j){
if(/extern/.test(divs[j].className))divs[j].style.display='none';}
d.style.display='block';l.onclick=function(){
var divs=gebtn('div',this.p);for(var j=0;j<divs.length;++j){
if(/extern/.test(divs[j].className))divs[j].style.display='block';}
this.d.style.display='none';return false;}}
function voteCallback(responseText, responseXML) {
showInfoMsg(); this.link.busy = false; var post = this.link.post; var xmlreply = new ajaxml.Reply(); xmlreply.process(responseXML); if (xmlreply.didSucceed()) {
var votes = xmlreply.getField('votes'); gebi('votebtnup-' + post).style.display = 'none'; gebi('votebtndown-' + post).style.display = 'none'; gebi('vidvotes-' + post).innerHTML = votes; var v=gebi('vote_count-' + post); if(v)v.innerHTML = votes; if (fbperms=xmlreply.getField('wantfbprompt')) if (typeof(FB)!='undefined') FB.Connect.showPermissionDialog(fbperms,function(x){
if (/email/.test(x)) alert('Thanks for granting email access! You will receive only selective updates. Limit them in your VideoSift preferences.'); if (/publish_stream/.test(x)) alert('Thanks for granting update access! Your Facebook page will only be updated for activity as selected in your VideoSift preferences.'); }); }
else alert(xmlreply.getStringError());}
function prepVoteBtn(div) {
var post = div.id.split('-')[1]; var links = gebtn('a', div); for (var j = 0; j < links.length; ++j) {
links[j].post = post; links[j].onclick = function() {
if (this.busy) {
alert('Still busy casting your vote. Please wait...'); return false; }
if (/votedown/.test(this.className)) {
if (!confirm('Are you sure you really want to down vote this video?')) 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; showInfoMsg('Please wait...'); this.busy = true; 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 pollCB(text, xml){
showInfoMsg();this.form.busy=false;var xr=new ajaxml.Reply();xr.process(xml);if(xr.didSucceed()){
var vv=xr.getField('votes').split(',');for(var i=0;i<vv.length;++i){
var v=vv[i].split('=');gebi('pollopt-'+this.pid+'-'+v[0]).parentNode.innerHTML=v[0]==this.opt?'&raquo;':'';var c=gebi('pollvotes-'+this.pid+'-'+v[0]);var d=gebi('polllbl-'+this.pid+'-'+v[0]);$(d).attr("votes", v[1]);c.innerHTML='('+v[1]+' '+(v[1]==1?'vote':'votes')+')';}
this.form.submit.style.display='none';showPollVotes(this.pid);}
else{
alert(xr.getStringError());this.form.submit.disabled=false;}}
function pollVote(pid,form){
if(form.busy){
alert('Still busy casting your vote. Please wait...');return false;}
var p=form.pollopt;var v=false;for(var i=0;i<p.length;++i){
if(p[i].checked)v=p[i].value;}
if(!v)return false;form.busy=form.submit.disabled=true;var opt=v.split('-')[1];var vars=getQstrMap(form.action);var ret_url=vars['return'];showInfoMsg('Please wait...');var rq=new ajax.Request();rq.pid=pid;rq.opt=opt;rq.form=form;rq.onComplete=pollCB;rq.sendRequest('POST', '/pollvote.php?pid='+pid+'&return='+ret_url, 'opt=' + opt
);return false;}
function showPollVotes(p){
var t=gebi('polltbl-'+p);if(!t)return false;gebi('pollshow-'+p).style.display='none';var bs=gebtn('span',t);for(var i=0;i<bs.length;++i){
if(/^pollvoter?s-/.test(bs[i].id))bs[i].style.display='inline';}
prepPoll(p);return false;}
function prepNextBB(){
var l=gebi('next-billboard');if(!l)return;l.d=gebi('billboard');if(!l.d)return;l.d.shown=l.d.className.split('-')[1];l.onclick=function(){
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
this.busy=true;var rq=new ajax.Request();rq.link=this;rq.onComplete=function(txt,xml){
var xr=new ajaxml.Reply();xr.process(xml);if(xr.didSucceed()){
var s=xr.getField('shown');if(s=='')this.link.style.display='none';var b=xr.getField('body');this.link.d.innerHTML=b;this.link.d.shown=s;if(b==''&&s!='')this.sendRequest('GET', '/rs/billboard.php','shown='+s);else this.link.busy=false;}
else alert(xr.getStringError());}
rq.sendRequest('GET', '/rs/billboard.php', 'shown='+this.d.shown
);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 ignoreCB(responseText, responseXML){
showInfoMsg();var comment=this.link.comment;var a=gebi('ignore-' + comment);a.busy=false;var xmlreply=new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
alert(xmlreply.getField('alert'));a.title=xmlreply.getField('ignoretitle');a.innerHTML=xmlreply.getField('ignorelink');}
else alert(xmlreply.getStringError());}
function prepIgnoreLink(link){
link.onclick=function(){
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
var vars=getHrefArr(this.href, 'ignore');var comment=vars[0];vars=getQstrMap(this.href);var ret_url=vars['return'];if(comment=='')return true;showInfoMsg('Please wait...');var a=gebi('ignore-' + comment);if(a)a.busy=true;this.comment=comment;var request=new ajax.Request();request.link=this;request.onComplete=ignoreCB;request.sendRequest('GET', '/rs/ignore.php', 'comment=' + comment, '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');if($(this.link).is(":has(img)")){
if($(this.link).css("opacity")<1)$(this.link).css({"opacity":1});else $(this.link).css({"opacity":0.4});}
else 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 addvidCallback(responseText, responseXML){
showInfoMsg();this.form.busy = false;var xmlreply = new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
if(!$(this.link).is(":has(img)")){
var parts = this.link.innerHTML.split('(');this.link.innerHTML = parts[0] + '(' + xmlreply.getField('count')+ ')';}
plpopClose.call(this);}
else alert(xmlreply.getStringError());}
function plcreateCallback(responseText, responseXML){
showInfoMsg();busifyForm(this.createform, false);var xmlreply = new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
this.createform = null;linkReload.call(this.link);return;}
xmlreply.displayArrayErrors('pltitle');xmlreply.displayArrayErrors('access');xmlreply.displayArrayErrors('summary');err = xmlreply.getStringError();if(err)alert(err);}
function plcreateformCallback(responseText, responseXML){
showInfoMsg();this.createlink.busy = false;var xmlreply = new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
this.div.innerHTML = xmlreply.getField('createform');this.createform = this.div.firstChild;var submitcreate = document.forms['createpl']['submit'];submitcreate.request = this;submitcreate.onclick = function(){
var form = this.form;busifyForm(form, true);ajaxml.Reply.clearErrors('pltitle');ajaxml.Reply.clearErrors('access');ajaxml.Reply.clearErrors('summary');showInfoMsg('Please wait...');this.request.onComplete = plcreateCallback;this.request.sendRequest('POST', '/rs/playlist/popup.php', 'id=' + this.request.link.vdid, 'pltitle=' + form.pltitle.value, 'access=' + form.access.value, 'reverse=' +(form.reverse.checked ? 'reverse' : ''), 'sortable=' +(form.sortable.checked ? 'sortable' : ''), 'summary=' + form.summary.value, 'commentemail=' +(form.commentemail.checked ? 'commentemail' : ''), 'submit=submit', 'type=create'
);return false;}
var cancelcreate = document.forms['createpl']['cancel'];cancelcreate.request = this;cancelcreate.onclick = function(){
plpopCancel.call(this.request);this.request.div.removeChild(this.request.createform);this.request.div.appendChild(this.request.addvidform);return false;}}
else alert(xmlreply.getStringError());}
function addvidformPrepare(){
var createlink = gebi('createpl-' + this.link.vdid);createlink.request = this;this.createlink = createlink;createlink.onclick = function(){
if(this.request.createform){
this.request.div.removeChild(this.request.addvidform);this.request.div.appendChild(this.request.createform);return false;}
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
plpopCancel.call(this.request);this.busy = true;showInfoMsg('Please wait...');this.request.link.request = this.request;this.request.onComplete = plcreateformCallback;this.request.sendRequest('GET', '/rs/playlist/popup.php?title=' + this.request.url_title, 'id=' + this.request.link.vdid, 'type=createform'
);return false;}
var form = gebi('pladdvid-' + this.link.vdid);form.request = this;this.form = form;form['cancel'].onclick = function(){
plpopClose.call(form.request);return false;}
form['submit'].onclick = function(){
if(form.busy){
alert('Still busy processing your request. Please wait...');return false;}
plpopCancel.call(form.request);form.busy = true;var inputs = form.getElementsByTagName('input');var dest = new Array();for(var i = 0;i < inputs.length;++i){
var input = inputs[i];if(input.type=='checkbox'){
var parts = input.id.split('-');var plid = parts[1];if(input.checked)dest.append(plid);}}
showInfoMsg('Please wait...');form.request.link.request = form.request;form.request.onComplete = addvidCallback;form.request.sendRequest('POST', '/rs/playlist/popup.php?title=' + form.request.url_title, 'id=' + form.request.link.vdid, 'dest=' + dest, 'submit=submit', 'type=addvid'
);return false;}}
function addvidformCallback(responseText, responseXML){
showInfoMsg();var xmlreply = new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
this.url_title = xmlreply.getField('video_url_title');this.div.innerHTML = xmlreply.getField('addvidform');this.addvidform = this.div.firstChild;addvidformPrepare.call(this);}
else alert(xmlreply.getStringError());}
function plpopClose(){
this.link.popped = false;this.div.style.display = 'none';plpopCancel.call(this);}
function plpopCancel(){
showInfoMsg();if(this.createlink)this.createlink.busy = false;if(this.form)this.form.busy = false;this.abortRequest();}
function linkReload(){
plpopCancel.call(this.request);showInfoMsg('Please wait...');this.div.innerHTML = 'Loading...';this.request.onComplete = addvidformCallback;this.request.sendRequest('GET', '/rs/playlist/popup.php', 'id=' + this.vdid, 'type=addvidform'
);}
function prepPlpop(link){
var parts = link.id.split('-');link.vdid = parts[1];var div = gebi('postpopup-' + link.vdid);link.div = div;div.link = link;link.onclick = function(){
this.popped = !this.popped;if(!this.request){
this.request = new ajax.Request();this.request.link = this;this.request.div = this.div;}
if(this.popped){
this.div.style.display = 'block';if(!this.request.addvidform)linkReload.call(this);}
else plpopClose.call(this.request);return false;}}
function commentPopCB(responseText, responseXML){
var link=this.link;var div=link.div;link.busy=false;showInfoMsg();var xmlreply=new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
link.loaded=true;link.expanded=true;div.innerHTML=xmlreply.getField('listing');$(div).slideDown("def");if(typeof urchinTracker=='function')urchinTracker(link.vidurl);if(typeof _trackPageview=='function')_trackPageview(link.vidurl);if(typeof prepThumbVoteLink=='function'){
var as=gebtn('a',div);for(var i=0;i<as.length;++i){
var a=as[i];if(/^thumb(up|down|spam)-[0-9]+/.test(a.id)){
var cid=a.id.split('-')[1];initEl('thumbup-'+cid,prepThumbVoteLink);initEl('thumbdown-'+cid,prepThumbVoteLink);initEl('thumbspam-'+cid,prepThumbVoteLink);initEl('ignore-'+cid,prepIgnoreLink);}}
var sps=gebtn('span',div);for(var i=0;i<sps.length;++i){
var cc=sps[i];if(/^commentcontents-[0-9]+/.test(cc.id)&&cc.className=='ignored'){
cc.style.display='none';var sc=document.createElement('a');sc.cc=cc;sc.href='#';sc.innerHTML='<em>[show the body of this ignored comment]</em>';sc.onclick=function(){
this.cc.style.display='inline';this.style.display='none';return false;}
cc.parentNode.insertBefore(sc,cc);}}
}}
else alert(xmlreply.getStringError());}
function prepCommentPop(l){
l.vid=l.id.split('-')[1];l.div=gebi('commentpopup-'+l.vid);if(!l.div)return;l.onclick=function(){
if(this.loaded){
if(this.expanded)$(this.div).slideUp("def");else $(this.div).slideDown("def");this.expanded=!this.expanded;return false;}
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
this.busy=true;showInfoMsg('Please wait...');this.vidurl=gebi('postlink-'+this.vid).href;var request=new ajax.Request();request.link=this;request.onComplete=commentPopCB;request.sendRequest('GET', '/rs/commentpop.php', 'vid=' + this.vid, 'vidurl=' + this.vidurl, 'return=' + window.location.href
);return false;}}
function recvoteCB(text,xml){
var l=this.link;l.busy=false;showInfoMsg();var xr=new ajaxml.Reply();xr.process(xml);if(xr.didSucceed()){
var p=l.parentNode;p.innerHTML='&raquo;You have successfully reclaimed your vote for this video';var b=gebi('votebtnup-'+l.vdid);if(b)b.style.display='none';b=gebi('votebtndown-'+l.vdid);if(b)b.style.display='none';}
else alert(xr.getStringError());}
function prepReclaimVote(l){
l.vdid=l.id.split('-')[1];l.onclick=function(){
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
if(!confirm('Do you really want to reclaim a siftbot vote as your own?'))return false;var vars=getHrefArr(this.href, 'reclaimvote');var p=vars[0];vars=getQstrMap(this.href);var ret_url=vars['return'];if(p=='')return true;this.busy=true;showInfoMsg('Please wait...');var rq=new ajax.Request();rq.link=this;rq.onComplete=recvoteCB;rq.sendRequest('GET', '/rs/reclaimvote.php', 'title=' + p, 'return=' + ret_url
);return false;}}
function embedformCallback(responseText, responseXML){
var box=this.box;var link=box.link;box.setLoading(false);var xr=new ajaxml.Reply();xr.process(responseXML);if(xr.didSucceed()){
box.body.style.padding='10px';box.body.innerHTML=xr.getField('embedbody');}
else alert(xr.getStringError());}
function modalShowEmbed(){
var rq=new ajax.Request();rq.box=this;rq.onComplete=embedformCallback;rq.sendRequest('GET', '/rs/modal/embed.php', 'title='+this.link.title
);}
function prepVidEmbedLink(l){
l.onclick=function(){
var vars=getHrefArr(this.href, 'embed');this.title=vars[0];var modalbox=new modalpage.Box(550,275);modalbox.setInitFunc(modalShowEmbed);modalbox.setCancelFunc(function(){delete this.box;});modalbox.link=this;modalbox.open();return false;}}
function emailSuccess(xmlreply){
var m=xmlreply.getField('message');if(m.length>0){
this.box.resize(550, 140);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.title
);}
function prepVidEmailLink(l){
l.onclick=function(){
var vars=getHrefArr(this.href, 'email');this.title=vars[0];var modalbox=new modalpage.Box(750,525);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 rq=new ajax.Request();rq.box=this;rq.onComplete=contactformCallback;rq.sendRequest('GET', '/rs/modal/contact.php');}
function prepContactLink(l){
if(/\/contact(\.php)?/.test(l.href)){
l.onclick=function(){
var modalbox=new modalpage.Box(750,525);modalbox.setInitFunc(modalShowContact);modalbox.setCancelFunc(function(){delete this.box;});modalbox.link=this;modalbox.open();return false;}}
}
function chrmCallback(responseText, responseXML){
var link=this.link;link.busy=false;showInfoMsg();var xmlreply=new ajaxml.Reply();xmlreply.process(responseXML);if(xmlreply.didSucceed()){
if(xmlreply.getField('removeid')==link.vdid)gebi('chanrem-'+link.vdid).innerHTML='<div class="note buffer"><strong>Post has been removed from this channel</strong></div>';}
else alert(xmlreply.getStringError());}
function chrmPrepare(){
var ls=gebtn('a');for(var i=0;i<ls.length;++i){
var l=ls[i];if(/^chprm-[0-9]+$/.test(l.id)){
l.vdid=l.id.split('-')[1];l.onclick=function(){
if(this.busy){
alert('Still busy processing your request. Please wait...');return false;}
if(!confirm('Are you sure you really want to remove this post from the channel?'))return false;var vars=getHrefArr(this.href, 'chanremove');var c=vars[0];var p=vars[1];vars=getQstrMap(this.href);var ret_url=vars['return'];if(c==''||p=='')return true;this.busy=true;showInfoMsg('Please wait...');var request=new ajax.Request();request.link=this;request.onComplete=chrmCallback;request.sendRequest('GET', '/rs/chanremove.php', 'channel=' + c, 'title=' + p, 'return=' + ret_url
);return false;}}
}}
addLoadEvent(chrmPrepare);function recalcEmbed(embed, x){
if(embed.search(/width=[\"|']([0-9]{2,4})[\"|']/)!=-1){
em_w = embed.match(/width=[\"|']([0-9]{2,4})[\"|']/)[1];em_h = embed.match(/height=[\"|']([0-9]{2,4})[\"|']/)[1];ar = em_h / em_w;new_w = $("#content_left").attr("clientWidth")- x;new_h = Math.round(new_w * ar);if(new_h > window.innerHeight){
new_h = window.innerHeight - 75;new_w = Math.round(new_h / ar);}
embed = embed.replace(/height=[\"|']([0-9]{2,4})[\"|']/g, 'height="'+new_h+'"');embed = embed.replace(/width=[\"|']([0-9]{2,4})[\"|']/g, 'width="'+new_w+'"');}
return embed;}
function vpembedCB(responseText, responseXML){
var div = this.div;var gallery = $("#postembed-" + div.vidthumb.vid).parent().is(".gallery_thumb");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(){
$(l).parents(".sift, .gallery_sift, .gallery_promoted").data("prev","false");if(gallery){
var ed = $("#postembed-" + div.vidthumb.vid).get(0);$(ed).parent().css({width:"130px"}).parent().css({marginLeft:""});$(ed).children("div").not(".gallerybadge").remove();$(ed).siblings(".video_flags_g").fadeIn("fast");$(ed).children(".gallerybadge").fadeIn("fast");$(ed).siblings(".promo_label").toggle();$(ed).parent().siblings(".galleryblocked").fadeIn("fast");$("#linkbar-" + div.vidthumb.vid).children(".gallery_title").css({'height':'86px'});$("#vidthumb-" + div.vidthumb.vid).fadeIn("def");$.scrollTo(ed,{offset:{top:-10, left:0}});$(this).remove();resizeGallery();}else{
$(this).parents("#sift_info").children(".video_flags, .galleryblocked").fadeIn("fast");thumbdiv = $(this).parents("#sift_info").children(".thumbcontainer");$(thumbdiv).siblings(".tmargin").animate({marginLeft:'135px'},{queue:true, duration:400});$(thumbdiv).fadeIn("def");$(this.div.embed).fadeOut("def");this.div.expanded = false;gebtn('div', this.div.embed).item(0).innerHTML = '';this.div.vidthumb.style.display = 'block';}
return false;}
if(gallery){
div.embedcode = recalcEmbed(div.embedcode, 125);var ed = $("#postembed-" + div.vidthumb.vid);$(ed).parents(".sift, .gallery_sift, .gallery_promoted").data("prev", "true");$(ed).parent().css({width:"auto"}).parent().css({marginLeft:"0px"});$("#vidthumb-" + div.vidthumb.vid).fadeOut("def");$("#linkbar-" + div.vidthumb.vid).children(".gallery_title").css({'height':'auto'});$(ed).children(".gallerybadge").stop(true, true).fadeOut("fast");$(ed).siblings(".video_flags_g").stop(true, true).fadeOut("fast");$(ed).siblings(".promo_label").toggle();$(ed).parent().siblings(".galleryblocked").stop(true, true).fadeOut("fast");emb = document.createElement("div");emb.innerHTML = div.embedcode;$(ed).append(emb);$(l).addClass("fright");$("#linkbar-" + div.vidthumb.vid).append(l);div.expanded = true;$.scrollTo(ed, 600,{offset:{top:-10, left:0}});}else{
div.embedcode = recalcEmbed(div.embedcode, 150);$("#video-" + div.vidthumb.vid + " .video_flags").stop().fadeOut("fast");var ed = gebi('embedcode-' + div.vidthumb.vid);$(ed).parents(".sift, .gallery_sift").data("prev", "true");$(ed).parent().siblings(".galleryblocked").stop(true, true).fadeOut("fast");ed.innerHTML = '<div>' + div.embedcode + '</div>';ed.insertBefore(l, ed.firstChild);div.embed = ed;thumbdiv = div.parentNode;if(div.embedcode.search(/width=\"([0-9]{2,4})\"/)!=-1)var lw = div.embedcode.match(/width=\"([0-9]{2,4})\"/)[1];else lw = 360;$(thumbdiv).fadeOut("normal");$(thumbdiv).siblings(".tmargin").animate({marginLeft:'0px'},{queue:true, duration:400});$(div.embed).fadeIn("normal");div.expanded = true;$.scrollTo(ed.parentNode.parentNode, 600,{offset:{top:-10, left:0}});var newcontrols = document.createElement("div");$(newcontrols).addClass("controls").css("width", lw + "px").appendTo(ed);$("#linkbar-" + div.vidthumb.vid + ' a').clone(true).appendTo(newcontrols);$(newcontrols).children("a").each(function(){
$(this).click(function(){
$("#" + this.id).click();return false;});});}}
else div.vidthumb.onclick = function(){
return true;}}
document.video_divs = new Array();function prepVidPreview(div){
var gallery = $(div).parent().is(".gallery_thumb");var c = $(div).children("a").get(0);div.expanded = false;div.vidthumb = c;c.div = div;document.video_divs.append(div);var parts = div.id.split('-');c.vid = parts[1];c.onclick = function(){
if(this.div.embed){
thumbdiv = this.parentNode.parentNode;$(thumbdiv).parents(".sift, .gallery_sift").data("prev", "true");$(thumbdiv.parentNode).children('#video_flags').fadeOut("fast");$(thumbdiv).siblings(".tmargin").animate({marginLeft:'0px'},{queue:true, duration:400});$(thumbdiv).fadeOut("normal");this.div.expanded = true;gebtn('div', this.div.embed).item(0).innerHTML = this.div.embedcode;$(this.div.embed).fadeIn("normal");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);enableDefaultWidth();function NiftyLoad(){
Nifty("div.panel");Nifty("div.pager-all","big");Nifty("div.pager-top","top,big");Nifty("div.pager-bottom","bottom,big");Nifty("div.contents","big");Nifty("div#notification");Nifty("div#invocations");Nifty("div.voted","top");Nifty("a.voteup","top");Nifty("a.votedown","bottom");Nifty("div.votecast","bottom");if(BrowserDetect.browser!='Explorer')Nifty("#header-tabs li a","top");}
