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 rel_kw = '';var pointerColor;jQuery.fn.replaceHTML = function(rxString, repString) {
return this.each(function() { 
$(this).html($(this).html().replace(rxString,repString)); });};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 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); if (e.target.id.search("ico_info") != -1) {
idnum = e.target.id.replace("ico_info-", ""); leftOffset = 23; topOffset = 6; } else {
idnum = e.target.parentNode.id.replace("vidthumb-", ""); leftOffset = 131; topOffset = 1; }
$("#gallery_popup").html($("#gallery_hidden-" + idnum).html()); $("#gallery_popup").css({'left' : (coords.left - scrollPos().left + leftOffset) + 'px', 'top' : (coords.top - scrollPos().top - topOffset) + 'px'}); $("#gallery_popup").stop(1, 1); $("#gallery_popup").fadeIn("normal"); $(window).scroll(function () {$("#gallery_popup").css({'left' : (coords.left - scrollPos().left + leftOffset) + 'px', 'top' : (coords.top - scrollPos().top - topOffset) + 'px'});});}
function hideGalleryPopup(e) {
showFlags(e); if (!($(e.relatedTarget).is("#gallery_popup, #gallery_popup *, .gallery_title"))) {
$("#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("div"); $(bar).addClass("pollbar").html("&nbsp;"); if (votes != 0) $(bar).css({width:'0%', height: '16px', background: 'url('+arrColors[i]+') repeat-x'}); else $(bar).css({width:'3px', height: '16px', background: 'url('+arrColors[i]+') repeat-x'}); 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>"); });}
function initUserMenu() {
$("#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);}
function initGuestMenu(e) {
$("#userlink").mouseenter(showUserMenu); $("#userlink").mouseleave(hideUserMenu); $("#usermenu").mouseleave(hideUserMenu); $("#usermenu").mouseenter(function(e) {
usermenuhide = false; }); $("#guestlink").click(function() {
if ($("#guestbox").css('display') == 'block') {
} else {
$("#guestbox").fadeIn("def"); }
});}
function onYouTubePlayerReady(playerId) {
if ($.browser.msie) {
ytplayer = $("object").filter(function() {
if ($(this).attr("altHtml").indexOf(playerId) > -1) return this; }).get(0); } else {
ytplayer = $("embed[src*="+playerId+"]").get(0); }
ytplayer.addEventListener("onStateChange", "stateChange("+playerId+")");}
function stateChange(pid) {
if ($.browser.msie) {
ytp = $("object").filter(function() {
if ($(this).attr("altHtml").indexOf(pid) > -1) return this; }).get(0); } else ytp = $("embed[src*="+pid+"]").get(0); contend = $(ytp).parents("div[id*=postembed-]"); if ($(contend).size() == 0) {
paId = "embedcode"; }
else paId = "postembed"; contend = $(ytp).parents("div[id*="+paId+"-]"); function addRelatedVid(item, contend) {
relcont = $("#relcontent", $(contend)); newLine = $("<div class='relvid'><div>"); $("<div class='fleft'></div>") .append($('<a href="'+item.url+'"><img width="130" height="98" src="'+item.img+'" alt="thumbnail"/></a>')) .appendTo($(newLine)); $("<div style='text-align:left;margin-left: 140px;'></div>") .append('<a class="title" href="'+item.url+'">'+item.title+'</a>') .append("<br />") .append("<br />") .append("<span>submitted by: "+item.author+"</span>") .append("<br />") .append("<span>"+item.views+" views</span>") .appendTo($(newLine)); $(newLine) .hide() .appendTo(relcont) .fadeIn("slow"); }
function changePage(p, contend) {
if (p < 4 && p > 0) {
$("#rel_prev", $(contend)).show(); $("#rel_next", $(contend)).show(); if (p == 1) $("#rel_prev", $(contend)).hide(); else if (p == 3) $("#rel_next", $(contend)).hide(); curpage = p; l = p * 3; $("#relcontent .relvid", $(contend)).remove(); $.each(jsond.items, function(i,item){
if (i < l && i >= (l-3)) {
addRelatedVid(item, contend); }
}); }
}
if (ytp.getPlayerState() == 0) {
if ($("#relatedDiv", $(contend)).size() > 0) {
if ($.browser.safari) {
$("#relatedDiv", $(contend)).remove(); stateChange(pid); } else {
if ($.browser.msie) {
$(ytp).css({opacity:'0', height:'0'}); if (!$(ytp).parent().hasClass("post-embed")) $(ytp).parent().css("height", "0"); } else { 
$(ytp).parent().css({opacity:'0', height:'0'}); if (!$(ytp).parent().parent().hasClass("post-embed")) $(ytp).parent().parent().css("height", "0"); }
$("#gallery_flags", $(contend)).hide(); $("#relatedDiv", $(contend)).fadeIn(1000); }
} else {
var jsond; var curpage = 1; vid = $(contend).attr("id").split("-")[1]; w = $(ytp).parent().attr("width"); h = $(ytp).parent().attr("height"); rel_title = "Related videos"; rel_kw = ""; $('<div id="relatedDiv" style="position:relative;"><div id="relcontent" style="text-align: center;"><br /><span class="title" style="margin-left: 40px;">'+rel_title+'</span></div></div>') .prependTo(contend) .hide(); relcont = $("#relcontent", $(contend)); $("#relcontent", $(contend)).append("<br />"); $('<div class="fright rel_arrow"><img id="rel_next" src="http://static1.videosift.com/cdm/rel_right2.png" alt=">" title="next page" style="cursor:pointer;"/></div>') .click(function(e) {
contend = $(e.target).parents("div[id*="+paId+"-]"); changePage(curpage + 1, contend); }) .appendTo(relcont); $('<div class="fleft rel_arrow"><img id="rel_prev" src="http://static1.videosift.com/cdm/rel_left2.png" alt="<" title="previous page" style="cursor:pointer;" /></div>') .click(function(e) {
contend = $(e.target).parents("div[id*="+paId+"-]"); changePage(curpage - 1, contend); }) .appendTo(relcont); $.getJSON("http://videosift.com/api.php?apikey=491f50292a3e79e0b651c132f257dc41&action=relatedvids&kw="+rel_kw+"&id="+vid+"&callback=?", function(json){
if (ytp.getPlayerState() == 0) {
jsond = json; changePage(1, contend); if ($.browser.msie) {
$(ytp).css({opacity:'0', height:'0'}); if (!$(ytp).parent().hasClass("post-embed")) $(ytp).parent().css("height", "0"); } else { 
$(ytp).parent().css({opacity:'0', height:'0'}); if (!$(ytp).parent().parent().hasClass("post-embed")) $(ytp).parent().parent().css("height", "0"); }
$("#gallery_flags", $(contend)).hide(); $("<div class='fright center'><a href='#'><img src='http://static1.videosift.com/cdm/refresh.png' alt'replay' title='replay the video'/><br />replay video</a></div>").click(function(e) {
contend = $(e.target).parents("div[id*="+paId+"-]"); $("#relatedDiv", $(contend)).hide(); if ($.browser.msie) { 
ytpl = $(contend).find("object").get(0); $(ytp).css({opacity:'', height:''}); if (!$(ytp).parent().hasClass("post-embed")) $(ytp).parent().css("height", ""); } else { 
ytpl = $(contend).find("embed").get(0); $(ytp).parent().css({opacity:'', height:''}); if (!$(ytp).parent().parent().hasClass("post-embed")) $(ytp).parent().parent().css("height", ""); }
$("#gallery_flags", $(contend)).show(); return false; }).prependTo(relcont); if ($.browser.msie) $("#relatedDiv", $(contend)).show(); else $("#relatedDiv", $(contend)).css({'width': w+'px', 'z-index':501}).fadeIn(1000); } else {
$("#relatedDiv", $(contend)).remove(); }
}); }
}}
function ph(img) {
s = img.src.split("-"); if (s.length == 1) img.src = "http://static1.videosift.com/avatars/default.png"; else {
d = s[1].split("."); img.src = "http://static1.videosift.com/avatars/default-"+d[0]+".png"; }}
$(document).ready(function () {
fixLongTitles(); pointerColor = $("#footer").prev().css("background-color"); $("#styleicon").click(changeStyle); $("#gallery_popup").mouseleave(hideGalleryPopup); showAlertMsg(); initEmbedPop(); initFixedWidthToggle(); $(".gal_thumb").each(function(){
$(this).mouseenter(showGalleryPopup); $(this).mouseleave(hideGalleryPopup); }
); $(".thumbn").each(function(){
$(this).mouseenter(hideFlags); $(this).mouseleave(showFlags); }
); resizeGallery();});regProfile = new RegExp(/(<em>&gt;&gt; <a (?:rel=["]?nofollow["]? )?href="([A-Za-z0-9:\/.#-_?]{3,200})"(?: rel=["]?nofollow["]?)?>.([A-Za-z0-9_]{3,30})<\/a>:(?:<br ?\/?> ?){1,5}(.*)(<br\/?>){0,5}<\/em>)/i);regVideo = new RegExp(/((?:<br\/?>\ ?){0,2}<a (?:rel=["]?nofollow["]? )?href="([A-Za-z0-9:\/.#-_?]{3,200})"(?: rel=["]?nofollow["]?)?>In reply to this comment by ([A-Za-z0-9_]{3,30})<\/a>:(?:<br\/?>\ ?){1,5}<em>(.*)<\/em>)/i);var prevUser;jQuery.fn.outerHTML = function(s) {
return (s) ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html();}
function wrapQuote(link, user, text, i) {
if (i == 1) arrVals = new Array("left", "margin-left:52px;padding-top:1px;", "9668"); else arrVals = new Array("right", "margin-top:1px;right:52px;", "9658"); if (($.browser.msie) && ($.browser.version != "8.0")) arrVals2 = new Array(" ", " "); else arrVals2 = new Array("position:relative;", '<div style="position: absolute;'+arrVals[1]+' font-size: 10px;" class="commentarrow">&#'+arrVals[2]+';</div>'); return '<div style="margin: 10px; overflow: auto; width: 80%; float: '+arrVals[0]+';'+arrVals2[0]+'" class="convoPiece"><a href="'+link+'" rel="nofollow"> \
'+user+'&nbsp;said:</a><a href="http://www.videosift.com/member/'+user+'"><img style="margin: 4px 10px 10px; float: '+arrVals[0]+'; width: 40px;" \
src="http://static1.videosift.com/avatars/'+user.charAt(0).toLowerCase()+'/'+user+'-s.jpg" onerror="ph(this)"/></a>'+arrVals2[1]+'<div style="padding: 8px; \
margin-'+arrVals[0]+': 60px; margin-top: 2px; min-height: 30px;" class="nestedComment box">'+text+'</div></div>';}
function makeConvo(content, i) {
$(content).find("em + br").remove(); $(content).find("em + br").remove(); if (regVideo.test($(content).html()) && regProfile.test($(content).html())) {
if ($(content).html().search(regProfile) < $(content).html().search(regVideo)) {
regProfile.test($(content).html()); } else {
regVideo.test($(content).html()); }
if (prevUser != RegExp.$3) i++; if (i == 3) i = 1; var newQuote = wrapQuote(RegExp.$2, RegExp.$3, RegExp.$4, i); $(content).replaceHTML(RegExp.$1, ""); $(content).append("<br />"); $(content).append("<div>"+newQuote+"</div>"); prevUser = RegExp.$3; makeConvo(content, i); } else {
var j = 0; while (regVideo.test($(content).html()) || regProfile.test($(content).html())) {
if (prevUser != RegExp.$3) i++; if (i == 3) i = 1; var newQuote = wrapQuote(RegExp.$2, RegExp.$3, RegExp.$4, i); $(content).replaceHTML(RegExp.$1, ""); if (j == 0) $(content).append("<br />"); $(content).append("<br />"); $(content).append("<div>"+newQuote+"</div>"); prevUser = RegExp.$3; j++; }
}}
function checkWidth(div) {
}
function multiQuote(div) {
var matches = 0;regP = new RegExp(/(<em>&gt;&gt; <a (?:rel=["]?nofollow["]? )?href="([A-Za-z0-9:\/.#-_?]{3,200})"(?: rel=["]?nofollow["]?)?>.([A-Za-z0-9_]{3,30})<\/a>:(?:<br ?\/?> ?){1,5}(.*?)(<br\/?>){0,5}<\/em>)/gi);regV = new RegExp(/((?:<br\/?>\ ?){0,2}<a (?:rel=["]?nofollow["]? )?href="([A-Za-z0-9:\/.#-_?]{3,200})"(?: rel=["]?nofollow["]?)?>In reply to this comment by ([A-Za-z0-9_]{3,30})<\/a>:(?:<br\/?>\ ?){1,5}<em>(.*?)<\/em>)/gi);if (regV.exec($(div).html()) != null) matches = $(div).html().match(regV).length;if (regP.exec($(div).html()) != null) matches += $(div).html().match(regP).length;return (matches > 1);}
function initConvos(div) {
prevuser = ''; $(div).find(".comment-body").each(function () {
checkWidth(this); preview = false; if (this.id == "comment-pvbody") { 
content = this; preview = true; } else var content = $("#commentcontents-" + (this.parentNode.id.split('-')[1])); if (!$(this).hasClass("convo")) {
this.raw = $(content).html(); if (($(content).children("em").length > 1) && multiQuote($(content))) {
$(content).children("em").each(function (i) {
if (regVideo.test($(this).outerHTML()) || regProfile.test($(this).outerHTML())) $(this).wrap("<div class='chunk' style='clear:both;overflow:auto;'></div>"); }); $(content).find(".chunk").each(function () {
makeConvo(this, 0); }); $(content).find(".chunk").eq(0).css('clear', 'none'); } else makeConvo(content, 0); if (!preview) $(this).addClass("convo"); }
});}
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>';}
function insertAtCursor(fld,str){
if (document.selection) {
fld.focus(); var sel = document.selection.createRange(); sel.text = str; }
else if (fld.selectionStart || fld.selectionStart == '0') {
var startPos = fld.selectionStart; var endPos = fld.selectionEnd; fld.value = fld.value.substring(0, startPos) +
str +
fld.value.substring(endPos, fld.value.length); }
else fld.value += str;}
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}); $(this.link).children("img").css({"filter":"alpha(opacity=100)"}); } else { 
$(this.link).css({"opacity":0.3}); $(this.link).children("img").css({"filter":"alpha(opacity=30)"}); }
}
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"); div.innerHTML+='<div class="box" style="text-align:center;padding:10px 0;"><a href="#" style="font-size:18px;" id="dyncommload-'+
link.vid+'">Load More Comments &#9660;</a></div>'+
'<div id="dyncommloadall-'+link.vid+
'" style="text-align:right;font-size:0.85em;"><a href="#">Load All Comments</a></div>'+
'<br/><br/>'; dynCommPrepare('post',link.vid, true); if (typeof urchinTracker == 'function') urchinTracker(link.vidurl); if (typeof _trackPageview == 'function') _trackPageview(link.vidurl); if (typeof prepThumbVoteLink == 'function') {
var prepComments = false; 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); }
}
}
$("#postlink-" + link.vid, $("#commentpopup-" + link.vid)).click(function() {
showInfoMsg("Loading..."); $.getJSON("/api.php?apikey=491f50292a3e79e0b651c132f257dc41&action=commentform&loctype=post&locid="+link.vid+"&return="+Url.encode(window.location.href)+"&callback=?", function(data){
showInfoMsg(); $(div).append(data.commentform); $(div).find("#postlink-"+link.vid).remove(); $(div).scrollTop($(div)[0].scrollHeight); $(div).find("#addcomment").css({width: '97%', margin: '0 auto'}); $(div).find("#commenttxtbox-"+link.vid).keyup(function() {
if ($(this).html != "") {
$(div).find("#comment-pv").fadeIn(); $(div).find("#comment-pvbody").html(parseHTML($(this).val())); initConvos($(div).find("#comment-pv")); } else $(div).find("#comment-pv").fadeOut(); }); }
); return false; }); }
else alert(xmlreply.getStringError());}
function prepCommentPop(l) {
l.vid=l.id.split('-')[1]; secondLink = $("#ext_info > span", $("#video-" + l.vid)).get(1); if (secondLink) {
$(secondLink).wrap('<a href="'+$(l).attr("href")+'"></a>'); $(secondLink).parent("a").click(function() {
$(l).click(); return false; }); } 
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 if (xr.getField('die')) window.location.reload(); 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 dynCommPrepare(loctype,locid,noform) {
var suff='-'+locid; var a=gebi('dyncommloadall'+suff); if (!a) {
suff=''; a=gebi('dyncommloadall'); }
if(!a) return; a.loadall=true; var b=gebi('dyncommload'+suff); b.loadall=false; var c=gebi('comments'+suff); var rq=new ajax.Request(); rq.loctype=loctype; rq.locid=locid; rq.all=a; rq.btn=b; rq.div=c; rq.dyncommpg=0; rq.noform=noform?1:0; rq.onComplete=function(txt,xml){
this.busy=false; showInfoMsg(); eval('var data='+txt); var div=this.div; $("#comments").add("#comments"+suff).append(data.listing); if(!this.stat){
div.dyncommfetched=0; div.dyncommttlcomm=data.comments; var d=document.createElement('div'); insertAfter(d,this.btn); this.stat=d; }
var c=data.comments?data.comments:div.dyncommttlcomm; div.dyncommfetched+=data.curcomments; this.stat.innerHTML='<small>showing '+div.dyncommfetched+' of '+c+'</small>'; if(this.loadall || div.dyncommfetched >= c) {
this.btn.style.display=this.all.style.display='none'; $(this.stat.parentNode).siblings("div[id*=comment-]").remove(); }
if (typeof prepThumbVoteLink == 'function') {
var ds=gebtn('div',div); for(var i=0;i<ds.length;++i){
var d=ds[i]; if(/^comment-[0-9]+$/.test(d.id)){
var cid=d.id.split('-')[1]; var cc=gebi('commentcontents-'+cid); var rx=/\.authorNick='([^']+)'/; if(rx.test(d.innerHTML)) cc.authorNick=RegExp.$1; if ($("#commentquote-"+cid).size() > 0) {
var cq=gebi('commentquote-'+cid); cq.cid=cid; cq.nick=RegExp.$1; cq.body=gebi('commentbody-'+cid).raw; cq.onclick=function(){quoteComment(this.cid,this.nick,this.body);}
}
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); }
}
}
initConvos(div); }
a.rq=b.rq=rq; a.onclick=b.onclick=function(){
var rq=this.rq; if (rq.busy){
alert('Still busy processing your request. Please wait...'); return false; }
rq.busy=true; showInfoMsg('Loading Comments...'); rq.loadall=this.loadall; rq.sendRequest('GET', '/api.php', 'apikey=491f50292a3e79e0b651c132f257dc41', 'action=loadcomments', 'output=json', 'loctype='+rq.loctype, 'locid='+rq.locid, 'loadall='+(this.loadall?1:0), 'pgnum='+(++rq.dyncommpg), 'uistyle='+window.uistyle, 'noform='+rq.noform, 'return='+location.href
); return false; }
if ($.browser.msie) $(document).ready(function () {b.onclick();}); else b.onclick();}function commentCallback(responseText, responseXML) {
showInfoMsg(); var form=this.form; busifyForm(form, false); form.contents.disabled = false; if (form.private) form.private.disabled = false; if (form.siftbot) form.siftbot.disabled = false; if (form.hidden) form.hidden.disabled = false; var xr = new ajaxml.Reply(); xr.process(responseXML); if (xr.didSucceed()) {
form.contents.value = ''; if (form.private) form.private.checked = false; if (form.siftbot) form.siftbot.checked = false; if (form.hidden) form.hidden.checked = false; var c = $("div[id*=comments]", form.parentNode.parentNode).get(0); $(c).siblings("#addcomment").children("#comment-pv").fadeOut(); var body=xr.getField('body'); if (/(profile|playlist)/.test(form.meth.value))c.innerHTML = xr.getField('body') + c.innerHTML; else if ($("div[id*=dyncommloadall]", c.parentNode).is(":visible")) {
cdyn = $("div[id*=dyncommloadall]", $(c.parentNode)).get(0); if ($(cdyn).next().hasClass("comment")) cdyn = $(cdyn).next(); $(body).insertAfter(cdyn); }
else $(c).append(body); var ds=gebtn('div',c); var cid=xr.getField('cid'); vid = form.key.value; if ($("#commentpopup-"+vid).size() > 0) $("#commentpopup-"+vid).scrollTo($("#comment-"+cid), 100); else top.location.href = '#comment-'+cid; initConvos($("#comment-"+cid)); if (fbperms=xr.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.'); }); return; }
setInnerById('comment_error', xr.getStringError());}
function submitComment(form) {
if (form.contents.value.trim() == '') {
alert('Your submission is incomplete.'); form.contents.focus(); return false; }
busifyForm(form, true); form.contents.disabled = true; if (form.private) form.private.disabled = true; if (form.siftbot) form.siftbot.disabled = true; if (form.hidden) form.hidden.disabled = true; showInfoMsg('Please wait...'); form.contents.changed = false; var rq = new ajax.Request(); rq.form = form; rq.onComplete = commentCallback; rq.sendRequest('POST', '/rs/comment.php', 'token=' + form.token.value, 'return=' + form['return'].value, 'contents=' + form.contents.value, 'meth=' + form.meth.value, 'key=' + form.key.value, 'ident=' + form.ident.value, 'private=' + (form.private ? (form.private.checked ? form.private.value : '') : ''), 'siftbot=' + (form.siftbot ? (form.siftbot.checked ? form.siftbot.value : '') : ''), 'hidden=' + (form.hidden ? (form.hidden.checked ? form.hidden.value : '') : ''), 'uistyle=' + window.uistyle, 'submit=submit'
); return false;}
var smiley_map = {
'\\^\\^' : 'smilecute', '\\^_\\^' : 'smilecute', '\\^\\.\\^' : 'smilecute', '\\^-\\^' : 'smilecute', '>:\\(' : 'angry', '>:\\)' : 'smileevil', '>:\\|' : 'blankevil', '<:\\|' : 'blanksoft', '<:o' : 'ohsoft', '<:O' : 'ohsoft', '<:s' : 'sicksoft', '<:S' : 'sicksoft', '<:\\)\\)' : 'smileopensoft', '<:\\)' : 'smilesoft', '<:D' : 'teethsoft', '<:P' : 'tonguesoft', '<:p' : 'tonguesoft', '<;p' : 'tonguewinksoft', '<;P' : 'tonguewinksoft', '<:\\(\\(' : 'whasoft', '<:\\(' : 'sad', '<:\\/' : 'oopssoft', '<:\\\\' : 'oopssoft', ':\\)\\)' : 'smileopen', ':\\)' : 'smile', ':\\(\\(' : 'wha', ':\\(' : 'frown', ':\\|' : 'blank', ':o' : 'oh', ':O' : 'oh', ':s' : 'sick', ':S' : 'sick', ':D' : 'teeth', ':P' : 'tongue', ':p' : 'tongue', ';P' : 'tonguewink', ';p' : 'tonguewink', ';\\)' : 'wink', ':\\\\' : 'oops', ':\\/' : 'oops'
};function parseHTML(html) {
html = html.replace(/<\s*br\s*\/?>/gi, '[{br /}]'); html = html.replace(/<a[^<>]*href=(['"])([^'"]*)\1[^<>]*>([^<>]*)<\/a>/gi, '[{a href="$2"}]$3[{/a}]'); html = html.replace(/<\s*(\/)?\s*(i|em|b|strong|blockquote|u|small|sup|sub|strike|s|ol|ul|li|code|kbd|tt)\s*>/gi, '[{$1$2}]'); for (var face in smiley_map) html = html.replace(eval('/(^|\\s|>|\\*)(' + face + ')/g'), '$1[{img src="/cdm/i/emoticon/' + smiley_map[face] + '.gif" /}]'); html = html.replace(/</g, '&lt;'); html = html.replace(/>/g, '&gt;'); html = html.replace(/\[\{/g, '<'); html = html.replace(/\}\]/g, '>'); html = html.replace(/\r\n/g, '<br />'); html = html.replace(/\n/g, '<br />'); html = html.replace(/\r/g, '<br />'); return html;}
function commentPreview() {
var c = document.forms['comment'].contents; if (!c.changed) { setTimeout('commentPreview()', 500); return; }
c.changed=false; if (c.value.trim()=='') { c.pv.style.display='none'; setTimeout('commentPreview()', 750); return; }
if (c.pv.style.display!='block') c.pv.style.display='block'; c.pvbody.innerHTML = parseHTML(c.value) + '<br /><br />'; $(c.pvbody).removeClass("convo"); initConvos(c.pvbody.parentNode); setTimeout('commentPreview()', 1000);}
function commentPopPreview(vid) {
f = $("form", $("#commentpop-" + vid)).get(0); var c = f.contents; if (!c.changed) { setTimeout('commentPopPreview('+vid+')', 500); return; }
c.changed=false; if (c.value.trim()=='') { c.pv.style.display='none'; setTimeout('commentPopPreview('+vid+')', 750); return; }
if (c.pv.style.display!='block') c.pv.style.display='block'; c.pvbody.innerHTML = parseHTML(c.value) + '<br /><br />'; $(c.pvbody).removeClass("convo"); initConvos(c.pvbody.parentNode); setTimeout('commentPopPreview('+vid+')', 1000);}
function commentformPrepare() {
var form = document.forms['comment']; if (!form) return; var c = form.contents; c.pv = gebi('comment-pv'); c.pvbody = gebi('comment-pvbody'); c.onchange = c.onkeyup = c.onkeydown = function() {
this.changed = true; }
if (c.value.trim()!='') c.changed = true; commentPreview();}
function commentdelCallback(responseText, responseXML) {
showInfoMsg(); this.link.busy = false; var xr = new ajaxml.Reply(); xr.process(responseXML); if (xr.didSucceed()) {
var div = gebi('comment-' + this.link.cid); if (div) div.parentNode.removeChild(div); }
else alert(xr.getStringError());}
function commentdelPrepare() {
var c = gebi('comments'); if (!c) return; var links = c.getElementsByTagName('a'); for (var i = 0; i < links.length; ++i) {
var link = links[i]; if (/^commentdel-[0-9]+$/.test(link.id)) {
var parts = link.id.split('-'); link.cid = parts[1]; link.onclick = function() {
if (this.busy) {
alert('Still busy processing your request. Please wait...'); return false; }
if (!confirm('Are you sure you want to delete this comment?')) return false; var vars = getHrefArr(this.href, 'commentdel'); var cid = vars[0]; vars = getQstrMap(this.href); var ret_url = vars['return']; if (this.cid != cid) return false; this.busy = true; showInfoMsg('Please wait...'); var rq = new ajax.Request(); rq.link = this; rq.onComplete = commentdelCallback; rq.sendRequest('GET', '/rs/commentdel.php', 'comment=' + cid, 'return=' + ret_url
); return false; }
}
}}
addLoadEvent(commentformPrepare);addLoadEvent(commentdelPrepare);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"); $("#ico_info-" + div.vidthumb.vid).remove(); $("#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"}); if ($.browser.msie) $("#vidthumb-" + div.vidthumb.vid).hide(); else $("#vidthumb-" + div.vidthumb.vid).fadeOut("def"); $("#linkbar-" + div.vidthumb.vid).children(".gallery_title").css({'height':'auto'}).prepend('<img class="fright" id="ico_info-'+div.vidthumb.vid+'" src="/cdm/ico/info.png">'); $("#ico_info-" + div.vidthumb.vid).css({'cursor':'pointer', 'padding':'0'}) .mouseenter(showGalleryPopup) .mouseleave(hideGalleryPopup); $(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"); $(ed).append('<div id="prevcontain-'+div.vidthumb.vid+'" style="overflow:hidden"></div>'); emb = document.getElementById("prevcontain-"+div.vidthumb.vid); emb.innerHTML = div.embedcode; $(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");}
