//fl1-50
var adminUser = 'WFTV';
var user = '';
var commentsList = "";
var ka_token = "ZAI9+G6LSQ3PE2+4cTwuqtLMHq/Wiqdh";
var orig_token = "ZAI9+G6LSQ3PE2+4cTwuqtLMHq/Wiqdh";
var ka_as = "6696";
var useAnchorJump =false;
var allowFavorite=false;
//search request: http://api.kickapps.com/rest/externalmedia/6696?t=ZAI9+G6LSQ3PE2+4cTwuqtLMHq/Wiqdh&url=http%3A%2F%2Fwww.wftv.com%2Fnews%2F19090082%2Fdetail.html
var ka_mediaId = "1234";
var alertBadLoginMsg = "Login Failed. If you previously signed up for Slantly, you will need to create a new profile for WFTV.com's community before leaving a comment.";
var timezoneAbbr ='EDT';
var timezoneOffset = -4;
var g_commentsJSON;
var firstRate = false;
if(typeof(st)=='undefined'){
st='';
}
if(typeof(tid)=='undefined'){
tid='';
}
if(typeof(uid)=='undefined'){
uid='';
}
if(typeof(isLogout)=='undefined'){
var isLogout=false;
}
function ka_checkKeyPress(e) {
if(window.event){
if(window.event.keyCode==13){
login();
}
} else {
if(e.which==13){
login();
}
}
return true;
}
function checkLoginSiteSide(theJson) {
if(theJson.status == "1"){
st = theJson.st;
tid = theJson.tid;
uid = theJson.userid;
token = theJson.token;
user = theJson.username;
email = theJson.email;
createCookie("6696username",user);
createCookie("6696loggedIn",st+","+tid+","+uid+","+token+","+email,1);
paintCommentAdd();
paintLoggedInBox();
manualCommentsRefresh(ka_token);
} else {
if (alertBadLoginMsg!=""){
alert(alertBadLoginMsg);
}
paintLoginBox(true);
manualCommentsRefresh(ka_token);
}
}
function ka_user_loggedInSiteSide(json){
if(json.isLoggedIn=="true"){
//alert("json is logged in:"+json.isLoggedIn);
var u = json.username;
var request = 'http://clientapps.kickapps.com/coxtv/login.php?u=' +u+'&p=SiteSide&remember_me=false&callback=checkLoginSiteSide&as=6696';
aObj = new JSONscriptRequest(request);
aObj.buildScriptTag();
aObj.addScriptTag();
} else {
manualCommentsRefresh(ka_token);
}
}
function isUserLoggedInKASide(){
aObj = new JSONscriptRequest("http://my.wftv.com/kickapps/service/isUserLoggedIn.kickAction?callback=ka_user_loggedInSiteSide");
aObj.buildScriptTag();
aObj.addScriptTag();
}
function refresh() {
//var sURL = unescape(window.location.pathname);
//window.location.replace( sURL );
if (useAnchorJump==true){
window.location.hash = "#COMMENTTOP";
}
window.location.reload(true);
}
function isFavorite(){
if (allowFavorite==true){
var username = readCookie('6696'+'username');
if (username == null || username == '') {
favoriteAdd = document.getElementById('ka_favorite_area');
favoriteAdd.innerHTML='Login to Favorite this article!';
} else {
aObj = new JSONscriptRequest('http://clientapps.kickapps.com/coxtv/favoriteCheck.php?url=http%3A%2F%2Fwww.wftv.com%2Fnews%2F19090082%2Fdetail.html&callback=isFavoriteMediaCheck&u='+username+'&as=6696' );
aObj.buildScriptTag();
aObj.addScriptTag();
}
}
}
function isFavoriteMediaCheck(theJson){
favoriteAdd = document.getElementById('ka_favorite_area');
favoriteAdd.innerHTML='';
if(theJson.status=="1"){
if (theJson.isFavorite=="1"){
favoriteAdd.innerHTML = 'One of your favorites!(click here to remove as a favorite)';
} else {
paintFavoriteAdd();
}
} else {
//error just assume not favorite
paintFavoriteAdd();
}
}
function writeContainer() {
var container = document.getElementById('comment_content_container');
container.innerHTML = '
WFTV.com
The following are comments from our users. This is not content created by WFTV.com. By posting your comments you agree to accept the Terms of Use
';
}
var pageSize = 5;
var currentAverage = 0;
var currentVotes = 0;
var commentAddHTML = '';
var favAddHTML = '';
var moderatedComments = false;
function paintCommentAdd() {
commentsAdd = document.getElementById('ka_orig_button');
commentsAdd.innerHTML = '';
if (readCookie('6696'+'username') == null || readCookie('6696'+'username') == '') {
commentAddHTML = '
';
commentsAdd.innerHTML=commentAddHTML;
}
}
function paintFavoriteAdd() {
favoriteAdd = document.getElementById('ka_favorite_area');
favoriteAdd.innerHTML='';
if (readCookie('6696'+'username') == null || readCookie('6696'+'username') == '') {
//Not logged in - not going to allow fav
favAddHTML = 'Login to Favorite this Article!';
} else {
favAddHTML = 'Add To Favorites';
}
favoriteAdd.innerHTML=favAddHTML;
}
var aObj;
function manualCommentsRefresh(localToken) {
var origURL = encodeURIComponent("http://api.kickapps.com/rest/externalmedia/6696?t="+ka_token+"&url=http%3A%2F%2Fwww.wftv.com%2Fnews%2F19090082%2Fdetail.html&callback=gotSocData");
aObj = new JSONscriptRequest("http://clientapps.kickapps.com/coxtv/fetchData.php?d="+origURL );
aObj.buildScriptTag();
aObj.addScriptTag();
}
function addedFavoriteArticle(json){
favoriteAdd = document.getElementById('ka_favorite_area');
favoriteAdd.innerHTML='';
if (json.status==1){
favoriteAdd.innerHTML = 'One of your favorites!(click here to remove as a favorite)';
} else {
favoriteAdd.innerHTML='Sorry unable to add to favorites at this time.';
}
}
function removedFavoriteArticle(json){
favoriteAdd = document.getElementById('ka_favorite_area');
favoriteAdd.innerHTML='';
if (json.status==1){
favoriteAdd.innerHTML='Add To Favorites';
} else {
favoriteAdd.innerHTML='Sorry unable to add to favorites at this time.';
}
}
function favoriteArticle(localToken){
aObj = new JSONscriptRequest("http://api.kickapps.com/rest/favorite/add/emedia/1234/6696?t="+localToken+"&callback=addedFavoriteArticle&url=http%3A%2F%2Fwww.wftv.com%2Fnews%2F19090082%2Fdetail.html" );
aObj.buildScriptTag();
aObj.addScriptTag();
//setTimeout("refresh()", 1000);
}
function removeFavoriteArticle(localToken){
aObj = new JSONscriptRequest("http://api.kickapps.com/rest/favorite/remove/emedia/1234/6696?t="+localToken+"&callback=removedFavoriteArticle&url=http%3A%2F%2Fwww.wftv.com%2Fnews%2F19090082%2Fdetail.html" );
aObj.buildScriptTag();
aObj.addScriptTag();
//setTimeout("refresh()", 1000);
}
function paintLoggedInBox() {
loginHTML = "You are logged in as " + user + "logout";
document.getElementById('ka_login').innerHTML = loginHTML;
}
function paintLoginBox(isAfterFailure) {
if (isAfterFailure == false) {
loginHTML = "Register or log in here: ";
} else {
loginHTML = "Login failed, try again or register: ";
}
document.getElementById('ka_login').innerHTML = loginHTML;
}
function gotToken(json) {
if (json.token == ""|| typeof(json.token)=='undefined') {
if (alertBadLoginMsg!=""){
alert(alertBadLoginMsg);
}
paintLoginBox(true);
} else {
st = json.st;
tid = json.tid;
uid = json.userid;
token = json.token;
//alert("values:"+st+","+tid+","+uid+","+token);
createCookie("6696loggedIn",st+","+tid+","+uid+","+token,1);
//ka_token = json.token;
createCookie('6696'+'username', user, 7);
paintCommentAdd();
paintLoggedInBox();
manualCommentsRefresh(ka_token);
}
}
//Aug 1 2008 02:44:00 GMT
function parseDateGMT(timeobj){
var timesplit = timeobj.split(" ");
var date = timesplit[0];
var month = timesplit[1];
var year = timesplit[2];
var hhmm = timesplit[3];
var hours = timesplit[3].split(":");
var hh = hours[0];
var mm = hours[1];
var ss = hours[2];
var TimezoneOffset = -3; // adjust for time zone
var timetime = month+" "+date+", "+year+" "+hh+":"+mm+":"+ss+ " GMT";
var localTime = new Date(timetime);
var offset = (localTime.getTimezoneOffset()+(timezoneOffset*60))*60000;
var timeInMillis = localTime.getTime()+offset;
localTime.setTime(timeInMillis);
return localTime;
}
function GetMonth(intMonth){
var MonthArray = ["Jan", "Feb", "Mar","Apr", "May", "Jun","Jul", "Aug", "Sep","Oct", "Nov", "Dec"];
return MonthArray[intMonth];
}
function get_month(timeobj){
var localTime = parseDateGMT(timeobj);
var time = localTime;
var curTime = GetMonth(time.getMonth());
return curTime;
}
function get_year(timeobj){
var localTime = parseDateGMT(timeobj);
var time = localTime;
var curTime = time.getFullYear();
return curTime;
}
function get_day(timeobj){
var localTime = parseDateGMT(timeobj);
var time = localTime;
var date = time.getDate();
return date;
}
function get_time(timeobj){
var localTime = parseDateGMT(timeobj);
var time = localTime;
var hour = time.getHours() ;
var minute = time.getMinutes();
var secs = time.getSeconds();
var curTime = ((hour > 12) ? hour - 12 : hour);
if(hour==0) {
curTime = "12";
}
curTime += ((minute < 10) ? ":0" : ":") + minute;
//curTime += ((secs < 10) ? ":0" : ":") + secs;
curTime += (hour >= 12) ? "pm" : "am";
return curTime;
}
function paginationBarNew(pageNum) {
var bar = "";
var numPages = g_commentsJSON.length / pageSize;
var remainder = g_commentsJSON.length % pageSize;
numPages = (g_commentsJSON.length-remainder)/pageSize;
if (remainder > 0) {
numPages++;
}
if (numPages==1){
} else {
var max = numPages-1;
var currentPlus = pageNum+3;
if (currentPlus > (numPages-1)){
currentPlus = numPages-1;
}
var startPage = pageNum-1;
if (startPage < 0){
startPage=pageNum;
//currentPlus++;
}
if (currentPlus==(numPages-1)){
if (numPages>5){
startPage = numPages-5;
}
}
if (pageNum!=0){
bar = bar + '«';
}
if (pageNum>1){
bar = bar + '1…';
}
for (var i = startPage ; i <= currentPlus; i++) {
if (i==pageNum){
if (i>=currentPlus){
bar = bar + '' + (i+1) + '';
}else {
bar = bar + '' + (i+1) + '';
}
} else {
if (i>=currentPlus){
bar = bar + '' + (i+1) + '';
} else {
bar = bar + '' + (i+1) + '';
}
}
}
if (currentPlus<= (numPages-2)){
indexPage = numPages-1;
bar = bar + '…' + numPages + '';
}
if (max>pageNum){
bar = bar + '»';
}
}
return bar;
}
function paginationBar(pageNum) {
var bar = "";
var numPages = g_commentsJSON.length / pageSize;
var remainder = g_commentsJSON.length % pageSize;
numPages = (g_commentsJSON.length-remainder)/pageSize;
if (remainder > 0) {
numPages++;
}
for (var i = 0 ; i <= numPages - 1; i++) {
var stuff = numPages-1;
if (i==0 && pageNum!=0){
bar = bar + '«';
}
if (i==pageNum){
if (i>=stuff){
bar = bar + '' + (i+1) + '';
}else {
bar = bar + '' + (i+1) + '';
}
} else {
if (i>=stuff){
bar = bar + '' + (i+1) + '';
} else {
bar = bar + '' + (i+1) + '';
}
}
if (i>=stuff&&stuff>pageNum){
bar = bar + '»';
}
}
return bar;
}
firstRate = false;
function refreshCommentsWithPage(pageNum) {
var myLoggedInKey = readCookie("6696loggedIn");
if(myLoggedInKey!==''&&myLoggedInKey!==null){
var keyArr = myLoggedInKey.split(",");
st = keyArr[0];
tid=keyArr[1];
token = keyArr[3];
} else {
token = '';
}
commentsJSON = g_commentsJSON;
var newComments = "
";
if (pageNum == null) {
pageNum = 0;
}
var numPerPage = pageSize;
for (var i = (numPerPage * pageNum); (i < commentsJSON.length && i < (numPerPage * pageNum + numPerPage)); i++) {
newComments +='