/*Tuesday, 14 February 2012 10:01 AM*/
/**/
/**/

/*
* jScrollPane - v2.0.0beta11 - 2011-05-02
* http://jscrollpane.kelvinluck.com/
*
* Copyright (c) 2010 Kelvin Luck
* Dual licensed under the MIT and GPL licenses.
*/
(function (b, a, c) {
    b.fn.jScrollPane = function (e) {
        function d(D, O) {
            var az, Q = this, Y, ak, v, am, T, Z, y, q, aA, aF, av, i, I, h, j, aa, U, aq, X, t, A, ar, af, an, G, l, au, ay, x, aw, aI, f, L, aj = true, P = true, aH = false, k = false, ap = D.clone(false, false).empty(), ac = b.fn.mwheelIntent ? "mwheelIntent.jsp" : "mousewheel.jsp"; aI = D.css("paddingTop") + " " + D.css("paddingRight") + " " + D.css("paddingBottom") + " " + D.css("paddingLeft"); f = (parseInt(D.css("paddingLeft"), 10) || 0) + (parseInt(D.css("paddingRight"), 10) || 0); function at(aR) { var aM, aO, aN, aK, aJ, aQ, aP = false, aL = false; az = aR; if (Y === c) { aJ = D.scrollTop(); aQ = D.scrollLeft(); D.css({ overflow: "hidden", padding: 0 }); ak = D.innerWidth() + f; v = D.innerHeight(); D.width(ak); Y = b('<div class="jspPane" />').css("padding", aI).append(D.children()); am = b('<div class="jspContainer" />').css({ width: ak + "px", height: v + "px" }).append(Y).appendTo(D) } else { D.css("width", ""); aP = az.stickToBottom && K(); aL = az.stickToRight && B(); aK = D.innerWidth() + f != ak || D.outerHeight() != v; if (aK) { ak = D.innerWidth() + f; v = D.innerHeight(); am.css({ width: ak + "px", height: v + "px" }) } if (!aK && L == T && Y.outerHeight() == Z) { D.width(ak); return } L = T; Y.css("width", ""); D.width(ak); am.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end() } Y.css("overflow", "auto"); if (aR.contentWidth) { T = aR.contentWidth } else { T = Y[0].scrollWidth } Z = Y[0].scrollHeight; Y.css("overflow", ""); y = T / ak; q = Z / v; aA = q > 1; aF = y > 1; if (!(aF || aA)) { D.removeClass("jspScrollable"); Y.css({ top: 0, width: am.width() - f }); n(); E(); R(); w(); ai() } else { D.addClass("jspScrollable"); aM = az.maintainPosition && (I || aa); if (aM) { aO = aD(); aN = aB() } aG(); z(); F(); if (aM) { N(aL ? (T - ak) : aO, false); M(aP ? (Z - v) : aN, false) } J(); ag(); ao(); if (az.enableKeyboardNavigation) { S() } if (az.clickOnTrack) { p() } C(); if (az.hijackInternalLinks) { m() } } if (az.autoReinitialise && !aw) { aw = setInterval(function () { at(az) }, az.autoReinitialiseDelay) } else { if (!az.autoReinitialise && aw) { clearInterval(aw) } } aJ && D.scrollTop(0) && M(aJ, false); aQ && D.scrollLeft(0) && N(aQ, false); D.trigger("jsp-initialised", [aF || aA]) } function aG() { if (aA) { am.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'), b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'), b('<div class="jspDragBottom" />'))), b('<div class="jspCap jspCapBottom" />'))); U = am.find(">.jspVerticalBar"); aq = U.find(">.jspTrack"); av = aq.find(">.jspDrag"); if (az.showArrows) { ar = b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp", aE(0, -1)).bind("click.jsp", aC); af = b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp", aE(0, 1)).bind("click.jsp", aC); if (az.arrowScrollOnHover) { ar.bind("mouseover.jsp", aE(0, -1, ar)); af.bind("mouseover.jsp", aE(0, 1, af)) } al(aq, az.verticalArrowPositions, ar, af) } t = v; am.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function () { t -= b(this).outerHeight() }); av.hover(function () { av.addClass("jspHover") }, function () { av.removeClass("jspHover") }).bind("mousedown.jsp", function (aJ) { b("html").bind("dragstart.jsp selectstart.jsp", aC); av.addClass("jspActive"); var s = aJ.pageY - av.position().top; b("html").bind("mousemove.jsp", function (aK) { V(aK.pageY - s, false) }).bind("mouseup.jsp mouseleave.jsp", ax); return false }); o() } } function o() { aq.height(t + "px"); I = 0; X = az.verticalGutter + aq.outerWidth(); Y.width(ak - X - f); try { if (U.position().left === 0) { Y.css("margin-left", X + "px") } } catch (s) { } } function z() {
                if (aF) {
                    am.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'), b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'), b('<div class="jspDragRight" />'))), b('<div class="jspCap jspCapRight" />'))); an = am.find(">.jspHorizontalBar"); G = an.find(">.jspTrack"); h = G.find(">.jspDrag"); if (az.showArrows) {
                        ay = b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp", aE(-1, 0)).bind("click.jsp", aC); x = b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp", aE(1, 0)).bind("click.jsp", aC);
                        if (az.arrowScrollOnHover) { ay.bind("mouseover.jsp", aE(-1, 0, ay)); x.bind("mouseover.jsp", aE(1, 0, x)) } al(G, az.horizontalArrowPositions, ay, x)
                    } h.hover(function () { h.addClass("jspHover") }, function () { h.removeClass("jspHover") }).bind("mousedown.jsp", function (aJ) { b("html").bind("dragstart.jsp selectstart.jsp", aC); h.addClass("jspActive"); var s = aJ.pageX - h.position().left; b("html").bind("mousemove.jsp", function (aK) { W(aK.pageX - s, false) }).bind("mouseup.jsp mouseleave.jsp", ax); return false }); l = am.innerWidth(); ah()
                } 
            } function ah() { am.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function () { l -= b(this).outerWidth() }); G.width(l + "px"); aa = 0 } function F() { if (aF && aA) { var aJ = G.outerHeight(), s = aq.outerWidth(); t -= aJ; b(an).find(">.jspCap:visible,>.jspArrow").each(function () { l += b(this).outerWidth() }); l -= s; v -= s; ak -= aJ; G.parent().append(b('<div class="jspCorner" />').css("width", aJ + "px")); o(); ah() } if (aF) { Y.width((am.outerWidth() - f) + "px") } Z = Y.outerHeight(); q = Z / v; if (aF) { au = Math.ceil(1 / y * l); if (au > az.horizontalDragMaxWidth) { au = az.horizontalDragMaxWidth } else { if (au < az.horizontalDragMinWidth) { au = az.horizontalDragMinWidth } } h.width(au + "px"); j = l - au; ae(aa) } if (aA) { A = Math.ceil(1 / q * t); if (A > az.verticalDragMaxHeight) { A = az.verticalDragMaxHeight } else { if (A < az.verticalDragMinHeight) { A = az.verticalDragMinHeight } } av.height(A + "px"); i = t - A; ad(I) } } function al(aK, aM, aJ, s) { var aO = "before", aL = "after", aN; if (aM == "os") { aM = /Mac/.test(navigator.platform) ? "after" : "split" } if (aM == aO) { aL = aM } else { if (aM == aL) { aO = aM; aN = aJ; aJ = s; s = aN } } aK[aO](aJ)[aL](s) } function aE(aJ, s, aK) { return function () { H(aJ, s, this, aK); this.blur(); return false } } function H(aM, aL, aP, aO) { aP = b(aP).addClass("jspActive"); var aN, aK, aJ = true, s = function () { if (aM !== 0) { Q.scrollByX(aM * az.arrowButtonSpeed) } if (aL !== 0) { Q.scrollByY(aL * az.arrowButtonSpeed) } aK = setTimeout(s, aJ ? az.initialDelay : az.arrowRepeatFreq); aJ = false }; s(); aN = aO ? "mouseout.jsp" : "mouseup.jsp"; aO = aO || b("html"); aO.bind(aN, function () { aP.removeClass("jspActive"); aK && clearTimeout(aK); aK = null; aO.unbind(aN) }) } function p() { w(); if (aA) { aq.bind("mousedown.jsp", function (aO) { if (aO.originalTarget === c || aO.originalTarget == aO.currentTarget) { var aM = b(this), aP = aM.offset(), aN = aO.pageY - aP.top - I, aK, aJ = true, s = function () { var aS = aM.offset(), aT = aO.pageY - aS.top - A / 2, aQ = v * az.scrollPagePercent, aR = i * aQ / (Z - v); if (aN < 0) { if (I - aR > aT) { Q.scrollByY(-aQ) } else { V(aT) } } else { if (aN > 0) { if (I + aR < aT) { Q.scrollByY(aQ) } else { V(aT) } } else { aL(); return } } aK = setTimeout(s, aJ ? az.initialDelay : az.trackClickRepeatFreq); aJ = false }, aL = function () { aK && clearTimeout(aK); aK = null; b(document).unbind("mouseup.jsp", aL) }; s(); b(document).bind("mouseup.jsp", aL); return false } }) } if (aF) { G.bind("mousedown.jsp", function (aO) { if (aO.originalTarget === c || aO.originalTarget == aO.currentTarget) { var aM = b(this), aP = aM.offset(), aN = aO.pageX - aP.left - aa, aK, aJ = true, s = function () { var aS = aM.offset(), aT = aO.pageX - aS.left - au / 2, aQ = ak * az.scrollPagePercent, aR = j * aQ / (T - ak); if (aN < 0) { if (aa - aR > aT) { Q.scrollByX(-aQ) } else { W(aT) } } else { if (aN > 0) { if (aa + aR < aT) { Q.scrollByX(aQ) } else { W(aT) } } else { aL(); return } } aK = setTimeout(s, aJ ? az.initialDelay : az.trackClickRepeatFreq); aJ = false }, aL = function () { aK && clearTimeout(aK); aK = null; b(document).unbind("mouseup.jsp", aL) }; s(); b(document).bind("mouseup.jsp", aL); return false } }) } } function w() { if (G) { G.unbind("mousedown.jsp") } if (aq) { aq.unbind("mousedown.jsp") } } function ax() { b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp"); if (av) { av.removeClass("jspActive") } if (h) { h.removeClass("jspActive") } } function V(s, aJ) { if (!aA) { return } if (s < 0) { s = 0 } else { if (s > i) { s = i } } if (aJ === c) { aJ = az.animateScroll } if (aJ) { Q.animate(av, "top", s, ad) } else { av.css("top", s); ad(s) } } function ad(aJ) { if (aJ === c) { aJ = av.position().top } am.scrollTop(0); I = aJ; var aM = I === 0, aK = I == i, aL = aJ / i, s = -aL * (Z - v); if (aj != aM || aH != aK) { aj = aM; aH = aK; D.trigger("jsp-arrow-change", [aj, aH, P, k]) } u(aM, aK); Y.css("top", s); D.trigger("jsp-scroll-y", [-s, aM, aK]).trigger("scroll") } function W(aJ, s) {
                if (!aF) { return } if (aJ < 0) { aJ = 0 } else { if (aJ > j) { aJ = j } } if (s === c) { s = az.animateScroll } if (s) {
                    Q.animate(h, "left", aJ, ae)
                } else { h.css("left", aJ); ae(aJ) } 
            } function ae(aJ) { if (aJ === c) { aJ = h.position().left } am.scrollTop(0); aa = aJ; var aM = aa === 0, aL = aa == j, aK = aJ / j, s = -aK * (T - ak); if (P != aM || k != aL) { P = aM; k = aL; D.trigger("jsp-arrow-change", [aj, aH, P, k]) } r(aM, aL); Y.css("left", s); D.trigger("jsp-scroll-x", [-s, aM, aL]).trigger("scroll") } function u(aJ, s) { if (az.showArrows) { ar[aJ ? "addClass" : "removeClass"]("jspDisabled"); af[s ? "addClass" : "removeClass"]("jspDisabled") } } function r(aJ, s) { if (az.showArrows) { ay[aJ ? "addClass" : "removeClass"]("jspDisabled"); x[s ? "addClass" : "removeClass"]("jspDisabled") } } function M(s, aJ) { var aK = s / (Z - v); V(aK * i, aJ) } function N(aJ, s) { var aK = aJ / (T - ak); W(aK * j, s) } function ab(aW, aR, aK) { var aO, aL, aM, s = 0, aV = 0, aJ, aQ, aP, aT, aS, aU; try { aO = b(aW) } catch (aN) { return } aL = aO.outerHeight(); aM = aO.outerWidth(); am.scrollTop(0); am.scrollLeft(0); while (!aO.is(".jspPane")) { s += aO.position().top; aV += aO.position().left; aO = aO.offsetParent(); if (/^body|html$/i.test(aO[0].nodeName)) { return } } aJ = aB(); aP = aJ + v; if (s < aJ || aR) { aS = s - az.verticalGutter } else { if (s + aL > aP) { aS = s - v + aL + az.verticalGutter } } if (aS) { M(aS, aK) } aQ = aD(); aT = aQ + ak; if (aV < aQ || aR) { aU = aV - az.horizontalGutter } else { if (aV + aM > aT) { aU = aV - ak + aM + az.horizontalGutter } } if (aU) { N(aU, aK) } } function aD() { return -Y.position().left } function aB() { return -Y.position().top } function K() { var s = Z - v; return (s > 20) && (s - aB() < 10) } function B() { var s = T - ak; return (s > 20) && (s - aD() < 10) } function ag() { am.unbind(ac).bind(ac, function (aM, aN, aL, aJ) { var aK = aa, s = I; Q.scrollBy(aL * az.mouseWheelSpeed, -aJ * az.mouseWheelSpeed, false); return aK == aa && s == I }) } function n() { am.unbind(ac) } function aC() { return false } function J() { Y.find(":input,a").unbind("focus.jsp").bind("focus.jsp", function (s) { ab(s.target, false) }) } function E() { Y.find(":input,a").unbind("focus.jsp") } function S() { var s, aJ, aL = []; aF && aL.push(an[0]); aA && aL.push(U[0]); Y.focus(function () { D.focus() }); D.attr("tabindex", 0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp", function (aO) { if (aO.target !== this && !(aL.length && b(aO.target).closest(aL).length)) { return } var aN = aa, aM = I; switch (aO.keyCode) { case 40: case 38: case 34: case 32: case 33: case 39: case 37: s = aO.keyCode; aK(); break; case 35: M(Z - v); s = null; break; case 36: M(0); s = null; break } aJ = aO.keyCode == s && aN != aa || aM != I; return !aJ }).bind("keypress.jsp", function (aM) { if (aM.keyCode == s) { aK() } return !aJ }); if (az.hideFocus) { D.css("outline", "none"); if ("hideFocus" in am[0]) { D.attr("hideFocus", true) } } else { D.css("outline", ""); if ("hideFocus" in am[0]) { D.attr("hideFocus", false) } } function aK() { var aN = aa, aM = I; switch (s) { case 40: Q.scrollByY(az.keyboardSpeed, false); break; case 38: Q.scrollByY(-az.keyboardSpeed, false); break; case 34: case 32: Q.scrollByY(v * az.scrollPagePercent, false); break; case 33: Q.scrollByY(-v * az.scrollPagePercent, false); break; case 39: Q.scrollByX(az.keyboardSpeed, false); break; case 37: Q.scrollByX(-az.keyboardSpeed, false); break } aJ = aN != aa || aM != I; return aJ } } function R() { D.attr("tabindex", "-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp") } function C() { if (location.hash && location.hash.length > 1) { var aK, aJ; try { aK = b(location.hash) } catch (s) { return } if (aK.length && Y.find(location.hash)) { if (am.scrollTop() === 0) { aJ = setInterval(function () { if (am.scrollTop() > 0) { ab(location.hash, true); b(document).scrollTop(am.position().top); clearInterval(aJ) } }, 50) } else { ab(location.hash, true); b(document).scrollTop(am.position().top) } } } } function ai() { b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack") } function m() { ai(); b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack", function () { var s = this.href.split("#"), aJ; if (s.length > 1) { aJ = s[1]; if (aJ.length > 0 && Y.find("#" + aJ).length > 0) { ab("#" + aJ, true); return false } } }) } function ao() {
                var aK, aJ, aM, aL, aN, s = false; am.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp", function (aO) { var aP = aO.originalEvent.touches[0]; aK = aD(); aJ = aB(); aM = aP.pageX; aL = aP.pageY; aN = false; s = true }).bind("touchmove.jsp", function (aR) {
                    if (!s) { return } var aQ = aR.originalEvent.touches[0], aP = aa, aO = I; Q.scrollTo(aK + aM - aQ.pageX, aJ + aL - aQ.pageY); aN = aN || Math.abs(aM - aQ.pageX) > 5 || Math.abs(aL - aQ.pageY) > 5;
                    return aP == aa && aO == I
                }).bind("touchend.jsp", function (aO) { s = false }).bind("click.jsp-touchclick", function (aO) { if (aN) { aN = false; return false } })
            } function g() { var s = aB(), aJ = aD(); D.removeClass("jspScrollable").unbind(".jsp"); D.replaceWith(ap.append(Y.children())); ap.scrollTop(s); ap.scrollLeft(aJ) } b.extend(Q, { reinitialise: function (aJ) { aJ = b.extend({}, az, aJ); at(aJ) }, scrollToElement: function (aK, aJ, s) { ab(aK, aJ, s) }, scrollTo: function (aK, s, aJ) { N(aK, aJ); M(s, aJ) }, scrollToX: function (aJ, s) { N(aJ, s) }, scrollToY: function (s, aJ) { M(s, aJ) }, scrollToPercentX: function (aJ, s) { N(aJ * (T - ak), s) }, scrollToPercentY: function (aJ, s) { M(aJ * (Z - v), s) }, scrollBy: function (aJ, s, aK) { Q.scrollByX(aJ, aK); Q.scrollByY(s, aK) }, scrollByX: function (s, aK) { s = (s >= 0) ? Math.max(s, 1) : Math.min(s, -1); var aJ = aD() + s, aL = aJ / (T - ak); W(aL * j, aK) }, scrollByY: function (s, aK) { s = (s >= 0) ? Math.max(s, 1) : Math.min(s, -1); var aJ = aB() + s, aL = aJ / (Z - v); V(aL * i, aK) }, positionDragX: function (s, aJ) { W(s, aJ) }, positionDragY: function (aJ, s) { V(aJ, s) }, animate: function (aJ, aM, s, aL) { var aK = {}; aK[aM] = s; aJ.animate(aK, { duration: az.animateDuration, ease: az.animateEase, queue: false, step: aL }) }, getContentPositionX: function () { return aD() }, getContentPositionY: function () { return aB() }, getContentWidth: function () { return T }, getContentHeight: function () { return Z }, getPercentScrolledX: function () { return aD() / (T - ak) }, getPercentScrolledY: function () { return aB() / (Z - v) }, getIsScrollableH: function () { return aF }, getIsScrollableV: function () { return aA }, getContentPane: function () { return Y }, scrollToBottom: function (s) { V(i, s) }, hijackInternalLinks: function () { m() }, destroy: function () { g() } }); at(O)
        } e = b.extend({}, b.fn.jScrollPane.defaults, e); b.each(["mouseWheelSpeed", "arrowButtonSpeed", "trackClickSpeed", "keyboardSpeed"], function () { e[this] = e[this] || e.speed }); return this.each(function () { var f = b(this), g = f.data("jsp"); if (g) { g.reinitialise(e) } else { g = new d(f, e); f.data("jsp", g) } })
    }; b.fn.jScrollPane.defaults = { showArrows: false, maintainPosition: true, stickToBottom: false, stickToRight: false, clickOnTrack: true, autoReinitialise: false, autoReinitialiseDelay: 500, verticalDragMinHeight: 0, verticalDragMaxHeight: 99999, horizontalDragMinWidth: 0, horizontalDragMaxWidth: 99999, contentWidth: c, animateScroll: false, animateDuration: 300, animateEase: "linear", hijackInternalLinks: false, verticalGutter: 4, horizontalGutter: 4, mouseWheelSpeed: 0, arrowButtonSpeed: 0, arrowRepeatFreq: 50, arrowScrollOnHover: false, trackClickSpeed: 0, trackClickRepeatFreq: 70, verticalArrowPositions: "split", horizontalArrowPositions: "split", enableKeyboardNavigation: true, hideFocus: false, keyboardSpeed: 0, initialDelay: 300, speed: 30, scrollPagePercent: 0.8}
})(jQuery, this);

// ************** video Settings
//Param Init
var moVideoParam = new Array();
moVideoParam['appFeedAlias'] = "main-player";
moVideoParam['apiKey'] = "movideoNetwork10";
//moVideoParam['mediaId'] = ""; 
moVideoParam['token'] = "";
moVideoParam['videoPageURL'] = "http://ten.com.au/video-player.htm";
moVideoParam['feedSearchTag'] = "['catch%20up%20tv']";
//Default playlist
moVideoParam['playlist'] = "40338";
moVideoParam['apiUrl'] = '/api/rest/';
 

/* ---------------------------------------------------------------------------------------- */
/* MO-VIDEO API SETTINGS
/* ---------------------------------------------------------------------------------------- */
var videoSettings = new Object();
/* Account Settings */
videoSettings.appName = "main-player";
videoSettings.apiKey = "movideoNetwork10";
/* URL Settings */
videoSettings.videoPageURL = "/video-player.htm";
/* Omniture Settings */
videoSettings.omnitureAccount = "nwtten";
videoSettings.omnitureGlobalSuite = "nwtglobal";
videoSettings.omniutreSuite = "networkten";
/* VAST Settings */
videoSettings.vastSite = "tendigital";
videoSettings.vastPlayer = "TEN";
videoSettings.vastMediaTag = "";
videoSettings.vastReplaceToken = "mediaPath";
/* General Settings */
videoSettings.mediaParam = "movideo_m";
videoSettings.playlistParam = "movideo_p";
videoSettings.apiUrl = "/api/rest/";

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Common JS Script
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Redirect from iframe to Fullpage
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //if(top.location != self.location)
   // {
   //     top.location.href = self.location;
   // }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Retrieve Single Parameter
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Usage: writeIFrame('index2.html', 'successPage=/ausidol/login.html', 'height="300 width="300"');
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function writeIFrame(src, params, iframeoptions) {
  var str=window.location.href;
  if (str.indexOf('?') != -1)
  {
        str = (str.substr(str.indexOf('?'), str.length));
  }
  else 
        str='';
     
  if (params != null && params != '')
  {
     if (str.indexOf('?') != -1)
          str = str + '&' + params;
     else 
          str = '?' + params;
  }
  document.write('<iframe src="' + src + str + '" '+ iframeoptions + '/></iframe>');
  
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Usage: writeIFrameExternal('index2.html', 'successPage=/login.html', 'height="300 width="300"');
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function writeIFrameExternal(src, params, iframeoptions) {
  document.write('<iframe src="' + src + '" '+ iframeoptions + '/></iframe>');
  //alert('writeIFrameExternal called from common.js <iframe src="' + src + '" '+ iframeoptions + '/></iframe>' );
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Write Error Messages
//Usage: write error messages on div error_msg
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function writeError(errorMsg)
{
  document.getElementById('error_msg').innerHTML = errorMsg;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//For Header Animated Logo
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getCookie(c_name)
{
            if (document.cookie.length>0)
              {
              c_start=document.cookie.indexOf(c_name + "=");
              if (c_start!=-1)
                        { 
                        c_start=c_start + c_name.length+1;
                        c_end=document.cookie.indexOf(";",c_start);
                        if (c_end==-1) c_end=document.cookie.length
                                    return unescape(document.cookie.substring(c_start,c_end));
                        } 
              }
            return "";
}
function setCookie(c_name,value,expiredays)
{
            var exdate=new Date();
            exdate.setDate(exdate.getDate()+expiredays);
            document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
var cookieName = 'flashSession';
function isNewSession()
{
            if (getCookie(cookieName) == 'true') {
                        return false;
            }
            else {
                        setCookie(cookieName, 'true', null);
                        return true;
            }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Update iframe height
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function updateIFrame( height ) {
   var iframe = document.getElementById( 'iclpFrame' );
   iframe.setAttribute( 'height', height );
   setTimeout('window.stop()',20000);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Validate String for URL
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function validateURL(urlString) {
    var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
    return regexp.test(urlString);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
// This notice must stay intact for legal use.
// Visit http://www.dynamicdrive.com/ for full source code
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getposOffset(overlay, offsettype){
    var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
    var parentEl=overlay.offsetParent;
    while (parentEl!=null){
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
        parentEl=parentEl.offsetParent;
    }
    return totaloffset;
}
function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
    var subobj=document.getElementById(subobjstr)
    subobj.style.display=(subobj.style.display!="block")? "block" : "none"
    var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
    var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
    subobj.style.left=xpos+"px"
    subobj.style.top=ypos+"px"
    return false
}
else
    return true
}
function overlayclose(subobj){
    document.getElementById(subobj).style.display="none"
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Function String Trancate
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function truncateText(val, maxChars, wholeWords) {
                if (wholeWords == undefined)
                    wholeWords = true;
                if (val.length <= maxChars) {
                    return val;
                }
                else {
                    if (wholeWords) {
                        var lastSpace = val.indexOf(' ', maxChars);
                        if (lastSpace <= 0)
                            lastSpace = maxChars;
                        return val.substring(0, lastSpace) + '...';
                    }
                    else {
                        return val.substring(0, maxChars) + '...';
                    }
                }
            }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// URL encode / decode
// http://www.webtoolkit.info/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var Url = {
    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },
    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },
    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        }
        return utftext;
    },
    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;
        while ( i < utftext.length ) {
            c = utftext.charCodeAt(i);
            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }
        }
        return string;
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Function for lightbox url params
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getURLParam(strParamName){
    var strReturn = "";
    var strHref = window.location.href;
    if ( strHref.indexOf("?") > -1 ){
        var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
        var aQueryString = strQueryString.split("&");
        for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
            if (
                aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
                var aParam = aQueryString[iParam].split("=");
                strReturn = aParam[1];
                break;
            }
        }
    }
    return unescape(strReturn);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//End Common JS Script
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
{ // a dummy block, so I can collapse all the meta stuff in the editor
/****************************************************************************
 * jQuery 1.3.x plugin to shorten styled text to fit in a block, appending
 * an ellipsis ("...", &hellip;, Unicode: 2026) or other text.
 * (Only supports ltr text for now.)
 *
 * This is achieved by placing the text of the 'selected' element (eg. span or
 * div) inside a table and measuring its width. If it's too big to big to fit in
 * the element's parent block it's shortened and measured again until it (and
 * appended ellipsis or text) fits inside the block. A tooltip on the 'selected'
 * element displays the full original text.
 *
 * If the browser supports truncating text using the 'text-overflow:ellipsis'
 * CSS property then that will be used (if the text to append is the default
 * ellipsis).
 *
 * If the text is truncated by the plugin any markup in the text will be
 * stripped (eg: "<a" starts stripping, "< a" does not). This behaviour is
 * dictated by the jQuery .text(val) method.
 * The appended text may contain HTML however (a link or span for example).
 *
 * Usage Example ('selecting' a div with an id of "element"):
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.textTruncate.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#element").textTruncate();
        });
    </script>
 * By default the plugin will use the parent block's width as maximum width and
 * an ellipsis as appended text when truncating.
 *
 * There are three ways of configuring the plugin:
 *
 * 1) Passing a configuration hash as the plugin's argument, eg:
    .textTruncate({
        width: 300,
        tail: ' <a href="#">more</a>',
        tooltip: false
    });
 * 2) Using two optional arguments (deprecated!):
 * width = the desired pixel width, integer
 * tail = text/html to append when truncating
 *
 * 3) By changing the plugin defaults, eg:
    $.fn.textTruncate.defaults.tail = ' <a href="#">more</a>';
 * Note: there is no default width (unless you create one).
 *
 * You may want to set the element's css to {visibility:hidden;} so it won't
 * initially flash at full width.
 *
 *
 * Created by M. David Green (www.mdavidgreen.com) in 2009. Free to use for
 * personal or commercial purposes under MIT (X11) license with no warranty
 *
 * Heavily modified/simplified/improved by Marc Diethelm (http://web5.me/).
 *
****************************************************************************/
}
(function ($) {
    $.fn.textTruncate = function() {
        var userOptions = {};
        var args = arguments; // for better minification
        var func = args.callee // dito; and much shorter than $.fn.textTruncate
        if ( args.length ) {
            if ( args[0].constructor == Object ) {
                userOptions = args[0];
            } else if ( args[0] == "options" ) {
                return $(this).eq(0).data("options-truncate");
            } else {
                userOptions = {
                    width: parseInt(args[0]),
                    tail: args[1]
                }
            }
        }
        this.css("visibility","hidden"); // Hide the element(s) while manipulating them
        // apply options vs. defaults
        var options = $.extend({}, func.defaults, userOptions);
        /**
         * HERE WE GO!
         **/
        return this.each(function () {
            var $this = $(this);
            $this.data("options-truncate", options);
            /**
             * If browser implements text-overflow:ellipsis in CSS and tail is "...", use it!
             **/
            if ( options.tail == "..." && func._native ) {
                this.style[func._native] = "ellipsis";
                /*var css_obj = {}
                css_obj[func._native] = "ellipsis";
                $this.css(css_obj);*/
                $this.css("visibility","visible");
                return true;
            }
            var width = options.width || $this.parent().width();
            var text = $this.text();
            var textlength = text.length;
            var css = "padding:0; margin:0; border:none; font:inherit;";
            var $table = $('<table style="'+ css +'width:auto;zoom:1;position:absolute;"><tr style="'+ css +'"><td style="'+ css +'white-space:nowrap;">' + options.tail + '</td></tr></table>');
            var $td = $("td", $table);
            $this.html( $table );
            var tailwidth = $td.width();
            var targetWidth = width - tailwidth;
            $td.text( text );
            if ($td.width() > width) {
                if ( options.tooltip ) {
                    $this.attr("title", text);
                }
                while ($td.width() >= targetWidth ) {
                    textlength--;
                    $td.html($td.html().substring(0, textlength)); // .html(val) is faster than .text(val) and we already used .text(val) to strip/escape html
                }
                text = $.trim( $td.html() );
                $this.html( text + options.tail );
            } else {
                $this.html( text );
            }
            this.style.visibility = "visible";
            return true;
        });
        return true;
    };
    var css = document.documentElement.style;
    var _native = false;
    if ( "textOverflow" in css ) {
        _native = "textOverflow";
    } else if ( "OTextOverflow" in css ) {
        _native = "OTextOverflow";
    }
    $.fn.textTruncate._native = _native;
    $.fn.textTruncate.defaults = {
        tail: "&hellip;",
        tooltip: true
    };
})(jQuery);
jQuery.fn.limitCharacters = function (maxChars) {
    // set to true if you don't want to break whole words
    var wholeWords = false;
    this.each(function () {
        var val = $(this).text();
        $(this).attr('title', val);
        if (val.length <= maxChars) {
            return;
        }
        else {
            if (wholeWords) {
                var lastSpace = val.indexOf(' ', maxChars);
                if (lastSpace <= 0)
                    lastSpace = maxChars;
                val = val.substring(0, lastSpace) + '...';
            }
            else {
                val = val.substring(0, maxChars) + '...';
            }
        }
        $(this).text(val);
    });
};

/* MODIFIED BY AT                                                                       */
/* ------------------------------------------------------------------------------------ */
(function ($) {
    $.fn.tweet = function (o) {
        var s = {
            username: [],              // [string]   required, unless you want to display our tweets. :) it can be an array, just do ["username1","username2","etc"]
            list: null,                              //[string]   optional name of list belonging to username
            avatar_size: null,                      // [integer]  height and width of avatar if displayed (48px max)
            count: 3,                               // [integer]  how many tweets to display?
            intro_text: null,                       // [string]   do you want text BEFORE your your tweets?
            outro_text: null,                       // [string]   do you want text AFTER your tweets?
            join_text: null,                       // [string]   optional text in between date and tweet, try setting to "auto"
            auto_join_text_default: "i said,",      // [string]   auto text for non verb: "i said" bullocks
            auto_join_text_ed: "i",                 // [string]   auto text for past tense: "i" surfed
            auto_join_text_ing: "i am",             // [string]   auto tense for present tense: "i was" surfing
            auto_join_text_reply: "i replied to",   // [string]   auto tense for replies: "i replied to" @someone "with"
            auto_join_text_url: "i was looking at", // [string]   auto tense for urls: "i was looking at" http:...
            loading_text: null,                     // [string]   optional loading text, displayed while tweets load
            query: null                             // [string]   optional search query
        };
        if (o) $.extend(s, o);
        $.fn.extend({
            linkUrl: function () {
                var returning = [];
                var regexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
                this.each(function () {
                    returning.push(this.replace(regexp, "<a target='_blank' href=\"$1\">$1</a>"));
                });
                return $(returning);
            },
            linkUser: function () {
                var returning = [];
                var regexp = /[\@]+([A-Za-z0-9-_]+)/gi;
                this.each(function () {
                    returning.push(this.replace(regexp, "<a target='_blank' href=\"http://twitter.com/$1\">@$1</a>"));
                });
                return $(returning);
            },
            linkHash: function () {
                var returning = [];
                var regexp = /(?:^| )[\#]+([A-Za-z0-9-_]+)/gi;
                this.each(function () {
                    returning.push(this.replace(regexp, ' <a target="_blank" href="http://search.twitter.com/search?q=&tag=$1&lang=all&from=' + s.username.join("%2BOR%2B") + '">#$1</a>'));
                });
                return $(returning);
            },
            capAwesome: function () {
                var returning = [];
                this.each(function () {
                    returning.push(this.replace(/\b(awesome)\b/gi, '<span class="awesome">$1</span>'));
                });
                return $(returning);
            },
            capEpic: function () {
                var returning = [];
                this.each(function () {
                    returning.push(this.replace(/\b(epic)\b/gi, '<span class="epic">$1</span>'));
                });
                return $(returning);
            },
            makeHeart: function () {
                var returning = [];
                this.each(function () {
                    returning.push(this.replace(/(&lt;)+[3]/gi, "<tt class='heart'>&#x2665;</tt>"));
                });
                return $(returning);
            }
        });
        function parse_date(date_str) {
            // The non-search twitter APIs return inconsistently-formatted dates, which Date.parse
            // cannot handle in IE. We therefore perform the following transformation:
            // "Wed Apr 29 08:53:31 +0000 2009" => "Wed, Apr 29 2009 08:53:31 +0000"
            return Date.parse(date_str.replace(/^([a-z]{3})( [a-z]{3} \d\d?)(.*)( \d{4})$/i, '$1,$2$4$3'));
        }
        function relative_time(time_value) {
            var parsed_date = parse_date(time_value);
            var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
            var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
            var r = '';
            if (delta < 60) {
                r = delta + ' seconds ago';
            } else if (delta < 120) {
                r = 'a minute ago';
            } else if (delta < (45 * 60)) {
                r = (parseInt(delta / 60, 10)).toString() + ' minutes ago';
            } else if (delta < (2 * 60 * 60)) {
                r = 'an hour ago';
            } else if (delta < (24 * 60 * 60)) {
                r = '' + (parseInt(delta / 3600, 10)).toString() + ' hours ago';
            } else if (delta < (48 * 60 * 60)) {
                r = 'a day ago';
            } else {
                r = (parseInt(delta / 86400, 10)).toString() + ' days ago';
            }
            return 'about ' + r;
        }
        function build_url() {
            var proto = ('https:' == document.location.protocol ? 'https:' : 'http:');
            if (s.list) {
                return proto + "//api.twitter.com/1/" + s.username[0] + "/lists/" + s.list + "/statuses.json?per_page=" + s.count + "&callback=?";
            } else if (s.query == null && s.username.length == 1) {
                return proto + '//api.twitter.com/1/statuses/user_timeline.json?screen_name=' + s.username[0] + '&count=' + s.count + '&include_rts=1&callback=?';
            } else {
                var query = (s.query || 'from:' + s.username.join(' OR from:'));
                return proto + '//search.twitter.com/search.json?&q=' + encodeURIComponent(query) + '&rpp=' + s.count + '&callback=?';
            }
        }
        return this.each(function (i, widget) {
            var list = $('<ul class="tweet_list">').appendTo(widget);
            var intro = '<p class="tweet_intro">' + s.intro_text + '</p>';
            var outro = '<p class="tweet_outro">' + s.outro_text + '</p>';
            var loading = $('<p class="loading">' + s.loading_text + '</p>');
            if (typeof (s.username) == "string") {
                s.username = [s.username];
            }
            if (s.loading_text) $(widget).append(loading);
            $.getJSON(build_url(), function (data) {
                if (s.loading_text) loading.remove();
                if (s.intro_text) list.before(intro);
                var tweets = (data.results || data);
                $.each(tweets, function (i, item) {
                    var from_user = item.from_user || item.user.screen_name;
                    // auto join text based on verb tense and content
                    if (s.join_text == "auto") {
                        if (item.text.match(/^(@([A-Za-z0-9-_]+)) .*/i)) {
                            var join_text = s.auto_join_text_reply;
                        } else if (item.text.match(/(^\w+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+) .*/i)) {
                            var join_text = s.auto_join_text_url;
                        } else if (item.text.match(/^((\w+ed)|just) .*/im)) {
                            var join_text = s.auto_join_text_ed;
                        } else if (item.text.match(/^(\w*ing) .*/i)) {
                            var join_text = s.auto_join_text_ing;
                        } else {
                            var join_text = s.auto_join_text_default;
                        }
                    } else if (s.join_text == "user") {
                        var join_text = '<a target="_blank" class="tweet_avatar" href="http://twitter.com/' + from_user + '">' + from_user + '</a>';
                    }
                    else {
                        var join_text = s.join_text;
                    };
                    var profile_image_url = item.profile_image_url || item.user.profile_image_url;
                    var join_template = '<span class="tweet_join"> ' + join_text + ' </span>';
                    var join = ((s.join_text) ? join_template : ' ');
                    var avatar_template = '<a target="_blank" class="tweet_avatar" href="http://twitter.com/' + from_user + '"><img src="' + profile_image_url + '" height="' + s.avatar_size + '" width="' + s.avatar_size + '" alt="' + from_user + '" title="' + from_user + '" border="0"/></a>';
                    var avatar = (s.avatar_size ? avatar_template : '');
                    var date = '<span class="tweet_time"><a target="_blank" href="http://twitter.com/' + from_user + '/statuses/' + item.id + '" title="view tweet on twitter">' + relative_time(item.created_at) + '</a></span>';
                    var text = '<span class="tweet_text">' + $([item.text]).linkUrl().linkUser().linkHash().makeHeart().capAwesome().capEpic()[0] + '</span>';
                    // until we create a template option, arrange the items below to alter a tweet's display.
                    //list.append('<li>' + avatar + join + date + text + '</li>');
                    //modified - AT
                    list.append('<li>' + avatar + '<div class="tweet_caption">' + join + date + '</div>' + text + '</li>');
                    list.children('li:first').addClass('tweet_first');
                    list.children('li:odd').addClass('tweet_even');
                    list.children('li:even').addClass('tweet_odd');
                });
                if (s.outro_text) list.after(outro);
                $(widget).trigger("loaded").trigger((tweets.length == 0 ? "empty" : "full"));
                // following line added by AT - 9 Nov 2010
                if (o.finished) o.finished();
            });
        });
    };
})(jQuery);

(function ($) {
    /*
    jquery.twitter.js v1.0
    Last updated: 26 October 2008
    Created by Damien du Toit
    http://coda.co.za/blog/2008/10/26/jquery-plugin-for-twitter
    Licensed under a Creative Commons Attribution-Non-Commercial 3.0 Unported License
    http://creativecommons.org/licenses/by-nc/3.0/
    */
    $.fn.getTwitter = function (options) {
        var o = $.extend({}, $.fn.getTwitter.defaults, options);
        // hide container element
        $(this).hide();
        // add heading to container element
        if (o.showHeading) {
            $(this).append('<h2>' + o.headingText + '</h2>');
        }
        // add twitter list to container element
        $(this).append('<ul id="twitter_update_list"><li></li></ul>');
        // hide twitter list
        $("ul#twitter_update_list").hide();
        // add preLoader to container element
        var pl = $('<p id="' + o.preloaderId + '">' + o.loaderText + '</p>');
        $(this).append(pl);
        // add Twitter profile link to container element
        if (o.showProfileLink) {
            $(this).append('<a id="profileLink" href="http://twitter.com/' + o.userName + '" target="_blank"><img src="/logo_twitter.gif"></a>');
        }
        // show container element
        $(this).show();
        $.getScript("http://twitter.com/javascripts/blogger.js");
        $.getScript("http://twitter.com/statuses/user_timeline/" + o.userName + ".json?callback=twitterCallback2&count=" + o.numTweets, function () {
            // remove preLoader from container element
            $(pl).remove();
            // show twitter list
            if (o.slideIn) {
                $("ul#twitter_update_list").slideDown(1000);
            }
            else {
                $("ul#twitter_update_list").show();
            }
            // give first list item a special class
            //$("ul#twitter_update_list li:first").addClass("firstTweet");
            // give last list item a special class
            $("ul#twitter_update_list li:last").addClass("lastTweet");
            $("ul#twitter_update_list li a").each(function () {
                var parentTag = $(this).parent().get(0).tagName;
                if (parentTag == "LI") {
                    $(this).addClass("twitLink");
                    $(this).attr("target", "_blank");
                };
            });
        });
    };
    // plugin defaults
    $.fn.getTwitter.defaults = {
        userName: null,
        numTweets: 5,
        preloaderId: "preloader",
        loaderText: "Loading tweets...",
        slideIn: false,
        showHeading: true,
        headingText: "Latest Tweets",
        showProfileLink: true
    };
})(jQuery);
/*
* jTwitter 1.0 - Twitter API abstraction plugin for jQuery
*
* Copyright (c) 2009 jQuery Howto
*
* Licensed under the GPL license:
*   http://www.gnu.org/licenses/gpl.html
*
* URL:
*   http://jquery-howto.blogspot.com
*
* Author URL:
*   http://me.boo.uz
*
*/
(function ($) {
    $.extend({
        jTwitter: function (username, fnk) {
            var url = "http://twitter.com/status/user_timeline/"
            + username + ".json?count=1&callback=?";
            var info = {};
            $.getJSON(url, function (data) {
                if (typeof fnk == 'function') fnk.call(this, data[0].user);
            });
        }
    });
})(jQuery);
/*
// (function(b){b.extend({jTwitter:function(d,a,c){if(!(d=="undefined"||a=="undefined")){if(b.isFunction(a)){c=a;a=5}b.getJSON("http://twitter.com/status/user_timeline/"+d+".json?count="+a+"&callback=?",function(e){b.isFunction(c)&&c.call(this,e)})}}})})(jQuery);function showTwitter(twitterAccount){$.jTwitter(twitterAccount,10,function(data){$('.twitter-widget .tweets').empty().append('<ul></ul>');$('.twitter-widget .followers').html(data[0].user.followers_count+' followers');$('.twitter-widget .image IMG').attr('src',data[0].user.profile_image_url);$('.twitter-widget .text A').append(data[0].user.name).attr('href','http://twitter.com/'+twitterAccount);$.each(data,function(i,post){var li=$('<li class="item"><div class="text"></div><div class="subtext"></div></li>');li.find('.text').append(linkify(post.text));li.find('.subtext').append(niceDate(post.created_at));$('.twitter-widget .tweets ul').append(li);});$('.twitter-widget .tweets').jScrollPane({scrollbarWidth:14,dragMaxHeight:27});});}
*/
/*
 * jTwitter 1.1.1 - Twitter API abstraction plugin for jQuery
 * Copyright (c) 2009 jQuery Howto
 * Licensed under the GPL license:
 *   http://www.gnu.org/licenses/gpl.html
 * Plugin + Author URL:
 *   http://jquery-howto.blogspot.com
 */
(function (b) { b.extend({ jTwitter: function (d, a, c) { if (!(d == "undefined" || a == "undefined")) { if (b.isFunction(a)) { c = a; a = 5 } b.getJSON("http://twitter.com/status/user_timeline/" + d + ".json?count=" + a + "&callback=?", function (e) { b.isFunction(c) && c.call(this, e) }) } } }) })(jQuery);
/*
 * Custom functions 
 */
 function showTwitter(twitterAccount) {
    
    // load tweets
     $.jTwitter(twitterAccount, 10, function (data) {
         // create list
         $('.twitter-widget .tweets').empty().append('<ul></ul>');
         // append name/image/followers
         $('.twitter-widget .followers').html(data[0].user.followers_count + ' followers');
         $('.twitter-widget .image IMG').attr('src', data[0].user.profile_image_url);
         $('.twitter-widget .text A').append(data[0].user.name).attr('href', 'http://twitter.com/' + twitterAccount);
         // add each tweet to list
         $.each(data, function (i, post) {
             var li = $('<li class="item"><div class="text"></div><div class="subtext"></div></li>');
             li.find('.text').append(linkify(post.text));
             li.find('.subtext').append(niceDate(post.created_at));
             $('.twitter-widget .tweets ul').append(li);
         });
         // apply custom scroller
         var isiPad = navigator.userAgent.match(/iPad/i) != null;
         if (!isiPad) {
             $('.twitter-widget .tweets').jScrollPane({ 
                verticalDragMinHeight: 52,
                verticalDragMaxHeight: 52
             });
         }
         else {
            $('.twitter-widget .tweets').css('overflow', 'auto');
         }
     });
}
jQuery.fn.showTwitter = function (options) {
    var content = this;
    // default settings
    var defaults = {
        twitteraccount: '',
        twitterquery: '',
        count: 50
    }
    var o = $.extend(defaults, options);
    content.find('.tweets').empty().append('<ul></ul>');
    $.jTwitter(o.twitteraccount, 10, function (data) {
        // append name/image/followers
        content.find('.followers').html(data[0].user.followers_count + ' followers');
        content.find('.image IMG').attr('src', data[0].user.profile_image_url);
        content.find('.text A').append(data[0].user.name).attr('href', 'http://twitter.com/' + o.twitteraccount);
    });
    
    if (o.twitterquery == '') {
        o.twitterquery = 'from:' + o.twitteraccount;
    } 
    
    content.find('.tweets').tweet({
        query: o.twitterquery,
        join_text: "user",
        avatar_size: 50,
        count: o.count,
        auto_join_text_default: "we said",
        auto_join_text_ed: "we",
        auto_join_text_ing: "we were",
        auto_join_text_reply: "we replied",
        auto_join_text_url: "we were checking out",
        loading_text: "",
        finished: function () {
            content.find('.tweets li').each(function () {
                var caption = $(this).find('.tweet_caption');
                var captionCopy = caption.clone();
                caption.remove();
                $(this).find('.tweet_text').before(captionCopy);
            });
            // apply custom scroller
            content.find('.tweets').jScrollPane({
                verticalDragMinHeight: 52,
                verticalDragMaxHeight: 52
            });
        }
    });
};/* ------------------------------------------------------------------------------------ */
/* Start of --- Srollable Promo and ad unit                                              */
/* ------------------------------------------------------------------------------------ */
//Ad-served iframe population
jQuery.fn.adScrollerIframe = function (positionList, position, width, height) {
    var content = this;
    var oaspage = sitepage + '/1' + RNS + '@' + positionList + '!' + position + '?' + OAS_query;
    var iframeUrl = oas + 'adstream_jx.ads/' + oaspage;
    var proxyUrl = 'ads-scroller-iframe.htm' + "?&uri=" + encodeURIComponent(iframeUrl);
    content.attr('src', proxyUrl);
};

//Init ads scroller
jQuery.fn.adsScroller = function (options) {
    var autoScroll;
    // default settings
    var defaults = {
        speed: 3000
    }        
    // get settings passed to the function
    var o = $.extend(defaults, options);
    var content = this;
    
    content.find('.ads-scroller li').each(function(index) {
        var li = $('<li><a class="button">' + (index + 1) + '</a></li>');
        if (index == 0) {
            li.addClass('selected');
        }
        content.find('.button-list').append(li);
    })
    
    content.find('.ads-scroller').jCarouselLite({
        auto: 0,
        speed: 250,
        visible: 1,
        start: 0,
        pauseOnHover: true,
        btnNext: content.find(".section-nav-next"),
        btnPrev: content.find(".section-nav-prev"),
        btnGo: content.find(".section-nav li a"),
        afterEnd: function(obj) {
            
            var index = obj.index() - 1;
            if (obj.index() > content.find('.section-nav .button-list li').length) {
                index = 0;
            }
            
            if (index < 0) {
                index = content.find('.section-nav .button-list li').length - 1;
            }
            
            var button = null;
            content.find('.section-nav .button-list li').each(function(i) { 
                if (i == index) {
                    button = $(this);                
                }
            });
            
            if (button != null) {
                content.find('.section-nav .button').not(button).parent('li').removeClass('selected');
                button.addClass('selected');
            }    
            
            
            if (o.speed > 0) {
                clearInterval(autoScroll);
                autoScroll = setInterval(function () {
                    content.find(".section-nav-next").click();
                }, o.speed);
            }
            
        }
    });
    
    if (o.speed > 0) {
        //simulate autoscroll by simulating "click" on next link
        autoScroll = setInterval(function () {
            content.find(".section-nav-next").click();
        }, o.speed);
    }
    content.find('.section-nav .button').click(function() {
        content.find('.section-nav .button').not(this).parent('li').removeClass('selected');
        $(this).parent('li').addClass('selected');    
    });
    
    content.find('.section-nav .button-list a').mouseenter(function() {
        $(this).click();
    });
    
};
 
/* ------------------------------------------------------------------------------------ */
/* End of --- Srollable Promo and ad unit                                               */
/* ------------------------------------------------------------------------------------ *//* ------------------------------------------------------------------------------------ */
/* Start of --- Horizontal Sroller Video unit                                           */
/* ------------------------------------------------------------------------------------ */
jQuery.fn.featureScroller = function (options) {
    var autoScroll;
    // default settings
    var defaults = {
        speed: 1000
    };
    // get settings passed to the function
    var o = $.extend(defaults, options);
    var content = this;
    // Create windows
    var pageSize = 4;
    var items = content.find('.video-panel li');
    var pages = Math.ceil(items.length / pageSize);
    var windows = $('<ul class="windows" />');
    for (i = 1; i <= pages; i++) {
        var scrollerWindow = $('<li class="window" />');
        var ul = $('<ul class="video-panel" />');
        var startIndex = (i - 1) * pageSize;
        var endIndex = startIndex + pageSize - 1;
        for (x = startIndex; x <= endIndex && x < items.length; x++) {
            var video_item = $(items[x]);
            ul.append(video_item);
        }
        scrollerWindow.append(ul);
        windows.append(scrollerWindow);
    }
    content.find('.video-panel-window').empty().append(windows);
    // Navigation
    var scrollMenu = content.find('.section-nav');
    if (pages > 1) {
        var scrollMenuUl = $('<ul />');
        scrollMenu.empty().append(scrollMenuUl);
        for (i = 1; i <= pages; i++) {
            scrollMenuUl.append('<li><a>' + i + '</a></li>');
        }
        scrollMenuUl.before('<a class="section-nav-prev" />');
        scrollMenuUl.after('<a class="section-nav-next" />');
        scrollMenuUl.find('li:first').addClass('selected');
        $('.section-nav-prev').addClass('disabled');
    }
    // Apply scroller
    content.find('.video-panel-window').jCarouselLite({
        speed: o.speed,
        circular: false,
        vertical: false,
        visible: 1,
        scroll: 1,
        btnNext: content.find(".section-nav-next"),
        btnPrev: content.find(".section-nav-prev"),
        btnGo: content.find(".section-nav li a"),
        afterEnd: function (obj) {
            var link = scrollMenu.find('li')[obj.index()];
            content.find('.section-nav li').not(link).removeClass('selected');
            $(link).addClass('selected');
            var linkIndex = $(link).index();
            var lastIndex = windows.find('.window').length - 1;
            (linkIndex === 0) ? $('.section-nav-prev').addClass('disabled') : $('.section-nav-prev').removeClass('disabled');
            (linkIndex == lastIndex) ? $('.section-nav-next').addClass('disabled') : $('.section-nav-next').removeClass('disabled');
        }
    });
};
/*carousellite.customs.js*/
(function ($) {
    $.fn.jCarouselLite = function (o) {
        o = $.extend({
            btnPrev: null,
            btnNext: null,
            btnGo: null,
            mouseWheel: false,
            auto: null,
            speed: 200,
            easing: null,
            vertical: false,
            circular: true,
            visible: 3,
            start: 0,
            scroll: 1,
            pauseOnHover: false,
            beforeStart: null,
            afterEnd: null
        },
        o || {});
        return this.each(function () {
            var running = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width";
            var div = $(this),
            ul = $(div.find("ul")[0]),
            tLi = ul.children("li"),
            tl = tLi.size(),
            v = o.visible,
            paused = 0;
            if (o.circular) {
                ul.prepend(tLi.slice(tl - v - 1 + 1).clone()).append(tLi.slice(0, v).clone());
                o.start += v;
            }
            o.pauseOnHover ? ul.hover(function () {
                paused = 1;
            }, function () {
                paused = 0;
            }) : "";
            var li = $($(this).find("ul")[0]).children("li"), itemLength = li.size(), curr = o.start;
            div.css("visibility", "visible");
            li.css({ "overflow": "hidden", "float": o.vertical ? "none" : "left" });
            ul.css({ margin: "0", padding: "0", position: "relative", 'list-style-type': "none", 'z-index': "1" });
            div.css({ overflow: "hidden", position: "relative", 'z-index': "2", left: "0px" });
            var liSize = o.vertical ? height(li) : width(li);
            var ulSize = liSize * itemLength;
            var divSize = liSize * v;
            li.css({ width: li.width(), height: li.height() });
            ul.css(sizeCss, ulSize + "px").css(animCss, -(curr * liSize));
            div.css(sizeCss, divSize + "px");
            if (o.btnPrev) {
                $(o.btnPrev).click(function () {
                    return go(curr - o.scroll);
                });
            }
            if (o.btnNext) {
                $(o.btnNext).click(function () {
                    return go(curr + o.scroll);
                });
            }
            if (o.btnGo) {
                $.each(o.btnGo, function (i, val) {
                    $(val).click(function () {
                        return go(o.circular ? o.visible + i : i);
                    });
                });
            }
            if (o.mouseWheel && div.mousewheel) {
                div.mousewheel(function (e, d) {
                    return d > 0 ? go(curr - o.scroll) : go(curr + o.scroll);
                });
            }
            if (o.auto) {
                setInterval(function () {
                    go(curr + o.scroll);
                }, o.auto + o.speed);
            }
            function vis() {
                return li.slice(curr).slice(0, v);
            }
            function go(to) {
                try {
                    if (!running && !paused) {
                        if (o.beforeStart) {
                            o.beforeStart.call(this, vis());
                        }
                        if (o.circular) {
                            if (to <= o.start - v - 1) {
                                ul.css(animCss, -((itemLength - v * 2) * liSize) + "px");
                                curr = to == o.start - v - 1 ? itemLength - v * 2 - 1 : itemLength - v * 2 - o.scroll;
                            } else if (to >= itemLength - v + 1) {
                                ul.css(animCss, -(v * liSize) + "px");
                                curr = to == itemLength - v + 1 ? v + 1 : v + o.scroll;
                            } else {
                                curr = to;
                            }
                        } else {
                            if (to < 0 || to > itemLength - v) {
                                return;
                            } else {
                                curr = to;
                            }
                        }
                        running = true;
                        ul.animate(animCss == "left" ? { left: -(curr * liSize)} : { top: -(curr * liSize) }, o.speed, o.easing, function () {
                            if (o.afterEnd) {
                                o.afterEnd.call(this, vis());
                            }
                            running = false;
                        });
                        if (!o.circular) {
                            $(o.btnPrev + ("," + o.btnNext)).removeClass("disabled");
                            $(curr - o.scroll < 0 && o.btnPrev || curr + o.scroll > itemLength - v && o.btnNext || []).addClass("disabled");
                        }
                    }
                }
                catch (e) { }
            }
        });
    };
    function css(el, prop) {
        return parseInt($.css(el[0], prop)) || 0;
    }
    function width(el) {
        return el[0].offsetWidth + css(el, "marginLeft") + css(el, "marginRight");
    }
    function height(el) {
        return el[0].offsetHeight + css(el, "marginTop") + css(el, "marginBottom");
    }
} (jQuery));
/*end of carousellite.customs.js*/
 
/* ------------------------------------------------------------------------------------ */
/* End of --- Horizontal Sroller Video unit                                             */
/* ------------------------------------------------------------------------------------ *//* Turn polite loading OFF for mrec */
for (y=0; y < adPositions.length; y++) {
    if (adPositions[y].positionList == 'Middle' && adPositions[y].position == 'Middle') {
        adPositions[y].adType = 'standard';
    }
}(function($){$.tiny=$.tiny||{};$.tiny.carousel={options:{start:1,display:1,axis:'x',controls:true,pager:false,interval:false,intervaltime:3000,rewind:false,animation:true,duration:1000,callback:null}};$.fn.tinycarousel=function(options){var options=$.extend({},$.tiny.carousel.options,options);this.each(function(){$(this).data('tcl',new Carousel($(this),options));});return this;};$.fn.tinycarousel_start=function(){$(this).data('tcl').start();};$.fn.tinycarousel_stop=function(){$(this).data('tcl').stop();};$.fn.tinycarousel_move=function(iNum){$(this).data('tcl').move(iNum-1,true);};function Carousel(root,options){var oSelf=this;var oViewport=$('.viewport:first',root);var oContent=$('.overview:first',root);var oPages=oContent.children();var oBtnNext=$('.next:first',root);var oBtnPrev=$('.prev:first',root);var oPager=$('.pager:first',root);var iPageSize,iSteps,iCurrent,oTimer,bPause,bForward=true,bAxis=options.axis=='x';function initialize(){iPageSize=bAxis?$(oPages[0]).outerWidth(true):$(oPages[0]).outerHeight(true);var iLeftover=Math.ceil(((bAxis?oViewport.outerWidth():oViewport.outerHeight())/(iPageSize*options.display))-1);iSteps=Math.max(1,Math.ceil(oPages.length/options.display)-iLeftover);iCurrent=Math.min(iSteps,Math.max(1,options.start))-2;oContent.css(bAxis?'width':'height',(iPageSize*oPages.length));oSelf.move(1);setEvents();return oSelf;};function setEvents(){if(options.controls&&oBtnPrev.length>0&&oBtnNext.length>0){oBtnPrev.click(function(){oSelf.move(-1);return false;});oBtnNext.click(function(){oSelf.move(1);return false;});}if(options.interval){root.hover(oSelf.stop,oSelf.start);}if(options.pager&&oPager.length>0){$('a',oPager).click(setPager);}};function setButtons(){if(options.controls){oBtnPrev.toggleClass('disable',!(iCurrent>0));oBtnNext.toggleClass('disable',!(iCurrent+1<iSteps));}if(options.pager){var oNumbers=$('.pagenum',oPager);oNumbers.removeClass('active');$(oNumbers[iCurrent]).addClass('active');}};function setPager(oEvent){if($(this).hasClass('pagenum')){oSelf.move(parseInt(this.rel),true);}return false;};function setTimer(){if(options.interval&&!bPause){clearTimeout(oTimer);oTimer=setTimeout(function(){iCurrent=iCurrent+1==iSteps?-1:iCurrent;bForward=iCurrent+1==iSteps?false:iCurrent==0?true:bForward;oSelf.move(bForward?1:-1);},options.intervaltime);}};this.stop=function(){clearTimeout(oTimer);bPause=true;};this.start=function(){bPause=false;setTimer();};this.move=function(iDirection,bPublic){iCurrent=bPublic?iDirection:iCurrent+=iDirection;if(iCurrent>-1&&iCurrent<iSteps){var oPosition={};oPosition[bAxis?'left':'top']=-(iCurrent*(iPageSize*options.display));oContent.animate(oPosition,{queue:false,duration:options.animation?options.duration:0,complete:function(){if(typeof options.callback=='function')options.callback.call(this,oPages[iCurrent],iCurrent);}});setButtons();setTimer();}};return initialize();};})(jQuery);

