var jq = jQuery.noConflict();
/* IN HOUSE PLUGINS BELOW -- consult MH for usage details */
/* 
||plugin template||
(function($){
jq.fn.nameOfYourPlugin = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'someSetting' : true
}, settings);
// methods and routines here
};
})(jQuery);
*/
/* declare GLOBAL JS VARS here */
/* TCM NAMESPACE vars should begin with "t_" */
var t_tcmhost = window.location.host, 
t_tcmhosthref = "http://"+t_tcmhost,
t_apv_iframeviewer = false;
jq(document).ready( function() { // GLOBAL EVENT LISTENERS
initShoppingSearchListen();	
if (jq.fn.isDevice() === true) { // check for devices and do device routines
jq.fn.deviceDetect();
}
jq(".dvdimg p, p.dvdinfo").find("br").remove(); // cleaning up input html
/* ARCHIVE IMG VIEWER */	
jq(".btn-tcmarch").click(function(e){ // imgs on the title pages "TCMDb Archive Materials" 
e.preventDefault();
var btnid = jq(this).attr('id');
var archivecontentId = btnid.replace(/[^0-9]/g,"");
jq("#archive-overlay-wrap").remove();	
jq("<div id='archive-overlay-wrap'></div>").appendTo("body");	
jq('#archive-overlay-wrap').load('/structure/archive-viewer.html?contentId='+archivecontentId, function() {
jq("#ephoto").photoViewerInit({ "jsonFeed" : "/json/archive.html?id="+archivecontentId});
});	
});
/* APV OVERLAY AUTO LOADER */
//http://localhost.tcm.com:8080/#tcmarcp-100001
var lhash = location.hash;
if(lhash.length > 0) { // is there a hash?
var arcp = lhash.split("-"); 
if(arcp[0] === '#tcmarcp' && arcp[1] > 0 && !arcp[2]) { // archive photo hash check.. load APV 
jq("<div id='archive-overlay-wrap'></div>").appendTo("body");	
jq('#archive-overlay-wrap').load('/structure/archive-viewer.html?contentId='+arcp[1], function() {
jq("#ephoto").photoViewerInit({ "jsonFeed" : "/json/archive.html?id="+arcp[1]});
});	
}
if(arcp[0] === '#tcmarcp' && arcp[1] > 0 && arcp[2] > 0 ) { // archive photo hash check, for subcontent deeplinking.. load APV 
jq("<div id='archive-overlay-wrap'></div>").appendTo("body");	
jq('#archive-overlay-wrap').load('/structure/archive-viewer.html?contentId='+arcp[1]+'&'+arcp[2], function() {
jq("#ephoto").photoViewerInit({ "jsonFeed" : "/json/archive.html?id="+arcp[1] , "deepLinkID" : arcp[2] });
});	
}
}
/* timezone */
var theLocation = jq.cookie("nationCookie");
var natLinker;
if (theLocation == 'ca'){
natLinker = 'http://www.tcm.com/schedule/canada/monthly.html';
jq('#mSchdlLink').attr('href', natLinker);
}else if (theLocation == 'us') {
natLinker = 'http://www.tcm.com/schedule/monthly.html';
jq('#mSchdlLink').attr('href', natLinker);
}else{
natLinker = 'http://www.tcm.com//schedule/monthly.html';
jq('#mSchdlLink').attr('href', natLinker);
}	
});
/* SITE WIDE EVENT LISTENERS - define function below, add function to the document ready above */
function initShoppingSearchListen() { // nav - shopping listeners
jq('#tcmdbinpt').click(function(){
var preInput = jq('#tcmdbSearchInput').val();
var inputval = removeAccents(preInput);
jq('#tcmdbLogo').removeClass('shopsearch sitesearch');
jq('#tcmdbLogo').addClass('tcmdbsearch');
jq('#tcmdbSearchInput').removeClass('siteindent shopindent');
jq('#tcmdbSearchInput').addClass('tcmdbindent');
jq("#tcmsearchfrm").attr('action' , t_tcmhosthref+'/search/index.html');
jq("#tcmdbSearchInput").attr('name' , 'text');
if(inputval.length <= 0 && jq.browser.msie === true){ // IE8 cursor placementfix
jq('#tcmdbSearchInput').val("internet exploder 8 yeah!");
jq('#tcmdbSearchInput').focus();	
}	
jq('#tcmdbSearchInput').val(inputval);
});
jq('#siteinpt').click(function(){
var preInput = jq('#tcmdbSearchInput').val();
var inputval = removeAccents(preInput);
jq('#tcmdbLogo').removeClass('shopsearch tcmdbsearch');
jq('#tcmdbLogo').addClass('sitesearch');
jq('#tcmdbSearchInput').removeClass('tcmdbindent shopindent');
jq('#tcmdbSearchInput').addClass('siteindent');
jq("#tcmsearchfrm").attr('action' , t_tcmhosthref+'/search/index.html');
jq("#tcmdbSearchInput").attr('name' , 'text');
if(inputval.length <= 0 && jq.browser.msie === true){ // IE8 cursor placementfix
jq('#tcmdbSearchInput').val("internet exploder 8 yeah!");
jq('#tcmdbSearchInput').focus();	
}
jq('#tcmdbSearchInput').val(inputval);
});
jq('#shopinpt').click(function(){
var preInput = jq('#tcmdbSearchInput').val();
var inputval = removeAccents(preInput);
jq('#tcmdbLogo').removeClass('tcmdbsearch sitesearch');
jq('#tcmdbLogo').addClass('shopsearch');
jq('#tcmdbSearchInput').removeClass('siteindent tcmdbindent');
jq('#tcmdbSearchInput').addClass('shopindent');
jq("#tcmsearchfrm").attr('action' , 'http://tcm.resultspage.com/search?v=tcm&asug=&w='+inputval); // do the swap for shop searches
jq("#tcmdbSearchInput").attr('name' , 'w');
if(inputval.length <= 0 && jq.browser.msie === true){ // IE8 cursor placementfix
jq('#tcmdbSearchInput').val("internet exploder 8 yeah!");
jq('#tcmdbSearchInput').focus();	
}
jq('#tcmdbSearchInput').val(inputval);
});
jq('#tcmdbSearchButton').click(function(e){
e.preventDefault();
var preInput = jq('#tcmdbSearchInput').val();
var searchterm = removeAccents(preInput);
jq('#tcmdbSearchInput').val(searchterm);
if (searchterm != "" && searchterm.length > 0) {
jq("#tcmsearchfrm").submit();	
}
});
}
/* determines if device is not a desktop/laptop */
(function($){
jq.fn.isDevice = function() {
var platformtype = navigator.platform;
platformtype = platformtype.toLowerCase();
var matched = platformtype.match("ipad");	
if( jq.browser.mobile === true || matched == "ipad" || (navigator.userAgent.indexOf('Android') != -1) === true ){ // allmobile, android+tablets or ipad
return true;
} else {
return false;
}
};
})(jQuery);
/* detects all mobiles.. then specifically android and ipad, add more if req */
(function($){
jq.fn.deviceDetect = function() { 
var platformtype = navigator.platform;
platformtype = platformtype.toLowerCase();
var matched = platformtype.match("ipad");
if( jq.fn.isDevice() === true ){ // allmobile, android+tablets or ipad
var updateForDevice = function(devicetype) { // apply per device type add new case for specifics
switch(devicetype) {
case 'all':
$('head').append( $('<link rel="stylesheet" type="text/css" />').attr('href', 'http://i.cdn.turner.com/tegwebapps/tcm/tcm-www-2010/css/devices/all.css') );
jq('body').addClass('noflash');
jq("#morlock").remove();
break;
default:
}
}
if (matched == "ipad") { // ipad detect
updateForDevice('all');
} 
if ( (navigator.userAgent.indexOf('Android') != -1) ) { // android detect
updateForDevice('all');
}
if(jq.browser.mobile) { // detect all mobile devices
updateForDevice('all');
}
};
};
})(jQuery);
/* tcm HPT non-flash plugin */
(function($){
$.fn.noflashHPT = function(settings) {
var config = $.extend({ 
'element' : $(this),
'imgdirectory' : 'http://i.cdn.turner.com/v5cache/TCM/images/redesign/homepage/2011/images/noflashimgs',
'categories' : [
{ 'name' : 'Cival War', 'url' : 'http://www.tcm.com' , 'images' : [ 'civilwar-v1-1.jpg','civilwar-v1-2.jpg','civilwar-v1-3.jpg','civilwar-v1-4.jpg','civilwar-v1-5.jpg' ]}	
],
'showDelay' : 8000, // delay before changing the img
'fadeSpeed' : 1386, // animation speed for img fadein
'categorySpeed' : 1486 // animation speed for category
}, settings);
$("#flashContainer").css({ 'background-image' : 'none'});
$.fn.HPTinitContainer(config); // init the plugin	
};
$.fn.HPTinitContainer = function(settings) { /* build html */
var config = settings;
var len = config.categories.length, a=0, hpthtml = [];
hpthtml[a++] = '<div id="hptcont" class="doff">'; // html container
for (i=0; i<len; i++) { // build the html
var name = config.categories[i].name;
var url = config.categories[i].url;
var imglen = config.categories[i].images.length;
var hidden = (i != 0) ? 'doff' : ''; // if not the first category, hide it
hpthtml[a++] = '<div id="hptcat'+i+'" class="'+hidden+' hptcat"><a href="'+url+'">'; // category container and link
for (n=0;n<imglen;n++){
var imgsrc = config.categories[i].images[n];
//hpthtml[a++] = '<img src="'+config.imgdirectory+'/'+imgsrc+'" width="986" height="327" alt="" />';
hpthtml[a++] = '<img src="'+imgsrc+'" width="986" height="327" alt="" />';
//var firstimgsrc = (i === 0 && n === 0) ? config.imgdirectory+'/'+imgsrc : ''; // if first image then apply it to the html, rest just build the img html without src
//hpthtml[a++] = '<img src="'+firstimgsrc+'" width="986" height="327" alt="" />';
}
hpthtml[a++] = '</a></div>'; // close/hptcat#
}
hpthtml[a++] = '</div>'; // close/hptcont
var hpthtml = hpthtml.join('');
$("#flashContainer").html(hpthtml); // apply html to page
$.fn.HPTstartIt(config); 
};
$.fn.HPTstartIt = function(settings) { /* begin the animation */
var config = settings;
config.element.find("img").css({'opacity' : 0});
$("#hptcont").removeClass('doff');
var currentcat = config.element.find('.hptcat').eq(0);
var firstimg = config.element.find("#hptcat0").find("img").eq(0);
$.fn.HPTanimateCategory( config, currentcat);
$.fn.HPTanimateImage(config, firstimg);
$.fn.HPTcycleNext(config);	
};
$.fn.HPTcycleNext = function(settings) { /* animation cycler */
var config = settings;
var currentcat = config.element.find(".cimg").parent().parent();
currentcat.delayit(config.showDelay, "hptcycle", function() {
var currentimg = currentcat.find('.cimg');
var nextimg = currentimg.next();
if(nextimg.attr('src')){ // get next img if it exists
currentimg.removeClass('cimg');
$.fn.HPTanimateImage(config, nextimg);
$.fn.HPTcycleNext(config);
} else { // else if its the last img in category
nextcat = currentcat.next();
if(nextcat.hasClass('hptcat') === true) { // next category
currentcat.addClass('doff'); // turn off old category
nextcat.removeClass('doff');
config.element.find(".hptcat img").removeClass('cimg');
var nextimg = nextcat.find('img').eq(0).addClass('cimg');
$.fn.HPTanimateImage(config, nextimg);
$.fn.HPTanimateCategory(config, nextcat);
$.fn.HPTcycleNext(config);
} else { // if last category then start at the first category
config.element.find("img").css({'opacity' : 0});
$(".hptcat:last-child").addClass('doff');
var firstcat = $(".hptcat:first-child");
firstcat.removeClass('doff');
var firstimg = config.element.find("#hptcat0").find("img").eq(0);
config.element.find(".hptcat img").removeClass('cimg');
$.fn.HPTanimateImage(config, firstimg);
$.fn.HPTanimateCategory(config, firstcat);	
$.fn.HPTcycleNext(config);	
}
}
});
};
$.fn.HPTanimateImage = function(settings , nextimg) { // animated the img
var config = settings;
nextimg.css({ "display" : "block"}).animate({ "opacity" : 1 }, config.fadeSpeed).addClass('cimg');
};
$.fn.HPTanimateCategory = function(settings , currentcat) { // animated the category change
var config = settings;
var animatedSelections = [ 'slideup', 'slidedown','slideleft', 'slideright' ];
var len = animatedSelections.length;
var randomnum = Math.floor(Math.random()*len); // random animation switcher #
var animateTheCategory = function(field) { 
switch(field) {
case 'slidedown':
currentcat.css({ "bottom" : "-327px" , "left" : 0 });
currentcat.animate({ "bottom" : 0 }, config.categorySpeed);
break;
case 'slideup':
currentcat.css({ "top" : "-327px" , "left" : 0 });
currentcat.animate({ "top" : 0 }, config.categorySpeed);
break;
case 'slideleft':
currentcat.css({ "left" : "-986px" , "top" : 0 });
currentcat.animate({ "left" : 0 }, config.categorySpeed);
break;
case 'slideright':
currentcat.css({ "right" : "-986px" , "top" : 0 });
currentcat.animate({ "right" : 0 }, config.categorySpeed);
break;
default:
currentcat.css({ "bottom" : "-327px" , "left" : 0 });
currentcat.animate({ "bottom" : 0 }, config.categorySpeed);
}
}
currentcat.removeAttr("style");
animateTheCategory(animatedSelections[randomnum]);
};
})(jQuery);
/* tcm header image slider */
(function($){
$.fn.startTcmPortraits = function(settings) {
var config = $.extend({ 
'element' : $(this),
/* list your images to cycle here */
'images' : [ 'http://i.cdn.turner.com/v5cache/TCM/images/redesign/nav/logo1-1.png',
'http://i.cdn.turner.com/tegwebapps/tcm/tcm-www/static/images/logo2.png',
'http://i.cdn.turner.com/v5cache/TCM/images/redesign/nav/logo3-1.png',
'http://i.cdn.turner.com/v5cache/TCM/images/redesign/nav/logo4-1.png',
'http://i.cdn.turner.com/tegwebapps/tcm/tcm-www/static/images/logo5.png',
'http://i.cdn.turner.com/v5cache/TCM/images/redesign/nav/logo6-1.png'
],
'showDelay' : 8000,
'hideDelay' : 7777,
'firstImage' : false,
'lastImage' : false,
'focusoff' : false
}, settings);
var len = config.images.length;
var imageshtml = [], a=0; 
for (i=0; i<len; i++) { // build the images html 
imageshtml[a++] = "<img src='"+config.images[i]+"' id='cfpt"+i+"' alt='' />";
}
var imageshtml = imageshtml.join('');
$("#tcm-homepage-link").html(imageshtml); // add images html to dom
$.fn.slideNextPortrait(config); // start the animation
};
$.fn.slideNextPortrait = function(settings) {
var config = settings,
len = config.images.length,
wfocus = true;
$("#tcm-homepage-link img").eq(0).addClass('cfpt'); // initing the first image
$(".cfpt").animate({ "bottom" : "0" });
$(".cfpt").delayit(config.hideDelay, "hideportrait", function() { // hide it after delay
$(".cfpt").animate({ "bottom" : "-65" });
});
/* stop animation when focus is lost on tab/window + restart when focus is back */
if (/*@cc_on!@*/false) { // for IE
document.onfocusin = function(){
wfocus = true;
$("#tcm-homepage-link img").css({ "bottom" : "-65" }).removeClass("cfpt");
cyclePortrait();
}
document.onfocusout = function(){
wfocus = false;
$("#tcm-homepage-link img").css({ "bottom" : "-65" }).removeClass("cfpt");
window.clearTimeout(timer_portrait);
}
} else { // all others
window.onfocus = function(){
wfocus = true;
$("#tcm-homepage-link img").css({ "bottom" : "-65" }).removeClass("cfpt");
cyclePortrait();
}
window.onblur = function(){
wfocus = false;
$("#tcm-homepage-link img").css({ "bottom" : "-65" }).removeClass("cfpt");
window.clearTimeout(timer_portrait);
}
}
var cyclePortrait = function() {
if (wfocus === true) {
config.element.delayit(config.showDelay, "portrait", function() { 
var curcfpt = $(".cfpt").attr('id');
curcfpt = curcfpt.replace(/[^0-9]/g,"");
var lastcheck = Number(curcfpt) + 1;
if (curcfpt === '0' && config.firstImage === true) { // if the first image
$("#cfpt0").animate({ "bottom" : "0" });
config.firstImage = false;
} else if (lastcheck >= len){ // if its last image in set
var nextcfpt = 0;
$('img').removeClass('cfpt');
$("#cfpt"+nextcfpt).addClass('cfpt');
$(".cfpt").animate({ "bottom" : "0" });
} else { // if not first or not last then get animate next image
var nextcfpt = Number(curcfpt) + 1;
$('img').removeClass('cfpt');
$("#cfpt"+nextcfpt).addClass('cfpt');
$(".cfpt").animate({ "bottom" : "0" });
}
cyclePortrait(); // load/reload animation
$(".cfpt").delayit(config.hideDelay, "hideport", function() { // hide it after delay
$(".cfpt").animate({ "bottom" : "-65" });
});
});
}	
};
cyclePortrait(); // starts the cycle process for first time
};
})(jQuery);
/* accordian menu / used on homepage ...*/
jq.fn.menuAccord = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'cElements' : jq(this).children(),
'headerElement' : jq(this).children().eq(0),
'contentElement' : jq(this).children().eq(1),
'headerClass' : jq(this).children().eq(0).attr('class'),
'contentClass' : jq(this).children().eq(1).attr('class'),
'firstClass' : 'num1',
'lastClass' : 'last1'
}, settings);
config.headerElement.addClass(config.firstClass);
config.cElements.filter(":last-child").addClass(config.lastClass);
config.element.find('.'+config.headerClass).live('click', function(e){
e.preventDefault();
var element = jq(this);
jq("."+config.headerClass).slideDown('normal');
element.slideUp('normal');
jq("."+config.contentClass).slideUp('normal');
if(element.next().is(':hidden') == true) {
element.next().slideDown('normal');
}
});
};
/* search results shopping fetcher */
(function(jq){
jq.fn.getShoppingSearch = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'someSetting' : true
}, settings);
config.element.each(function(){ // go and gets shopping matches for search result ids
var element = jq(this);
var titleid = element.attr('id');
titleid = titleid.replace(/[^0-9]/g,""); // titleid#
if (titleid.length > 1) {
var jsonurl = '/json/shop/shop.html?id='+titleid;
jq.getJSON(jsonurl, function(data) { 
jsondata = data;
if (jsondata.mu.item[0].sku.length > 1) { // we got one! 
var title = jsondata.mu.item[0].title;
var listprice = jsondata.mu.item[0].listprice;
var boxcoverurl = jsondata.mu.item[0].boxcoverurl;
var centerinfo = jsondata.mu.item[0].centerinfo;
var boxcoverurl = jsondata.mu.item[0].boxcoverurl;
var producturl = jsondata.mu.item[0].producturl;
if(centerinfo == "undefined" || centerinfo == undefined) {
centerinfo = "";
}
var html = '<img src="'+boxcoverurl+'" width="60" height="86" alt="'+title+' DVD Cover" /><p><strong>'+title+'</strong><br/><span class="sale"><strong>'+listprice+'</strong></span><br/>'+centerinfo+'<br/><a href="'+producturl+'" class="btn-ordernow" title="Order Now">Order Now</a></p>';
jq("#srshop"+titleid+" .pad8").html(html); // put the shopping html on its slot
};
});
}
});
};
})(jq);
/* center div on page */
(function($){ /* stopped working somehow */ 
$.fn.centerIt = function() {
var element = $(this);
var vertOffset = ($("body").scrollTop()) ? $("body").scrollTop() : $("html").scrollTop();
var vheight = document.documentElement["scrollHeight"];
var divHeight = element.height();
var divTop = ($(window).height() - element.outerHeight())/2
var left = ($(window).width() - element.outerWidth()) / 2;
element.css({position:'absolute', margin:0, top: (divTop > 0 ? divTop : 0)+'px', left: (left > 0 ? left : 0)+'px'});
}; 
})(jQuery);
/* center div on page - working */
(function($){ 
$.fn.centerThis = function () {
this.css("position","absolute");
this.css({"top" : ( jq(window).height() - this.height() ) / 2+jq(window).scrollTop() + "px" , "left" : ( jq(window).width() - this.width() ) / 2+jq(window).scrollLeft() + "px"});
return this;
};
})(jQuery);
/* finish out pages for IE browsers */
(function(jq){
jq.fn.oddRows = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'className' : 'oddrow'
}, settings);
if(jq.browser.msie) {
config.element.filter(":odd").addClass(config.className);
};
};
})(jQuery);
/* schedule reminder overlay */
(function(jq){
jq.fn.scheduleReminder = function(element) {
var element = element;
var btnclass = element.attr('class');
var movieid = btnclass.replace(/[^0-9]/g,"");
jq("<div class='img-v-wrap'></div>").appendTo("body");	
jq("<div id='reminder_overlay'></div>").appendTo("body");	
jq('#reminder_overlay').load('/structure/reminder.html?id='+movieid, function() {
var vheight = document.documentElement["scrollHeight"];
jq(".img-v-wrap").height(vheight);
jq(this).centerIt();
});	
};
})(jQuery);
/* tcmdb photo archives feature module */
(function(jq){
jq.fn.archivePhotoFeature = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'jsonfeed' : '/json/archives/archive-latest.html'
}, settings);
jq.getJSON(config.jsonfeed, function(data) {
jsondata = data;
if( jsondata.tcm.archives[0].images.length > 0){ // if there are archives
//for ( n in jsondata.tcm.archives[0]) {
var img = jsondata.tcm.archives[0].images[0].thumbnails[0].url;
var title = jsondata.tcm.archives[0].title;
var description = jsondata.tcm.archives[0].description;
var publishdate = jsondata.tcm.archives[0].publishDate;
var contentId = jsondata.tcm.archives[0].contentId;
var category = jsondata.tcm.archives[0].category;
category = category.replace("_" , " ");
//category = category.toUpperCase();
//var contributor = jsondata.tcm.archives[0].description; .. dont know path 
jq("#dbartsrc").attr('id' , 'dbartsrc'+contentId); // unique id now for APViewer
jq(".btn-viewarchive").attr('id' , 'btndbt'+contentId); // unique id now for APViewer
jq("#dbarttl").html(title);	
jq("#dbardsc").html(description);	
jq(".tcmdb-archive-pub").html(category);	
jq("#dbarpbdt").html(publishdate);
//jq("#dbarttl").html(contributor);
jq('#dbartsrc'+contentId).css({'backgroundImage' : "url("+img+")" , 'backgroundPosition' : 'center center' });
//}
} 
});
// methods and routines here
};
})(jq);
/* Self-aware Content Expander 
/*
usage:init with btn class name as selector jq('.your-btn-class').expander(); You can use same classname for multiple btns to simplify js call	
usage:add a class to your btn html with the class name that will surround your expandable boxes, and append "_ref" to classname on btn 
html ex: <a href="#" class="btn-expand bsynopsis_ref">button</a>	
<p class="bsynopsis">Content 1</p>	
<p class="bsynopsis" style="display:none">Content 2</p> 
*/
jq.fn.expander = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'expandedClass' : 'expanded', // classname that is added to btn when its activated, and removed on subsequent minimize
'btnClass' : 'btn-expand', // classname for your button that will activate expanding
'boxRef' : '_ref', // classname that is appended to your btn and content containers class ref(see html example)
'addedClass' : '' // if you have added another classname to your button
}, settings);
config.element.each(function(){ // hides empty cast and crew divs
var classnames = jq(this).attr('class');
var ref = classnames.replace(config.btnClass,'').replace(config.expandedClass,'').replace(config.addedClass,'').replace(config.boxRef,'');
ref = jq.trim(ref);
var html = jq("."+ref).html();
if (html.length < 2){
jq("."+ref).prev().remove();
jq("."+ref).prev().remove();
jq("."+ref+", ."+ref+"_ref").remove();
}
});
config.element.live('click', function(e) { 
e.preventDefault();
config.element = jq(this);
var classnames = jq(this).attr('class');
var ref = classnames.replace(config.btnClass,'').replace(config.expandedClass,'').replace(config.addedClass,'').replace(config.boxRef,''); // finding classnames set
ref = jq.trim(ref);
if (config.element.hasClass('expanded')) { 
var html = config.element.html();
html = html.replace('CLOSE','READ').replace('CLOSE','READ');
config.element.html(html);
} else { 
var html = config.element.html();
html = html.replace('READ','CLOSE').replace('SEE','CLOSE');
config.element.html(html);
}
jq("."+ref).each(function () {
if( jq(this).is(':visible') ) {
jq(this).hide();
} else if ( jq(this).not(':visible') ) {
jq(this).slideDown('slow');
config.element.toggleClass(config.expandedClass);
}
});
});
};
/* Credits content expander -
/* version 0.99 */
jq.fn.creditsexpander = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'expandedClass' : 'expanded', // classname that is added to btn when its activated, and removed on subsequent minimize
'btnClass' : 'btn-expand-credits', // classname for your button that will activate expanding
'addedClass' : '' // if you have added another classname to your button
}, settings);
config.element.live('click', function(e) { 
e.preventDefault();
config.element = jq(this);
var classnames = jq(this).attr('class');
var ref = classnames.replace(config.btnClass,'').replace(config.expandedClass,'').replace(config.addedClass,'').replace(config.boxRef,'');
if (config.element.hasClass('expanded')) { 
var html = config.element.html();
html = html.replace('CLOSE','READ').replace('CLOSE','READ');
config.element.html(html);
} else { 
var html = config.element.html();
html = html.replace('READ','CLOSE').replace('SEE','CLOSE');
config.element.html(html);
}
ref = jq.trim(ref);
jq("."+ref).each(function () {
if( jq(this).is(':visible') ) {
jq(this).hide();
} else if ( jq(this).not(':visible') ) {
jq(this).slideDown('slow');
config.element.toggleClass(config.expandedClass);
}
});
});
};
/* Auto Font Resizer - jq Plugin by SA 
Plugin usage info
version 0.99 
*/
jq.fn.fontresizer = function(settings) { 
var config = jq.extend({
/* configurable properties*/
'fontSizeMin' : 12, /* lowest font size allowed */
'resizeDeg' : 1.0, /* rate at which the font is resized until width match is found. Too low of a value can degrade performance */
'resizeMethodSpeed' : 500, /* animation speed */
'constraintWidth' : 748, /* override to fix width calulaction variables */ 
'offSetWidth' : '', /* offset your width calculation with a defined num */
'resizeMethod' : '', /* 'animate' or '' default */
/* properties set by application */
'element' : jq(this),
'elementRef' : '',
'text' : '',
'fontSizeMax' : '',
'textTransform' : '',
'fontWeight' : '',
'letterSpacing' : '',
'fontFamily' : '',
'resizerSpan' : '',
'resizerSpanWidth' : '',
'currentFontSize' : '',
/* application methods */
'getSpanWidth' : function() { config.resizerSpanWidth = config.resizerSpan.width(); },
'getStyles' : function(){ 
config.textTransform = config.elementRef.css('text-transform');
config.fontWeight = config.elementRef.css('font-weight');
config.letterSpacing = config.elementRef.css('letter-spacing');
config.fontSizeMax = config.elementRef.css('font-size');
config.fontFamily = config.elementRef.css('font-family');
},
'resizeFont' : function() { 
switch(config.resizeMethod) { 
case 'animate' :
config.elementRef.animate({ 'font-size' : config.newFontSize, 'line-height' : config.newLineHeight+"px" }, config.resizeMethodSpeed);
break;
case 'default' :
config.elementRef.css({ 'font-size' : config.newFontSize, 'line-height' : config.newLineHeight+"px" });
break;
default :
if (config.newFontSize < 74) { // limit the line height for design aesthetics
config.newLineHeight = 74;
} else {
config.newLineHeight = config.newFontSize;	
}
config.elementRef.css({ 'font-size' : config.newFontSize, 'line-height' : config.newLineHeight+"px" });
if(navigator.appVersion.indexOf("Mac")!=-1 && jq.browser.mozilla) { // check for mac os/ff use, then remove bold from title
jq("#dbartimgtitle h1 .db-movietitle").css({ "font-weight" : "normal"});
};
if(navigator.appVersion.indexOf("X11")!=-1 && jq.browser.webkit) { // check for linux os/chrome use, then remove bold from title
jq("#dbartimgtitle h1 .db-movietitle").css({ "font-weight" : "normal"});
};
}
config.elementRef.parent().css({ "visibility" : "visible"});
} 
},settings);
if(jq.browser.msie) {
config.constraintWidth = config.constraintWidth - 90; // adjusting for IE spacing issues	
};
config.element.each(function() {
config.elementRef = jq(this);
config.constraintWidthRef = config.elementRef.parent().width() - config.offSetWidth;
config.text = config.elementRef.html();
jq('body').append('<span class="resizertext">'+config.text+'</span>');
config.resizerSpan = jq('.resizertext');
config.getStyles();
config.resizerSpan.css({'font-size' : config.fontSizeMax ,
'text-transform' : config.textTransform, 
'font-weight' : config.fontWeight,
'letter-spacing' : config.letterSpacing,
'font-family' : config.fontFamily,
'display' : 'none'
});
config.getSpanWidth();
var constraintWidth = 650;
if (config.resizerSpanWidth > constraintWidth) {
while (config.resizerSpanWidth > constraintWidth) {
config.currentFontSize = config.resizerSpan.css('font-size').replace('px','');
config.newFontSize = config.currentFontSize - config.resizeDeg;
config.resizerSpan.css({'font-size' : config.newFontSize+'px'});
config.getSpanWidth();
}
config.newFontSize = (config.newFontSize<config.fontSizeMin) ? config.fontSizeMin+'px' : config.newFontSize;
config.resizeFont();
} else {
if(navigator.appVersion.indexOf("Mac")!=-1 && jq.browser.mozilla) { // check for mac os/ff use, then remove bold from title
console.log("its mac and ff");
jq("#dbartimgtitle h1 .db-movietitle").css({ "font-weight" : "normal"});
};
if(navigator.appVersion.indexOf("X11")!=-1 && jq.browser.webkit) { // check for linux os/chrome use, then remove bold from title
jq("#dbartimgtitle h1 .db-movietitle").css({ "font-weight" : "normal"});
};
config.elementRef.parent().css({ "visibility" : "visible"});
}
config.resizerSpan.remove();
});
};
/* Input field texter - jq Plugin by SA 
USAGE: jq('#search-input').inputtxt({ 'defaultValue' : 'Enter Your Search Here' }); 
*/
jq.fn.inputtxt = function(settings) { 
var config = jq.extend({ 
'element' : jq(this),
'defaultValue' : 'Input default text goes here',
'ivalue' : '',
'initInput' : function() {
config.element.val(config.defaultValue);	
}
}, settings);
config.element.live('click, focus', function() { 
config.ivalue = config.element.val();
if (config.ivalue === config.defaultValue) { 
config.element.val('');
} else if (config.ivalue === '') { 
config.element.val(config.defaultValue);
}
});
config.element.live( 'blur', function() {
config.ivalue = config.element.val();
if (config.ivalue === '') {
config.element.val(config.defaultValue);
}	
});
config.initInput();
};	
/* Contribute - limits a text field to a set length(need to dynama'ize it) - by SA */
jq.fn.limitField = function(settings) {
var config = jq.extend({
'element' : jq(this),
'limitLength' : '200'
},settings);
config.element.keyup(function() {
var len = jq(this).val().length;
if (len >= config.limitLength) {
var val = jq(this).val();
val = val.substring(0, config.limitLength);
jq(this).val(val);
jq("#maxdescr").animate({ "fontSize" : "13px"}, 300, function(){
jq(this).animate({ "fontSize" : "11px"}, 386);
});
}
});	
};
/* USER Reviews - limits a text field to a set length(need to dynama'ize it) - by SA */
jq.fn.limitFieldReview = function(settings) {
var config = jq.extend({
'element' : jq(this),
'limitLength' : '2000'
},settings);
config.element.keyup(function() {
var len = jq(this).val().length;
if (len >= config.limitLength) {
var val = jq(this).val();
val = val.substring(0, config.limitLength);
jq(this).val(val);
jq("#reviewlimit").css({ "display" : "block" , "opacity" : 0}).animate({'opacity' : 1 }, 1000, function(){
jq('body').delayit(2200, "limiter", function() { 
jq("#reviewlimit").fadeOut();
});
});
}
});	
};
/* completes the tcmdb title page cast and crew display by finding the empty elements and turning them off and also the expand button method Ex. no dancers for particular movie then hide the Dancers container */
/* jq('.credits-cont').completeCredits(); 
*/
jq.fn.completeCredits = function(settings) {	
var config = jq.extend({ 
'element' : jq(this),
'creditViewNum' : [1,10,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1]	// how many rows to show by default for each section
}, settings);
config.element.each(function(index) {
/* hides if no credits */
config.elementRef = jq(this);
config.ehtml = config.elementRef.find('.castandcrew-cont').html();
if(config.ehtml.length < 2){ 
config.elementRef.hide();
}
/* minimizes section view to set length */
var creditRowsRef = config.elementRef.find('.credit-rw');
var creditrowsNum = creditRowsRef.size();
var showNum = config.creditViewNum[index];
if(showNum < creditrowsNum) {
creditRowsRef.slice(showNum, creditrowsNum).hide();	
}
config.elementRef.find('.btn-expand-credits').live('click', function(e){
e.preventDefault();
var btnNum = index;
var html = jq(this).html();
if(jq(this).hasClass('expanded')){
creditRowsRef.slice(showNum, creditrowsNum).slideUp();
jq(this).toggleClass('expanded');
html = html.replace('HIDE','SEE');
jq(this).html(html);
} else {
jq(this).toggleClass('expanded');
creditRowsRef.slice(0, creditrowsNum).slideDown();
html = html.replace('SEE','HIDE');
jq(this).html(html);
}
});	
});
};
/* constricts visibly a series of list elements to the set length(defaultShow), allowing them to be expanded via button action */
jq.fn.expandByNum = function(settings) {	
var config = jq.extend({ 
'element' : jq(this),
'defaultShow' : 5,
'expandBtn' : jq('.btn-expand-articles'),
'btnContainer' : jq('#mainBody'),
'elementType' : 'li'
}, settings);
config.element.each(function(index) {
var elementList = config.element.find(config.elementType);
var elementLength = config.element.find(config.elementType).size();	
if(config.defaultShow < elementLength) {
elementList.slice(config.defaultShow, elementLength).hide();
} 
if (config.defaultShow > elementLength) {
config.expandBtn.hide();
}
config.expandBtn.live('click', function(e){
e.preventDefault();
var btnNum = index;
var html = jq(this).html();
if(jq(this).hasClass('expanded')){
elementList.slice(config.defaultShow, elementLength).hide();
jq(this).toggleClass('expanded');
html = html.replace('HIDE','SEE');
jq(this).html(html);
} else {
jq(this).toggleClass('expanded');
elementList.slice(0, elementLength).fadeIn();
html = html.replace('SEE','HIDE');
jq(this).html(html);
}
});	
});
};
/* Match Column Heights */
/* Adjusts height of targeted element(selector element) to match the column height of a specificed div(elementMatch) within a parent column(parentElement) */
/* check title user reviews, and tcmdb home page for different usage cases /*
/* jq('#left-col-lastmod').matchheight({ 'elementMatch' : jq('#search-cont'), 'parentEleconment' : jq('#search-left-col') })
*/
jq.fn.matchheight = function(settings) {
var config = jq.extend({
'element' : jq(this),
'elementHeight' : '',
'elementMatch' : '',
'parentElement' : ''
}, settings);
config.element.each( function(){
var elementRef = jq(this);
config.parentElementHeight = config.parentElement.height();
config.elementHeight = elementRef.height();
config.matchHeight = config.elementMatch.height();
if(config.parentElementHeight < config.matchHeight ){
config.heightDiff = config.matchHeight - config.parentElementHeight;
config.newHeight = Number(config.elementHeight) + Number(config.heightDiff);
elementRef.height(config.newHeight);
} else { 
elementRef.removeAttr("style");
}
});
};
/* movie ratings and review */
jq.fn.getRatings = function (settings) { 
var config = jq.extend({
'ratingBoxRef' : jq(this),
'starWidth' : 18,
'overallStarWidth' : 35,
'jsonfeed' : '',
'ratingTextClass' : 'rating-info-user',
'ratingMaltinTextClass' : 'rating-info',
'lmaltinRatingRef' : jq('.rating-stars'),
'maltinRating' : [],
'maltinScore' : 0,
'maltinratings' : true
},settings);
var totalScoreArray = [],totalVoteArray = [],scoreValueArray = [],a = 0, b = 0,c = 0, maltin = true;
var getJsonUser = function(){
// gets user ratings
jq.getJSON(config.jsonfeed, function(data) {
jsondata = data;
if( jsondata.tcm.title.userRatings.length > 0 ){ // if there are ratings
for ( n in jsondata.tcm.title.userRatings ) { 
var totalscore = jsondata.tcm.title.userRatings[n].totalScore;
var totalvote = jsondata.tcm.title.userRatings[n].totalVote;
var score = ((totalscore / totalvote) / 2);
var score=Math.round(score*100)/100;
totalScoreArray[a++] = totalscore;
totalVoteArray[b++] = totalvote;
scoreValueArray[c++] = score;
}
} else if (jsondata.tcm.title.userRatings.length === 0 && maltin !== true) { // are both user and maltin empty
//jq(".ratingsandreviews").remove();
} else { // then just hide the user ratings
jq("#userrating-cont").hide();
jq("#tcmdb-noreviews").show();
jq(".ratingsandreviews").css({ 'padding-top' : '13px'});
}
getJsonMaltin();
});
};
var getJsonMaltin = function(){
jq.getJSON(config.maltinjsonfeed, function(data) {
var maltinjsondata = data;
var review = maltinjsondata.tcm.title.maltinReview.review;
var reviewrating = maltinjsondata.tcm.title.maltinReview.rating;
if(reviewrating != null){ // if malting rating exists
// if text is too long, truncate it -code commentet based on request TENDP-4776
/*if(review.length > 300) { 
review = review + ' <a href="#" class="btn-maltin-more-exp">LESS &gt;</a>';
var reviewtruncated = review.substring(0,600) + '... <a href="#" class="btn-maltin-more">MORE &gt;</a>';
jq(".rating-info-c2").html(reviewtruncated);
jq(".rating-info-c2exp").html(review);
jq(".btn-maltin-more").click(function(e){
e.preventDefault();
jq(this).parent().hide();
jq(".rating-info-c2exp").slideDown()
});
jq(".btn-maltin-more-exp").click(function(e){
e.preventDefault();
jq(this).parent().hide();
jq(".rating-info-c2").show()
});
} else { */
// show the full text
jq(".rating-info-c2").remove();
jq(".rating-info-c2exp").html(review).show();
//}
for(i=0; i<4; i++){
var rating = reviewrating.charAt(i);
if(rating === "*"){ // for whole value
config.maltinScore += 1;
} else if(rating === "1") { // for 1/2
config.maltinScore += 0.5;
}
}
buildMaltinRating();
} else {
jq("#maltin-cont , #lmarthdr").hide();// hide maltin html
maltin = false;
buildRating();
}
});
};
var updateRatingText = function() { // updates maltin value view
var textbox = config.lmaltinRatingRef.find('.'+config.ratingMaltinTextClass);
if (config.scoreValue >= 0.001){ 
var ratinghtml = '<strong>'+config.maltinScore+'</strong> out of 4 Stars';
} else { 
var ratinghtml = '<strong>No rating</strong>';
textbox.css({ 'right' : '32px'});
};
textbox.html(ratinghtml);
};
var buildMaltinRating = function() { 
config.scoreValue = scoreValueArray[0];
/* whole values */
if (config.maltinScore >= 1) { 
var starBox = config.lmaltinRatingRef.find('.onestar div');
starBox.css({ 'width' : config.overallStarWidth+'px' });
}
if (config.maltinScore >= 2) { 
var starBox = config.lmaltinRatingRef.find('.twostar div');
starBox.css({ 'width' : config.overallStarWidth+'px' });
}
if (config.maltinScore >= 3) { 
var starBox = config.lmaltinRatingRef.find('.threestar div');
starBox.css({ 'width' : config.overallStarWidth+'px' });
}
if (config.maltinScore >= 4) { 
var starBox = config.lmaltinRatingRef.find('.fourstar div');
starBox.css({ 'width' : config.overallStarWidth+'px' });
}
/* percents */
if (config.maltinScore > 0 && config.maltinScore < 1 ) { 
var starBox = config.lmaltinRatingRef.find('.onestar div');
var starValue = Math.floor(config.maltinScore);
var percent = config.maltinScore - starValue;
var width = (percent * config.overallStarWidth);
starBox.css({ 'width' : width+'px' });
}
if (config.maltinScore > 1 && config.maltinScore < 2 ) { 
var starBox = config.lmaltinRatingRef.find('.twostar div');
var starValue = Math.floor(config.maltinScore);
var percent = config.maltinScore - starValue;
var width = (percent * config.overallStarWidth);
starBox.css({ 'width' : width+'px' });
}
if (config.maltinScore > 2 && config.maltinScore < 3 ) { 
var starBox = config.lmaltinRatingRef.find('.threestar div');
var starValue = Math.floor(config.maltinScore);
var percent = config.maltinScore - starValue;
var width = (percent * config.overallStarWidth);
starBox.css({ 'width' : width+'px' });
}
if (config.maltinScore > 3 && config.maltinScore < 4 ) { 
var starBox = config.lmaltinRatingRef.find('.fourstar div');
var starValue = Math.floor(config.maltinScore);
var percent = config.maltinScore - starValue;
var width = (percent * config.overallStarWidth);
starBox.css({ 'width' : width+'px' });
}
updateRatingText();
buildRating();
};
var buildRating = function() {
for (i=0;i<9;i++) { 
config.ratingBoxRefDiv = config.ratingBoxRef.find('.rrref').eq(i);
config.scoreValue = scoreValueArray[i];
/* whole values */
var divClassArray = [ 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar'];
for(j=0; j<5; j++) {
if (config.scoreValue > j) { 
var starBox = config.ratingBoxRefDiv.find('.'+divClassArray[j]+' div');
starBox.css({ 'width' : config.starWidth+'px' });
}
}
/* percents */
for(n=0; n<5; n++) {
var nj = n + 1;
if (config.scoreValue > n && config.scoreValue < nj ) { 
var starBox = config.ratingBoxRefDiv.find('.'+divClassArray[n]+' div');
var starValue = Math.floor(config.scoreValue);
var percent = config.scoreValue - starValue;
var width = (percent * config.starWidth);
starBox.css({ 'width' : width+'px' });
}
}
var textbox = config.ratingBoxRef.find('.'+config.ratingTextClass).eq(i);
if (config.scoreValue >= 0.001){ 
var ratinghtml = '<strong>'+config.scoreValue+'</strong> out of 5';
} else { 
var ratinghtml = '<strong>No rating</strong>';
textbox.css({ 'margin-left' : '10px'});	
};
textbox.html(ratinghtml);
}
};
getJsonUser(); // start the ratings process
};
/* user-ratings detailed */
jq.fn.getDetailedRatings = function(settings) { 
var config = jq.extend({
'ratingBoxRef' : jq(this),
'starWidth' : 14,
'lgstarWidth' : 51,
'jsonfeed' : '',
'itemRef' : 'dtr',
'overallRef' : jq(".ratings-overall-detailed ul"),
'overallScore' : ''
},settings);
var totalScoreArray = [],totalVoteArray = [],scoreValueArray = [],a = 0, b = 0,c = 0;
var buildRatingsData = function() { 
jq.getJSON(config.jsonfeed, function(data) {
ratingsjson = data;
ratingslen = ratingsjson.tcm.title.userRatings.length;
if(ratingslen > 0) {
for ( n in ratingsjson.tcm.title.userRatings ) {
var score = ((ratingsjson.tcm.title.userRatings[n].totalScore / ratingsjson.tcm.title.userRatings[n].totalVote) / 2);
score=Math.round(score*100)/100;
ratingsjson.tcm.title.userRatings[n].score = score;
scoreValueArray[c++] = score;
totalVoteArray[b++] = ratingsjson.tcm.title.userRatings[n].totalVote;
}
scoreValueArray.length = ratingsjson.tcm.title.userRatings.length;
jq(".membertotal p").html(totalVoteArray[0]+' Member Ratings');
getOverallRating();
buildRating();
buildOverallRating();
}
});
};
var getOverallRating = function() {
var totalscore = 0, overalltotalscore;
for (i=0;i<ratingslen;i++) { 
totalscore = totalscore + Number(scoreValueArray[i]);
}
config.overallScore = (totalscore / ratingslen);
};
var buildRating = function() {
for (i=0;i<ratingslen;i++) { 
config.ratingBoxRefDiv = config.ratingBoxRef.find('.dtr'+ratingsjson.tcm.title.userRatings[i].id);
config.scoreValue = ratingsjson.tcm.title.userRatings[i].score;
var staract = config.ratingBoxRef.parent().find('.staract'+ratingsjson.tcm.title.userRatings[i].id);	
staract.html(ratingsjson.tcm.title.userRatings[i].score);
/* whole values */
var divClassArray = [ 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar'];
for(j=0; j<5; j++) {
if (config.scoreValue >= j) { 
var starBox = config.ratingBoxRefDiv.find('.'+divClassArray[j]+' div');
starBox.css({ 'width' : config.starWidth+'px' });
}
}
/* percents */
for(n=0; n<5; n++) {
var nj = n + 1;
if (config.scoreValue > n && config.scoreValue < nj ) { 
var starBox = config.ratingBoxRefDiv.find('.'+divClassArray[n]+' div');
var starValue = Math.floor(config.scoreValue);
var percent = config.scoreValue - starValue;
var width = (percent * config.starWidth);
starBox.css({ 'width' : width+'px' });
}
}
}
};
var buildOverallRating = function() {
/* whole values */
var divClassArray = [ 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar'];
for(j=0; j<5; j++) {
if (config.overallScore >= j) { 
var starBox = config.overallRef.find('.'+divClassArray[j]+' div');
starBox.css({ 'width' : config.lgstarWidth+'px' });
}
}
/* percents */
for(n=0; n<5; n++) {
var nj = n + 1;
if (config.overallScore > n && config.overallScore < nj ) { 
var starBox = config.overallRef.find('.'+divClassArray[n]+' div');
var starValue = Math.floor(config.overallScore);
var percent = config.overallScore - starValue;
var width = (percent * config.lgstarWidth);
starBox.css({ 'width' : width+'px' });
}
}
}
buildRatingsData();
};
/* participant fan comments reviews and ratings */
jq.fn.getDetailedPersonsRatings = function(settings) { 
var config = jq.extend({
'ratingBoxRef' : jq(this),
'starWidth' : 14,
'lgstarWidth' : 51,
'lgstarWidthLR' : 35,
'jsonfeed' : '',
'itemRef' : 'dtr',
'overallRef' : jq(".ratings-overall-detailed ul"),
'overallRefLR' : jq(".ratings-overall ul"),
'overallScore' : ''
},settings);
var totalScoreArray = [],totalVoteArray = [],scoreValueArray = [],a = 0, b = 0,c = 0;
var buildRatingsData = function() { 
jq.getJSON(config.jsonfeed, function(data) {
ratingsjson = data;
ratingslen = ratingsjson.tcm.person.userRatings.length;
if(ratingslen > 0) {
for ( n in ratingsjson.tcm.person.userRatings ) {
var score = ((ratingsjson.tcm.person.userRatings[n].totalScore / ratingsjson.tcm.person.userRatings[n].totalVote) / 2);
score=Math.round(score*100)/100;
ratingsjson.tcm.person.userRatings[n].score = score;
scoreValueArray[c++] = score;
totalVoteArray[b++] = ratingsjson.tcm.person.userRatings[n].totalVote;
}
scoreValueArray.length = ratingsjson.tcm.person.userRatings.length;
jq(".membertotal p").html(totalVoteArray[0]+' Member Ratings');
getOverallRating();
buildRating();
buildOverallRating();
buildOverallRatingLR();
}
});
};
var getOverallRating = function() {
var totalscore = 0, overalltotalscore;
for (i=0;i<ratingslen;i++) { 
totalscore = totalscore + Number(scoreValueArray[i]);
}
config.overallScore = (totalscore / ratingslen);
};
var buildRating = function() {
for (i=0;i<ratingslen;i++) { 
config.ratingBoxRefDiv = config.ratingBoxRef.find('.dtr'+ratingsjson.tcm.person.userRatings[i].id);
config.scoreValue = ratingsjson.tcm.person.userRatings[i].score;
var staract = config.ratingBoxRef.parent().find('.staract'+ratingsjson.tcm.person.userRatings[i].id);	
staract.html(ratingsjson.tcm.person.userRatings[i].score);
/* whole values */
var divClassArray = [ 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar'];
for(j=0; j<5; j++) {
if (config.scoreValue >= j) { 
var starBox = config.ratingBoxRefDiv.find('.'+divClassArray[j]+' div');
starBox.css({ 'width' : config.starWidth+'px' });
}
}
/* percents */
for(n=0; n<5; n++) {
var nj = n + 1;
if (config.scoreValue > n && config.scoreValue < nj ) { 
var starBox = config.ratingBoxRefDiv.find('.'+divClassArray[n]+' div');
var starValue = Math.floor(config.scoreValue);
var percent = config.scoreValue - starValue;
var width = (percent * config.starWidth);
starBox.css({ 'width' : width+'px' });
}
}
}
};
var buildOverallRating = function() {
/* whole values */
var divClassArray = [ 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar'];
for(j=0; j<5; j++) {
if (config.overallScore >= j) { 
var starBox = config.overallRef.find('.'+divClassArray[j]+' div');
starBox.css({ 'width' : config.lgstarWidth+'px' });
}
}
/* percents */
for(n=0; n<5; n++) {
var nj = n + 1;
if (config.overallScore > n && config.overallScore < nj ) { 
var starBox = config.overallRef.find('.'+divClassArray[n]+' div');
var starValue = Math.floor(config.overallScore);
var percent = config.overallScore - starValue;
var width = (percent * config.lgstarWidth);
starBox.css({ 'width' : width+'px' });
}
}
}
var buildOverallRatingLR = function() { // left rail participant pages
/* whole values */
var divClassArray = [ 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar'];
for(j=0; j<5; j++) {
if (config.overallScore >= j) { 
var starBox = config.overallRefLR.find('.'+divClassArray[j]+' div');
starBox.css({ 'width' : config.lgstarWidthLR+'px' });
}
}
/* percents */
for(n=0; n<5; n++) {
var nj = n + 1;
if (config.overallScore > n && config.overallScore < nj ) { 
var starBox = config.overallRefLR.find('.'+divClassArray[n]+' div');
var starValue = Math.floor(config.overallScore);
var percent = config.overallScore - starValue;
var width = (percent * config.lgstarWidthLR);
starBox.css({ 'width' : width+'px' });
}
}
}
buildRatingsData();
};
/*ratings-user-detailed*/
/* this handles the title+participant user review/fan comments pages */
/* initial ratings view, written rating and non writen reviews (stars) */
(function(jq){
jq.fn.addRatings = function(settings) {
var config = jq.extend({
'element' : jq(this),
'elementBtn' : jq(this).find('.starsel'),
'elementOverall' : false
}, settings);
detailedActive = false; // quick fix check if user has chosen a detailed rating vs just the overall rating
if(config.elementOverall === true){ // overall ratings
jq("#user-overall-rating").find('.overallr').live('click', function() { // medium star btn
var overallStarRefs = jq(this).parent().parent().find('.overallr');
var removeStar = false;
var btnlen = overallStarRefs.size();
var btnclass = jq(this).attr('class');
var btnnum = btnclass.replace(/[^0-9]/g,"");
if(jq(this).hasClass('rated')){
jq(this).removeClass('rated');
overallStarRefs.removeClass('hrated');	
jq(this).addClass('hrated');
overallStarRefs.slice(btnnum, btnlen).removeClass('rated');
removeStar = true;
} else if (jq(this).hasClass('hrated')) {
jq(this).removeClass('hrated');
overallStarRefs.slice(btnnum, btnlen).removeClass('rated');
} else {
overallStarRefs.removeClass('rated');
overallStarRefs.slice(0, btnnum).removeClass('hrated');
overallStarRefs.slice(0, btnnum).toggleClass('rated');
}
/*jq('.user-rate-view-act2').each(function(){ // updates all write your review detailed ratings star btns -- removed old funt, might want back.. it force the detailed ratings, to all equal the overall rating selection.. now they are independant.. 
var starRefs = jq(this).find('.starsel');
starRefs.removeClass('rated');
starRefs.slice(0, btnnum).addClass('rated');
if(removeStar === true) {
jq('.rate'+btnnum).removeClass('rated');
}
});*/
});
};
config.elementBtn.live('click', function() { // rating small star btn click
detailedActive = true;
jq(".ratings-overall-user").show();
jq(".ratings-overall-detailed").hide();
var starRefs = jq(this).parent().find('.starsel');
var btnlen = starRefs.size();
var btnclass = jq(this).attr('class');
var btnnum = btnclass.replace(/[^0-9]/g,"");
if(jq(this).hasClass('rated')){ // click on full star
jq(this).removeClass('rated');
starRefs.removeClass('hrated');	
jq(this).addClass('hrated');
starRefs.slice(btnnum, btnlen).removeClass('rated');
var parentClass = jq(this).parent().attr('class');
if(parentClass === 'user-rate-view-act2') { // determines if its written review or non-written review ratings
jq(this).ratingsUpdateOverall({'elementRef' : '.writeli-reviews .user-rate-view-act2'});
jq(this).ratingsUpdateOverallDisplay({'elementRef' : '.writeli-reviews .user-rate-view-act2'});
} else {
jq(this).ratingsUpdateOverallDisplay({'elementRef' : '#add-rating-reg .user-rate-view-act'});
}
} else if (jq(this).hasClass('hrated')) { // click on half rating
starRefs.removeClass('hrated');
starRefs.slice(btnnum, btnlen).removeClass('rated');
var parentClass = jq(this).parent().attr('class');
if(parentClass === 'user-rate-view-act2') {
jq(this).ratingsUpdateOverall({'elementRef' : '.writeli-reviews .user-rate-view-act2'});
jq(this).ratingsUpdateOverallDisplay({'elementRef' : '.writeli-reviews .user-rate-view-act2'});
} else {
jq(this).ratingsUpdateOverallDisplay({'elementRef' : '#add-rating-reg .user-rate-view-act'});
}
} else { // click on empty star
starRefs.removeClass('rated');
starRefs.slice(0, btnnum).removeClass('hrated');
starRefs.slice(0, btnnum).toggleClass('rated');
var parentClass = jq(this).parent().attr('class');
if(parentClass === 'user-rate-view-act2') {
jq(this).ratingsUpdateOverall({'elementRef' : '.writeli-reviews .user-rate-view-act2'});
jq(this).ratingsUpdateOverallDisplay({'elementRef' : '.writeli-reviews .user-rate-view-act2'});
} else {
jq(this).ratingsUpdateOverallDisplay({'elementRef' : '#add-rating-reg .user-rate-view-act'});
}
}
});
};
jq.fn.ratingsSubmit = function(settings){ // gets user detailed ratings and preps for ajax submit
var config = jq.extend({ 
'elementRef' :'',
'posturl' : '', // ajax post to url
'detailedWritten' : true, // is it a written ratings review
'person' : false // is this a person page submit?
}, settings);
var isValid = false,
validNum = 0;
var validateUserRatings = [ 'name', 'title', 'review']; // validation checks
var validateWrittenForm = function() { // validated the written form
var validateFieldUserRatings = function(field) { // run validation 
switch(field) {
case 'name':
if(jq("#review-name").val().length === 0) { // require 
jq("#review-name").addClass('invalid');
} else {
jq("#review-name").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'title':
if(jq("#review-title").val().length === 0) { // require 
jq("#review-title").addClass('invalid');
} else {
jq("#review-title").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'review':
if(jq("#review-comment").val().length === 0) { // require 
jq("#review-comment").addClass('invalid');
} else {
jq("#review-comment").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'israted':
/* this was used before when we used to force user to make a starred rating on detail rating */
var beenrated = false;
jq(".user-overall-ratingul .user-rate-view-act li").each(function(){
if( jq(this).hasClass('rated') || jq(this).hasClass('hrated')){ // has user made a rating?
beenrated = true;
}
});
if(beenrated === true) { // is valid
jq(".user-write-overall p").eq(0).removeClass('invalid');
validNum = validNum + 1; 
} else {
jq(".user-write-overall p").eq(0).addClass('invalid');
}
break;
default:
}
}
len = validateUserRatings.length;
for(i=0; i<len; i++) { // validate each field(arrayed order)
validateFieldUserRatings(validateUserRatings[i]);
}
submitDetailedWritten(); // now go and submit
};
var submitDetailedWritten = function () { // written review 
if(validNum === validateUserRatings.length) { // are all fields validated? if so submit form
jq('.btn-closedetailed-ratings, .btn-adddetailed-ratings').hide();
jq('.btn-ratings-submitrev, .btn-ratings-goback').fadeIn();
jq('.writeli-reviews, .btn-ratings-preview, .cancel2').slideUp(function(){
jq('#blankspaceart').matchheight({ 'elementMatch' : jq('#mainBody'), 'parentElement' : jq('#rightContent') });	
});
var ratingArray = [], overallRatingVal=0, a=0;
if(detailedActive === false){// if user has only selected the overall rating
var element = jq(".user-write-overall .user-rate-view-act"); // hard wiring this in could fix later
element.each(function(index){ // loop over stars elements and find scores/build ratingsArray
var elementHalf = jq(this).find('.hrated:last');
var element = jq(this).find('.rated:last');
var element = (elementHalf.length > 0) ? elementHalf : element; // if half/whole star
if(element.attr('class') !== undefined) {
var btnclass = element.attr('class');
var btnnum = btnclass.replace(/[^0-9]/g,"");
if (elementHalf.length > 0){ // if it was a half star
btnnum = btnnum - 0.5;
}	
ratingArray = [btnnum,btnnum,btnnum,btnnum,btnnum,btnnum,btnnum,btnnum,btnnum]; // setting all scores = over selection only, not aggregated by detail selections
} else {
ratingArray[a++] = 0;
}
});
} else { // if user has selected a detailed rating
jq(config.elementRef).each(function(index){
var elementHalf = jq(this).find('.hrated:last');
var element = jq(this).find('.rated:last');
var element = (elementHalf.length > 0) ? elementHalf : element; // if half/whole star
if(element.attr('class') !== undefined) {
var btnclass = element.attr('class');
var btnnum = btnclass.replace(/[^0-9]/g,"");
if (elementHalf.length > 0){ // if it was a half star
btnnum = btnnum - 0.5;
}	
ratingArray[a++] = Number(btnnum);
} else {
ratingArray[a++] = 0;
}
});
}
jq("#review-comment").replaceMSWordChars();
var name = jq('#review-name').val();
var email = jq('#review-email').val();
var location = jq('#review-location').val();
var reviewtitle = jq('#review-title').val();
var review = jq('#review-comment').val();
location = escape(location);
reviewtitle = escape(reviewtitle);
review = escape(review);
/*var questionsArray = [], a=0, b=0;
for(i=0;i<9;i++){
var rating;
if (ratingArray[n] > 5) { // security checks on the ratings values, keeps them within 0-5range
rating = 5;	
} else if (ratingArray[n] < 0) { 
rating = 0;	
} else if (isNaN(ratingArray[n]) === true) { 
rating = 0;	
} else {
rating = ratingArray[n];
}
questionsArray[a++] = rating;
};*/	
for (i=0;i<9;i++) { // set rating by 10
var rating = ratingArray[i];
if (rating === undefined) { // if user didnt select a rating, set it to 0 
rating = 0;
}
ratingArray[i] = Number(rating) * 2;
}
if(config.person != true) {
var querystring = "userName="+name+
"&email="+email+
"&location="+location+
"&reviewTitle="+reviewtitle+
"&review="+review+
"&question4="+ratingArray[0]+
"&question5="+ratingArray[1]+
"&question6="+ratingArray[2]+
"&question7="+ratingArray[3]+
"&question8="+ratingArray[4]+
"&question20="+ratingArray[5]+
"&question3="+ratingArray[6]+
"&question2="+ratingArray[7]+
"&question1="+ratingArray[8];
} else {
var querystring = "userName="+name+
"&email="+email+
"&location="+location+
"&reviewTitle="+reviewtitle+
"&review="+review+
"&question14="+ratingArray[0]+
"&question15="+ratingArray[1]+
"&question16="+ratingArray[2]+
"&question17="+ratingArray[3]+
"&question11="+ratingArray[4]+
"&question12="+ratingArray[5]+
"&question13="+ratingArray[6]+
"&question18="+ratingArray[7]+
"&question19="+ratingArray[8];
}
jq.ajax({ // post review data to server
type:"POST",
url: config.posturl , 
data:querystring,	
cache: false,
dataType: "json",
success: function(data){
var jsonreturn = data;
var reviewtitle = jsonreturn.censored.reviewtitle;
var reviewbody = jsonreturn.censored.reviewbody;
if (config.fsubmit === true){ 
jq('.ratingp1, .ratingp2, .btn-ratings-submit, .btn-ratings-cancel').hide();
jq('#add-thankyou, .btn-ratings-write, .btn-ratings-read').fadeIn();	
} else {
jq('#write-review-li input , #write-review-li textarea').addClass('previewed');
var reviewcopy = jq("#review-comment").val();
jq("<div class='preview-review'><p>"+reviewcopy+"</p></div>").appendTo(".writeli5");
jq("#review-comment").hide();
jq('#review-title').val(reviewtitle);
jq('#review-comment').val(reviewbody);
}	
}
});
} 
};
var submitDetailed = function () {	// non-written review
var ratingArray = [], overallRatingVal=0, a=0;	
var elementRef = jq(".rtg-cont2 .user-rate-view-act");
elementRef.each(function(index){
var elementHalf = jq(this).find('.hrated:last');
var element = jq(this).find('.rated:last');
var element = (elementHalf.length > 0) ? elementHalf : element; // if half/whole star
if(element.attr('class') !== undefined) {
var btnclass = element.attr('class');
var btnnum = btnclass.replace(/[^0-9]/g,"");
if (elementHalf.length > 0){ // if it was a half star
btnnum = btnnum - 0.5;
}	
ratingArray[a++] = Number(btnnum);
} else {
ratingArray[a++] = 0;
}
});
var questionsArray = [], a=0;
for( n in ratingsjson.tcm.title.userRatings){
var rating;
if (ratingArray[n] > 5) { // security checks on the ratings values, keeps them within 0-5range
rating = 5;	
} else if (ratingArray[n] < 0) { 
rating = 0;	
} else if (isNaN(ratingArray[n]) === true) { 
rating = 0;	
} else {
rating = ratingArray[n];
}
questionsArray[a++] = rating;
};
jq.ajax({ // post review non-written data to server
type:"POST",
url: config.posturl , 
data:"&question4="+ratingArray[0]+
"&question5="+ratingArray[1]+
"&question6="+ratingArray[2]+
"&question7="+ratingArray[3]+
"&question8="+ratingArray[4]+
"&question20="+ratingArray[5]+
"&question3="+ratingArray[6]+
"&question2="+ratingArray[7]+
"&question1="+ratingArray[8],	
cache: false,
dataType: "json",
success: function(data){
var jsonreturn = data;
jq('#add-thankyou, .btn-ratings-write, .btn-ratings-read').fadeIn();	
jq('.ratingp1, .ratingp2, .btn-ratings-submit, .btn-ratings-cancel').hide();
}
});
}	
/* choose which submit routine to follow */	
if(config.detailedWritten === true) { // is this a detailed written review submit or just the regular ratings submit
validateWrittenForm();
} else { // submit non-written detailed review
submitDetailed();	
} 
};
jq.fn.ratingsUpdateOverallDisplay = function(settings){ // (large one) updates the user overall rating selector 
var config = jq.extend({ 
'elementRef' :''
}, settings);
var ratingArray = [], a=0;
jq(config.elementRef).each(function(index){ // find the selected ratings
var element = jq(this).find('.rated:last');
var elementHalf = jq(this).find('.hrated:last'); // half star rating
if (element.length > 0 || elementHalf.length > 0){
if(element.length > 0) { // if its whole star
var btnclass = element.attr('class');
var btnnum = Number(btnclass.replace(/[^0-9]/g,""));
}
if(elementHalf.length > 0) { // if its a half star
var btnclass = elementHalf.attr('class');
var btnnum = btnclass.replace(/[^0-9]/g,"");
btnnum = (Number(btnnum) - 0.5);
}
ratingArray[a++] = btnnum;
}
});
ratingarraylen = ratingArray.length, scoreComposite=0;
for (i=0; i<ratingarraylen; i++) {
var scoreComposite = Number(scoreComposite) + Number(ratingArray[i]);
}
var scoreComposite = (scoreComposite / ratingarraylen);
var divClassArray = [ 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar'];
var overallBoxRef = jq('#ratings-overall-user');
/*for(j=0; j<5; j++) { // updated overall stars view
var num = j + 0.49;
//var num = j;
var starBox = overallBoxRef.find('.'+divClassArray[j]);
console.log(scoreComposite , num);
if (scoreComposite > num) {
starBox.addClass('rated');
}
if (scoreComposite < num && scoreComposite >= j) {
overallBoxRef.find('.overallr').slice(j,5).removeClass('rated');
}
}; */
/* whole values */
overallBoxRef.find('li div').removeAttr('style');
var divClassArray = [ 'onestar', 'twostar', 'threestar', 'fourstar', 'fivestar'];
for(j=0; j<4; j++) {
if (scoreComposite > j) { 
var starBox = overallBoxRef.find('.'+divClassArray[j]+' div');
starBox.css({ 'width' : '51px' });
}
}
/* percents */
for(n=0; n<4; n++) {
var nj = n + 1;
if (scoreComposite > n && scoreComposite < nj ) { 
var starBox = overallBoxRef.find('.'+divClassArray[n]+' div');
var starValue = Math.floor(scoreComposite);
var percent = scoreComposite - starValue;
var width = (percent * 51); //
starBox.css({ 'width' : width+'px' });
}
}
};
jq.fn.ratingsUpdateOverall = function(settings){ // (middle size one)updates the overall rating selector on the write review page
var config = jq.extend({ 
'elementRef' :''
}, settings);
var ratingArray = [], a=0;
jq(config.elementRef).each(function(index){
var element = jq(this).find('.rated:last');
var elementHalf = jq(this).find('.hrated:last'); // half star rating
if (element.length > 0 || elementHalf.length > 0){
var btnclass = element.attr('class') || elementHalf.attr('class');
var btnnum = btnclass.replace(/[^0-9]/g,"");
ratingArray[a++] = btnnum;
}
});
ratingarraylen = ratingArray.length, scoreComposite=0;
for (i=0; i<ratingarraylen; i++) {
var scoreComposite = Number(scoreComposite) + Number(ratingArray[i]);
}
var scoreComposite = (scoreComposite / ratingarraylen);
var divClassArray = [ 'onestar-rate1', 'twostar-rate2', 'threestar-rate3', 'fourstar-rate4', 'fivestar-rate5'];
var overallBoxRef = jq('#user-overall-rating .user-rate-view-act');
overallBoxRef.find('.overallr').removeClass('rated').removeClass('hrated'); // clearing current
for(j=0; j<5; j++) {
var num = j + 0.49;
var starBox = overallBoxRef.find('.'+divClassArray[j]);
if (scoreComposite > num) {
starBox.addClass('rated');
}
if (scoreComposite < num && scoreComposite >= j) {
overallBoxRef.find('.overallr').slice(j,5).removeClass('rated').removeClass('hrated');
}
}
};
})(jq);
/* removes microsoft word entities and replaces with usable entities */
(function($){ 
jQuery.fn.replaceMSWordChars = function(settings) {
var element = jQuery(this);
var str = jQuery(this).val();
var count = 0;
var myReplacements = new Array();
var myCode, intReplacement;
myReplacements[174] = 174; // copyright
myReplacements[8216] = 39;
myReplacements[8217] = 39;
myReplacements[8220] = 34;
myReplacements[8221] = 34;
myReplacements[8212] = 45;
myReplacements[8211] = "-";
myReplacements[8218] = "'";
myReplacements[8222] = '"';
myReplacements[8224] = "+";
myReplacements[8226] = ".";
myReplacements[8230] = "...";
myReplacements[8249] = "<";
myReplacements[8250] = ">";
for (c = 0; c < str.length; c++) {
var myCode = str.charCodeAt(c);
if (myReplacements[myCode] != undefined) {
intReplacement = myReplacements[myCode];
str = str.substr(0, c) + String.fromCharCode(intReplacement) + str.substr(c + 1);
count = count + 1;
}
}
element.val(str);
}; 
})(jQuery);
/* delay method | time for dealy, timeoutname, callback */
jq.fn.delayit = function(time,tname,func){
this.each(function(){
if (!tname) {
setTimeout(func,time);
} else {
if(tname) {
eval("timer_"+tname+"=setTimeout(func,time)");
}
}
});
return this;
};
/* use this instead of console.log -- jq.fn.logThis("your log");*/
jq.fn.logThis = function(text){
if( (window['console'] !== undefined) ){
console.log( text );
}
};
/* input a valid email address? return true/false */
(function($){
jq.fn.isValidEmail = function(email) {
var emailaddr = email;
var emailpattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return emailpattern.test(emailaddr);
};
})(jQuery);
/*!
* jQuery Pagination(pagenator) plugin: a simple and robust pagination plugin for jQuery to quickly paginate a set of dom elements
* Examples and documentation at: http://jquery.sa86.com/pagination
* version 0.90 (sometime-2010)
*/
(function(jq){
jq.fn.pager = function(settings) {
var config = jQuery.extend({ // default configuration
'show' : 6, // how many items to show per page
'nav' : jq("#navigation"), // navigation container
'navorder' : ["previous","buttons","next","ofpage"], // navigation reordering, from left to right
'navsplit' : false, // true(auto) or false(none)
'visible' : 5, // how many pages to show in your navsplit before it applies 
'showpages' : true, // true/false show or hide page# btns 
'showcpage' : true, // true/false show or hide #/# pages
'shownpbtns' : true, // true/false show or hide next/previous btns
'btncont' : 'pages', // container class for 1-# btns
'hclass' : 'current', // classname for high state btn of current page
'btnnext' : 'next', // next btn classname
'btnprev' : 'previous', // prev btn classname
'btnpage' : 'pgbtn', // page btn classname
'btntype' : 'a', // btn type html, options = "button", "a", "div" or other open + close tagged html
'cpage' : 'cpage', // current page container classname
'curpage' : 'curpage', // current page # class name
'ofpage' : 'ofpage', // total page # class name
'cpagedv' : ' of ', // txt that seperates curpage+ofpage Ex. 2 of 3, 4/50, etc
'splittxt' : '- ', // seperator character between split pages
'septext' : ' | ', // seperator character between pages
'checkPageDistance' : 8, // to account for the size of your potential 'splittxt' and buttons sizes, which effect the width of the navigation element. If you create custom elements, and your navigation is breaking or not starting its slit method soon enough. Then try and adjust this value + or -. It's the guess work size of the additional buttons/text sizes that the splitter methods invoke.
'initAnimatePage' : { opacity : "show"}, // initial load animation
'initAPspeed' : 333, // initial load animation speed
'animatePage' : { opacity : "show"}, // page change animation
'aPspeed' : 200, // page change animation speed
'items' : '', // leave empty, totals # of items
'pages' : '', // leave empty, calculated total # of page's
'gotoPage' : '', // leave empty, set during navigation
'currentPage' : '1', // leave as is, current page
'controlsHtml' : '', // defined by script
'pageElement' : jq(this) // dont touch
}, settings);
/* variable initialization */
config.items = config.pageElement.size(); // total page elements
config.pages = Math.ceil(config.items / config.show); // total pages
/* setting up the page */
var config = jq.extend(config , settings);	
jq(this).hide(); // init the view
jq(this).each(function (index, domEle) { // show the first content set
if (index < config.show ) {
jq(domEle).animate( config.initAnimatePage , config.initAPspeed );
} 
});
/* button click listeners */
config.nav.find('.'+config.btnpage).live('click', function(e) { // BTN gotopage
e.preventDefault();
config.btnGotoPage = jq(this).data('page');	
gotoPage();
});
config.nav.find('.'+config.btnprev).live('click', function(e) { // BTN previous
e.preventDefault();	
prevPage();
});
config.nav.find('.'+config.btnnext).live('click', function(e) { // BTN next
e.preventDefault();
nextPage();	
});
/* buttons */
var nextPage = function() { // next page method
if (config.currentPage >= config.pages) { // on last page?
config.btnGotoPage = 1;
gotoPage();
jq.fn.updateNav(config);	
} else { // goto next
var gotoNextPage = Number(config.currentPage) + 1;
var gotoNum = config.currentPage * config.show;
var gotoEnd = Number(config.show) + Number(gotoNum);
config.pageElement.hide();
config.pageElement.slice(gotoNum,gotoEnd).animate(config.animatePage , config.aPspeed);
config.currentPage = gotoNextPage;
jq.fn.updateNav(config);	
config.nav.find('.'+config.hclass).removeClass(config.hclass);
config.nav.find('.pg'+config.currentPage).addClass(config.hclass);
updateCpage();
}	
};
var prevPage = function(settings) { // previous page method
if (config.currentPage == 1) { // on first page?
config.btnGotoPage = config.pages;	
gotoPage();
jq.fn.updateNav(config);	
} else { // goto previous
var gotoPrevPage = Number(config.currentPage) - 1;
var gotoNum = gotoPrevPage * config.show;
var gotoEnd = (Number(config.show) + Number(gotoNum)) - config.show * 2; 
config.pageElement.hide();
config.pageElement.slice(gotoEnd,gotoNum).animate(config.animatePage , config.aPspeed);	
config.currentPage = gotoPrevPage;
jq.fn.updateNav(config);	
config.nav.find('.'+config.hclass).removeClass(config.hclass);
config.nav.find('.pg'+config.currentPage).addClass(config.hclass);
updateCpage();	
}
};
var gotoPage = function(settings) { // goes to specified page in config.btnGotoPage
var gotoNextPage = config.btnGotoPage;
config.gotoPage = gotoNextPage;
if(config.currentPage != gotoNextPage) { // if btn not of same page, then display selected page
var gotoNum = (config.gotoPage * config.show) - config.show;
var gotoEnd = Number(config.show) + Number(gotoNum);
config.pageElement.hide();
config.pageElement.slice(gotoNum,gotoEnd).animate(config.animatePage , config.aPspeed);	
config.currentPage = gotoNextPage;
jq.fn.updateNav(config);	
updateCpage();	
}
var btnGotoPage = config.nav.find('.pg'+config.btnGotoPage);
config.nav.find('.'+config.hclass).removeClass(config.hclass);
btnGotoPage.addClass(config.hclass);
};
/* view */
var updateCpage = function(settings) { // updated current page/of view
if (config.showcpage != false) {
jq(config.nav).find('.'+config.curpage).html(config.currentPage);	
}
};
jq.fn.buildControls(config); // initialize the nav for the first time
};
/* page split methods(3)below - handle the three types of views that the navigation will show when browsing long+ nav units */
jq.fn.pageSplitFirst = function(config) { 
var pageBtnsHtml = { 
"sec0" : "<span class='sasec0'></span>",
"sec1" : "<span class='sasec1'>"+config.splittxt+"<span class='sesec1n'></span>"+config.splittxt+"</span>",
"sec2" : "<span class='sasec2'></span>",
"sec3" : "<span class='sasec3'>"+config.splittxt+"<span class='sesec3n'></span>"+config.splittxt+"</span>",
"sec4" : "<span class='sasec4'></span>",
"sec5" : "<span class='sasec5'></span>"
};
var pageBtnsHtmlval = pageBtnsHtml.sec0 + pageBtnsHtml.sec1 + pageBtnsHtml.sec2 + pageBtnsHtml.sec3 + pageBtnsHtml.sec4 + pageBtnsHtml.sec5; 
jq(config.nav).find('span.'+config.btncont).html(pageBtnsHtmlval);
jq(".sasec2").html('');
navpages = jq(config.nav).find('span.'+config.btncont);
navpages.find(".sasec0 , .sasec1").hide();
navpages.find(".sasec3 , .sasec4").show();
var pgbtns = [], a = 0;
for ( i=0; i<config.visible; i++) { 
var pageNum = i+1;
pgbtns[a++] = "<"+config.btntype+" class='pg"+pageNum+" "+config.btnpage+"'>"+pageNum+"</"+config.btntype+">";
}
var pgbtnsHtml = pgbtns.join('');
navpages.find(".sasec2").html(pgbtnsHtml);
var meanPage = Math.ceil(((config.pages - config.visible) / 2 ) + Number(config.visible)); 
var btnHtml = { "button" : "<button class='pg"+meanPage+" "+config.btnpage+"'>"+meanPage+"</button>", "a" : " <a href='#' class='pg"+meanPage+" "+config.btnpage+"'>"+meanPage+"</a> " };
var btnHtmlval = btnHtml[config.btntype];	
navpages.find(".sesec3n").html(btnHtmlval);
var btnHtml = { "button" : "<button class='pg"+config.pages+" "+config.btnpage+"'>"+config.pages+"</button>", "a" : " <a href='#' class='pg"+config.pages+" "+config.btnpage+"'>"+config.pages+"</a> " };
var btnHtmlval = btnHtml[config.btntype];	
navpages.find(".sasec4").html(btnHtmlval);
};
jq.fn.pageSplitMiddle = function(config) { 
navpages = jq(config.nav).find('span.'+config.btncont);
navpages.find(".sasec3 , .sasec4, .sasec0 , .sasec1").show();
var btnHtml = { "button" : "<button class='pg1 "+config.btnpage+"'>1</button>", "a" : " <a href='#' class='pg1 "+config.btnpage+"'>1</a> " };
var btnHtmlval = btnHtml[config.btntype];	
navpages.find(".sasec0").html(btnHtmlval);
var btnHtml = { "button" : "<button class='pg"+config.pages+" "+config.btnpage+"'>"+config.pages+"</button>", "a" : " <a href='#' class='pg"+config.pages+" "+config.btnpage+"'>"+config.pages+"</a> " };
var btnHtmlval = btnHtml[config.btntype];	
navpages.find(".sasec4").html(btnHtmlval);
var pgbtns = [], a = 0;
var nstart = Math.ceil((config.currentPage - (config.visible / 2)));
var maxlen = Math.ceil(Number(nstart) + Number(config.visible));
for ( i=nstart; i<maxlen; i++) { 
var pageNum = i;
pgbtns[a++] = "<"+config.btntype+" class='pg"+pageNum+" "+config.btnpage+"'>"+pageNum+"</"+config.btntype+">";
}
var pgbtnsHtml = pgbtns.join('');
navpages.find(".sasec2").html(pgbtnsHtml);
var pagevar = (config.currentPage - (config.visible / 2));
var meanPage = Math.ceil((pagevar - 1) / 2); 
var btnHtml = { "button" : "<button class='pg"+meanPage+" "+config.btnpage+"'>"+meanPage+"</button>", "a" : " <a href='#' class='pg"+meanPage+" "+config.btnpage+"'>"+meanPage+"</a> " };
var btnHtmlval = btnHtml[config.btntype];	
navpages.find(".sesec1n").html(btnHtmlval);
var pagevar = (config.currentPage - (config.visible / 2));
var num1 = (Number(pagevar) + Number(config.visible)) - 1;
var num2 = config.pages - num1;
var num3 = (num2 / 2);
var meanPage = Math.ceil(Number(num3) + Number(num1));
var btnHtml = { "button" : "<button class='pg"+meanPage+" "+config.btnpage+"'>"+meanPage+"</button>", "a" : " <a href='#' class='pg"+meanPage+" "+config.btnpage+"'>"+meanPage+"</a> " };
var btnHtmlval = btnHtml[config.btntype];	
navpages.find(".sesec3n").html(btnHtmlval);
};
jq.fn.pageSplitLast = function(config) { 
navpages = jq(config.nav).find('span.'+config.btncont);
navpages.find(".sasec3 , .sasec4").hide();
navpages.find(".sasec0 , .sasec1").show();
var btnHtml = { "button" : "<button class='pg1 "+config.btnpage+"'>1</button>", "a" : " <a href='#' class='pg1 "+config.btnpage+"'>1</a> " };
var btnHtmlval = btnHtml[config.btntype];	
navpages.find(".sasec0").html(btnHtmlval);
var pgbtns = [], a = 0, inum = config.currentPage - config.visible;
var inum = (inum < 1) ? 1 : inum ;
if (inum < (config.pages - config.visible)) { inum = config.pages - config.visible; } 
for ( i=inum; i<config.pages; i++) { 
var pageNum = i+1;
pgbtns[a++] = "<"+config.btntype+" class='pg"+pageNum+" "+config.btnpage+"'>"+pageNum+"</"+config.btntype+">";
}
var pgbtnsHtml = pgbtns.join('');
navpages.find(".sasec2").html(pgbtnsHtml);
var meanPage = Math.ceil((config.pages - config.visible) / 2);
var btnHtml = { "button" : "<button class='pg"+meanPage+" "+config.btnpage+"'>"+meanPage+"</button>", "a" : " <a href='#' class='pg"+meanPage+" "+config.btnpage+"'>"+meanPage+"</a> " };
var btnHtmlval = btnHtml[config.btntype];	
navpages.find(".sesec1n").html(btnHtmlval);
};
jq.fn.updateNav = function(config) { // updates pager navigation
var checkPageCount = config.pages - config.checkPageDistance;
if (config.visible < checkPageCount && config.navsplit != false) { // draw the split navigation UI if pagenum exceeds config.visible setting
if (config.currentPage === 1 || config.currentPage < config.visible ) { // if on the first page, or within the first set visible scope
jq.fn.pageSplitFirst(config);	
} else
if (config.currentPage === config.pages || (Number(config.currentPage) + Number(config.visible)) > config.pages + 1) { // last scope
jq.fn.pageSplitLast(config);
} else { // middle page scope
jq.fn.pageSplitMiddle(config);	
}
} 
config.nav.find('.pg'+config.currentPage).addClass(config.hclass);
config.nav.find('.'+config.btnpage).each(function (index, domEle) { // add data for each page# to appropriate button for click functionality.
var btnclass = jq(domEle).attr('class');
btnclass = btnclass.replace(/[^0-9]/g,"");	
jq.data(domEle, "page", btnclass );
});
};
jq.fn.buildControls = function(config) { // builds pager navigation controls
var controlsHtml = { // define next/prev btns + nav containers html 
previous : "<"+config.btntype+" class='"+config.btnprev+"'>Prev</"+config.btntype+">",
buttons : "<span class='"+config.btncont+"'></span>",
ofpage : " <span class='"+config.cpage+"'>(<span class='"+config.curpage+"'>"+config.currentPage+"</span><span class='cpagedv'>"+config.cpagedv+"</span><span class='"+config.ofpage+"'>"+config.pages+"</span>)</span>" ,
next : "<"+config.btntype+" class='"+config.btnnext+"'>Next</"+config.btntype+">" 
};
var navref = config.nav;
controlsHtml = controlsHtml[config.navorder[0]] + controlsHtml[config.navorder[1]] + controlsHtml[config.navorder[2]] + controlsHtml[config.navorder[3]] + "<div class='clr'></div>";
navref.html(controlsHtml);
var pgbtns = [], a = 0;
for ( i=0; i<config.pages; i++) { 
var pageNum = i+1;
pgbtns[a++] = "<"+config.btntype+" class='pg"+pageNum+" "+config.btnpage+"'>"+pageNum+"</"+config.btntype+">";
}
var pgbtnsHtml = pgbtns.join('');
jq(config.nav).find('span.'+config.btncont).html(pgbtnsHtml);	
config.nav.find('.'+config.btnpage).each(function (index, domEle) {
jq.data(domEle, "page", index+=1 );
});
if (config.showpages === false) config.nav.find('.'+config.btncont).hide(); 
if (config.showcpage === false) config.nav.find('.'+config.cpage).remove(); 
if (config.shownpbtns === false) config.nav.find('.'+config.btnnext+', .'+config.btnprev).remove(); 
jq.fn.updateNav(config); // more navigation updates ok
};
})(jq);
/* img pan+zoom view on archive page */
(function(jq){	
jq.fn.photoViewerInit = function(settings) { // init the archive page process
var config = jq.extend({ 
'element' : jq(this),
'jsonFeed' : '',
'contentId': '',
'deepLinkID' : ''
}, settings);
var vheight = document.documentElement["scrollHeight"];
jq(".img-v-wrap").height(vheight);
jq('html, body').animate({scrollTop:48});
jq.fn.getArchiveData(config); // gets archive json feed+continue
}; 
jq.fn.panViewer = function(settings) { // builds interface controls and panning html/functionality. Is loaded once getArchiveData() has completed
var config = jq.extend({ // settings
'element' : jq("#ephoto"),
'width' : '847', 
'height' : '705',
'zoomInSpeed' : 0.1, 
'zoomOutSpeed' : 0.1,
'panImgId' : (jq(this).prop('id') + "-pcont"), 
'panMaskId' : (jq(this).prop('id') + "-pmask"), 
'panState' : false, 
'mouseStartX' : 0, 
'mouseStartY' : 0, 
'mouseDropX' : 0, 
'mouseDropY' : 0, 
'btnZoom' : jq(".btn-pa-plus"),
'btnZoomOut' : jq(".btn-pa-min"),
'photoThumb' : jq(".pbtn"),
'btnRight' : jq(".btn-pa-right"),
'btnLeft' : jq(".btn-pa-left"),
'currentThumb' : 0,
'viewWidth' : document.documentElement.clientWidth
}, settings);
config.element = jq(this);	
var bconfig = jq.extend({ // bounding settings
'bwidth' : config.element.prop('width'),
'bheight' : config.element.prop('height'),
'bminX' : (config.width - config.element.prop('width')),
'bminY' : (config.height - config.element.prop('height')),
'bmaxX' : 0,
'bmaxY' : 0
}, settings);
(function(jq){ // init the viewer and load image
config.element.wrap('<div id="'+config.panImgId+'" style="position:relative;width:'+config.width+'px; height:'+config.height+'px; overflow:hidden;"><div id="'+config.panMaskId+'" style="position:relative;left:0px;top:0px;"></div></div>');
if(config.deepLinkID.length <= 0){ // not deeplinked
jq("#ul-photo li").eq(0).addClass('selected');
} else { // with deeplink
var thumbnails = jq("#ul-photo li"), 
a = 0;
thumbnails.each(function(){
var deepID = jq(this).getAttrId({ "type" : "id"});
if (config.deepLinkID == deepID) {
jq(this).addClass('selected');
config.currentThumb = a; // deep linked photo
}
a = a + 1;
});
}
jq('.p-c-cur').html( jq(".selected").find(".p-thumbnum").html() ); 
config.element.css({ 'visibility' : 'hidden'});
config.element.prop("src" , fullsizeImageArray[config.currentThumb] ); //load first image
jq.fn.getElementBounds(config,bconfig);
jq.fn.updateArchiveInfo(config,bconfig);
if(config.viewWidth <= 1286 || t_apv_iframeviewer === true) { // resizes viewport if user viewport is smaller than
jq("#"+config.panImgId).css({ "width" : 508 });
jq('#img-v-title').css({ "width" : 939 });
jq('#img-v-content').css({ "width" : 939 });
jq('#img-v-photobox').css({ "width" : 508 , "height" : 425 });
config.width = 508;
config.height = 425;
jq.fn.getElementBounds(config,bconfig);
}
config.element.css({ 'visibility' : 'visible'});
jq("#archives-img-viewer").show(); // once resized turn on the view
})(jq);
config.element.load(function(){ // listens to img src + updates on change
config.element.css({ 'visibility' : 'hidden'});	
config.element.removeAttr('width').removeAttr('height').removeAttr('style').removeAttr('alt'); // remove old value
var twidth = config.element.prop('width'); // new imgs w/h
var theight = config.element.prop('height');
if (twidth < config.width){ // sets img width to actual if width is less than viewport 
config.element.prop('width',twidth);
} 
config.element.prop('height',config.element.height());
if (theight > config.height) { // now check if the height isnt centered(kinda cheap this way, but i will revisit when my head isnt hurting)
config.element.prop('height', config.height);
config.element.removeAttr('width');
var iwidth = config.element.prop('width');
var margleft = iwidth / 2;
margleft = "-"+margleft+"px";
jq('#'+config.panMaskId).addClass('centerith').css({ 'margin-left' : margleft});
}
config.element.prop('alt' , imgDescription[config.currentThumb]);
config.viewCurrViewWidth = jq("#"+config.panImgId).width();
config.viewCurrViewHeight = jq("#"+config.panImgId).height();
/* handles centering of image if smaller(w/h) than viewport // need to methododize this for multi use */ 
if (twidth <= config.width ) { 
var margleft = twidth / 2;
var margleft = "-"+margleft+"px";
jq('#'+config.panMaskId).addClass('centerith').css({ 'margin-left' : margleft});
}
//if (twidth >= config.width ) { // if the img is larger than the view port then remove centering
//jq('#'+config.panMaskId).removeClass('centerith').css({ 'margin-left' : 0}); //somehow this works when disabled, fix for height centering on load, seem to be no ill effects
//}
if (config.element.height() < config.height ) { 
var margtop = ((config.height - config.element.height()) / 2);
jq('#'+config.panMaskId).css({ 'margin-top' : margtop+"px"});
}
if (config.element.height() >= config.height ) { 
jq('#'+config.panMaskId).css({ 'margin-top' : 0});
}
jq("#embed-link").val(config.element.prop('src'));
config.element.css({ 'visibility' : 'visible'});
jq.fn.getElementBounds(config,bconfig);
jq.fn.updateArchiveInfo(config);
config.element.parent().css({ "top" : 0, "left" : 0 });
});
config.element.mousedown( function(e){ // img mouse down
e.preventDefault();
config.panState = true;
config.mouseStartY = e.pageY;
config.mouseStartX = e.pageX;
config.element.css('cursor','move');
jq(document.body).mousemove(function(e) { // on mousedown init mousemover
if(config.panState === true) {
var currentTop = jq('#'+config.panMaskId).css('top')
var currentLeft = jq('#'+config.panMaskId).css('left')
var leftLoc = config.mouseDropX - (config.mouseStartX - e.pageX);
var topLoc = config.mouseDropY - (config.mouseStartY - e.pageY);
if(topLoc < bconfig.bminY) { // check if at bounds
topLoc = bconfig.bminY;
} else if(topLoc > bconfig.bmaxY) {
topLoc = bconfig.bmaxY;
}
if(leftLoc < bconfig.bminX) { // check if at bounds
leftLoc = bconfig.bminX;
} else if(leftLoc > bconfig.bmaxX) {
leftLoc = bconfig.bmaxX;
}
if(config.element.height() < config.element.parent().parent().parent().parent().height()) { // if img is smaller than vis box stay put
topLoc = 0;
}
if(config.element.width() <= config.element.parent().parent().width()) { 
leftLoc = 0;
}
jq('#'+config.panMaskId).css({'left' : leftLoc + 'px' , 'top' : topLoc + 'px'});
}
});
});
config.element.mouseup( function(e){ // img mouse release
config.panState = false;
config.mouseDropY = jq("#"+config.panMaskId).css("top").replace("px" , "");
config.mouseDropX = jq("#"+config.panMaskId).css("left").replace("px" , "");
config.element.css('cursor','default');
jq(document.body).unbind('mousemove'); 
});
config.btnZoom.click(function(e){ // zoom in btn
e.preventDefault();
var photoWidth = config.element.width();
var photoHeight = config.element.height();
var increaseW = photoWidth * config.zoomInSpeed;
var increaseH = photoHeight * config.zoomOutSpeed
increaseW = increaseW + photoWidth;
increaseH = increaseH + photoHeight;
var leftpx = jq("#"+config.panMaskId).css( "left");
var toppx = jq("#"+config.panMaskId).css( "top");
config.element.css({ 'width' : increaseW+"px" , 'height' : increaseH+"px" }); //when done reset the w/h+bounds
var photoResizedWidth = config.element.prop('width');
var photoResizedHeight = config.element.prop('height');
centerPhoto(photoResizedWidth, photoResizedHeight);
config.element.prop( 'width' , increaseW);
config.element.prop( 'height' , increaseH);
jq.fn.getElementBounds(config,bconfig);
});
config.btnZoomOut.click(function(e){ // zoom out btn
e.preventDefault();
var photoWidth = config.element.width();
var photoHeight = config.element.height();
var increaseW = photoWidth * config.zoomInSpeed;
var increaseH = photoHeight * config.zoomOutSpeed
increaseW = photoWidth - increaseW ;
increaseH = photoHeight - increaseH;
var leftpx = jq("#"+config.panMaskId).css( "left");
var toppx = jq("#"+config.panMaskId).css( "top");	
config.element.css({ 'width' : increaseW+"px" , 'height' : increaseH+"px" });
var photoResizedWidth = config.element.prop('width');
var photoResizedHeight = config.element.prop('height');
centerPhoto(photoResizedWidth, photoResizedHeight);
config.element.prop( 'width' , increaseW);
config.element.prop( 'height' , increaseH);
jq.fn.getElementBounds(config,bconfig);	
});
config.photoThumb.click(function(e){ // btn thumbnails - load hi rez
e.preventDefault();
config.element.removeAttr('width').removeAttr('height').removeAttr('style').css({ 'visibility' : 'hidden'});
config.element.fadeOut('fast' , function(){
config.element.prop("src" , fullsizeImageArray[config.currentThumb] );	
});
jq("#archive-photo-wrap li").removeClass('selected');
jq(this).addClass('selected');
config.currentThumb = jq(".selected").find(".p-thumbnum").html();
jq('.p-c-cur').html(config.currentThumb);
/* deep linking */
if (t_apv_iframeviewer === false) {
var subcontentId = jq(this).attr('id');
subcontentId = subcontentId.replace(/[^0-9]/g,"");
var lhash = location.hash;
lhash = lhash.split("-"); 
lhash[2] = subcontentId; // add subcontent id to hash for deep linking
location.hash = lhash[0] +"-"+ lhash[1] +"-"+ lhash[2];
}
config.currentThumb = config.currentThumb - 1;
});
config.btnRight.click(function(e){ // btns right
e.preventDefault();
config.element.fadeOut('fast');	
var currentSelected = jq(".selected");
var nextSelected = jq(".selected").next();
if(nextSelected.hasClass('pbtn')){
jq("#archive-photo-wrap li").removeClass('selected');
nextSelected.addClass('selected');
} else {
jq("#archive-photo-wrap li").removeClass('selected');
jq(".pbtn:first").addClass('selected');
}
config.currentThumb = jq(".selected").find(".p-thumbnum").html();
jq('.p-c-cur').html(config.currentThumb);
config.currentThumb = config.currentThumb - 1;
config.element.fadeOut('fast' , function(){
config.element.prop("src" , fullsizeImageArray[config.currentThumb] );	
});
});
config.btnLeft.click(function(e){ // btns left
e.preventDefault();
config.element.fadeOut('fast');
var currentSelected = jq(".selected");
var nextSelected = jq(".selected").prev();
if(nextSelected.hasClass('pbtn')){
jq("#archive-photo-wrap li").removeClass('selected');
nextSelected.addClass('selected');
} else {
jq("#archive-photo-wrap li").removeClass('selected');
jq(".pbtn:last").addClass('selected');
}
config.currentThumb = jq(".selected").find(".p-thumbnum").html();
jq('.p-c-cur').html(config.currentThumb);
config.currentThumb = config.currentThumb - 1;
config.element.fadeOut('fast' , function(){
config.element.prop("src" , fullsizeImageArray[config.currentThumb] );	
});
});
var centerPhoto = function(rwidth, rheight){
if (rwidth <= config.width ) { 
var margleft = rwidth / 2;
var margleft = "-"+margleft+"px";
jq('#'+config.panMaskId).addClass('centerith').css({ 'margin-left' : margleft});
}
if (rwidth >= config.width ) { // if the img is larger than the view port then remove centering
jq('#'+config.panMaskId).removeClass('centerith').css({ 'margin-left' : 0});
}
if (rheight <= config.height ) { 
var margtop = ((config.height - rheight) / 2);
jq('#'+config.panMaskId).css({ 'margin-top' : margtop+"px"});
}
if (rheight >= config.height ) { 
jq('#'+config.panMaskId).css({ 'margin-top' : 0});
}
};
}; /* /panViewer() */
jq.fn.getElementBounds = function(config, bconfig) { // gets container bounds
bconfig.bwidth = config.element.prop('width');
bconfig.bheight = config.element.prop('height');
bconfig.bminX = (config.width - bconfig.bwidth);
bconfig.bminY = (config.height - bconfig.bheight);
bconfig.bmaxX = 0;
bconfig.bmaxY = 0;
jq("#"+config.panMaskId).css({ "width" : bconfig.bwidth+"px" , "height" : bconfig.bheight+"px" });
};
jq.fn.updateArchiveInfo = function(config) { // updates archive right rail info
jq(".img-rr-text").html(thumbnailsAltArray[config.currentThumb]);
var pictured = thumbnailsPictured[config.currentThumb];
if (pictured === undefined) {
pictured = '';
jq(".img-rr-t1").hide();
} else {
//pictured = pictured.split("|").join(", "); // display updates, removed pipes
//pictured = jq.trim(pictured);
//pictured = pictured.replace(pictured.charAt(0),''); // trim first ,
//pictured = pictured.substring(0, pictured.length-1); // trim last ,
jq(".img-rr-t1").show();
}
// update rr info
jq(".img-rr-pic").html(pictured);
var cname = archivejson.tcm.archives[0].images[config.currentThumb].contributor;
var cstatement = archivejson.tcm.archives[0].images[config.currentThumb].contributorStatement;
if(cname != undefined) { // if contrib has details
var cname = archivejson.tcm.archives[0].images[config.currentThumb].contributor;
jq(".rr-details-name").html(cname);
jq(".rr-details-statement").html(cstatement);
jq(".img-rr-details li, .rr-details-cs, .rr-details-cnm").eq(1).show();
} else if( cname == undefined) {
jq(".rr-details-cnm").hide();
}
if(cstatement != undefined) { // if contrib has details
var cname = archivejson.tcm.archives[0].images[config.currentThumb].contributor;
jq(".rr-details-name").html(cname);
jq(".rr-details-statement").html(cstatement);
jq(".img-rr-details li, .rr-details-cs").eq(1).show();
}
if (cname == undefined && cstatement == undefined) {
jq(".img-rr-details li").eq(1).hide();
} 
if (cstatement == undefined) {
jq(".rr-details-cs").hide();
}
};
jq.fn.getArchiveData = function(config) { // gets and builds thumbnails + sets up pager 
jq.getJSON(config.jsonFeed, function(data) { 
archivejson = data;
var a = 0,	b = 0, c = 0, d = 0, e = 0, f = 0;
thumbnailsSrcArray = [], thumbnailsAltArray = [], thumbnailsPictured = [], fullsizeImageArray = [], imgDescription = [], subcontentId = [];
var len = archivejson.tcm.archives[0].images.length;
for ( i=0; i < len; i++ ) { //reference json data into container arrays
var num = Number(i)+1;
if (archivejson.tcm.archives[0].images[i].thumbnails.length < 1) { // in case there arent anythumbnails show no image img.
var url = "http://i.cdn.turner.com/v5cache/TCM/images/redesign/nav/logo3-1.png";
} else {
var url = archivejson.tcm.archives[0].images[i].thumbnails[0].url;
}
/*	if (archivejson.tcm.archives[0].images[i].pictured.length < 1) { // does picture info exist?
var pictured = 'No information available.'
} else {
var pictured = archivejson.tcm.archives[0].images[i].pictured;
}*/
//console.log(i);
/*	if (archivejson.tcm.archives[0].images[i].pictured.length < 1) { // does picture info exist?
var pictured = 'No information available.'
} else {
var pictured = archivejson.tcm.archives[0].images[i].pictured;
}*/
var pictured = archivejson.tcm.archives[0].images[i].pictured;
var largeurl = archivejson.tcm.archives[0].images[i].url;
var descr = archivejson.tcm.archives[0].images[i].description;
var subid = archivejson.tcm.archives[0].images[i].contentId;
thumbnailsSrcArray[a++] = url;
thumbnailsPictured[c++] = pictured;
fullsizeImageArray[d++] = largeurl;
imgDescription[e++] = descr;
subcontentId[f++] = subid;
if(archivejson.tcm.archives[0].images[i].description != undefined){ // if no description use main desc
thumbnailsAltArray[b++] = archivejson.tcm.archives[0].images[i].description;
} else {
thumbnailsAltArray[b++] = archivejson.tcm.archives[0].title;
imgDescription[e++] = archivejson.tcm.archives[0].title;	
}
}
jq("#img-v-descr").html(archivejson.tcm.archives[0].description); // rr description box	
jq("#img-v-h1m").html(archivejson.tcm.archives[0].title); // h1 title	
var chref = jq(".contrib-upload").prop('href');
var thumbnailsNavigation = [];
thumbnailsNavigation[a++] = '<ul id="ul-photo">';
for ( i=0; i<thumbnailsSrcArray.length; i++){ // build the thumbnail navigation html
thumbnailsNavigation[a++] = '<li class="pbtn" id="subid-'+subcontentId[i]+'"><div class="p-thumb"><img src="'+thumbnailsSrcArray[i]+'" alt="'+thumbnailsAltArray[i]+'" width="82" alt="'+imgDescription[i]+'" /></div><div class="p-thumbnum">'+(i+1)+'</div></li>';	
}
thumbnailsNavigation[a++] = '</ul>';
jq(thumbnailsNavigation.join('')).appendTo("#archive-photo-wrap");
jq('.p-c-end').html(thumbnailsSrcArray.length);
var contentid = config.jsonFeed.replace(/[^0-9]/g,"");
if(t_apv_iframeviewer !== true && config.deepLinkID.length <= 0) { // dont modifiy hash if APV is in a iframe
location.hash = "#tcmarcp-"+contentid; // set hash for bookmarking ability
}
if(t_apv_iframeviewer !== true && config.deepLinkID.length > 0) { // dont modifiy hash if APV is in a iframe, deep linking hash
location.hash = "#tcmarcp-"+contentid+"-"+config.deepLinkID; // set hash for bookmarking ability
}
config.element.panViewer(config); // now that data is ready, init the viewer interface+viewer methods
var buildControls = function(config) { // building pager navigation controls below TODO(check for below 9 listing, and disable nav checks for L/R)
jq('<a href="#" class="btn-photo-left gtext">scroll thumbnails left</a>').prependTo("#archive-photo-wrap");
jq('<a href="#" class="btn-photo-right gtext">scroll thumbnails right</a>').appendTo("#archive-photo-wrap");
};
jq.fn.buildControls = buildControls; // override pager method
var paginateThumbnails = { 
'show' : 9,
'navsplit' : false,
'nav' : jq("#archive-photo-wrap"),
'navorder' : ["previous","buttons","next","ofpage"],
'showpages' : false,
'shownpbtns' : true,
'showcpage' : false,
'btntype' : 'a',
'btnnext' : 'btn-photo-right',
'btnprev' : 'btn-photo-left'
}
jq("#ul-photo li.pbtn").pager(paginateThumbnails); // init pager for the thumbnail nav
});
};
})(jq);
/* video more expander */
/* see example on title-video with anchor more btn */
/* jq('.btn-more-vid').moreExpander(); */
(function(jq){	
jq.fn.moreExpander = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'elementParent' : jq(this).parent().parent(),
'btnClass' : 'btn-more-vid',
'wrapElement' : 'title-video-wrap'
}, settings);
var parentElementClass = config.elementParent.attr('class');
var wrapElement = jq("."+config.wrapElement).find("."+parentElementClass);
wrapElement.each(function(){
var p1text = jq(this).find("p").eq(0).html();
var p2text = jq(this).find("p").eq(1).html();
if( p1text.length === p2text.length || (p1text.length+1) === p2text.length ){ // if description wasnt truncated, turn off the more button
jq(this).find("p").eq(0).find("a").hide();
}
});
config.element.live('click', function(e) { 
e.preventDefault();
config.element = jq(this);
var elementRef = jq(this).attr('class');
elementRef = elementRef.replace(config.btnClass, '');
elementRef = elementRef.replace(/\s/g, ""); /* whitespace */
var p1 = jq("p."+elementRef).eq(0);
var p2 = jq("p."+elementRef).eq(1);
var a1 = jq("a."+elementRef).eq(0);
var a2 = jq("a."+elementRef).eq(1);
if( p1.is(':visible') ) {
p1.hide();
a1.hide();
p2.show();
a2.show();
} else if ( p2.is(':visible') ) {
p1.show();
a1.show();
p2.hide();
a2.hide();
} 
});
};
})(jq);
/* handles client side page validation and data handling for contribute form's.. */
/* usage : applied to submit button, also integrated with on page javascript */
(function(jq){	
jq.fn.submitContrib = function(settings) { 
var config = jq.extend({
'element' : jq(this),
'submitcopy' : false,
'validated' : false
},settings);
(function(jq){ // run on init
var isValid = false,
validNum = 0;
var submitContributeMedia = function() { // builds forms and submits the page
if(jq("#srcPage").val() === "part" ) { // if participant submit
if(jq("#msUniqueId").val() === null || jq("#msUniqueId").val() === "") { // if not logged in?
jq("#msUniqueId").val("tegId");
}
var query = "![CDATA["	+jq("#msUniqueId").val()+",@,"
+"400412,@,"
+jq("#filmTitle").val()+",@,"
+jq("#message").val()+",@,"
+jq("#user_firstname").val()+",@,"
+jq("#postDescription").val()+"]]";
jq("#darkMeta").val(query);
}
if (jq("#srcPage").val() === "title" ) { // if title submit
if(jq("#msUniqueId").val() === null || jq("#msUniqueId").val() === "") {
//alert("title msUniqueId is empty");
jq("#msUniqueId").val("tegId");
}
var query =	"![CDATA["	+jq("#msUniqueId").val()+",@,"
+jq("#filmId").val()+",@,"
+jq("#filmTitle").val()+",@,"
+jq("#message").val()+",@,"
+jq("#user_firstname").val()+",@,"
+jq("#postDescription").val()+"]]";
jq("#darkMeta").val(query);
}
var url = jq("#real_return_url").val()+"&displayname="+escape(jq("#user_firstname").val())
+"&desc="+escape(jq("#postDescription").val())
+"&title="+escape(jq("#postTitle").val())
+"&mess="+escape(jq("#message").val())
+"&email="+escape(jq("#user_email").val())
+"&id="+jq("#filmId").val()
+"&retId="+jq("#retId").val()
+"&src="+jq("#srcPage").val()
+"&afi="+jq("#afiId").val();
jq("#success_url").val(url);
/* update thankyou html */
jq("#ty-username").html(jq("#user_firstname").val());
jq("#ty-title").html(jq("#postTitle").val());
jq("#ty-descr").html(jq("#postDescription").val());
jq("#ty-coll").html(jq("#message").val());
jq("#submitwait-overlay").css({ "opacity" : 0 , "display" : "block"});
jq("#submitwait-overlay").animate({ "opacity" : 0.8}, 700);
jq("#submitwait-overlay2").css({ "opacity" : 0 , "display" : "block"});
jq("#submitwait-overlay2").animate({ "opacity" : 1}, 700);
jq("#tcmupdate").ajaxSubmit();
};	
var submitContributeComment = function() { // builds forms and submits the page
jq("#desc").val(jq("#postDescription").val());
jq("#displayname").val(jq("#user_firstname").val());
jq("#mess").val(escape(jq("#postDescription").val()));
jq("#contribute").val(jq("#postDescription").val());
jq("#contributorEmail").val(jq("#email").val());
if(jq("#srcPage").val() === "title" ) {
jq("#contributionType").val("contribTitle");
jq("#contribType").val("contribTitle");
} else {
jq("#contribType").val("contribPart");
jq("#contributionType").val("contribPart");
}
var membername = jq("#user_firstname").val();
var email = jq("#user_email").val();
var title = jq("#title").val();
var postDescriptionComment = jq("#postDescriptionComment").val();
var id = jq("#catid").val();
var src = jq("#src").val();
if(src === "title") {
src = "contribTitle";
} else {
src = "contribPart";
}	
var strScarlettSelectCat = jq("#scarlettSelectCat").val();
jq("#selectCat").val(strScarlettSelectCat);
var category = jq("#scarlettSelectCat option:selected").text(); 
/*jq("#tcmupdate").attr("action" , "/TCMDBCFA/contribute/submitUgcContribution.jsp?category="+category);*/
jq("#submitwait-overlay").css({ "opacity" : 0 , "display" : "block"});
jq("#submitwait-overlay").animate({ "opacity" : 0.5}, 700);
jq("#submitwait-overlay2").css({ "opacity" : 0 , "display" : "block"});
jq("#submitwait-overlay2").animate({ "opacity" : 1}, 700);
/* update thankyou html */
jq("#ty-username").html(jq("#user_firstname").val());
jq("#ty-title").html(jq("#title").val());
jq("#ty-descr").html(jq("#postDescriptionComment").val());
jq(".collection-descr").hide();
jq.ajax({ // post review data to server
type:"POST",
url: "/processor/ugc/submitTextContribution.html", 
data:"contributor="+membername+
"&contributorEmail="+email+
"&title="+title+
"&selectCategory="+category+
"&selectCategoryId="+strScarlettSelectCat+
"&id="+id+	
"&contributionType="+src+	
"&contribution="+postDescriptionComment,	
cache: false,
dataType: "json",
success: function(data){
var returndata = data;
if(returndata === 0){
submitsuccess = true; // let our JS environment know that the form submit was a success
jq(".mainView").fadeOut('fast');// hide the submitting/form div
jq("#thanks-overlay").fadeIn('slow'); // show the thanks div
jq("#tcmupdate").clearForm(); // clear the form values
jq("#submitwait-overlay, #submitwait-overlay2").remove(); // remove waiting overlay
}
}
});
};	
var validateListMedia = [ 'signedin', 'comments', 'file', 'title', 'description', 'terms' ]; // validation checks
var validateFieldMedia = function(field) { // run validation check on media form
switch(field) {
case 'signedin':
if(jq("#user_firstname").val().length === 0 || jq("#user_email").val().length === 0) { // require - is user signed in?
alert("Need to show login overlay since your not logged in");
jq("#user_firstname").addClass('invalid');
jq("#user_email").addClass('invalid');
} else {
jq("#user_firstname").removeClass('invalid');
jq("#user_email").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'comments':
if (jq("#message").val() === "Enter your text here. If you are submitting more than one item please provide a description of the collection.") { // if comments werent added, clear value
jq("#message").val('');
}
validNum = validNum + 1;
break;
case 'file':
if(jq("#file1").val().length === 0) { // must select one file to upload
jq("#div_post1").addClass('invalid');
} else { // its valid
jq("#div_post1").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'title':
if(jq("#postTitle").val().length === 0) { // require comment title
jq("#postTitle").addClass('invalid');
} else {
jq("#postTitle").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'description':
if(jq("#postDescription").val().length === 0) { // require comment description
jq("#postDescription").addClass('invalid');
} else {
jq("#postDescription").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'terms':
if(jq("#terms_accept:checked").val() != "on") { // require terms and use
jq("#terms-cont").addClass('invalid');
} else {
jq("#terms-cont").removeClass('invalid');
validNum = validNum + 1;
}
break;
default:
}
}
var validateListComment = [ 'signedin', 'title', 'description', 'terms' ]; // validation checks	
var validateFieldComment = function(field) { // run validation check on comments
switch(field) {
case 'signedin':
if(jq("#user_firstname").val().length === 0 || jq("#user_email").val().length === 0) { // require - is user signed in?
alert("Need to show login overlay since your not logged in");
jq("#user_firstname").addClass('invalid');
jq("#user_email").addClass('invalid');
} else {
jq("#user_firstname").removeClass('invalid');
jq("#user_email").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'title':
if(jq("#title").val().length === 0) { // require comment title
jq("#title").addClass('invalid');
} else {
jq("#title").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'description':
if(jq("#postDescriptionComment").val().length === 0) { // require comment description
jq("#postDescriptionComment").addClass('invalid');
} else {
jq("#postDescriptionComment").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'terms':
if(jq("#tcmagree:checked").val() != "on") { // require term and use
jq("#tcmagree-cont").addClass('invalid');
} else {
jq("#tcmagree-cont").removeClass('invalid');
validNum = validNum + 1;
}
break;
default:
}
}
if (config.submitcopy === false) { // if submit for media form
len = validateListMedia.length;
for(i=0; i<len; i++) { // validate each field(arrayed order)
validateFieldMedia(validateListMedia[i]);
}
if(validNum === validateListMedia.length) { // are all fields validated? 
config.validated = true;
var poststring = jq("#tcmupdate").serialize();
submitContributeMedia(); // now go and run submit routine
}
}
if (config.submitcopy === true) { // if submit for comment form
len = validateListComment.length;
for(i=0; i<len; i++) { // validate each field(arrayed order)
validateFieldComment(validateListComment[i]);
}
if(validNum === validateListComment.length) { // are all fields validated? 
config.validated = true;
var poststring = jq("#tcmupdate").serialize();
submitContributeComment(); // now go and run submit routine
}
}
})(jq); /* ./end init run */
}
jq.fn.updateUgcElements = function(){ // updated page form based off cookies
var cookies = jq.fn.getUgcCookies();
var dname = cookies["displayname"];
if (dname == null || dname == "") {
jq("#user_firstname").val('');
} else {
jq("#user_firstname").val(dname);
}
var ename = cookies["msemail"];
if (ename == null || ename == "") {
jq("#user_email").val('');
} else {
jq("#user_email").val(ename);
}
var tegId = cookies["TEGid"];
if (tegId == null || tegId == "") {
jq("#msUniqueId").value = "";
} else {
jq("#msUniqueId").val(tegId);
}
jq("#form_url").val(window.location.href);
};
jq.fn.getUgcCookies = function(){ // get cookie info
var hash = new Array;
if (document.cookie != null) {
var a = document.cookie.split('; ');
for (var i=0; i < a.length; i++) {
var nv = a[i].split('=');
if (nv[1] != null) {
hash[nv[0]] = unescape(nv[1]);
}
}
}
return hash;
};
/* turned off until multiple submits is corrected server side *
/*jq.fn.fileChanged = function(newfilenum){ // when user adds file to upload, display additional upload boxes up to 10
jq("#div_post"+newfilenum).removeAttr('style');
jq("#div_post1").removeClass('invalid');
if(newfilenum < 11){
jq("#file"+newfilenum).focus();
}
};*/	
})(jq);
/* validate the book corner form and submit it */
(function(jq){	// 
jq.fn.submitBookCnr = function(settings) { 
var config = jq.extend({
'element' : jq(this),
'validated' : false
},settings);
(function(jq){ // run on init
var validNum = 0;
var validateList = [ 'firstname', 'lastname', 'email', 'address', 'city', 'state', 'zip' , 'phone1', 'phone2', 'phone3' ]; // validation checks
var validateField = function(field) { // run validation check on book corner form
switch(field) {
case 'firstname':
if(jq("#bkfrm-fn").val().length === 0 ) { // require first name
jq("#bkfrm-fn").addClass('invalid');
} else {
jq("#bkfrm-fn").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'lastname':
if(jq("#bkfrm-ln").val().length === 0 ) { // require last name
jq("#bkfrm-ln").addClass('invalid');
} else {
jq("#bkfrm-ln").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'email':
if(jq("#bkfrm-email").val().length === 0) { // require email
jq("#bkfrm-email").addClass('invalid');
} else { // its valid
jq("#bkfrm-email").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'address':
if(jq("#bkfrm-address").val().length === 0) { // require address
jq("#bkfrm-address").addClass('invalid');
} else {
jq("#bkfrm-address").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'city':
if(jq("#bkfrm-city").val().length === 0) { // require city
jq("#bkfrm-city").addClass('invalid');
} else {
jq("#bkfrm-city").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'state':
if(jq("#bkfrm-state").val().length < 2) { // require state
jq("#bkfrm-state").addClass('invalid');
} else {
jq("#bkfrm-state").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'zip':
if(jq("#bkfrm-zip").val().length === 0) { // require zip
jq("#bkfrm-zip").addClass('invalid');
} else {
jq("#bkfrm-zip").removeClass('invalid');
validNum = validNum + 1;
}
case 'phone1':
if(jq("#bkfrm-phone1").val().length < 3 ) { // require phone
jq("#bkfrm-phone1").addClass('invalid');
} else {
jq("#bkfrm-phone1").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'phone2':
if(jq("#bkfrm-phone2").val().length < 3 ) { // require phone
jq("#bkfrm-phone2").addClass('invalid');
} else {
jq("#bkfrm-phone2").removeClass('invalid');
validNum = validNum + 1;
}
break;
case 'phone3':
if(jq("#bkfrm-phone3").val().length < 4 ) { // require phone
jq("#bkfrm-phone3").addClass('invalid');
} else {
jq("#bkfrm-phone3").removeClass('invalid');
validNum = validNum + 1;
}
break;
default:
}
}
len = validateList.length;
for(i=0; i<len; i++) { // validate each field(arrayed order)
validateField(validateList[i]);
}
if(validNum >= validateList.length) { // are all fields validated? 
config.validated = true;
var fname = jq("#bkfrm-fn").val();
var lname = jq("#bkfrm-ln").val();
var email = jq("#bkfrm-email").val();
var phone = jq("#bkfrm-phone1").val() + "-" + jq("#bkfrm-phone2").val() + "-" + jq("#bkfrm-phone3").val();
var address = jq("#bkfrm-address").val();
var city = jq("#bkfrm-city").val();
var state = jq("#bkfrm-state").val();
var zip = jq("#bkfrm-zip").val();
var opt_in = jq("#offers-accept").val();
var contentId = jq("#bkfrm-contentId").val();
if(opt_in === 'on') { opt_in = 'Y'}
var dateObj = new Date();
var intYear = dateObj.getFullYear();
var yob = jq("#dob-year").val();
var age = intYear - yob;
jq.ajax({ // post form data to server
type:"POST",
url: "/processor/this-month/book-corner.html", 
data:"firstName="+fname+
"&lastName="+lname+
"&email="+email+
"&age="+age+
"&phone="+phone+
"&address="+address+
"&city="+city+
"&state="+state+
"&zip="+zip+
"&optIn="+opt_in+
"&contentId="+contentId,
cache: false,
dataType: "json",
success: function(data){
if (data === null) { 
jq("#bknr-form-fields, .bkfrm-copy").remove();
jq("#bkfrm-thanks").show();
}
}
});
}
})(jq); /* ./end init run */
};
})(jq); /* /jq.fnsubmitBookCnr */
/* validates + submits the fan site form on title and person pages */
(function(jq){ 
jq.fn.fanSiteSubmit = function(bttn) {
jq("#fan-site-tks").hide();
var whichBttn = bttn;
var whichURL;
var cacheTitleId;
var cacheSplit;
var whichTitleId = jq("#contentId").val();
if (whichBttn == 'titleBttn'){
whichURL = "/processor/title/fan-site.html";
cacheTitleId = whichTitleId;
}else if(whichBttn == 'personBttn') {
whichURL = "/processor/person/fan-site.html";
cacheSplit = whichTitleId.split("|");
cacheTitleId = cacheSplit[0];
}
var url = jq("#submit-link").val();
var urlTitle = jq("#submit-link-title").val();
var titleId = cacheTitleId;
if(url != "Enter Link to Add" && urlTitle != "Enter Title for Link" 
&& url != "" && urlTitle != ""
&& url.length >= 6 && urlTitle.length >= 6
) { // simple validation
jq.ajax({ // post fan site data to server
type:"POST",
url: whichURL , 
data:
"&url="+url+
"&urlTitle="+urlTitle+
"&titleId="+titleId,
cache: false,
success: function(data){
jq("#submit-link").val('Enter Link to Add');
jq("#submit-link-title").val('Enter Title for Link');
jq("#fan-site-tks").fadeIn(); // show the thank you html
}
});
} 
if(url === "Enter Link to Add" || url === "" || url.length <= 6){ // not valid
jq("#submit-link").css({ "border" : "1px solid red"});	
} else if(url != "Enter Link to Add" && url != "" && url.length >= 6) { // valid
jq("#submit-link").removeAttr("style");
}
if(urlTitle === "Enter Title for Link" || urlTitle === "" || urlTitle.length <= 6){ // not valid
jq("#submit-link-title").css({ "border" : "1px solid red"});	
} else if(urlTitle != "Enter Title for Link" && urlTitle != "" && urlTitle.length >= 6) { // valid
jq("#submit-link-title").removeAttr("style");
}
}	
})(jq);
/* gets ID # from either class or ID usage */
(function($){
jq.fn.getAttrId = function(settings) {
var config = jq.extend({ 
'element' : jq(this),
'type' : 'class'
}, settings);
if(config.type !== "class") {
var attrid = jq(this).attr('id');
} else {
var attrid = jq(this).attr('class');
}
attrid = attrid.replace(/[^0-9]/g,"");
return attrid;
};
})(jQuery);
/* upcoming titles stepper/scroller */
(function($){
jq.fn.airingStepper = function(settings) {
var config = jq.extend({ 
'element' : jq(this)
}, settings);
//Sets up the variables for the controller
var myContainer = jq('.upcomingTitles');
var upArrow = jq('#upArrow');
var downArrow = jq('#downArrow');
//set the initial values for the calculations
var myHeight = myContainer.height();
var offset = myContainer.offset();
var myTop = offset.top;
var ceiling = myHeight + myTop;
var difference = ceiling - myTop;
var slidesDown = difference / 28;
var slidesDown = Math.floor(slidesDown);
var slidesUp = 0;
var airinglen = jq(".upcomingTitlesList li").size();
var airingheight = jq(".upcomingTitlesList li").eq(0).height() + jq(".upcomingTitlesList li").eq(1).height()
if(airinglen <= 2 && airingheight <= 28) { // removed more buttons if less than scrollable length
jq("#more").remove();
}
function moveContentUp() {
slidesDown = slidesDown - 1;
slidesUp = slidesUp + 1;
myContainer.animate({ top: '-=28px'}, 300, function () {}); //move the content
if (slidesDown < 2) {
downArrow.removeClass();
downArrow.addClass('hide');
upArrow.removeClass();
upArrow.addClass('moreAbove');
}
else {
downArrow.removeClass();
downArrow.addClass('moreBelow');
upArrow.removeClass('hide');
upArrow.removeClass('moreAbove');
upArrow.addClass('show');
}
}
function moveContentDown(){
slidesUp = slidesUp - 1;
slidesDown = slidesDown + 1;
myContainer.animate({ top: '+=28px' }, 300, function () {});
if (slidesUp < 1) {
upArrow.removeClass();
upArrow.addClass('hide');
downArrow.removeClass();
downArrow.addClass('show');
}
else {
upArrow.removeClass();
upArrow.addClass('show');
downArrow.removeClass();
downArrow.addClass('moreBelow');
}
}
jq('#downArrow').click(function () {
moveContentUp();
});
jq('#upArrow').click(function () {
moveContentDown();
});	
};
})(jQuery);
/* SEARCH -- FOREIGN CHARACTER REMOVAL - Yeah...it's a doozy */
var defaultAccentMap = [
{'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
{'base':'AA','letters':/[\uA732]/g},
{'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g},
{'base':'AO','letters':/[\uA734]/g},
{'base':'AU','letters':/[\uA736]/g},
{'base':'AV','letters':/[\uA738\uA73A]/g},
{'base':'AY','letters':/[\uA73C]/g},
{'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},
{'base':'C', 'letters':/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},
{'base':'D', 'letters':/[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]/g},
{'base':'DZ','letters':/[\u01F1\u01C4]/g},
{'base':'Dz','letters':/[\u01F2\u01C5]/g},
{'base':'E', 'letters':/[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]/g},
{'base':'F', 'letters':/[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]/g},
{'base':'G', 'letters':/[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]/g},
{'base':'H', 'letters':/[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]/g},
{'base':'I', 'letters':/[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]/g},
{'base':'J', 'letters':/[\u004A\u24BF\uFF2A\u0134\u0248]/g},
{'base':'K', 'letters':/[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]/g},
{'base':'L', 'letters':/[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]/g},
{'base':'LJ','letters':/[\u01C7]/g},
{'base':'Lj','letters':/[\u01C8]/g},
{'base':'M', 'letters':/[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]/g},
{'base':'N', 'letters':/[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]/g},
{'base':'NJ','letters':/[\u01CA]/g},
{'base':'Nj','letters':/[\u01CB]/g},
{'base':'O', 'letters':/[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]/g},
{'base':'OI','letters':/[\u01A2]/g},
{'base':'OO','letters':/[\uA74E]/g},
{'base':'OU','letters':/[\u0222]/g},
{'base':'P', 'letters':/[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]/g},
{'base':'Q', 'letters':/[\u0051\u24C6\uFF31\uA756\uA758\u024A]/g},
{'base':'R', 'letters':/[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]/g},
{'base':'S', 'letters':/[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]/g},
{'base':'T', 'letters':/[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]/g},
{'base':'TZ','letters':/[\uA728]/g},
{'base':'U', 'letters':/[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]/g},
{'base':'V', 'letters':/[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]/g},
{'base':'VY','letters':/[\uA760]/g},
{'base':'W', 'letters':/[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]/g},
{'base':'X', 'letters':/[\u0058\u24CD\uFF38\u1E8A\u1E8C]/g},
{'base':'Y', 'letters':/[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]/g},
{'base':'Z', 'letters':/[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]/g},
{'base':'a', 'letters':/[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]/g},
{'base':'aa','letters':/[\uA733]/g},
{'base':'ae','letters':/[\u00E6\u01FD\u01E3]/g},
{'base':'ao','letters':/[\uA735]/g},
{'base':'au','letters':/[\uA737]/g},
{'base':'av','letters':/[\uA739\uA73B]/g},
{'base':'ay','letters':/[\uA73D]/g},
{'base':'b', 'letters':/[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]/g},
{'base':'c', 'letters':/[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]/g},
{'base':'d', 'letters':/[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]/g},
{'base':'dz','letters':/[\u01F3\u01C6]/g},
{'base':'e', 'letters':/[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]/g},
{'base':'f', 'letters':/[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]/g},
{'base':'g', 'letters':/[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]/g},
{'base':'h', 'letters':/[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]/g},
{'base':'hv','letters':/[\u0195]/g},
{'base':'i', 'letters':/[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]/g},
{'base':'j', 'letters':/[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]/g},
{'base':'k', 'letters':/[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]/g},
{'base':'l', 'letters':/[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]/g},
{'base':'lj','letters':/[\u01C9]/g},
{'base':'m', 'letters':/[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]/g},
{'base':'n', 'letters':/[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]/g},
{'base':'nj','letters':/[\u01CC]/g},
{'base':'o', 'letters':/[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]/g},
{'base':'oi','letters':/[\u01A3]/g},
{'base':'ou','letters':/[\u0223]/g},
{'base':'oo','letters':/[\uA74F]/g},
{'base':'p','letters':/[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]/g},
{'base':'q','letters':/[\u0071\u24E0\uFF51\u024B\uA757\uA759]/g},
{'base':'r','letters':/[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]/g},
{'base':'s','letters':/[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]/g},
{'base':'t','letters':/[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]/g},
{'base':'tz','letters':/[\uA729]/g},
{'base':'u','letters':/[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]/g},
{'base':'v','letters':/[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]/g},
{'base':'vy','letters':/[\uA761]/g},
{'base':'w','letters':/[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]/g},
{'base':'x','letters':/[\u0078\u24E7\uFF58\u1E8B\u1E8D]/g},
{'base':'y','letters':/[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]/g},
{'base':'z','letters':/[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]/g}
];
var changes;
function removeAccents (str) {
if(!changes) {
changes = defaultAccentMap;
}
for(var i=0; i<changes.length; i++) {
str = str.replace(changes[i].letters, changes[i].base);
}
return str;
}
/*!!!!!!!!!!!!!!!!!!!!! IN HOUSE plugins all above !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*!!!!!!!!!!!!!!!!!!!!! THIRD PARTY plugins below this area !!!!!!!!!!!!!!!!!!!!!!!!*/
/* jq Cookie plugin */
/*jslint browser: true */ /*global jq: true */
/*
jq Cookie plugin
Copyright (c) 2010 Klaus Hartl (stilbuero.de)
Dual licensed under the MIT and GPL licenses:
http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl.html
Create a cookie with the given key and value and other optional parameters.
@example jq.cookie('the_cookie', 'the_value');
@desc Set the value of a cookie.
@example jq.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jq.com', secure: true });
@desc Create a cookie with all available options.
@example jq.cookie('the_cookie', 'the_value');
@desc Create a session cookie.
@example jq.cookie('the_cookie', null);
@desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
used when the cookie was set.
@param String key The key of the cookie.
@param String value The value of the cookie.
@param Object options An object literal containing key/value pairs to provide optional cookie attributes.
@option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
If set to null or omitted, the cookie will be a session cookie and will not be retained
when the the browser exits.
@option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
@option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
@option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
require a secure protocol (like HTTPS).
@type undefined
@name jq.cookie
@cat Plugins/Cookie
@author Klaus Hartl/klaus.hartl@stilbuero.de
Get the value of a cookie with the given key.
@example jq.cookie('the_cookie');
@desc Get the value of a cookie.
@param String key The key of the cookie.
@return The value of the cookie.
@type String
@name jq.cookie
@cat Plugins/Cookie
@author Klaus Hartl/klaus.hartl@stilbuero.de
*/jq.cookie = function (key, value, options) {
// key and value given, set cookie...
if (arguments.length > 1 && (value === null || typeof value !== "object")) {
options = jq.extend({}, options);
if (value === null) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
return (document.cookie = [
encodeURIComponent(key), '=',
options.raw ? String(value) : encodeURIComponent(String(value)),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || {};
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
/* alpha numeric form field restrictor @ http://www.itgroup.com.ph/alphanumeric/ */
(function(jq) {
jq.fn.alphanumeric = function (p) {
p = jq.extend({
ichars: "!@#jq%^&*()+=[]\\\';,/{}|\":<>?~`.- ",
nchars: "",
allow: ""
}, p);
return this.each(
function () {
if (p.nocaps) p.nchars += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (p.allcaps) p.nchars += "abcdefghijklmnopqrstuvwxyz";
s = p.allow.split('');
for (i = 0; i < s.length; i++) if (p.ichars.indexOf(s[i]) != -1) s[i] = "\\" + s[i];
p.allow = s.join('|');
var reg = new RegExp(p.allow, 'gi');
var ch = p.ichars + p.nchars;
ch = ch.replace(reg, '');
jq(this).keypress(
function (e) {
if (!e.charCode) k = String.fromCharCode(e.which);
else k = String.fromCharCode(e.charCode);
if (ch.indexOf(k) != -1) e.preventDefault();
if (e.ctrlKey && k == 'v') e.preventDefault();
});
jq(this).bind('contextmenu', function () {
return false
});
});
};
jq.fn.numeric = function (p) {
var az = "abcdefghijklmnopqrstuvwxyz";
az += az.toUpperCase();
p = jq.extend({
nchars: az
}, p);
return this.each(function () {
jq(this).alphanumeric(p);
});
};
jq.fn.alpha = function (p) {
var nm = "1234567890";
p = jq.extend({
nchars: nm
}, p);
return this.each(function () {
jq(this).alphanumeric(p);
});
};
})(jQuery);
/*
jQuery Url Plugin
* Version 1.0
* 2009-03-22 19:30:05
* URL: http://ajaxcssblog.com/jquery/url-read-get-variables/
* Description: jQuery Url Plugin gives the ability to read GET parameters from the actual URL
* Author: Matthias Jäggli
* Copyright: Copyright (c) 2009 Matthias Jäggli under dual MIT/GPL license.
*/
(function ($) {
$.url = {};
$.extend($.url, {
_params: {},
init: function(){
var paramsRaw = "";
try{
paramsRaw = 
(document.location.href.split("?", 2)[1] || "").split("#")[0].split("&") || [];
for(var i = 0; i< paramsRaw.length; i++){
var single = paramsRaw[i].split("=");
if(single[0])
this._params[single[0]] = unescape(single[1]);
}
}
catch(e){
alert(e);
}
},
param: function(name){
return this._params[name] || "";
},
paramAll: function(){
return this._params;
}
});
$.url.init();
})(jQuery);
/*
*jQuery browser plugin detection 1.0.3
* http://plugins.jquery.com/project/jqplugin
* Checks for plugins / mimetypes supported in the browser extending the jQuery.browser object
* Copyright (c) 2008 Leonardo Rossetti motw.leo@gmail.com
* MIT License: http://www.opensource.org/licenses/mit-license.php
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
jQuery.browser.flash //Flash
jQuery.browser.sl //Silverlight
jQuery.browser.pdf /PDF format
jQuery.browser.qtime //Quicktime
jQuery.browser.wmp //Windows Media Player
jQuery.browser.shk //Shockwave
jQuery.browser.rp //Realplayer 
*/
(function ($) {
//checks if browser object exists
if (typeof $.browser === "undefined" || !$.browser) {
var browser = {};
$.extend(browser);
}
var pluginList = {
flash: {
activex: ["ShockwaveFlash.ShockwaveFlash", "ShockwaveFlash.ShockwaveFlash.3", "ShockwaveFlash.ShockwaveFlash.4", "ShockwaveFlash.ShockwaveFlash.5", "ShockwaveFlash.ShockwaveFlash.6", "ShockwaveFlash.ShockwaveFlash.7"],
plugin: /flash/gim
},
sl: {
activex: ["AgControl.AgControl"],
plugin: /silverlight/gim
},
pdf: {
activex: ["acroPDF.PDF.1", "PDF.PdfCtrl.1", "PDF.PdfCtrl.4", "PDF.PdfCtrl.5", "PDF.PdfCtrl.6"],
plugin: /adobe\s?acrobat/gim
},
qtime: {
activex: ["QuickTime.QuickTime", "QuickTimeCheckObject.QuickTimeCheck.1", "QuickTime.QuickTime.4"],
plugin: /quicktime/gim
},
wmp: {
activex: ["WMPlayer.OCX", "MediaPlayer.MediaPlayer.1"],
plugin: /(windows\smedia)|(Microsoft)/gim
},
shk: {
activex: ["SWCtl.SWCtl", "SWCt1.SWCt1.7", "SWCt1.SWCt1.8", "SWCt1.SWCt1.9", "ShockwaveFlash.ShockwaveFlash.1"],
plugin: /shockwave/gim
},
rp: {
activex: ["RealPlayer", "rmocx.RealPlayer G2 Control.1"],
plugin: /realplayer/gim
}
};
var isSupported = function (p) {
if (window.ActiveXObject) {
$.browser[p] = false;
for (i = 0; i < pluginList[p].activex.length; i++) {
try {
new ActiveXObject(pluginList[p].activex[i]);
$.browser[p] = true;
} catch (e) {}	
}
} else {
$.each(navigator.plugins, function () {
if (this.name.match(pluginList[p].plugin)) {
$.browser[p] = true;
return false;
} else {
$.browser[p] = false;
}
});
}
};
$.each(pluginList, function (i, n) {
isSupported(i);
});
})(jQuery);
/* used on homepage for HPT flash treatments */
/*
### jQuery XML to JSON Plugin v1.0 - 2008-07-01 ###
* http://www.fyneworks.com/ - diego@fyneworks.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
###
Website: http://www.fyneworks.com/jquery/xml-to-json/
*/
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';5(10.M)(w($){$.N({11:w(j,k){5(!j)t{};w B(d,e){5(!d)t y;6 f=\'\',2=y,E=y;6 g=d.x,12=l(d.O||d.P);6 h=d.v||d.F||\'\';5(d.G){5(d.G.7>0){$.Q(d.G,w(n,a){6 b=a.x,u=l(a.O||a.P);6 c=a.v||a.F||\'\';5(b==8){t}z 5(b==3||b==4||!u){5(c.13(/^\\s+$/)){t};f+=c.H(/^\\s+/,\'\').H(/\\s+$/,\'\')}z{2=2||{};5(2[u]){5(!2[u].7)2[u]=p(2[u]);2[u][2[u].7]=B(a,R);2[u].7=2[u].7}z{2[u]=B(a)}}})}};5(d.I){5(d.I.7>0){E={};2=2||{};$.Q(d.I,w(a,b){6 c=l(b.14),C=b.15;E[c]=C;5(2[c]){5(!2[c].7)2[c]=p(2[c]);2[c][2[c].7]=C;2[c].7=2[c].7}z{2[c]=C}})}};5(2){2=$.N((f!=\'\'?A J(f):{}),2||{});f=(2.v)?(D(2.v)==\'16\'?2.v:[2.v||\'\']).17([f]):f;5(f)2.v=f;f=\'\'};6 i=2||f;5(k){5(f)i={};f=i.v||f||\'\';5(f)i.v=f;5(!e)i=p(i)};t i};6 l=w(s){t J(s||\'\').H(/-/g,"18")};6 m=w(s){t(D s=="19")||J((s&&D s=="K")?s:\'\').1a(/^((-)?([0-9]*)((\\.{0,1})([0-9]+))?$)/)};6 p=w(o){5(!o.7)o=[o];o.7=o.7;t o};5(D j==\'K\')j=$.S(j);5(!j.x)t;5(j.x==3||j.x==4)t j.F;6 q=(j.x==9)?j.1b:j;6 r=B(q,R);j=y;q=y;t r},S:w(a){6 b;T{6 c=($.U.V)?A 1c("1d.1e"):A 1f();c.1g=W}X(e){Y A L("Z 1h 1i 1j 1k 1l")};T{5($.U.V)b=(c.1m(a))?c:W;z b=c.1n(a,"v/1o")}X(e){Y A L("L 1p Z K")};t b}})})(M);',62,88,'||obj|||if|var|length||||||||||||||||||||||return|cnn|text|function|nodeType|null|else|new|parseXML|atv|typeof|att|nodeValue|childNodes|replace|attributes|String|string|Error|jQuery|extend|localName|nodeName|each|true|text2xml|try|browser|msie|false|catch|throw|XML|window|xml2json|nn|match|name|value|object|concat|_|number|test|documentElement|ActiveXObject|Microsoft|XMLDOM|DOMParser|async|Parser|could|not|be|instantiated|loadXML|parseFromString|xml|parsing'.split('|'),0,{}));
/**
* jQuery.browser.mobile (http://detectmobilebrowser.com/)
*
* jQuery.browser.mobile will be true if the browser is a mobile device
*
**/
(function(a){jQuery.browser.mobile=/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera);

