﻿//Variables
var BrowserDetect = {
    init: function() {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function(data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function(dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{
		    string: navigator.userAgent,
		    subString: "Chrome",
		    identity: "Chrome"
		},
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari",
		    versionSearch: "Version"
		},
		{
		    prop: window.opera,
		    identity: "Opera",
		    versionSearch: "Version"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.userAgent,
		    subString: "iPhone",
		    identity: "iPhone/iPod"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};
BrowserDetect.init();

var path_oldLandingBannersXML = "/Portals/0/RWS/oldLandingBanners.xml"; //change the path accordingly
var commonXML = "/Portals/0/RWS/common.xml"
var base_url = "/Portals/0/RWS/"; //include the slash at the back eg. folder_1/folder_0/
var flashvars_banner = {};
var flashvars_nav = {};
var params = {};
params.wmode = "transparent";
params.allowScriptAccess = "always";
var attributes = {};
var closeHeaderSubTimer = null;
var inHeaderSub = false;
var inProcessOfClosing = false;
var timeout = 500;
var closeHorNavTimer = 0;
var ddmenuitem = 0;
var currmenutab = null;
var newsFeedLoopingTime = "10s";
var textArray = new Array();
currCount = 0;
cArray = new Array();
cAppearedAlready = [null, true, false, false, false];
currentChosenTab = { tabNum: 0, depth: 0 };
selectedTabDepth = 0;
var photoContainer;
var photomodulepath = "/DesktopModules/MLAdvPhoto/SlideShow.aspx" //put this so tat html and modules can use it
var videoContainer;
var videomodulepath = "/DesktopModules/MLAdvVideo/" //put this so tat html and modules can use it
var tb_pathToImage = "/portals/0/RWS/images/loadingAnimation.gif";
var left_scrolling_banner_clips_array = new Array();
var left_scrolling_banner_clips_html = "";
var left_scrolling_banner_clipmax = 4;
var left_scrolling_banner_clipwidth = 160;
var left_scrolling_banner_squaredots_html = "";
var left_scrolling_banner_currClicked = 1;
var timePerClip = 100;

var xmlFile;
var xmlDoc;
var imageList = new Array();

var closeHeaderSubTimer = null;
var inHeaderSub = false;
var inProcessOfClosing = false;

var closeHeaderLangSubTimer = null;
var inHeaderLangSub = false;
var inProcessOfClosingLang = false;

//Left Panel Scroll
function left_panel_gotoClip(clipNum) {
    //alert(clipNum);
    if (clipNum != left_scrolling_banner_currClicked) {
        $("#left-panel-promo-clip" + left_scrolling_banner_currClicked).attr("src", $("#left-panel-section-scrolling-sqdots-off").attr("src"));
        if (clipNum == 0) {
            $("#left-panel-section-scrolling-promo-scroller").stop().animate({
                left: 0
            }, timePerClip, function() {
                $("#left-panel-section-scrolling-promo-scroller").css("left", -1 * left_scrolling_banner_clips_array.length * left_scrolling_banner_clipwidth);
            });

            clipNum = left_scrolling_banner_clips_array.length;
        }
        else {
            if (clipNum == (left_scrolling_banner_clips_array.length + 1)) {
                $("#left-panel-section-scrolling-promo-scroller").stop().animate({
                    left: -1 * clipNum * left_scrolling_banner_clipwidth
                }, timePerClip, function() {
                    $("#left-panel-section-scrolling-promo-scroller").css("left", -1 * left_scrolling_banner_clipwidth);
                });
                clipNum = 1;
            }
            else {
                var isPos = 1;
                if (clipNum < left_scrolling_banner_currClicked) isPos = -1;
                $("#left-panel-section-scrolling-promo-scroller").stop().animate({
                    left: -1 * clipNum * left_scrolling_banner_clipwidth
                }, timePerClip * isPos * (clipNum - left_scrolling_banner_currClicked));
            }
        }

        left_scrolling_banner_currClicked = clipNum;

        $("#left-panel-promo-clip" + clipNum).attr("src", $("#left-panel-section-scrolling-sqdots-on").attr("src"));
    }
}

//Buil-in
//Thickbox
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 } ('$(o).2S(9(){1u(\'a.18, 3n.18, 3i.18\');1w=1p 1t();1w.L=2H});9 1u(b){$(b).s(9(){6 t=X.Q||X.1v||M;6 a=X.u||X.23;6 g=X.1N||P;19(t,a,g);X.2E();H P})}9 19(d,f,g){3m{3(2t o.v.J.2i==="2g"){$("v","11").r({A:"28%",z:"28%"});$("11").r("22","2Z");3(o.1Y("1F")===M){$("v").q("<U 5=\'1F\'></U><4 5=\'B\'></4><4 5=\'8\'></4>");$("#B").s(G)}}n{3(o.1Y("B")===M){$("v").q("<4 5=\'B\'></4><4 5=\'8\'></4>");$("#B").s(G)}}3(1K()){$("#B").1J("2B")}n{$("#B").1J("2z")}3(d===M){d=""}$("v").q("<4 5=\'K\'><1I L=\'"+1w.L+"\' /></4>");$(\'#K\').2y();6 h;3(f.O("?")!==-1){h=f.3l(0,f.O("?"))}n{h=f}6 i=/\\.2s$|\\.2q$|\\.2m$|\\.2l$|\\.2k$/;6 j=h.1C().2h(i);3(j==\'.2s\'||j==\'.2q\'||j==\'.2m\'||j==\'.2l\'||j==\'.2k\'){1D="";1G="";14="";1z="";1x="";R="";1n="";1r=P;3(g){E=$("a[@1N="+g+"]").36();25(D=0;((D<E.1c)&&(R===""));D++){6 k=E[D].u.1C().2h(i);3(!(E[D].u==f)){3(1r){1z=E[D].Q;1x=E[D].u;R="<1e 5=\'1X\'>&1d;&1d;<a u=\'#\'>2T &2R;</a></1e>"}n{1D=E[D].Q;1G=E[D].u;14="<1e 5=\'1U\'>&1d;&1d;<a u=\'#\'>&2O; 2N</a></1e>"}}n{1r=1b;1n="1t "+(D+1)+" 2L "+(E.1c)}}}S=1p 1t();S.1g=9(){S.1g=M;6 a=2x();6 x=a[0]-1M;6 y=a[1]-1M;6 b=S.z;6 c=S.A;3(b>x){c=c*(x/b);b=x;3(c>y){b=b*(y/c);c=y}}n 3(c>y){b=b*(y/c);c=y;3(b>x){c=c*(x/b);b=x}}13=b+30;1a=c+2G;$("#8").q("<a u=\'\' 5=\'1L\' Q=\'1o\'><1I 5=\'2F\' L=\'"+f+"\' z=\'"+b+"\' A=\'"+c+"\' 23=\'"+d+"\'/></a>"+"<4 5=\'2D\'>"+d+"<4 5=\'2C\'>"+1n+14+R+"</4></4><4 5=\'2A\'><a u=\'#\' 5=\'Z\' Q=\'1o\'>1l</a> 1k 1j 1s</4>");$("#Z").s(G);3(!(14==="")){9 12(){3($(o).N("s",12)){$(o).N("s",12)}$("#8").C();$("v").q("<4 5=\'8\'></4>");19(1D,1G,g);H P}$("#1U").s(12)}3(!(R==="")){9 1i(){$("#8").C();$("v").q("<4 5=\'8\'></4>");19(1z,1x,g);H P}$("#1X").s(1i)}o.1h=9(e){3(e==M){I=2w.2v}n{I=e.2u}3(I==27){G()}n 3(I==3k){3(!(R=="")){o.1h="";1i()}}n 3(I==3j){3(!(14=="")){o.1h="";12()}}};16();$("#K").C();$("#1L").s(G);$("#8").r({Y:"T"})};S.L=f}n{6 l=f.2r(/^[^\\?]+\\??/,\'\');6 m=2p(l);13=(m[\'z\']*1)+30||3h;1a=(m[\'A\']*1)+3g||3f;W=13-30;V=1a-3e;3(f.O(\'2j\')!=-1){1E=f.1B(\'3d\');$("#15").C();3(m[\'1A\']!="1b"){$("#8").q("<4 5=\'2f\'><4 5=\'1H\'>"+d+"</4><4 5=\'2e\'><a u=\'#\' 5=\'Z\' Q=\'1o\'>1l</a> 1k 1j 1s</4></4><U 1W=\'0\' 2d=\'0\' L=\'"+1E[0]+"\' 5=\'15\' 1v=\'15"+1f.2c(1f.1y()*2b)+"\' 1g=\'1m()\' J=\'z:"+(W+29)+"p;A:"+(V+17)+"p;\' > </U>")}n{$("#B").N();$("#8").q("<U 1W=\'0\' 2d=\'0\' L=\'"+1E[0]+"\' 5=\'15\' 1v=\'15"+1f.2c(1f.1y()*2b)+"\' 1g=\'1m()\' J=\'z:"+(W+29)+"p;A:"+(V+17)+"p;\'> </U>")}}n{3($("#8").r("Y")!="T"){3(m[\'1A\']!="1b"){$("#8").q("<4 5=\'2f\'><4 5=\'1H\'>"+d+"</4><4 5=\'2e\'><a u=\'#\' 5=\'Z\'>1l</a> 1k 1j 1s</4></4><4 5=\'F\' J=\'z:"+W+"p;A:"+V+"p\'></4>")}n{$("#B").N();$("#8").q("<4 5=\'F\' 3c=\'3b\' J=\'z:"+W+"p;A:"+V+"p;\'></4>")}}n{$("#F")[0].J.z=W+"p";$("#F")[0].J.A=V+"p";$("#F")[0].3a=0;$("#1H").11(d)}}$("#Z").s(G);3(f.O(\'37\')!=-1){$("#F").q($(\'#\'+m[\'26\']).1T());$("#8").24(9(){$(\'#\'+m[\'26\']).q($("#F").1T())});16();$("#K").C();$("#8").r({Y:"T"})}n 3(f.O(\'2j\')!=-1){16();3($.1q.35){$("#K").C();$("#8").r({Y:"T"})}}n{$("#F").34(f+="&1y="+(1p 33().32()),9(){16();$("#K").C();1u("#F a.18");$("#8").r({Y:"T"})})}}3(!m[\'1A\']){o.21=9(e){3(e==M){I=2w.2v}n{I=e.2u}3(I==27){G()}}}}31(e){}}9 1m(){$("#K").C();$("#8").r({Y:"T"})}9 G(){$("#2Y").N("s");$("#Z").N("s");$("#8").2X("2W",9(){$(\'#8,#B,#1F\').2V("24").N().C()});$("#K").C();3(2t o.v.J.2i=="2g"){$("v","11").r({A:"1Z",z:"1Z"});$("11").r("22","")}o.1h="";o.21="";H P}9 16(){$("#8").r({2U:\'-\'+20((13/2),10)+\'p\',z:13+\'p\'});3(!(1V.1q.2Q&&1V.1q.2P<7)){$("#8").r({38:\'-\'+20((1a/2),10)+\'p\'})}}9 2p(a){6 b={};3(!a){H b}6 c=a.1B(/[;&]/);25(6 i=0;i<c.1c;i++){6 d=c[i].1B(\'=\');3(!d||d.1c!=2){39}6 e=2a(d[0]);6 f=2a(d[1]);f=f.2r(/\\+/g,\' \');b[e]=f}H b}9 2x(){6 a=o.2M;6 w=1S.2o||1R.2o||(a&&a.1Q)||o.v.1Q;6 h=1S.1P||1R.1P||(a&&a.2n)||o.v.2n;1O=[w,h];H 1O}9 1K(){6 a=2K.2J.1C();3(a.O(\'2I\')!=-1&&a.O(\'3o\')!=-1){H 1b}}', 62, 211, '|||if|div|id|var||TB_window|function||||||||||||||else|document|px|append|css|click||href|body||||width|height|TB_overlay|remove|TB_Counter|TB_TempArray|TB_ajaxContent|tb_remove|return|keycode|style|TB_load|src|null|unbind|indexOf|false|title|TB_NextHTML|imgPreloader|block|iframe|ajaxContentH|ajaxContentW|this|display|TB_closeWindowButton||html|goPrev|TB_WIDTH|TB_PrevHTML|TB_iframeContent|tb_position||thickbox|tb_show|TB_HEIGHT|true|length|nbsp|span|Math|onload|onkeydown|goNext|Esc|or|close|tb_showIframe|TB_imageCount|Close|new|browser|TB_FoundURL|Key|Image|tb_init|name|imgLoader|TB_NextURL|random|TB_NextCaption|modal|split|toLowerCase|TB_PrevCaption|urlNoQuery|TB_HideSelect|TB_PrevURL|TB_ajaxWindowTitle|img|addClass|tb_detectMacXFF|TB_ImageOff|150|rel|arrayPageSize|innerHeight|clientWidth|self|window|children|TB_prev|jQuery|frameborder|TB_next|getElementById|auto|parseInt|onkeyup|overflow|alt|unload|for|inlineId||100||unescape|1000|round|hspace|TB_closeAjaxWindow|TB_title|undefined|match|maxHeight|TB_iframe|bmp|gif|png|clientHeight|innerWidth|tb_parseQuery|jpeg|replace|jpg|typeof|which|keyCode|event|tb_getPageSize|show|TB_overlayBG|TB_closeWindow|TB_overlayMacFFBGHack|TB_secondLine|TB_caption|blur|TB_Image|60|tb_pathToImage|mac|userAgent|navigator|of|documentElement|Prev|lt|version|msie|gt|ready|Next|marginLeft|trigger|fast|fadeOut|TB_imageOff|hidden||catch|getTime|Date|load|safari|get|TB_inline|marginTop|continue|scrollTop|TB_modal|class|TB_|45|440|40|630|input|188|190|substr|try|area|firefox'.split('|'), 0, {}))

//swfobject
var swfobject = function() {
    var D = "undefined", r = "object", S = "Shockwave Flash", W = "ShockwaveFlash.ShockwaveFlash", q = "application/x-shockwave-flash", R = "SWFObjectExprInst", x = "onreadystatechange", O = window, j = document, t = navigator, T = false, U = [h], o = [], N = [], I = [], l, Q, E, B, J = false, a = false, n, G, m = true,
     M = function() { var aa = typeof j.getElementById != D && typeof j.getElementsByTagName != D && typeof j.createElement != D, ah = t.userAgent.toLowerCase(), Y = t.platform.toLowerCase(), ae = Y ? /win/.test(Y) : /win/.test(ah), ac = Y ? /mac/.test(Y) : /mac/.test(ah), af = /webkit/.test(ah) ? parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, X = ! +"\v1", ag = [0, 0, 0], ab = null; if (typeof t.plugins != D && typeof t.plugins[S] == r) { ab = t.plugins[S].description; if (ab && !(typeof t.mimeTypes != D && t.mimeTypes[q] && !t.mimeTypes[q].enabledPlugin)) { T = true; X = false; ab = ab.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); ag[0] = parseInt(ab.replace(/^(.*)\..*$/, "$1"), 10); ag[1] = parseInt(ab.replace(/^.*\.(.*)\s.*$/, "$1"), 10); ag[2] = /[a-zA-Z]/.test(ab) ? parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0 } } else { if (typeof O.ActiveXObject != D) { try { var ad = new ActiveXObject(W); if (ad) { ab = ad.GetVariable("$version"); if (ab) { X = true; ab = ab.split(" ")[1].split(","); ag = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)] } } } catch (Z) { } } } return { w3: aa, pv: ag, wk: af, ie: X, win: ae, mac: ac} } (),
     k = function() { if (!M.w3) { return } if ((typeof j.readyState != D && j.readyState == "complete") || (typeof j.readyState == D && (j.getElementsByTagName("body")[0] || j.body))) { f() } if (!J) { if (typeof j.addEventListener != D) { j.addEventListener("DOMContentLoaded", f, false) } if (M.ie && M.win) { j.attachEvent(x, function() { if (j.readyState == "complete") { j.detachEvent(x, arguments.callee); f() } }); if (O == top) { (function() { if (J) { return } try { j.documentElement.doScroll("left") } catch (X) { setTimeout(arguments.callee, 0); return } f() })() } } if (M.wk) { (function() { if (J) { return } if (!/loaded|complete/.test(j.readyState)) { setTimeout(arguments.callee, 0); return } f() })() } s(f) } } (); function f() { if (J) { return } try { var Z = j.getElementsByTagName("body")[0].appendChild(C("span")); Z.parentNode.removeChild(Z) } catch (aa) { return } J = true; var X = U.length; for (var Y = 0; Y < X; Y++) { U[Y]() } } function K(X) { if (J) { X() } else { U[U.length] = X } } function s(Y) {
         if (typeof O.addEventListener != D) { O.addEventListener("load", Y, false) } else {
             if (typeof j.addEventListener != D) { j.addEventListener("load", Y, false) } else {
                 if (typeof O.attachEvent != D) { i(O, "onload", Y) } else {
                     if (typeof O.onload == "function") {
                         var X = O.onload;
                         O.onload = function() { X(); Y() }
                     } else { O.onload = Y }
                 }
             }
         }
     }
    function h() { if (T) { V() } else { H() } } function V() {
        var X = j.getElementsByTagName("body")[0]; var aa = C(r); aa.setAttribute("type", q); var Z = X.appendChild(aa); if (Z) {
            var Y = 0; (function() {
                if (typeof Z.GetVariable != D) { var ab = Z.GetVariable("$version"); if (ab) { ab = ab.split(" ")[1].split(","); M.pv = [parseInt(ab[0], 10), parseInt(ab[1], 10), parseInt(ab[2], 10)] } } else { if (Y < 10) { Y++; setTimeout(arguments.callee, 10); return } }
                X.removeChild(aa); Z = null; H()
            })()
        } else { H() }
    } function H() { var ag = o.length; if (ag > 0) { for (var af = 0; af < ag; af++) { var Y = o[af].id; var ab = o[af].callbackFn; var aa = { success: false, id: Y }; if (M.pv[0] > 0) { var ae = c(Y); if (ae) { if (F(o[af].swfVersion) && !(M.wk && M.wk < 312)) { w(Y, true); if (ab) { aa.success = true; aa.ref = z(Y); ab(aa) } } else { if (o[af].expressInstall && A()) { var ai = {}; ai.data = o[af].expressInstall; ai.width = ae.getAttribute("width") || "0"; ai.height = ae.getAttribute("height") || "0"; if (ae.getAttribute("class")) { ai.styleclass = ae.getAttribute("class") } if (ae.getAttribute("align")) { ai.align = ae.getAttribute("align") } var ah = {}; var X = ae.getElementsByTagName("param"); var ac = X.length; for (var ad = 0; ad < ac; ad++) { if (X[ad].getAttribute("name").toLowerCase() != "movie") { ah[X[ad].getAttribute("name")] = X[ad].getAttribute("value") } } P(ai, ah, Y, ab) } else { p(ae); if (ab) { ab(aa) } } } } } else { w(Y, true); if (ab) { var Z = z(Y); if (Z && typeof Z.SetVariable != D) { aa.success = true; aa.ref = Z } ab(aa) } } } } } function z(aa) { var X = null; var Y = c(aa); if (Y && Y.nodeName == "OBJECT") { if (typeof Y.SetVariable != D) { X = Y } else { var Z = Y.getElementsByTagName(r)[0]; if (Z) { X = Z } } } return X }
    function A() { return !a && F("6.0.65") && (M.win || M.mac) && !(M.wk && M.wk < 312) } function P(aa, ab, X, Z) { a = true; E = Z || null; B = { success: false, id: X }; var ae = c(X); if (ae) { if (ae.nodeName == "OBJECT") { l = g(ae); Q = null } else { l = ae; Q = X } aa.id = R; if (typeof aa.width == D || (!/%$/.test(aa.width) && parseInt(aa.width, 10) < 310)) { aa.width = "310" } if (typeof aa.height == D || (!/%$/.test(aa.height) && parseInt(aa.height, 10) < 137)) { aa.height = "137" } j.title = j.title.slice(0, 47) + " - Flash Player Installation"; var ad = M.ie && M.win ? "ActiveX" : "PlugIn", ac = "MMredirectURL=" + O.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + ad + "&MMdoctitle=" + j.title; if (typeof ab.flashvars != D) { ab.flashvars += "&" + ac } else { ab.flashvars = ac } if (M.ie && M.win && ae.readyState != 4) { var Y = C("div"); X += "SWFObjectNew"; Y.setAttribute("id", X); ae.parentNode.insertBefore(Y, ae); ae.style.display = "none"; (function() { if (ae.readyState == 4) { ae.parentNode.removeChild(ae) } else { setTimeout(arguments.callee, 10) } })() } u(aa, ab, X) } } function p(Y) { if (M.ie && M.win && Y.readyState != 4) { var X = C("div"); Y.parentNode.insertBefore(X, Y); X.parentNode.replaceChild(g(Y), X); Y.style.display = "none"; (function() { if (Y.readyState == 4) { Y.parentNode.removeChild(Y) } else { setTimeout(arguments.callee, 10) } })() } else { Y.parentNode.replaceChild(g(Y), Y) } }
    function g(ab) { var aa = C("div"); if (M.win && M.ie) { aa.innerHTML = ab.innerHTML } else { var Y = ab.getElementsByTagName(r)[0]; if (Y) { var ad = Y.childNodes; if (ad) { var X = ad.length; for (var Z = 0; Z < X; Z++) { if (!(ad[Z].nodeType == 1 && ad[Z].nodeName == "PARAM") && !(ad[Z].nodeType == 8)) { aa.appendChild(ad[Z].cloneNode(true)) } } } } } return aa } function u(ai, ag, Y) {
        var X, aa = c(Y); if (M.wk && M.wk < 312) { return X } if (aa) {
            if (typeof ai.id == D) { ai.id = Y } if (M.ie && M.win) { var ah = ""; for (var ae in ai) { if (ai[ae] != Object.prototype[ae]) { if (ae.toLowerCase() == "data") { ag.movie = ai[ae] } else { if (ae.toLowerCase() == "styleclass") { ah += ' class="' + ai[ae] + '"' } else { if (ae.toLowerCase() != "classid") { ah += " " + ae + '="' + ai[ae] + '"' } } } } } var af = ""; for (var ad in ag) { if (ag[ad] != Object.prototype[ad]) { af += '<param name="' + ad + '" value="' + ag[ad] + '" />' } } aa.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + ah + ">" + af + "</object>"; N[N.length] = ai.id; X = c(ai.id) } else {
                var Z = C(r); Z.setAttribute("type", q); for (var ac in ai) { if (ai[ac] != Object.prototype[ac]) { if (ac.toLowerCase() == "styleclass") { Z.setAttribute("class", ai[ac]) } else { if (ac.toLowerCase() != "classid") { Z.setAttribute(ac, ai[ac]) } } } }
                for (var ab in ag) { if (ag[ab] != Object.prototype[ab] && ab.toLowerCase() != "movie") { e(Z, ab, ag[ab]) } } aa.parentNode.replaceChild(Z, aa); X = Z
            }
        } return X
    } function e(Z, X, Y) { var aa = C("param"); aa.setAttribute("name", X); aa.setAttribute("value", Y); Z.appendChild(aa) }
    function y(Y) { var X = c(Y); if (X && X.nodeName == "OBJECT") { if (M.ie && M.win) { X.style.display = "none"; (function() { if (X.readyState == 4) { b(Y) } else { setTimeout(arguments.callee, 10) } })() } else { X.parentNode.removeChild(X) } } }
    function b(Z) { var Y = c(Z); if (Y) { for (var X in Y) { if (typeof Y[X] == "function") { Y[X] = null } } Y.parentNode.removeChild(Y) } }
    function c(Z) { var X = null; try { X = j.getElementById(Z) } catch (Y) { } return X }
    function C(X) { return j.createElement(X) } function i(Z, X, Y) { Z.attachEvent(X, Y); I[I.length] = [Z, X, Y] }
    function F(Z) { var Y = M.pv, X = Z.split("."); X[0] = parseInt(X[0], 10); X[1] = parseInt(X[1], 10) || 0; X[2] = parseInt(X[2], 10) || 0; return (Y[0] > X[0] || (Y[0] == X[0] && Y[1] > X[1]) || (Y[0] == X[0] && Y[1] == X[1] && Y[2] >= X[2])) ? true : false }
    function v(ac, Y, ad, ab) { if (M.ie && M.mac) { return } var aa = j.getElementsByTagName("head")[0]; if (!aa) { return } var X = (ad && typeof ad == "string") ? ad : "screen"; if (ab) { n = null; G = null } if (!n || G != X) { var Z = C("style"); Z.setAttribute("type", "text/css"); Z.setAttribute("media", X); n = aa.appendChild(Z); if (M.ie && M.win && typeof j.styleSheets != D && j.styleSheets.length > 0) { n = j.styleSheets[j.styleSheets.length - 1] } G = X } if (M.ie && M.win) { if (n && typeof n.addRule == r) { n.addRule(ac, Y) } } else { if (n && typeof j.createTextNode != D) { n.appendChild(j.createTextNode(ac + " {" + Y + "}")) } } } function w(Z, X) { if (!m) { return } var Y = X ? "visible" : "hidden"; if (J && c(Z)) { c(Z).style.visibility = Y } else { v("#" + Z, "visibility:" + Y) } } function L(Y) { var Z = /[\\\"<>\.;]/; var X = Z.exec(Y) != null; return X && typeof encodeURIComponent != D ? encodeURIComponent(Y) : Y } var d = function() { if (M.ie && M.win) { window.attachEvent("onunload", function() { var ac = I.length; for (var ab = 0; ab < ac; ab++) { I[ab][0].detachEvent(I[ab][1], I[ab][2]) } var Z = N.length; for (var aa = 0; aa < Z; aa++) { y(N[aa]) } for (var Y in M) { M[Y] = null } M = null; for (var X in swfobject) { swfobject[X] = null } swfobject = null }) } } (); return { registerObject: function(ab, X, aa, Z) { if (M.w3 && ab && X) { var Y = {}; Y.id = ab; Y.swfVersion = X; Y.expressInstall = aa; Y.callbackFn = Z; o[o.length] = Y; w(ab, false) } else { if (Z) { Z({ success: false, id: ab }) } } }, getObjectById: function(X) { if (M.w3) { return z(X) } }, embedSWF: function(ab, ah, ae, ag, Y, aa, Z, ad, af, ac) { var X = { success: false, id: ah }; if (M.w3 && !(M.wk && M.wk < 312) && ab && ah && ae && ag && Y) { w(ah, false); K(function() { ae += ""; ag += ""; var aj = {}; if (af && typeof af === r) { for (var al in af) { aj[al] = af[al] } } aj.data = ab; aj.width = ae; aj.height = ag; var am = {}; if (ad && typeof ad === r) { for (var ak in ad) { am[ak] = ad[ak] } } if (Z && typeof Z === r) { for (var ai in Z) { if (typeof am.flashvars != D) { am.flashvars += "&" + ai + "=" + Z[ai] } else { am.flashvars = ai + "=" + Z[ai] } } } if (F(Y)) { var an = u(aj, am, ah); if (aj.id == ah) { w(ah, true) } X.success = true; X.ref = an } else { if (aa && A()) { aj.data = aa; P(aj, am, ah, ac); return } else { w(ah, true) } } if (ac) { ac(X) } }) } else { if (ac) { ac(X) } } }, switchOffAutoHideShow: function() { m = false }, ua: M, getFlashPlayerVersion: function() { return { major: M.pv[0], minor: M.pv[1], release: M.pv[2]} }, hasFlashPlayerVersion: F, createSWF: function(Z, Y, X) { if (M.w3) { return u(Z, Y, X) } else { return undefined } }, showExpressInstall: function(Z, aa, X, Y) { if (M.w3 && A()) { P(Z, aa, X, Y) } }, removeSWF: function(X) { if (M.w3) { y(X) } }, createCSS: function(aa, Z, Y, X) { if (M.w3) { v(aa, Z, Y, X) } }, addDomLoadEvent: K, addLoadEvent: s, getQueryParamValue: function(aa) { var Z = j.location.search || j.location.hash; if (Z) { if (/\?/.test(Z)) { Z = Z.split("?")[1] } if (aa == null) { return L(Z) } var Y = Z.split("&"); for (var X = 0; X < Y.length; X++) { if (Y[X].substring(0, Y[X].indexOf("=")) == aa) { return L(Y[X].substring((Y[X].indexOf("=") + 1))) } } } return "" }, expressInstallCallback: function() { if (a) { var X = c(R); if (X && l) { X.parentNode.replaceChild(l, X); if (Q) { w(Q, true); if (M.ie && M.win) { l.style.display = "block" } } if (E) { E(B) } } a = false } } }
} ();

//Jquery.Timers
jQuery.fn.extend({
    everyTime: function(interval, label, fn, times) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, times);
        });
    },
    oneTime: function(interval, label, fn) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, 1);
        });
    },
    stopTime: function(label, fn) {
        return this.each(function() {
            jQuery.timer.remove(this, label, fn);
        });
    }
});

jQuery.extend({
    timer: {
        global: [],
        guid: 1,
        dataKey: "jQuery.timer",
        regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
        powers: {
            // Yeah this is major overkill...
            'ms': 1,
            'cs': 10,
            'ds': 100,
            's': 1000,
            'das': 10000,
            'hs': 100000,
            'ks': 1000000
        },
        timeParse: function(value) {
            if (value == undefined || value == null)
                return null;
            var result = this.regex.exec(jQuery.trim(value.toString()));
            if (result[2]) {
                var num = parseFloat(result[1]);
                var mult = this.powers[result[2]] || 1;
                return num * mult;
            } else {
                return value;
            }
        },
        add: function(element, interval, label, fn, times) {
            var counter = 0;

            if (jQuery.isFunction(label)) {
                if (!times)
                    times = fn;
                fn = label;
                label = interval;
            }

            interval = jQuery.timer.timeParse(interval);

            if (typeof interval != 'number' || isNaN(interval) || interval < 0)
                return;

            if (typeof times != 'number' || isNaN(times) || times < 0)
                times = 0;

            times = times || 0;

            var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});

            if (!timers[label])
                timers[label] = {};

            fn.timerID = fn.timerID || this.guid++;

            var handler = function() {
                if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
                    jQuery.timer.remove(element, label, fn);
            };

            handler.timerID = fn.timerID;

            if (!timers[label][fn.timerID])
                timers[label][fn.timerID] = window.setInterval(handler, interval);

            this.global.push(element);

        },
        remove: function(element, label, fn) {
            var timers = jQuery.data(element, this.dataKey), ret;

            if (timers) {

                if (!label) {
                    for (label in timers)
                        this.remove(element, label, fn);
                } else if (timers[label]) {
                    if (fn) {
                        if (fn.timerID) {
                            window.clearInterval(timers[label][fn.timerID]);
                            delete timers[label][fn.timerID];
                        }
                    } else {
                        for (var fn in timers[label]) {
                            window.clearInterval(timers[label][fn]);
                            delete timers[label][fn];
                        }
                    }

                    for (ret in timers[label]) break;
                    if (!ret) {
                        ret = null;
                        delete timers[label];
                    }
                }

                for (ret in timers) break;
                if (!ret)
                    jQuery.removeData(element, this.dataKey);
            }
        }
    }
});

//jQuery(window).bind("unload", function() {
//    jQuery.each(jQuery.timer.global, function(index, item) {
//        jQuery.timer.remove(item);
//    });
//});

//JQuery.jcarousel

(function($) {
    $.fn.jcarousel = function(o) {
        if (typeof o == 'string') { var instance = $(this).data('jcarousel'), args = Array.prototype.slice.call(arguments, 1); return instance[o].apply(instance, args); } else
            return this.each(function() { $(this).data('jcarousel', new $jc(this, o)); });
    }; var defaults = { vertical: false, start: 1, offset: 1, size: null, scroll: 3, visible: null, animation: 'normal', easing: 'swing', auto: 0, wrap: null, initCallback: null, reloadCallback: null, itemLoadCallback: null, itemFirstInCallback: null, itemFirstOutCallback: null, itemLastInCallback: null, itemLastOutCallback: null, itemVisibleInCallback: null, itemVisibleOutCallback: null, buttonNextHTML: '<div></div>', buttonPrevHTML: '<div></div>', buttonNextEvent: 'click', buttonPrevEvent: 'click', buttonNextCallback: null, buttonPrevCallback: null }; $.jcarousel = function(e, o) {
        this.options = $.extend({}, defaults, o || {}); this.locked = false; this.container = null; this.clip = null; this.list = null; this.buttonNext = null; this.buttonPrev = null; this.wh = !this.options.vertical ? 'width' : 'height'; this.lt = !this.options.vertical ? 'left' : 'top'; var skin = '', split = e.className.split(' '); for (var i = 0; i < split.length; i++) { if (split[i].indexOf('jcarousel-skin') != -1) { $(e).removeClass(split[i]); skin = split[i]; break; } } if (e.nodeName == 'UL' || e.nodeName == 'OL') { this.list = $(e); this.container = this.list.parent(); if (this.container.hasClass('jcarousel-clip')) { if (!this.container.parent().hasClass('jcarousel-container')) this.container = this.container.wrap('<div></div>'); this.container = this.container.parent(); } else if (!this.container.hasClass('jcarousel-container')) this.container = this.list.wrap('<div></div>').parent(); } else { this.container = $(e); this.list = this.container.find('ul,ol').eq(0); } if (skin != '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1) this.container.wrap('<div class=" ' + skin + '"></div>'); this.clip = this.list.parent(); if (!this.clip.length || !this.clip.hasClass('jcarousel-clip')) this.clip = this.list.wrap('<div></div>').parent(); this.buttonNext = $('.jcarousel-next', this.container); if (this.buttonNext.size() == 0 && this.options.buttonNextHTML != null) this.buttonNext = this.clip.after(this.options.buttonNextHTML).next(); this.buttonNext.addClass(this.className('jcarousel-next')); this.buttonPrev = $('.jcarousel-prev', this.container); if (this.buttonPrev.size() == 0 && this.options.buttonPrevHTML != null) this.buttonPrev = this.clip.after(this.options.buttonPrevHTML).next(); this.buttonPrev.addClass(this.className('jcarousel-prev')); this.clip.addClass(this.className('jcarousel-clip')).css({ overflow: 'hidden', position: 'relative' }); this.list.addClass(this.className('jcarousel-list')).css({ overflow: 'hidden', position: 'relative', top: 0, left: 0, margin: 0, padding: 0 }); this.container.addClass(this.className('jcarousel-container')).css({ position: 'relative' }); var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null; var li = this.list.children('li'); var self = this; if (li.size() > 0) { var wh = 0, i = this.options.offset; li.each(function() { self.format(this, i++); wh += self.dimension(this, di); }); this.list.css(this.wh, wh + 'px'); if (!o || o.size === undefined) this.options.size = li.size(); } this.container.css('display', 'block'); this.buttonNext.css('display', 'block'); this.buttonPrev.css('display', 'block'); this.funcNext = function() { self.next(); }; this.funcPrev = function() { self.prev(); }; this.funcResize = function() { self.reload(); }; if (this.options.initCallback != null) this.options.initCallback(this, 'init'); if ($.browser.safari) { this.buttons(false, false); $(window).bind('load.jcarousel', function() { self.setup(); }); } else

            this.setup();
    }; var $jc = $.jcarousel; $jc.fn = $jc.prototype = { jcarousel: '0.2.4' }; $jc.fn.extend = $jc.extend = $.extend; $jc.fn.extend({ setup: function() { this.first = null; this.last = null; this.prevFirst = null; this.prevLast = null; this.animating = false; this.timer = null; this.tail = null; this.inTail = false; if (this.locked) return; this.list.css(this.lt, this.pos(this.options.offset) + 'px'); var p = this.pos(this.options.start); this.prevFirst = this.prevLast = null; this.animate(p, false); $(window).unbind('resize.jcarousel', this.funcResize).bind('resize.jcarousel', this.funcResize); }, reset: function() { this.list.empty(); this.list.css(this.lt, '0px'); this.list.css(this.wh, '10px'); if (this.options.initCallback != null) this.options.initCallback(this, 'reset'); this.setup(); }, reload: function() { if (this.tail != null && this.inTail) this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail); this.tail = null; this.inTail = false; if (this.options.reloadCallback != null) this.options.reloadCallback(this); if (this.options.visible != null) { var self = this; var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0; $('li', this.list).each(function(i) { wh += self.dimension(this, di); if (i + 1 < self.first) lt = wh; }); this.list.css(this.wh, wh + 'px'); this.list.css(this.lt, -lt + 'px'); } this.scroll(this.first, false); }, lock: function() { this.locked = true; this.buttons(); }, unlock: function() { this.locked = false; this.buttons(); }, size: function(s) { if (s != undefined) { this.options.size = s; if (!this.locked) this.buttons(); } return this.options.size; }, has: function(i, i2) { if (i2 == undefined || !i2) i2 = i; if (this.options.size !== null && i2 > this.options.size) i2 = this.options.size; for (var j = i; j <= i2; j++) { var e = this.get(j); if (!e.length || e.hasClass('jcarousel-item-placeholder')) return false; } return true; }, get: function(i) { return $('.jcarousel-item-' + i, this.list); }, add: function(i, s) {
        var e = this.get(i), old = 0, add = 0; if (e.length == 0) { var c, e = this.create(i), j = $jc.intval(i); while (c = this.get(--j)) { if (j <= 0 || c.length) { j <= 0 ? this.list.prepend(e) : c.after(e); break; } } } else
            old = this.dimension(e); e.removeClass(this.className('jcarousel-item-placeholder')); typeof s == 'string' ? e.html(s) : e.empty().append(s); var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null; var wh = this.dimension(e, di) - old; if (i > 0 && i < this.first) this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px'); this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px'); return e;
    }, remove: function(i) { var e = this.get(i); if (!e.length || (i >= this.first && i <= this.last)) return; var d = this.dimension(e); if (i < this.first) this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px'); e.remove(); this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px'); }, next: function() {
        this.stopAuto(); if (this.tail != null && !this.inTail) this.scrollTail(false); else
            this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size != null && this.last == this.options.size) ? 1 : this.first + this.options.scroll);
    }, prev: function() {
        this.stopAuto(); if (this.tail != null && this.inTail) this.scrollTail(true); else
            this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size != null && this.first == 1) ? this.options.size : this.first - this.options.scroll);
    }, scrollTail: function(b) { if (this.locked || this.animating || !this.tail) return; var pos = $jc.intval(this.list.css(this.lt)); !b ? pos -= this.tail : pos += this.tail; this.inTail = !b; this.prevFirst = this.first; this.prevLast = this.last; this.animate(pos); }, scroll: function(i, a) { if (this.locked || this.animating) return; this.animate(this.pos(i), a); }, pos: function(i) { var pos = $jc.intval(this.list.css(this.lt)); if (this.locked || this.animating) return pos; if (this.options.wrap != 'circular') i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i); var back = this.first > i; var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first; var c = back ? this.get(f) : this.get(this.last); var j = back ? f : f - 1; var e = null, l = 0, p = false, d = 0, g; while (back ? --j >= i : ++j < i) { e = this.get(j); p = !e.length; if (e.length == 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); c[back ? 'before' : 'after'](e); if (this.first != null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) { g = this.get(this.index(j)); if (g.length) this.add(j, g.children().clone(true)); } } c = e; d = this.dimension(e); if (p) l += d; if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size)))) pos = back ? pos + d : pos - d; } var clipping = this.clipping(); var cache = []; var visible = 0, j = i, v = 0; var c = this.get(i - 1); while (++visible) { e = this.get(j); p = !e.length; if (e.length == 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after'](e); if (this.first != null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) { g = this.get(this.index(j)); if (g.length) this.add(j, g.find('>*').clone(true)); } } c = e; var d = this.dimension(e); if (d == 0) { alert('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...'); return 0; } if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size) cache.push(e); else if (p) l += d; v += d; if (v >= clipping) break; j++; } for (var x = 0; x < cache.length; x++) cache[x].remove(); if (l > 0) { this.list.css(this.wh, this.dimension(this.list) + l + 'px'); if (back) { pos -= l; this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px'); } } var last = i + visible - 1; if (this.options.wrap != 'circular' && this.options.size && last > this.options.size) last = this.options.size; if (j > last) { visible = 0, j = last, v = 0; while (++visible) { var e = this.get(j--); if (!e.length) break; v += this.dimension(e); if (v >= clipping) break; } } var first = last - visible + 1; if (this.options.wrap != 'circular' && first < 1) first = 1; if (this.inTail && back) { pos += this.tail; this.inTail = false; } this.tail = null; if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) { var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom'); if ((v - m) > clipping) this.tail = v - clipping - m; } while (i-- > first) pos += this.dimension(this.get(i)); this.prevFirst = this.first; this.prevLast = this.last; this.first = first; this.last = last; return pos; }, animate: function(p, a) { if (this.locked || this.animating) return; this.animating = true; var self = this; var scrolled = function() { self.animating = false; if (p == 0) self.list.css(self.lt, 0); if (self.options.wrap == 'circular' || self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size == null || self.last < self.options.size) self.startAuto(); self.buttons(); self.notify('onAfterAnimation'); }; this.notify('onBeforeAnimation'); if (!this.options.animation || a == false) { this.list.css(this.lt, p + 'px'); scrolled(); } else { var o = !this.options.vertical ? { 'left': p} : { 'top': p }; this.list.animate(o, this.options.animation, this.options.easing, scrolled); } }, startAuto: function(s) { if (s != undefined) this.options.auto = s; if (this.options.auto == 0) return this.stopAuto(); if (this.timer != null) return; var self = this; this.timer = setTimeout(function() { self.next(); }, this.options.auto * 1000); }, stopAuto: function() { if (this.timer == null) return; clearTimeout(this.timer); this.timer = null; }, buttons: function(n, p) { if (n == undefined || n == null) { var n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size == null || this.last < this.options.size); if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size != null && this.last >= this.options.size) n = this.tail != null && !this.inTail; } if (p == undefined || p == null) { var p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1); if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size != null && this.first == 1) p = this.tail != null && this.inTail; } var self = this; this.buttonNext[n ? 'bind' : 'unbind'](this.options.buttonNextEvent + '.jcarousel', this.funcNext)[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true); this.buttonPrev[p ? 'bind' : 'unbind'](this.options.buttonPrevEvent + '.jcarousel', this.funcPrev)[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true); if (this.buttonNext.length > 0 && (this.buttonNext[0].jcarouselstate == undefined || this.buttonNext[0].jcarouselstate != n) && this.options.buttonNextCallback != null) { this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); }); this.buttonNext[0].jcarouselstate = n; } if (this.buttonPrev.length > 0 && (this.buttonPrev[0].jcarouselstate == undefined || this.buttonPrev[0].jcarouselstate != p) && this.options.buttonPrevCallback != null) { this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); }); this.buttonPrev[0].jcarouselstate = p; } }, notify: function(evt) { var state = this.prevFirst == null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev'); this.callback('itemLoadCallback', evt, state); if (this.prevFirst !== this.first) { this.callback('itemFirstInCallback', evt, state, this.first); this.callback('itemFirstOutCallback', evt, state, this.prevFirst); } if (this.prevLast !== this.last) { this.callback('itemLastInCallback', evt, state, this.last); this.callback('itemLastOutCallback', evt, state, this.prevLast); } this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast); this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last); }, callback: function(cb, evt, state, i1, i2, i3, i4) { if (this.options[cb] == undefined || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation')) return; var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb]; if (!$.isFunction(callback)) return; var self = this; if (i1 === undefined) callback(self, state, evt); else if (i2 === undefined) this.get(i1).each(function() { callback(self, this, i1, state, evt); }); else { for (var i = i1; i <= i2; i++) if (i !== null && !(i >= i3 && i <= i4)) this.get(i).each(function() { callback(self, this, i, state, evt); }); } }, create: function(i) { return this.format('<li></li>', i); }, format: function(e, i) { var $e = $(e).addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i)).css({ 'float': 'left', 'list-style': 'none' }); $e.attr('jcarouselindex', i); return $e; }, className: function(c) { return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical'); }, dimension: function(e, d) { var el = e.jquery != undefined ? e[0] : e; var old = !this.options.vertical ? el.offsetWidth + $jc.margin(el, 'marginLeft') + $jc.margin(el, 'marginRight') : el.offsetHeight + $jc.margin(el, 'marginTop') + $jc.margin(el, 'marginBottom'); if (d == undefined || old == d) return old; var w = !this.options.vertical ? d - $jc.margin(el, 'marginLeft') - $jc.margin(el, 'marginRight') : d - $jc.margin(el, 'marginTop') - $jc.margin(el, 'marginBottom'); $(el).css(this.wh, w + 'px'); return this.dimension(el); }, clipping: function() { return !this.options.vertical ? this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) : this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth')); }, index: function(i, s) { if (s == undefined) s = this.options.size; return Math.round((((i - 1) / s) - Math.floor((i - 1) / s)) * s) + 1; }
    }); $jc.extend({ defaults: function(d) { return $.extend(defaults, d || {}); }, margin: function(e, p) { if (!e) return 0; var el = e.jquery != undefined ? e[0] : e; if (p == 'marginRight' && $.browser.safari) { var old = { 'display': 'block', 'float': 'none', 'width': 'auto' }, oWidth, oWidth2; $.swap(el, old, function() { oWidth = el.offsetWidth; }); old['marginRight'] = 0; $.swap(el, old, function() { oWidth2 = el.offsetWidth; }); return oWidth2 - oWidth; } return $jc.intval($.css(el, p)); }, intval: function(v) { v = parseInt(v); return isNaN(v) ? 0 : v; } });
})(jQuery);

//JQuery.Jcarousel
(function($) {
    $.fn.jcarousel = function(o) {
        if (typeof o == 'string') { var instance = $(this).data('jcarousel'), args = Array.prototype.slice.call(arguments, 1); return instance[o].apply(instance, args); } else
            return this.each(function() { $(this).data('jcarousel', new $jc(this, o)); });
    }; var defaults = { vertical: false, start: 1, offset: 1, size: null, scroll: 3, visible: null, animation: 'normal', easing: 'swing', auto: 0, wrap: null, initCallback: null, reloadCallback: null, itemLoadCallback: null, itemFirstInCallback: null, itemFirstOutCallback: null, itemLastInCallback: null, itemLastOutCallback: null, itemVisibleInCallback: null, itemVisibleOutCallback: null, buttonNextHTML: '<div></div>', buttonPrevHTML: '<div></div>', buttonNextEvent: 'click', buttonPrevEvent: 'click', buttonNextCallback: null, buttonPrevCallback: null }; $.jcarousel = function(e, o) {
        this.options = $.extend({}, defaults, o || {}); this.locked = false; this.container = null; this.clip = null; this.list = null; this.buttonNext = null; this.buttonPrev = null; this.wh = !this.options.vertical ? 'width' : 'height'; this.lt = !this.options.vertical ? 'left' : 'top'; var skin = '', split = e.className.split(' '); for (var i = 0; i < split.length; i++) { if (split[i].indexOf('jcarousel-skin') != -1) { $(e).removeClass(split[i]); skin = split[i]; break; } } if (e.nodeName == 'UL' || e.nodeName == 'OL') { this.list = $(e); this.container = this.list.parent(); if (this.container.hasClass('jcarousel-clip')) { if (!this.container.parent().hasClass('jcarousel-container')) this.container = this.container.wrap('<div></div>'); this.container = this.container.parent(); } else if (!this.container.hasClass('jcarousel-container')) this.container = this.list.wrap('<div></div>').parent(); } else { this.container = $(e); this.list = this.container.find('ul,ol').eq(0); } if (skin != '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1) this.container.wrap('<div class=" ' + skin + '"></div>'); this.clip = this.list.parent(); if (!this.clip.length || !this.clip.hasClass('jcarousel-clip')) this.clip = this.list.wrap('<div></div>').parent(); this.buttonNext = $('.jcarousel-next', this.container); if (this.buttonNext.size() == 0 && this.options.buttonNextHTML != null) this.buttonNext = this.clip.after(this.options.buttonNextHTML).next(); this.buttonNext.addClass(this.className('jcarousel-next')); this.buttonPrev = $('.jcarousel-prev', this.container); if (this.buttonPrev.size() == 0 && this.options.buttonPrevHTML != null) this.buttonPrev = this.clip.after(this.options.buttonPrevHTML).next(); this.buttonPrev.addClass(this.className('jcarousel-prev')); this.clip.addClass(this.className('jcarousel-clip')).css({ overflow: 'hidden', position: 'relative' }); this.list.addClass(this.className('jcarousel-list')).css({ overflow: 'hidden', position: 'relative', top: 0, left: 0, margin: 0, padding: 0 }); this.container.addClass(this.className('jcarousel-container')).css({ position: 'relative' }); var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null; var li = this.list.children('li'); var self = this; if (li.size() > 0) { var wh = 0, i = this.options.offset; li.each(function() { self.format(this, i++); wh += self.dimension(this, di); }); this.list.css(this.wh, wh + 'px'); if (!o || o.size === undefined) this.options.size = li.size(); } this.container.css('display', 'block'); this.buttonNext.css('display', 'block'); this.buttonPrev.css('display', 'block'); this.funcNext = function() { self.next(); }; this.funcPrev = function() { self.prev(); }; this.funcResize = function() { self.reload(); }; if (this.options.initCallback != null) this.options.initCallback(this, 'init'); if ($.browser.safari) { this.buttons(false, false); $(window).bind('load.jcarousel', function() { self.setup(); }); } else
            this.setup();
    }; var $jc = $.jcarousel; $jc.fn = $jc.prototype = { jcarousel: '0.2.4' }; $jc.fn.extend = $jc.extend = $.extend; $jc.fn.extend({ setup: function() { this.first = null; this.last = null; this.prevFirst = null; this.prevLast = null; this.animating = false; this.timer = null; this.tail = null; this.inTail = false; if (this.locked) return; this.list.css(this.lt, this.pos(this.options.offset) + 'px'); var p = this.pos(this.options.start); this.prevFirst = this.prevLast = null; this.animate(p, false); $(window).unbind('resize.jcarousel', this.funcResize).bind('resize.jcarousel', this.funcResize); }, reset: function() { this.list.empty(); this.list.css(this.lt, '0px'); this.list.css(this.wh, '10px'); if (this.options.initCallback != null) this.options.initCallback(this, 'reset'); this.setup(); }, reload: function() { if (this.tail != null && this.inTail) this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail); this.tail = null; this.inTail = false; if (this.options.reloadCallback != null) this.options.reloadCallback(this); if (this.options.visible != null) { var self = this; var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0; $('li', this.list).each(function(i) { wh += self.dimension(this, di); if (i + 1 < self.first) lt = wh; }); this.list.css(this.wh, wh + 'px'); this.list.css(this.lt, -lt + 'px'); } this.scroll(this.first, false); }, lock: function() { this.locked = true; this.buttons(); }, unlock: function() { this.locked = false; this.buttons(); }, size: function(s) { if (s != undefined) { this.options.size = s; if (!this.locked) this.buttons(); } return this.options.size; }, has: function(i, i2) { if (i2 == undefined || !i2) i2 = i; if (this.options.size !== null && i2 > this.options.size) i2 = this.options.size; for (var j = i; j <= i2; j++) { var e = this.get(j); if (!e.length || e.hasClass('jcarousel-item-placeholder')) return false; } return true; }, get: function(i) { return $('.jcarousel-item-' + i, this.list); }, add: function(i, s) {
        var e = this.get(i), old = 0, add = 0; if (e.length == 0) { var c, e = this.create(i), j = $jc.intval(i); while (c = this.get(--j)) { if (j <= 0 || c.length) { j <= 0 ? this.list.prepend(e) : c.after(e); break; } } } else
            old = this.dimension(e); e.removeClass(this.className('jcarousel-item-placeholder')); typeof s == 'string' ? e.html(s) : e.empty().append(s); var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null; var wh = this.dimension(e, di) - old; if (i > 0 && i < this.first) this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px'); this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px'); return e;
    }, remove: function(i) { var e = this.get(i); if (!e.length || (i >= this.first && i <= this.last)) return; var d = this.dimension(e); if (i < this.first) this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px'); e.remove(); this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px'); }, next: function() {
        this.stopAuto(); if (this.tail != null && !this.inTail) this.scrollTail(false); else
            this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size != null && this.last == this.options.size) ? 1 : this.first + this.options.scroll);
    }, prev: function() {
        this.stopAuto(); if (this.tail != null && this.inTail) this.scrollTail(true); else
            this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size != null && this.first == 1) ? this.options.size : this.first - this.options.scroll);
    }, scrollTail: function(b) { if (this.locked || this.animating || !this.tail) return; var pos = $jc.intval(this.list.css(this.lt)); !b ? pos -= this.tail : pos += this.tail; this.inTail = !b; this.prevFirst = this.first; this.prevLast = this.last; this.animate(pos); }, scroll: function(i, a) { if (this.locked || this.animating) return; this.animate(this.pos(i), a); }, pos: function(i) { var pos = $jc.intval(this.list.css(this.lt)); if (this.locked || this.animating) return pos; if (this.options.wrap != 'circular') i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i); var back = this.first > i; var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first; var c = back ? this.get(f) : this.get(this.last); var j = back ? f : f - 1; var e = null, l = 0, p = false, d = 0, g; while (back ? --j >= i : ++j < i) { e = this.get(j); p = !e.length; if (e.length == 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); c[back ? 'before' : 'after'](e); if (this.first != null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) { g = this.get(this.index(j)); if (g.length) this.add(j, g.children().clone(true)); } } c = e; d = this.dimension(e); if (p) l += d; if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size)))) pos = back ? pos + d : pos - d; } var clipping = this.clipping(); var cache = []; var visible = 0, j = i, v = 0; var c = this.get(i - 1); while (++visible) { e = this.get(j); p = !e.length; if (e.length == 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after'](e); if (this.first != null && this.options.wrap == 'circular' && this.options.size !== null && (j <= 0 || j > this.options.size)) { g = this.get(this.index(j)); if (g.length) this.add(j, g.find('>*').clone(true)); } } c = e; var d = this.dimension(e); if (d == 0) { alert('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...'); return 0; } if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size) cache.push(e); else if (p) l += d; v += d; if (v >= clipping) break; j++; } for (var x = 0; x < cache.length; x++) cache[x].remove(); if (l > 0) { this.list.css(this.wh, this.dimension(this.list) + l + 'px'); if (back) { pos -= l; this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px'); } } var last = i + visible - 1; if (this.options.wrap != 'circular' && this.options.size && last > this.options.size) last = this.options.size; if (j > last) { visible = 0, j = last, v = 0; while (++visible) { var e = this.get(j--); if (!e.length) break; v += this.dimension(e); if (v >= clipping) break; } } var first = last - visible + 1; if (this.options.wrap != 'circular' && first < 1) first = 1; if (this.inTail && back) { pos += this.tail; this.inTail = false; } this.tail = null; if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) { var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom'); if ((v - m) > clipping) this.tail = v - clipping - m; } while (i-- > first) pos += this.dimension(this.get(i)); this.prevFirst = this.first; this.prevLast = this.last; this.first = first; this.last = last; return pos; }, animate: function(p, a) { if (this.locked || this.animating) return; this.animating = true; var self = this; var scrolled = function() { self.animating = false; if (p == 0) self.list.css(self.lt, 0); if (self.options.wrap == 'circular' || self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size == null || self.last < self.options.size) self.startAuto(); self.buttons(); self.notify('onAfterAnimation'); }; this.notify('onBeforeAnimation'); if (!this.options.animation || a == false) { this.list.css(this.lt, p + 'px'); scrolled(); } else { var o = !this.options.vertical ? { 'left': p} : { 'top': p }; this.list.animate(o, this.options.animation, this.options.easing, scrolled); } }, startAuto: function(s) { if (s != undefined) this.options.auto = s; if (this.options.auto == 0) return this.stopAuto(); if (this.timer != null) return; var self = this; this.timer = setTimeout(function() { self.next(); }, this.options.auto * 1000); }, stopAuto: function() { if (this.timer == null) return; clearTimeout(this.timer); this.timer = null; }, buttons: function(n, p) { if (n == undefined || n == null) { var n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size == null || this.last < this.options.size); if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size != null && this.last >= this.options.size) n = this.tail != null && !this.inTail; } if (p == undefined || p == null) { var p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1); if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size != null && this.first == 1) p = this.tail != null && this.inTail; } var self = this; this.buttonNext[n ? 'bind' : 'unbind'](this.options.buttonNextEvent + '.jcarousel', this.funcNext)[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true); this.buttonPrev[p ? 'bind' : 'unbind'](this.options.buttonPrevEvent + '.jcarousel', this.funcPrev)[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true); if (this.buttonNext.length > 0 && (this.buttonNext[0].jcarouselstate == undefined || this.buttonNext[0].jcarouselstate != n) && this.options.buttonNextCallback != null) { this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); }); this.buttonNext[0].jcarouselstate = n; } if (this.buttonPrev.length > 0 && (this.buttonPrev[0].jcarouselstate == undefined || this.buttonPrev[0].jcarouselstate != p) && this.options.buttonPrevCallback != null) { this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); }); this.buttonPrev[0].jcarouselstate = p; } }, notify: function(evt) { var state = this.prevFirst == null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev'); this.callback('itemLoadCallback', evt, state); if (this.prevFirst !== this.first) { this.callback('itemFirstInCallback', evt, state, this.first); this.callback('itemFirstOutCallback', evt, state, this.prevFirst); } if (this.prevLast !== this.last) { this.callback('itemLastInCallback', evt, state, this.last); this.callback('itemLastOutCallback', evt, state, this.prevLast); } this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast); this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last); }, callback: function(cb, evt, state, i1, i2, i3, i4) { if (this.options[cb] == undefined || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation')) return; var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb]; if (!$.isFunction(callback)) return; var self = this; if (i1 === undefined) callback(self, state, evt); else if (i2 === undefined) this.get(i1).each(function() { callback(self, this, i1, state, evt); }); else { for (var i = i1; i <= i2; i++) if (i !== null && !(i >= i3 && i <= i4)) this.get(i).each(function() { callback(self, this, i, state, evt); }); } }, create: function(i) { return this.format('<li></li>', i); }, format: function(e, i) { var $e = $(e).addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i)).css({ 'float': 'left', 'list-style': 'none' }); $e.attr('jcarouselindex', i); return $e; }, className: function(c) { return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical'); }, dimension: function(e, d) { var el = e.jquery != undefined ? e[0] : e; var old = !this.options.vertical ? el.offsetWidth + $jc.margin(el, 'marginLeft') + $jc.margin(el, 'marginRight') : el.offsetHeight + $jc.margin(el, 'marginTop') + $jc.margin(el, 'marginBottom'); if (d == undefined || old == d) return old; var w = !this.options.vertical ? d - $jc.margin(el, 'marginLeft') - $jc.margin(el, 'marginRight') : d - $jc.margin(el, 'marginTop') - $jc.margin(el, 'marginBottom'); $(el).css(this.wh, w + 'px'); return this.dimension(el); }, clipping: function() { return !this.options.vertical ? this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) : this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth')); }, index: function(i, s) { if (s == undefined) s = this.options.size; return Math.round((((i - 1) / s) - Math.floor((i - 1) / s)) * s) + 1; }
    }); $jc.extend({ defaults: function(d) { return $.extend(defaults, d || {}); }, margin: function(e, p) { if (!e) return 0; var el = e.jquery != undefined ? e[0] : e; if (p == 'marginRight' && $.browser.safari) { var old = { 'display': 'block', 'float': 'none', 'width': 'auto' }, oWidth, oWidth2; $.swap(el, old, function() { oWidth = el.offsetWidth; }); old['marginRight'] = 0; $.swap(el, old, function() { oWidth2 = el.offsetWidth; }); return oWidth2 - oWidth; } return $jc.intval($.css(el, p)); }, intval: function(v) { v = parseInt(v); return isNaN(v) ? 0 : v; } });
})(jQuery);


//Functions
function playInLightbox(isAudio, videoId, portalId, title, width, height) {

    var fixEmbeddedVideo = function(embedCode) {
        if (embedCode && embedCode.toLowerCase().indexOf('classid') == -1) {
            var objPos = embedCode.toLowerCase().indexOf('object') + 'object'.length;
            return embedCode.substr(0, objPos) + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' + embedCode.substr(objPos);
        } else {
            return embedCode;
        }
    }

    ensureVideoContainer();
    var swf = videomodulepath + "uvg.swf?vId=" + videoId + "&portalId=0&baseUrl=" + videomodulepath;
    var code = "<object allowFullScreen='True' allowScriptAccess='always' allowNetworking='all' width='500' height='425'><param name='movie' value='" + swf + "' /><param name='allowFullScreen' value='true' /><embed src='" + swf + "' type='application/x-shockwave-flash' allowFullScreen='True' allowScriptAccess='always' allowNetworking='all' width='500' height='425'></embed></object>";
    videoContainer.innerHTML = fixEmbeddedVideo(code);
    tb_show(title.replace("[SQM]", "'"), "#TB_inline?height=425&width=500&inlineId=" + videoContainer.id, null);
}

function ensureVideoContainer() {
    if (!videoContainer) {
        videoContainer = document.createElement("div");
        videoContainer.style.display = "none";
        videoContainer.id = "videoContainer";
        document.body.appendChild(videoContainer);
    }
}
function slideShow(itemID, title) {
    //file is Test.aspx and its full location
    ensurePhotoContainer();
    var movie = "";
    var code = "<iframe src ='" + photomodulepath + "?itemID=" + itemID + "&title=" + title + "' width='520px' height='478px' margin='0' scrolling='no' frameborder='0' />";
    photoContainer.innerHTML = code;
    tb_show(title.replace("[SQM]", "'"), "#TB_inline?height=470&width=520&inlineId=" + photoContainer.id, null);
}

function ensurePhotoContainer() {
    if (!photoContainer) {
        photoContainer = document.createElement("div");
        photoContainer.style.display = "none";
        photoContainer.id = "photoContainer";
        document.body.appendChild(photoContainer);
    }
}

function changeText() {
    $("#news-feed-text").fadeOut(300, function() {

        if ((textArray[currCount].url == null) || (textArray[currCount].url == "")) {

            document.getElementById('url').removeAttribute("href");
        }
        else {
            document.getElementById('url').href = (textArray[currCount].url);
        }
        $("#news-feed-title").html(textArray[currCount].title);
        $("#news-feed-description").html(textArray[currCount].textString);

        currCount++;
        if (currCount > textArray.length - 1) currCount = 0;
        $("#news-feed-text").fadeIn(300);
    });
}



function jsddm_open() {
    jsddm_canceltimer();
    jsddm_close();
    ddmenuitem = $(this).find('ul').css('visibility', 'visible');
    isFirstTab = $(this).find('#first');
    if (isFirstTab.html() != null) $(this).find('ul').css('margin-left', '-2px');
    if (ddmenuitem.html() != null) $(this).find('a').addClass("active_hasSub");
    else $(this).find('a').addClass("active");
}

function jsddm_close() {
    if (ddmenuitem && currmenutab != null) {
        ddmenuitem.css('visibility', 'hidden');
        currmenutab.find('a').removeClass("active");
        currmenutab.find('a').removeClass("active_hasSub");
    }
}

function jsddm_timer() {
    currmenutab = $(this);
    closeHorNavTimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer() {
    if (closeHorNavTimer) {
        window.clearTimeout(closeHorNavTimer);
        closeHorNavTimer = null;
    }
}



function getMetaData() {
    metaCollection = document.getElementsByTagName('meta');
    var pageLocString = "";
    for (i = 0; i < metaCollection.length; i++) {
        nameAttribute = metaCollection[i].name.search(/keywords/i);
        if (nameAttribute != -1) {
            var keywordsList = metaCollection[i].content;
            pageLocString = keywordsList.split(",", 1).toString();
            break;
        }
    }

    var pageLocList = pageLocString.split("#");
    var banBackURL = "";
    var foldersPath = "";
    var logoColor = pageLocList[1];
    var language = pageLocList[2];

    if (pageLocList[3] == "index") {
        foldersPath = DefaultURL + "swf/";
    }
    else {
        imgLevel = DefaultURL + pageLocList[3] + "/";
        foldersPath = DefaultURL + pageLocList[3] + "/swf/";
    }
    banBackURL = foldersPath + pageLocList[4];
    xmlFile = foldersPath + pageLocList[4].replace("swf", "xml");

    flashvars_banner.urlLink = banBackURL;
    flashvars_banner.siteLanguage = language;
    flashvars_banner.logoColor = logoColor;
    flashvars_banner.oldLandingBannersXML = path_oldLandingBannersXML;
    flashvars_nav.language = language; //en, jp, cn_s, cn_t, id
    flashvars_nav.pagePath = foldersPath;

}

function loadXMLDoc(XMLname) {
    var xmlDocf;
    if (window.XMLHttpRequest) {
        xmlDocf = new window.XMLHttpRequest();
        xmlDocf.open("GET", XMLname, false);
        xmlDocf.send("");
        return xmlDocf;
    }
    // IE 5 and IE 6
    else if (ActiveXObject("Microsoft.XMLDOM")) {
        xmlDocf = new ActiveXObject("Microsoft.XMLDOM");
        xmlDocf.async = false;
        xmlDocf.load(XMLname);
        return xmlDocf;
    }
    alert("Error loading XML!");
    return null;
}

function stateChangedChrome() {
    if (xmlDoc.readyState == 4 && xmlDoc.status == 200) {
        var xml = xmlDoc.responseXML;
        var root = xml.documentElement;
        for (var i = 0; i < root.childNodes.length; i++) {
            var child = root.childNodes[i];
            if (child.localName == "squareDotsConfig") {
                var size = child.attributes.getNamedItem("size").nodeValue;
                var spacing = child.attributes.getNamedItem("spacing").nodeValue;
                var yPosition = child.attributes.getNamedItem("yPosition").nodeValue;
                var defaultBorderColor = child.attributes.getNamedItem("defaultBorderColor").nodeValue.replace("0x", "#");
                var selectedBorderColor = child.attributes.getNamedItem("selectedBorderColor").nodeValue.replace("0x", "#");
                var selectedFillColor = child.attributes.getNamedItem("selectedFillColor").nodeValue.replace("0x", "#");

                var cssStr = ".squareDotDefault {width: " + size + "px;" +
                "height:" + size + "px;" +
                "border-width:1px;" +
                "border-style:solid;" +
                "border-color:#b1d8dc;" +
                "background:url(/Portals/0/RWS/images/banner/squaredots_blank_bg.gif);}" +
                ".squareDotSelected { " +
                "width: " + size + "px;" +
                "height:" + size + "px;" +
                "border-width:1px;" +
                "border-style:solid;" +
                "border-color:" + selectedBorderColor + ";" +
                "background:" + selectedFillColor + ";" +
                "}";

                newStyle(cssStr);

            }
            else if (child.localName == "clips") {
                var child = root.childNodes[i];
                var language = child.attributes.getNamedItem("language").nodeValue;
                if (flashvars_banner.siteLanguage == language) {
                    var clipCount = 0;
                    for (var j = 0; j < child.childNodes.length; j++) {
                        var clips = child.childNodes[j];
                        var content = clips.textContent;
                        var contentType = content.substring(content.indexOf('.') + 1).toUpperCase();
                        if (contentType == "JPG" || contentType == "PNG" || contentType == "JPEG" || contentType == "GIF" || contentType == "BMP") {
                            imageList[clipCount] = {};
                            imageList[clipCount].type = "image";
                            imageList[clipCount].content = content;
                            if (!(typeof (clips.attributes.getNamedItem("time"))) == 'null')
                                imageList[clipCount].time = clips.attributes.getNamedItem("time").nodeValue;
                            else
                                imageList[clipCount].time = "5"
                            imageList[clipCount].urllink = clips.attributes.getNamedItem("linkToURL").nodeValue;
                            imageList[clipCount].newwindow = clips.attributes.getNamedItem("openInNewWindow").nodeValue;
                            clipCount++;

                        }
                        else if (contentType == "SWF") {
                            imageList[clipCount] = {};
                            imageList[clipCount].type = "swf";
                            imageList[clipCount].content = content;
                            if (!(typeof (clips.attributes.getNamedItem("time"))) == 'null')
                                imageList[clipCount].time = clips.attributes.getNamedItem("time").nodeValue;
                            else
                                imageList[clipCount].time = "8"
                            imageList[clipCount].urllink = clips.attributes.getNamedItem("linkToURL").nodeValue;
                            imageList[clipCount].newwindow = clips.attributes.getNamedItem("openInNewWindow").nodeValue;
                            imageList[clipCount].frame = clips.attributes.getNamedItem("startFrame").nodeValue;
                            replayFlash = "false";
                            clipCount++;
                        }

                    }
                }
            }
        }
        var jsBanner = null;
        if ($('#flash-banner-main').length > 0) {
            if ($('#flash-banner-main #flash-banner-container').is('.javascript-version')) $('#flash-banner-main #flash-banner-container').jsBanner(imageList, $('#flash-banner-main').width(), $('#flash-banner-main').height(), 50);
            else swfobject.embedSWF("swf/flashbanner_back_loader.swf", "flash-banner-container", "970", "450", "9.0.0", "swf/expressInstall.swf", flashvars_banner, params, attributes);
        }
        else {
            if ($('#flash-banner-sub #flash-banner-container').is('.javascript-version')) jsBanner = $('#flash-banner-sub #flash-banner-container').jsBanner(imageList, $('#flash-banner-sub').width(), $('#flash-banner-sub').height(), 50);
            else swfobject.embedSWF("swf/flashbanner_back_sub_loader.swf", "flash-banner-container", "970", "370", "9.0.0", "swf/expressInstall.swf", flashvars_banner, params, attributes);
        }
    }
}

function stateChangedIE() {
    if (xmlDoc.readyState == 4 && xmlDoc.status == 200) {
        var xml = xmlDoc.responseXML;
        var root = xml.documentElement;
        for (var i = 0; i < root.childNodes.length; i++) {
            var child = root.childNodes[i];
            if (child.baseName == "squareDotsConfig") {
                var size = child.attributes.getNamedItem("size").nodeValue;
                var spacing = child.attributes.getNamedItem("spacing").nodeValue;
                var yPosition = child.attributes.getNamedItem("yPosition").nodeValue;
                var defaultBorderColor = child.attributes.getNamedItem("defaultBorderColor").nodeValue.replace("0x", "#");
                var selectedBorderColor = child.attributes.getNamedItem("selectedBorderColor").nodeValue.replace("0x", "#");
                var selectedFillColor = child.attributes.getNamedItem("selectedFillColor").nodeValue.replace("0x", "#");

                var cssStr = ".squareDotDefault {width: " + size + "px;" +
                "height:" + size + "px;" +
                "border-width:1px;" +
                "border-style:solid;" +
                "border-color:#b1d8dc;" +
                "background:url(/Portals/0/RWS/images/banner/squaredots_blank_bg.gif);}" +
                ".squareDotSelected { " +
                "width: " + size + "px;" +
                "height:" + size + "px;" +
                "border-width:1px;" +
                "border-style:solid;" +
                "border-color:" + selectedBorderColor + ";" +
                "background:" + selectedFillColor + ";" +
                "}";

                newStyle(cssStr);

            }
            else if (child.baseName == "clips") {
                var child = root.childNodes[i];
                var language = child.attributes.getNamedItem("language").nodeValue;
                if (flashvars_banner.siteLanguage == language) {
                    var clipCount = 0;
                    for (var j = 0; j < child.childNodes.length; j++) {
                        var clips = child.childNodes[j];
                        var content = clips.text;
                        var contentType = content.substring(content.indexOf('.') + 1).toUpperCase();
                        if (contentType == "JPG" || contentType == "PNG" || contentType == "JPEG" || contentType == "GIF" || contentType == "BMP") {
                            imageList[clipCount] = {};
                            imageList[clipCount].type = "image";
                            imageList[clipCount].content = content;
                            if (!(typeof (clips.attributes.getNamedItem("time"))) == 'null')
                                imageList[clipCount].time = clips.attributes.getNamedItem("time").nodeValue;
                            else
                                imageList[clipCount].time = "5"
                            imageList[clipCount].urllink = clips.attributes.getNamedItem("linkToURL").nodeValue;
                            imageList[clipCount].newwindow = clips.attributes.getNamedItem("openInNewWindow").nodeValue;
                            clipCount++;

                        }
                        else if (contentType == "SWF") {
                            imageList[clipCount] = {};
                            imageList[clipCount].type = "swf";
                            imageList[clipCount].content = content;
                            if (!(typeof (clips.attributes.getNamedItem("time"))) == 'null')
                                imageList[clipCount].time = clips.attributes.getNamedItem("time").nodeValue;
                            else
                                imageList[clipCount].time = "8"
                            imageList[clipCount].urllink = clips.attributes.getNamedItem("linkToURL").nodeValue;
                            imageList[clipCount].newwindow = clips.attributes.getNamedItem("openInNewWindow").nodeValue;
                            imageList[clipCount].frame = clips.attributes.getNamedItem("startFrame").nodeValue;
                            replayFlash = "false";
                            clipCount++;
                        }

                    }
                }
            }
        }
        var jsBanner = null;
        if ($('#flash-banner-main').length > 0) {
            if ($('#flash-banner-main #flash-banner-container').is('.javascript-version')) $('#flash-banner-main #flash-banner-container').jsBanner(imageList, $('#flash-banner-main').width(), $('#flash-banner-main').height(), 50);
            else swfobject.embedSWF("swf/flashbanner_back_loader.swf", "flash-banner-container", "970", "450", "9.0.0", "swf/expressInstall.swf", flashvars_banner, params, attributes);
        }
        else {
            if ($('#flash-banner-sub #flash-banner-container').is('.javascript-version')) jsBanner = $('#flash-banner-sub #flash-banner-container').jsBanner(imageList, $('#flash-banner-sub').width(), $('#flash-banner-sub').height(), 50);
            else swfobject.embedSWF("swf/flashbanner_back_sub_loader.swf", "flash-banner-container", "970", "370", "9.0.0", "swf/expressInstall.swf", flashvars_banner, params, attributes);
        }
    }
}

function newStyle(str) {
    var pa = document.getElementsByTagName('head')[0];
    var el = document.createElement('style');
    el.type = 'text/css';
    el.media = 'screen';
    if (el.styleSheet) el.styleSheet.cssText = str; // IE method
    else el.appendChild(document.createTextNode(str)); // others
    pa.appendChild(el);
    return el;
}

function checkWebsite() {
    var websitelink = $("#footer-nav").find(".footer-nav-link").attr("href");
    window.location.replace(websitelink);
}

function doNothing() {

}

function closeHeaderSub() {
    if (!inHeaderSub) $("#header-sub-nav").fadeOut(100);
    inProcessOfClosing = false;
}

function headerSubCancelTimer() {
    if (closeHeaderSubTimer) {
        window.clearTimeout(closeHeaderSubTimer);
        closeHeaderSubTimer = null;
    }
}


//Running Functions
getMetaData();
document.onclick = jsddm_close;


//Function Run When Page Ready
var spacing_added = false;

$(document).ready(function() {

    $("#selected-lang").html($("#header-sub-lang").find(".selected").first().html());
    $("#header-sub-lang").find(".selected").first().css('background-color', '#e3c891');

    $("#header-sub-lang").find(".lang-nav").mouseover(function() {
        $(this).css('background-color', '#e3c891');
    });

    $("#header-sub-lang").find(".lang-nav").mouseout(function() {
        $(this).css('background-color', '#fff');
    });

    $("#header-sub-lang").find(".lang-nav").click(function() {
        $("#selected-lang").html($(this).html());
        $("#header-sub-lang").find(".selected").removeClass('selected');
        $(this).addClass('selected');
        $('#header-sub-lang').css('display', 'none');
    });

    $("#header-sub-lang-dd").click(function() {
        $("#header-sub-lang").find(".lang-nav").css('background-color', '#fff');
        $("#header-sub-lang").find(".selected").first().css('background-color', '#e3c891');
        $('#header-sub-lang').stop().slideDown('fast');
    });

    $("body").click(function(event) {
        if ($(event.target).parents("#header-sub-lang").length == 0 && $(event.target).parents("#header-sub-lang-dd").length == 0) $('#header-sub-lang').slideUp('fast');
    });

    $("#header-sub-lang-dd").mouseenter(function() {
        headerLangSubCancelTimer();
        if ($("#header-sub-lang").css('display') == 'block') $("#header-sub-lang").stop().slideDown('fast');
    });

    $("#header-sub-lang-dd").mouseleave(function() {
        inProcessOfClosingLang = true;
        closeHeaderLangSubTimer = window.setTimeout(closeHeaderLangSub, 400);
    });

    $("#header-sub-lang").mouseenter(function() {
        inHeaderLangSub = true;
    });

    $("#header-sub-lang").mouseleave(function() {
        inHeaderLangSub = false;
        if (!inProcessOfClosingLang) $("#header-sub-lang").slideUp('fast');
    });

    function closeHeaderLangSub() {
        if (!inHeaderLangSub) $("#header-sub-lang").slideUp('fast');
        inProcessOfClosingLang = false;
    }

    function headerLangSubCancelTimer() {
        if (closeHeaderLangSubTimer) {
            window.clearTimeout(closeHeaderLangSubTimer);
            closeHeaderLangSubTimer = null;
        }
    }

    xmlDoc = loadXMLDoc(xmlFile);
    if (BrowserDetect.browser.toUpperCase() == "EXPLORER") {
        stateChangedIE();
    }
    else {
        stateChangedChrome();
    }
    //xmlDoc.send(null);

    //Left Panel Scroll
    $("#left-panel-section-scrolling-promo-content div").each(function(index) {
        if (index < left_scrolling_banner_clipmax) left_scrolling_banner_clips_array.push($(this).html());
    });

    if (left_scrolling_banner_clips_array.length >= 1) {

        if (left_scrolling_banner_clips_array.length == 1) {
            left_scrolling_banner_clips_html += "<div class='left-panel-section-scrolling-promo-clip' style='left:0px'>" + left_scrolling_banner_clips_array[0] + "</div>";
            $("#left-panel-section-scrolling-promo-scroller").html(left_scrolling_banner_clips_html);

        }

        else {
            left_scrolling_banner_clips_html += "<div class='left-panel-section-scrolling-promo-clip' style='left:0px'>" + left_scrolling_banner_clips_array[left_scrolling_banner_clips_array.length - 1] + "</div>";
            for (var h = 0; h < left_scrolling_banner_clips_array.length; h++) {
                left_scrolling_banner_clips_html += "<div class='left-panel-section-scrolling-promo-clip' style='left:" + ((h + 1) * left_scrolling_banner_clipwidth) + "px'>" + left_scrolling_banner_clips_array[h] + "</div>";
            }
            left_scrolling_banner_clips_html += "<div class='left-panel-section-scrolling-promo-clip' style='left:" + ((left_scrolling_banner_clips_array.length + 1) * left_scrolling_banner_clipwidth) + "px'>" + left_scrolling_banner_clips_array[0] + "</div>";
            $("#left-panel-section-scrolling-promo-scroller").html(left_scrolling_banner_clips_html);
            $("#left-panel-section-scrolling-promo-scroller").css("left", -1 * left_scrolling_banner_clipwidth);
        }


        if (left_scrolling_banner_clips_array.length > 1) {
            var squaredot_startx = ((160 - ((left_scrolling_banner_clips_array.length * 8) + ((left_scrolling_banner_clips_array.length - 1) * 3))) / 2) + 15;

            for (var i = 0; i < left_scrolling_banner_clips_array.length; i++) {
                var right_margin_val = "3px";
                var sqdot_image = $("#left-panel-section-scrolling-sqdots-off").attr("src");
                if (i == left_scrolling_banner_clips_array.length - 1) right_margin_val = '0px';
                if (i == 0) sqdot_image = sqdot_image = $("#left-panel-section-scrolling-sqdots-on").attr("src");
                left_scrolling_banner_squaredots_html += "<img id='left-panel-promo-clip" + (i + 1) + "' style='float:left;margin-right:" + right_margin_val + ";' src='" + sqdot_image + "' />";
            }

            left_scrolling_banner_squaredots_html += "<div style='clear:both;'><!-- --></div>";

            $("#left-panel-section-scrolling-squaredots").html(left_scrolling_banner_squaredots_html);
            $("#left-panel-section-scrolling-squaredots").css("left", squaredot_startx);

            for (var i = 0; i < left_scrolling_banner_clips_array.length; i++) {
                $("#left-panel-promo-clip" + (i + 1)).css('cursor', 'pointer');
                $("#left-panel-promo-clip" + (i + 1)).click(function() {
                    var leftpanel_clipNum = $(this).attr('id').substring(21);
                    left_panel_gotoClip(parseInt(leftpanel_clipNum));
                });
            }

            $("#left-panel-section-scrolling-promo-leftarrow").css("display", "block");
            $("#left-panel-section-scrolling-promo-leftarrow").css("cursor", "pointer");
            $("#left-panel-section-scrolling-promo-leftarrow").click(function() {
                left_panel_gotoClip(left_scrolling_banner_currClicked - 1);
            });
            $("#left-panel-section-scrolling-promo-rightarrow").css("display", "block");
            $("#left-panel-section-scrolling-promo-rightarrow").css("cursor", "pointer");
            $("#left-panel-section-scrolling-promo-rightarrow").click(function() {
                left_panel_gotoClip(left_scrolling_banner_currClicked + 1);
            });
        }

        else {
            $("#left-panel-section-scrolling-promo").css("height", 190);
        }

        $("#left-panel-section-scrolling-promo").css("display", "block");
    }
    //Loading Flash,Setting Dock-Offset, Setting Flag Color
    if (flashvars_banner.logoColor == "white") { /*metatag = white -> color of text in logo, rmb change setup->language and page settings metatag*/
        if (flashvars_nav.language == "en") {

            $("#rws_logo").attr("src", base_url + "images/img_logo_rws_light.png");
        }
        else if (flashvars_nav.language == "cn_s") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws_sim_cn_light.png");
        }
        else if (flashvars_nav.language == "cn_t") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws_trad_cn_light.png");
        }
        else if (flashvars_nav.language == "jp") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws_light.png");
        }
        else if (flashvars_nav.language == "id") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws_light.png");
        }
    }
    else if (flashvars_banner.logoColor == "black") { /*metatag = white -> color of text in logo, rmb change setup->language and page settings metatag*/
        if (flashvars_nav.language == "en") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws.png");
        }
        else if (flashvars_nav.language == "cn_s") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws_sim_cn.png");
        }
        else if (flashvars_nav.language == "cn_t") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws_trad_cn.png");
        }
        else if (flashvars_nav.language == "jp") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws.png");
        }
        else if (flashvars_nav.language == "id") {
            $("#rws_logo").attr("src", base_url + "images/img_logo_rws.png");
        }

    }

    //Getting Here Functions
    $("#getting-here-link").mouseover(function() {
        headerSubCancelTimer();
        $("#header-sub-nav").fadeIn(100);
    });

    $("#getting-here-link").mouseout(function() {
        inProcessOfClosing = true;
        closeHeaderSubTimer = window.setTimeout(closeHeaderSub, 400);
    });

    $("#header-sub-nav").bind('mouseenter', function() {
        inHeaderSub = true;
    });

    $("#header-sub-nav").bind('mouseleave', function() {
        inHeaderSub = false;
        if (!inProcessOfClosing) $("#header-sub-nav").fadeOut(100);
    });


    //Html Menu Navigation
    $('#jsddm > li').bind('mouseover', jsddm_open)
    $('#jsddm > li').bind('mouseout', jsddm_timer)
    $('#jssddm > li').bind('mouseover', jsddm_open)
    $('#jssddm > li').bind('mouseout', jsddm_timer)

    //NewsFeed
    if (textArray.length > 0) {
        $("#news-feed-title").html(textArray[currCount].title);
        $("#news-feed-description").html(textArray[currCount].textString);
        document.getElementById('url').href = (textArray[currCount].url);

        currCount++;
        if (currCount > textArray.length - 1) currCount = 0;
        $(this).everyTime(newsFeedLoopingTime, changeText);
    }

    //TabHighlights
    $('#tab1-content-carousel').jcarousel({
        initCallback: function(carousel) { cArray[1] = carousel; },
        wrap: 'circular',
        scroll: 4
    });

    $('#tab2-content-carousel').jcarousel({
        initCallback: function(carousel) { cArray[2] = carousel; },
        wrap: 'circular',
        scroll: 4
    });

    $('#tab3-content-carousel').jcarousel({
        initCallback: function(carousel) { cArray[3] = carousel; },
        wrap: 'circular',
        scroll: 4
    });

    $('#tab4-content-carousel').jcarousel({
        initCallback: function(carousel) { cArray[4] = carousel; },
        wrap: 'circular',
        scroll: 4
    });

    $('#tab5-content-carousel').jcarousel({
        initCallback: function(carousel) { cArray[5] = carousel; },
        wrap: 'circular',
        scroll: 4
    });


    for (var i = 1; i <= 5; i++) {
        if (i == 1) {
            $("#ctab1-bottom").css("display", "none");
            $("#ctab1").css("top", "0px");
            $("#ctab1").css("height", "33px");
            $("#ctab1").css("cursor", "default");
            $("#ctab1").css("color", "#880308");
            currentChosenTab.tabNum = 1;
            currentChosenTab.depth = $("#ctab1").css("z-index");
            selectedTabDepth = 75;
        }
        else {
            $("#ctab" + i).bind("mouseover", function(e) {
                $(this).css("color", "#880308");
            });

            $("#ctab" + i).bind("mouseout", function(e) {
                $(this).css("color", "#3a6b80");
            });
        }


        $("#ctab" + i).bind("click", { tabNum: i }, function(event) {
            if (currentChosenTab != i) {
                if (currentChosenTab.tabNum != 6) {
                    myCarousel = cArray[currentChosenTab.tabNum];
                    myCarousel.scroll(1);
                    $("#tab" + currentChosenTab.tabNum + "-content").css("display", "none");
                }

                $("#ctab" + currentChosenTab.tabNum + "-bottom").css("display", "block");
                $("#ctab" + currentChosenTab.tabNum).css("top", "10px");
                $("#ctab" + currentChosenTab.tabNum).css("height", "22px");
                $("#ctab" + currentChosenTab.tabNum).css("cursor", "pointer");
                $("#ctab" + currentChosenTab.tabNum).css("color", "#3a6b80");
                $("#ctab" + currentChosenTab.tabNum).css("z-index", currentChosenTab.depth);
                $("#ctab" + currentChosenTab.tabNum).bind("mouseover", function(e) {
                    $(this).css("color", "#880308");
                });
                $("#ctab" + currentChosenTab.tabNum).bind("mouseout", function(e) {
                    $(this).css("color", "#3a6b80");
                });


                currentChosenTab.tabNum = event.data.tabNum;
                currentChosenTab.depth = $("#ctab" + currentChosenTab.tabNum).css("z-index");
                $("#ctab" + currentChosenTab.tabNum + "-bottom").css("display", "none");
                $("#ctab" + currentChosenTab.tabNum).css("top", "0px");
                $("#ctab" + currentChosenTab.tabNum).css("height", "33px");
                $("#ctab" + currentChosenTab.tabNum).css("cursor", "default");
                $("#ctab" + currentChosenTab.tabNum).css("color", "#880308");
                $("#ctab" + currentChosenTab.tabNum).css("z-index", selectedTabDepth);
                $("#ctab" + currentChosenTab.tabNum).unbind("mouseover");
                $("#ctab" + currentChosenTab.tabNum).unbind("mouseout");

                if (currentChosenTab.tabNum != 6) {
                    if (!cAppearedAlready[currentChosenTab.tabNum]) {
                        //alert("here here");
                        $("#tab" + currentChosenTab.tabNum + "-content").removeClass("fake-hide-carousel");
                        $("#tab" + currentChosenTab.tabNum + "-content").addClass("selected-carousel");
                        //$("#tab"+currentChosenTab.tabNum+"-content").css("position","relative");
                        cAppearedAlready[currentChosenTab.tabNum] = true;
                    }
                    $("#tab" + currentChosenTab.tabNum + "-content").css("display", "block");
                }
            }
        });
    }

    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
        document.getElementById('dock').style.display = 'none';
        document.getElementById('dock-booking-panel').style.display = 'none';
        document.getElementById('dock-subscription-panel').style.display = 'none';
        document.getElementById('dock-offset').style.display = 'none';
    }
});

//Google Tracking
var _gaq = _gaq || [];
_gaq.push(
  ['_setAccount', 'UA-2510601-1'],
  ['_setAllowHash', false],
  ['_setDomainName', 'rwsentosa.com'],
  ['_addIgnoredRef', 'rwsentosa.com'],
  ['_trackPageview']
);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();



//--------------------------------------------
// Class for creating javascript based banners
// author: Christine@Nokomai
//--------------------------------------------

(function($) {

    //global vars
    var $container = null;
    var $bannersWrapper = null;
    var initpos = 0;
    var imageArray = new Array();
    var bannerWidth = 0;
    var bannerHeight = 0;
    var depth = 0;
    var preLabel = "jsbanner";
    var loadCurrNum = 0;
    var myAutoInterval;
    var myInterval;
    var inAuto = false;
    var currBanner = 0;
    var individualTime = 200;
    var lastSwfContainer = { container: null, left: 0 };

    //methods
    var methods = {

        init: function(imageList, width, height, zindex) {
            $container = $(this);
            imageArray = imageList;
            bannerWidth = width;
            bannerHeight = height;
            depth = zindex;

            //---------------
            //set-up banners
            //---------------

            //ensure the banner container is of correct width & height and that its overflow is set to hidden
            $container.html("");
            $container.css({
                'width': bannerWidth,
                'height': bannerHeight,
                'overflow': 'hidden',
                'position': 'relative'
            });

            //create a new div to hold all the banners and treat them as one entity
            $bannersWrapper = methods.createDiv($container, "banners-wrapper");
            $bannersWrapper.css({
                'position': 'absolute',
                'left': 0
            });

            //set-up individual banner holder
            for (var i = 0; i < imageArray.length + 1; i++) {
                var $banner = methods.createDiv($bannersWrapper, preLabel + i);

                $banner.css({
                    'width': bannerWidth,
                    'height': bannerHeight,
                    'overflow': 'hidden',
                    'position': 'absolute',
                    'left': initpos + (i * bannerWidth),
                    'z-index': depth
                });

            }

            //create preloader
            var preloader =
			"<div id='banner-preloader' style='position:absolute;z-index:55;'>" +
			"<table cellpadding='0' cellspacing='0'><tr><td align='center' width='" + bannerWidth + "' height='" + bannerHeight + "'>" +
			"<img src='/Portals/0/RWS/images/banner/banner_preloader.gif' alt='' />" +
			"</td></tr></table>" +
			"</div>";
            $container.prepend(preloader);

            //load images one by one
            methods.loadBanner();
        },

        createDiv: function($container, elementID) {
            var $divElement = $('<div id="' + elementID + '"/>');
            $container.append($divElement);
            return $('#' + elementID);
        },

        createImg: function($bannerholder, imagePath) {
            $('<img />', {
                'alt': '',
                'src': imagePath
            }).appendTo($bannerholder);
        },

        createSwf: function(bannerholder, swfPath, frame, urllink, newwindow) {
            lastSwfContainer = { container: $('#' + bannerholder), left: $('#' + bannerholder).css('left') };
            if (parseInt($('#' + bannerholder).css("left")) != 0) {
                $('#' + bannerholder).css("left", 0);
                $('#' + bannerholder).css({
                    'left': bannerWidth / 2,
                    'top': bannerHeight / 2,
                    'width': 1,
                    'height': 1
                });
            }
            var $flashContainer = methods.createDiv($('#' + bannerholder), bannerholder + "swf");
            var flashvars = {};
            flashvars.swfPath = swfPath;
            flashvars.startFrame = frame;
            flashvars.containerclass = $container.selector;
            flashvars.urllink = urllink;
            flashvars.newwindow = newwindow;
            var params = {};
            params.wmode = "transparent";
            params.allowScriptAccess = "always";
            var attributes = {};
            swfobject.embedSWF("/Portals/0/RWS/swf/jsBannerLoader.swf", bannerholder + "swf", bannerWidth, bannerHeight, "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
        },

        loadBanner: function() {
            var num = loadCurrNum;
            if (num == imageArray.length) num = 0;
            var $bannerholder = $('#' + preLabel + loadCurrNum);
            var bannerholder = preLabel + loadCurrNum;
            var imageDetails = imageArray[num];
            var type = imageDetails.type;

            switch (type) {
                case "image":
                    var imagePath = imageDetails.content;
                    methods.createImg($bannerholder, imagePath);
                    $container.waitForImages(methods.nextAction);
                    break;

                case "swf":
                    var swfPath = imageDetails.content;
                    var frameNum = 0;
                    if (typeof imageDetails.frame != "undefined") frameNum = imageDetails.frame;
                    var urllink = "";
                    if (typeof imageDetails.urllink != "undefined") urllink = imageDetails.urllink;
                    var newwindow = "";
                    if (typeof imageDetails.newwindow != "undefined") newwindow = imageDetails.newwindow;

                    imageDetails.firstPlay = true;
                    imageArray[num] = imageDetails;

                    methods.createSwf(bannerholder, swfPath, frameNum, urllink, newwindow);
                    break;
            }

        },

        swfLoaded: function(container) {
            var $thisContainer = lastSwfContainer.container;
            var actualLeft = lastSwfContainer.left;
            $thisContainer.css({
                left: actualLeft,
                top: 0,
                width: bannerWidth,
                height: bannerHeight
            });

            methods.nextAction();
        },

        nextAction: function() {
            if (loadCurrNum == 0) $('#banner-preloader').remove();
            if (loadCurrNum < imageArray.length) {
                var imageDetails = imageArray[loadCurrNum];
                if (imageDetails.type == "image" && imageDetails.urllink != "") {
                    var $bannherholder = $('#' + preLabel + loadCurrNum);
                    $bannherholder.css('cursor', 'pointer');
                    if (imageDetails.newwindow == "true") $bannherholder.bind('click', function() { window.open(imageDetails.urllink, '_blank'); });
                    else $bannherholder.bind('click', function() { window.location = imageDetails.urllink; });
                }
                methods.loadBanner(loadCurrNum++);
            }
            else {

                if (imageArray[0].type == "swf") {
                    imageArray[0].firstPlay = false;
                }

                if (imageArray.length > 1) {
                    //create square dots
                    for (var i = 0; i < imageArray.length; i++) {
                        $squareDiv = methods.createDiv($container, "squaredot" + i);
                        if (i == 0) $squareDiv.addClass('squareDotSelected');
                        else $squareDiv.addClass('squareDotDefault');
                        var dotWidth = $squareDiv.outerWidth() + 13;
                        var totalWidth = dotWidth * imageArray.length - 13;
                        var startX = (bannerWidth - totalWidth) / 2;

                        $squareDiv.css({
                            'position': 'absolute',
                            'top': bannerHeight - 67,
                            'left': startX + (i * dotWidth),
                            'z-index': depth + 1,
                            'cursor': 'pointer'
                        });

                        $squareDiv.bind('click', function() {
                            var dotName = $(this).attr('id');
                            var selectedDot = dotName.substring(9, dotName.length);
                            $container.find("#squaredot" + currBanner).removeClass('squareDotSelected').addClass('squareDotDefault');
                            $(this).removeClass('squareDotDefault').addClass('squareDotSelected');
                            methods.goSlide(selectedDot);
                        });
                    }

                    methods.startTimers();
                }
            }
        },

        startTimers: function() {
            myInterval = setInterval(methods.autoSlide, 5000);

            $container.mousemove(function() {
                inAuto = false;
                clearInterval(myAutoInterval);
                clearInterval(myInterval);
                myInterval = setInterval(methods.autoSlide, 5000);

            });
        },

        autoSlide: function() {
            inAuto = true;
            clearInterval(myInterval);
            var timeInterval = imageArray[currBanner].time * 1000;
            myAutoInterval = setInterval(methods.scrollNext, timeInterval);
        },

        scrollNext: function() {
            if (inAuto) {
                clearInterval(myAutoInterval);
                var nextX = parseInt($bannersWrapper.css('left')) - bannerWidth;
                $bannersWrapper.stop().animate({
                    'left': nextX
                }, 500, function() {
                    $container.find("#squaredot" + currBanner).removeClass('squareDotSelected').addClass('squareDotDefault');

                    if (currBanner == imageArray.length - 1) {
                        currBanner = 0;
                        $bannersWrapper.css('left', 0);
                    }
                    else currBanner++;

                    var myBanner = imageArray[currBanner];
                    if (myBanner.type == "swf" && ((typeof myBanner.replayFlash != "undefined" && myBanner.replayFlash == "true") || myBanner.firstPlay)) {
                        var mySwf = document.getElementById(preLabel + currBanner + "swf");
                        mySwf.playMovie(myBanner.frame);
                        if (myBanner.firstPlay) imageArray[currBanner].firstPlay = false;
                    }

                    $container.find("#squaredot" + currBanner).removeClass('squareDotDefault').addClass('squareDotSelected');

                    var timeInterval = imageArray[currBanner].time * 1000;
                    myAutoInterval = setInterval(methods.scrollNext, timeInterval);
                });
            }
        },

        goSlide: function(num) {
            var nextX = -1 * num * bannerWidth;
            var totalTime = (num - currBanner) * individualTime;
            if (num < currBanner) totalTime = -1 * totalTime;
            currBanner = num;
            $bannersWrapper.stop().animate({
                left: nextX
            }, totalTime, function() {
                var myBanner = imageArray[currBanner];
                if (myBanner.type == "swf" && ((typeof myBanner.replayFlash != "undefined" && myBanner.replayFlash == "true") || myBanner.firstPlay)) {
                    var mySwf = document.getElementById(preLabel + currBanner + "swf");
                    mySwf.playMovie(myBanner.frame);
                    if (myBanner.firstPlay) imageArray[currBanner].firstPlay = false;
                }
            });
        }
    };

    //constructor
    $.fn.jsBanner = function(method) {

        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.tooltip');
        }
    };

})(jQuery);



/*
* waitForImages 1.2.2
* -----------------
* Provides a callback when all images have loaded in your given selector.
* http://www.alexanderdickson.com/
*
*
* Copyright (c) 2011 Alex Dickson
* Licensed under the MIT licenses.
* See website for more info.
*
*/

(function($) {
    $.fn.waitForImages = function(finishedCallback, eachCallback, waitForAll) {

        // Handle options object.
        if (typeof finishedCallback === 'object') {
            eachCallback = finishedCallback.each;
            waitForAll = finishedCallback.waitForAll;
            finishedCallback = finishedCallback.finished;
        }

        // Handle missing callbacks.
        finishedCallback = finishedCallback || function() { };
        eachCallback = eachCallback || function() { };

        // Convert waitForAll to Boolean
        waitForAll = !!waitForAll;

        // Ensure callbacks are functions.
        if (!$.isFunction(finishedCallback) || !$.isFunction(eachCallback)) {
            throw new TypeError('An invalid callback was supplied.');
        };

        return this.each(function() {
            // Build a list of all imgs, dependent on what images will be considered.
            var obj = $(this),
                allImgs = [];

            if (waitForAll) {
                // CSS properties which may contain an image.
                var hasImgProperties = $.fn.waitForImages.hasImgProperties || [
                    'backgroundImage',
                    'listStyleImage',
                    'borderImage',
                    'borderCornerImage'
                    ];

                var matchUrl = /url\(['"]?(.*?)\1\)/g;

                // Get all elements, as any one of them could have a background image.
                obj.find('*').filter(function() {
                    var element = $(this);

                    // If an `img` element, add it. But keep iterating in case it has a background image too.
                    if (element.is('img')) {
                        allImgs.push({
                            src: element.attr('src'),
                            element: element[0]
                        });
                    }

                    $.each(hasImgProperties, function(i, property) {
                        var propertyValue = element.css(property);
                        // If it doesn't contain this property, skip.
                        if (!propertyValue) {
                            return true;
                        }

                        // Get all url() of this element.
                        var match;
                        while (match = matchUrl.exec(propertyValue)) {
                            allImgs.push({
                                src: match[1],
                                element: element[0]
                            });
                        };
                    });
                });
            } else {
                // For images only, the task is simpler.
                obj.find('img').each(function() {
                    allImgs.push({
                        src: this.src,
                        element: this
                    });
                });
            };

            var allImgsLength = allImgs.length,
                allImgsLoaded = 0;

            // If no images found, don't bother.
            if (allImgsLength == 0) {
                finishedCallback.call(obj[0]);
            };

            $.each(allImgs, function(i, img) {

                var image = new Image;

                image.onload = function() {
                    allImgsLoaded++;
                    eachCallback.call(img.element, allImgsLoaded, allImgsLength);
                    if (allImgsLoaded == allImgsLength) {
                        finishedCallback.call(obj[0]);
                        return false;
                    };
                };

                image.src = img.src;
            });
        });
    };
})(jQuery);

function handleOnClick(url) {
    if (/msie/i.test(navigator.userAgent)) {
        windowFeatures = "scrollbars = 1, top=0,left=0,resizable=yes,menubar=yes, toolbar=yes, status=yes, 	location=yes, width=" + (screen.width) + ",height=" + (screen.height);
        newwindowPackages = window.open(url, "_tab", windowFeatures);
        newwindowPackages.focus();
    }

    else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
        newwindowPackages = window.open(url, "_tab");
        newwindowPackages.focus();
    }

    else if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
        windowFeatures = "scrollbars = 1,top=0,left=0,resizable=yes,menubar=yes, toolbar=yes, status=yes, 	location=yes, width=" + (screen.width) + ",height=" + (screen.height);
        newwindowPackages = window.open(url, "_tab", windowFeatures);
        newwindowPackages.focus();
    }
    else {
        newwindowPackages = window.open(url, "_tab");
        newwindowPackages.focus();
    }
}

$.fn.toEm = function(settings) {
    settings = jQuery.extend({
        scope: 'body'
    }, settings);
    var that = parseFloat(this[0], 10);
    var scopeTest = $('<div style="display: none; font-size: 1em; margin: 0; padding:0; height: auto; line-height: 1; border:0;">&nbsp;</div>').appendTo(settings.scope);
    var scopeVal = scopeTest.height();
    scopeTest.remove();
    return ((that / scopeVal.toPrecision(10))).toFixed(5) + 'em';
};

function passSubscribeValue(moreOption) {
    var requiredFieldPass = false;
    if ($('#txtSubscribeName').val() == '') {
        alert('Please insert all required field.');
        $('#txtSubscribeName').focus();
    }
    else if ($('#txtSubscribeContryCode').val() == '') {
        alert('Please insert all required field.');
        $('#txtSubscribeContryCode').focus();
    }
    else if ($('#txtSubscribePhone').val() == '') {
        alert('Please insert all required field.');
        $('#txtSubscribePhone').focus();
    }
    else if (!(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/).test($('#txtSubscribeEmail').val())) {
        alert('Please provide a valid email address');
        $('#txtSubscribeEmail').focus();
    }
    else requiredFieldPass = true;

    if (requiredFieldPass) {
        var TBAnchor = document.getElementById('TBAnchor');
        TBAnchor.title = "Newsletter Subscription"
        if (moreOption) {
            var link = "http://edm.sg/rwsentosa/edm/form_template11/subscribe.php?name=" + $('#txtSubscribeName').val() +
                "&email=" + $('#txtSubscribeEmail').val() +
                "&code=" + $('#txtSubscribeContryCode').val() +
                "&contact=" + $('#txtSubscribePhone').val() +
                "&KeepThis=true&TB_iframe=true&height=600&width=605";

            TBAnchor.href = link;

            $('#TBAnchor').click(); closeSubscriptionPanel();
        }
        else {
            var link = "/Portals/0/subscription_processing.html?FormValue_CustomField2=" + $('#txtSubscribeName').val() +
                "&FormValue_CustomField33=" + $('#txtSubscribeContryCode').val() +
                "&FormValue_CustomField32=" + $('#txtSubscribePhone').val() +
                "&FormValue_Email=" + $('#txtSubscribeEmail').val() +
                "&KeepThis=true&TB_iframe=true&height=540&width=605";

            TBAnchor.href = link;

            $('#TBAnchor').click(); closeSubscriptionPanel();
        }

    }

}

function isNumberKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}

// BEGIN HTMLMenuNavigation
HTMLMenuNavigation = {

    initialize: function(expectedWidth) {
        $(window).load(function() {
            HTMLMenuNavigation._expand(expectedWidth);
        });
    },

    _expand: function(expectedWidth) {
        var menuCount = $('#jsddm li a').length;

        var currentWidth = 0;

        $('#jsddm > li').each(function() {
            currentWidth = currentWidth + $(this).width();
        });

        var requiredWidth = expectedWidth - currentWidth;

        var spacing = Math.floor(requiredWidth / (menuCount * 2));

        $('#jsddm > li > a').css('padding', '14px ' + spacing + 'px ' + '7px ' + spacing + 'px');

        currentWidth = 0;

        $('#jsddm > li').each(function() {
            currentWidth = currentWidth + $(this).width();
        });

        requiredWidth = expectedWidth - currentWidth;

        $('#htmlMenuHotDeals').width($('#htmlMenuHotDeals').width() + requiredWidth);
    }
}

HTMLMenuNavigation.initialize(970);
// END HTMLMenuNavigation
