/***********************************************************************************************
 *********************************************************************************************** 
 EXTERNAL JAVASCRIPTS
 **********************************************************************************************
***********************************************************************************************/

/**
 * ON LOAD HANDLER (Futurniture 2006)
 */
var OnLoadHandler = {isExecutingPageFunctions:false,functions:[],appendFunction:function(funcAsString, executeOnDOMLoad) {
    this.functions.push(new OLH_Function(funcAsString, executeOnDOMLoad));
},executeDOMFunctions:function() {
    if (!this.isExecutingPageFunctions) {
        OnLoadHandler.executeFunctions();
    }
},executePageFunctions:function() {
    OnLoadHandler.isExecutingPageFunctions = true;
    OnLoadHandler.executeFunctions();
},executeFunctions:function() {
    for (var i = 0; i < this.functions.length; i++) {
        if (!this.functions[i].isExecuted && (this.functions[i].executeOnDOMLoad || this.isExecutingPageFunctions)) {
            this.functions[i].execute();
        }
    }
}};
function OLH_Function(funcAsString,executeOnDOMLoad){this.funcAsString=funcAsString;this.executeOnDOMLoad=executeOnDOMLoad;}
OLH_Function.prototype.execute = function() {
    this.isExecuted = true;
    eval(this.funcAsString);
};
if(document.addEventListener){document.addEventListener("DOMContentLoaded",OnLoadHandler.executeDOMFunctions,false);}
/*@cc_on @*//*@if (@_win32)document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");var script=document.getElementById("__ie_onload");script.onreadystatechange=function(){if (this.readyState=="complete"){OnLoadHandler.executeDOMFunctions();}};/*@end @*/
if (/WebKit/i.test(navigator.userAgent)){var _timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(_timer);OnLoadHandler.executeDOMFunctions();}},10);}
window.onload=OnLoadHandler.executePageFunctions;

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

/**
 * jQuery Color Animations
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 */
(function(D){D.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(F,E){D.fx.step[E]=function(G){if(G.state==0){G.start=C(G.elem,E);G.end=B(G.end);}G.elem.style[E]="rgb("+[Math.max(Math.min(parseInt((G.pos*(G.end[0]-G.start[0]))+G.start[0]),255),0),Math.max(Math.min(parseInt((G.pos*(G.end[1]-G.start[1]))+G.start[1]),255),0),Math.max(Math.min(parseInt((G.pos*(G.end[2]-G.start[2]))+G.start[2]),255),0)].join(",")+")";
};});function B(F){var E;if(F&&F.constructor==Array&&F.length==3){return F;}if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return[parseInt(E[1]),parseInt(E[2]),parseInt(E[3])];}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return[parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55];
}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return[parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16)];}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return[parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16)];
}return A[D.trim(F).toLowerCase()];}function C(G,E){var F;do{F=D.curCSS(G,E);if(F!=""&&F!="transparent"||D.nodeName(G,"body")){break;}E="backgroundColor";}while(G=G.parentNode);return B(F);}var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};
})(jQuery);


/** 
 * SWFObject v2.1 <http://code.google.com/p/swfobject/>
 * Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
 * This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;
if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);
AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0;}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7");}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always";}catch(t){if(AC[0]==6){AB=true;
}}if(!AB){try{y=new ActiveXObject(p);}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)];}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);
/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w};}();var L=function(){if(!h.w3cdom){return ;}f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");
if(J){I(J,"onreadystatechange",S);}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E();}},10);}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null);}R(E);}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);
E();}}function E(){if(e){return ;}if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u);}catch(w){return ;}}e=true;if(Z){clearInterval(Z);Z=null;}var q=o.length;for(var r=0;r<q;r++){o[r]();}}function f(q){if(e){q();
}else{o[o.length]=q;}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false);}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false);}else{if(typeof j.attachEvent!=b){I(j,"onload",r);}else{if(typeof j.onload=="function"){var q=j.onload;
j.onload=function(){q();r();};}else{j.onload=r;}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";
if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r);}W(u,true);}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q]);}else{O(r);}}}}else{W(u,true);}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;
if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue);}else{w.setAttribute(y[u].nodeName,y[u].nodeValue);}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"));
}}}t.parentNode.replaceChild(w,t);}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId;}}else{M=G(u);}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310";}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137";
}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);
u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u);};I(j,"onload",v);}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x);}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");
t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t);};I(j,"onload",q);}else{t.parentNode.replaceChild(G(t),t);}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML;
}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true));}}}}}return u;}function U(AG,AE,t){var q,v=C(t);
if(v){if(typeof AG.id==b){AG.id=t;}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB];}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"';}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"';
}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />';}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id);}else{if(h.webkit&&h.webkit<312){var AC=a("embed");
AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z]);}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z]);}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z]);
}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y]);}}}v.parentNode.replaceChild(AC,v);q=AC;}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x]);
}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x]);}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w]);}}v.parentNode.replaceChild(u,v);q=u;}}}return q;}function F(t,q,r){var u=a("param");u.setAttribute("name",q);
u.setAttribute("value",r);t.appendChild(u);}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r);}else{j.attachEvent("onload",function(){B(r);});}}else{q.parentNode.removeChild(q);}}}function B(t){var r=C(t);
if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null;}}r.parentNode.removeChild(r);}}function C(t){var q=null;try{q=K.getElementById(t);}catch(r){}return q;}function a(q){return K.createElement(q);}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r];
}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false;}function V(v,r){if(h.ie&&h.mac){return ;}var u=K.getElementsByTagName("head")[0],t=a("style");
t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"));}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];
if(typeof q.addRule==Q){q.addRule(v,r);}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r;}else{V("#"+t,"visibility:"+r);}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s;}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;
for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2]);}var t=i.length;for(var u=0;u<t;u++){X(i[u]);}for(var r in h){h[r]=null;}h=null;for(var q in swfobject){swfobject[q]=null;}swfobject=null;});}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return ;
}var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false);},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t;}else{if(typeof u.SetVariable!=b){q=u;
}}}}return q;},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return ;}AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v];}}}AA.data=x;AA.width=AB;AA.height=AD;
var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u];}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t];}else{y.flashvars=t+"="+r[t];}}}}f(function(){U(AA,y,AE);
if(AA.id==AE){W(AE,true);}});}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF);});}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]};
},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q);}else{return undefined;}},removeSWF:function(q){if(h.w3cdom){X(q);}},createCSS:function(r,q){if(h.w3cdom){V(r,q);}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;
if(v==null){return g(u);}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)));}}}return"";},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);
if(l){W(l,true);if(h.ie&&h.win){M.style.display="block";}}M=null;l=null;A=false;}}}};}();


/** 
 * DHTML HISTORY
 */
window.dhtmlHistory = {
    /** Adds a history change listener. Note that
        only one listener is supported at this
        time. */
    /** public */ addListener: function(callback) {
       this.listener = callback;
    },
    
    /** Gets the current hash value that is in the browser's
        location bar, removing leading # symbols if they are present. */
    /** public */ getCurrentLocation: function() {
       return this.removeHash(window.location.hash);
    },
    
    /** Our current hash location, without the "#" symbol. */
    /** private */ currentLocation: null,
    
    /** Our history change listener. */
    /** private */ listener: null,
    
    /** Creates the DHTML history infrastructure. */
    /** private */ create: function(showDebug) {
       // get our initial location
       // var initialHash = this.getCurrentLocation();
       var initialHash = this.removeHash(window.location.hash);
       
       // save this as our current location
       this.currentLocation = initialHash;
       
       var newHash = escape(initialHash);
	   
	   newHash = newHash.replace(/%3D/g, "=");
	   newHash = newHash.replace(/%2C/g, ",");
       
       // write out a hidden iframe for IE and
       // set the amount of time to wait between add() requests
       // write out a hidden iframe for IE and
       // set the amount of time to wait between add() requests
       if (this.isInternetExplorer()) {
           if (showDebug) {
             document.write("<iframe style='border: 0px; width: 500px; "
                                + "height: 100px; position: absolute; bottom: 0px; "
                                + "right: 0px; visibility: visible;' "
                                + "name='DhtmlHistoryFrame' id='DhtmlHistoryFrame' "
                                + "src='/cws/js/blank.html?" + newHash + "'>"
                                + "</iframe>");
           } else {
             document.write("<iframe style='border: 0px; width: 1px; "
                                + "height: 1px; position: absolute; bottom: 0px; "
                                + "right: 0px; visibility: hidden;' "
                                + "name='DhtmlHistoryFrame' id='DhtmlHistoryFrame' "
                                + "src='/cws/js/blank.html?" + newHash + "'>"
                                + "</iframe>");
           }
       }
       
       // other browsers can use a location handler that checks
       // at regular intervals as their primary mechanism;
       // we use it for Internet Explorer as well to handle
       // an important edge case; see checkLocation() for
       // details
       var theInstance = this;
       var locationHandler = function() {
          theInstance.checkLocation();
       };
       
       setInterval(locationHandler, 100);
    },
    
    /** Notify the listener of new history changes. */
    /** private */ fireHistoryEvent: function(newHash) {
       // extract the value from our history storage for
       // this hash
       var historyData = null;

       // call our listener
       if (this.listener) {
           this.listener.call(null, newHash, historyData);
       }
    },
    
    /** Sees if the browsers has changed location.  This is the primary history mechanism
        for Firefox. For Internet Explorer, we use this to handle an important edge case:
        if a user manually types in a new hash value into their Internet Explorer location
        bar and press enter, we want to intercept this and notify any history listener. */
    /** private */ checkLocation: function() {
       // get hash location
       var hash = this.getCurrentLocation();
       
       // see if there has been a change
       if (hash == this.currentLocation) {
          return;
       }
       
       // save this new location
       this.currentLocation = hash;
       
       // notify listeners of the change
       this.fireHistoryEvent(hash);
    },  

    /** Removes any leading hash that might be on a location. */
    /** private */ removeHash: function(hashValue) {
       if (hashValue == null || hashValue == undefined)
          return null;
       else if (hashValue == "")
          return "";
       else if (hashValue.length == 1 && hashValue.charAt(0) == "#")
          return "";
       else if (hashValue.length >= 2 && hashValue.charAt(0) == "#")
          return hashValue.substring(1);
       else
          return hashValue;     
    },          
    
    /** Removes any leading hash that might be on a location. */
    /** private */ iframeLoaded: function(url) {
        // alert("iframe url = " + url);
        var pos = url.indexOf("?");

        var newHash = "";
        if ((pos != -1) && (url.length > pos + 1)) {
            newHash = url.substring(pos + 1);
        }

       // see if there has been a change
       if (newHash == this.currentLocation) {
          return;
       }
       
       this.currentLocation = newHash;
       
        //window.location.href = "#" + newHash;
       	 var loc=window.location.href;
	     var newLoc=loc.split('#')[0];
	     window.location.href = newLoc+"#"+newHash;
	     
         this.fireHistoryEvent(newHash);
    },
    
    
    /** Determines if this is Internet Explorer. */
    /** private */ isInternetExplorer: function() {
       var userAgent = navigator.userAgent.toLowerCase();
       if (document.all && userAgent.indexOf('msie')!=-1) {
          return true;
       }
       else {
          return false;
       }
    }
};

window.dhtmlHistory.create(false);


/*
 * jQuery ifixpng plugin
 * (previously known as pngfix)
 * Version 2.1  (23/04/2008)
 * @requires jQuery v1.1.3 or above
 *
 * Examples at: http://jquery.khurshid.com
 * Copyright (c) 2007 Kush M.
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function(B){B.ifixpng=function(C){B.ifixpng.pixel=C;};B.ifixpng.getPixel=function(){return B.ifixpng.pixel||"/cws/images/spacer.gif";};var A={ltie7:B.browser.msie&&B.browser.version<7,filter:function(C){return"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+C+"')";
}};B.fn.ifixpng=A.ltie7?function(){return this.each(function(){var C=B(this);var E=B("base").attr("href");if(E){E=E.replace(/\/[^\/]+$/,"/");}if(C.is("img")||C.is("input")){if(C.attr("src")){if(C.attr("src").match(/.*\.png([?].*)?$/i)){var D=(E&&C.attr("src").search(/^(\/|http:)/i))?E+C.attr("src"):C.attr("src");
C.css({filter:A.filter(D),width:C.width(),height:C.height()}).attr({src:B.ifixpng.getPixel()}).positionFix();}}}else{var F=C.css("backgroundImage");if(F.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)){F=RegExp.$1;F=(E&&F.substring(0,1)!="/")?E+F:F;C.css({backgroundImage:"none",filter:A.filter(F)}).children().children().positionFix();
}}});}:function(){return this;};B.fn.iunfixpng=A.ltie7?function(){return this.each(function(){var C=B(this);var D=C.css("filter");if(D.match(/src=["']?(.*\.png([?].*)?)["']?/i)){D=RegExp.$1;if(C.is("img")||C.is("input")){C.attr({src:D}).css({filter:""});}else{C.css({filter:"",background:"url("+D+")"});
}}});}:function(){return this;};B.fn.positionFix=function(){return this.each(function(){var D=B(this);var C=D.css("position");if(C!="absolute"&&C!="relative"){D.css({position:"relative"});}});};})(jQuery);

/*
    http://www.JSON.org/json2.js
    2010-03-20
*/    
if(!this.JSON){this.JSON={};}(function(){function f(n){return n<10?"0"+n:n;}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null;
};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;
function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];
if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key);}if(typeof rep==="function"){value=rep.call(holder,key,value);}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";
case"boolean":case"null":return String(value);case"object":if(!value){return"null";}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null";}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";
gap=mind;return v;}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);
if(v){partial.push(quote(k)+(gap?": ":":")+v);}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v;}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;
gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" ";}}else{if(typeof space==="string"){indent=space;}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify");
}return str("",{"":value});};}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);
if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");
return typeof reviver==="function"?walk({"":j},""):j;}throw new SyntaxError("JSON.parse");};}}());

/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 * 
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 *
 * Version: 1.3.1 (05/03/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
/*
(function(b){var m,u,x,g,D,i,z,A,B,p=0,e={},q=[],n=0,c={},j=[],E=null,s=new Image,G=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,S=/[^\.]\.(swf)\s*$/i,H,I=1,k,l,h=false,y=b.extend(b("<div/>")[0],{prop:0}),v=0,O=!b.support.opacity&&!window.XMLHttpRequest,J=function(){u.hide();s.onerror=s.onload=null;E&&E.abort();m.empty()},P=function(){b.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>',{scrolling:"no",padding:20,transitionIn:"none",transitionOut:"none"})},
K=function(){return[b(window).width(),b(window).height(),b(document).scrollLeft(),b(document).scrollTop()]},T=function(){var a=K(),d={},f=c.margin,o=c.autoScale,t=(20+f)*2,w=(20+f)*2,r=c.padding*2;if(c.width.toString().indexOf("%")>-1){d.width=a[0]*parseFloat(c.width)/100-40;o=false}else d.width=c.width+r;if(c.height.toString().indexOf("%")>-1){d.height=a[1]*parseFloat(c.height)/100-40;o=false}else d.height=c.height+r;if(o&&(d.width>a[0]-t||d.height>a[1]-w))if(e.type=="image"||e.type=="swf"){t+=r;
w+=r;o=Math.min(Math.min(a[0]-t,c.width)/c.width,Math.min(a[1]-w,c.height)/c.height);d.width=Math.round(o*(d.width-r))+r;d.height=Math.round(o*(d.height-r))+r}else{d.width=Math.min(d.width,a[0]-t);d.height=Math.min(d.height,a[1]-w)}d.top=a[3]+(a[1]-(d.height+40))*0.5;d.left=a[2]+(a[0]-(d.width+40))*0.5;if(c.autoScale===false){d.top=Math.max(a[3]+f,d.top);d.left=Math.max(a[2]+f,d.left)}return d},U=function(a){if(a&&a.length)switch(c.titlePosition){case "inside":return a;case "over":return'<span id="fancybox-title-over">'+
a+"</span>";default:return'<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">'+a+'</span><span id="fancybox-title-right"></span></span>'}return false},V=function(){var a=c.title,d=l.width-c.padding*2,f="fancybox-title-"+c.titlePosition;b("#fancybox-title").remove();v=0;if(c.titleShow!==false){a=b.isFunction(c.titleFormat)?c.titleFormat(a,j,n,c):U(a);if(!(!a||a==="")){b('<div id="fancybox-title" class="'+f+'" />').css({width:d,paddingLeft:c.padding,
paddingRight:c.padding}).html(a).appendTo("body");switch(c.titlePosition){case "inside":v=b("#fancybox-title").outerHeight(true)-c.padding;l.height+=v;break;case "over":b("#fancybox-title").css("bottom",c.padding);break;default:b("#fancybox-title").css("bottom",b("#fancybox-title").outerHeight(true)*-1);break}b("#fancybox-title").appendTo(D).hide()}}},W=function(){b(document).unbind("keydown.fb").bind("keydown.fb",function(a){if(a.keyCode==27&&c.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if(a.keyCode==
37){a.preventDefault();b.fancybox.prev()}else if(a.keyCode==39){a.preventDefault();b.fancybox.next()}});if(b.fn.mousewheel){g.unbind("mousewheel.fb");j.length>1&&g.bind("mousewheel.fb",function(a,d){a.preventDefault();h||d===0||(d>0?b.fancybox.prev():b.fancybox.next())})}if(c.showNavArrows){if(c.cyclic&&j.length>1||n!==0)A.show();if(c.cyclic&&j.length>1||n!=j.length-1)B.show()}},X=function(){var a,d;if(j.length-1>n){a=j[n+1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}if(n>0){a=
j[n-1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}},L=function(){i.css("overflow",c.scrolling=="auto"?c.type=="image"||c.type=="iframe"||c.type=="swf"?"hidden":"auto":c.scrolling=="yes"?"auto":"visible");if(!b.support.opacity){i.get(0).style.removeAttribute("filter");g.get(0).style.removeAttribute("filter")}b("#fancybox-title").show();c.hideOnContentClick&&i.one("click",b.fancybox.close);c.hideOnOverlayClick&&x.one("click",b.fancybox.close);c.showCloseButton&&z.show();W();b(window).bind("resize.fb",
b.fancybox.center);c.centerOnScroll?b(window).bind("scroll.fb",b.fancybox.center):b(window).unbind("scroll.fb");b.isFunction(c.onComplete)&&c.onComplete(j,n,c);h=false;X()},M=function(a){var d=Math.round(k.width+(l.width-k.width)*a),f=Math.round(k.height+(l.height-k.height)*a),o=Math.round(k.top+(l.top-k.top)*a),t=Math.round(k.left+(l.left-k.left)*a);g.css({width:d+"px",height:f+"px",top:o+"px",left:t+"px"});d=Math.max(d-c.padding*2,0);f=Math.max(f-(c.padding*2+v*a),0);i.css({width:d+"px",height:f+
"px"});if(typeof l.opacity!=="undefined")g.css("opacity",a<0.5?0.5:a)},Y=function(a){var d=a.offset();d.top+=parseFloat(a.css("paddingTop"))||0;d.left+=parseFloat(a.css("paddingLeft"))||0;d.top+=parseFloat(a.css("border-top-width"))||0;d.left+=parseFloat(a.css("border-left-width"))||0;d.width=a.width();d.height=a.height();return d},Q=function(){var a=e.orig?b(e.orig):false,d={};if(a&&a.length){a=Y(a);d={width:a.width+c.padding*2,height:a.height+c.padding*2,top:a.top-c.padding-20,left:a.left-c.padding-
20}}else{a=K();d={width:1,height:1,top:a[3]+a[1]*0.5,left:a[2]+a[0]*0.5}}return d},N=function(){u.hide();if(g.is(":visible")&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){b.event.trigger("fancybox-cancel");h=false;return}j=q;n=p;c=e;i.get(0).scrollTop=0;i.get(0).scrollLeft=0;if(c.overlayShow){O&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"});
x.css({"background-color":c.overlayColor,opacity:c.overlayOpacity}).unbind().show()}l=T();V();if(g.is(":visible")){b(z.add(A).add(B)).hide();var a=g.position(),d;k={top:a.top,left:a.left,width:g.width(),height:g.height()};d=k.width==l.width&&k.height==l.height;i.fadeOut(c.changeFade,function(){var f=function(){i.html(m.contents()).fadeIn(c.changeFade,L)};b.event.trigger("fancybox-change");i.empty().css("overflow","hidden");if(d){i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*
2,1),height:Math.max(l.height-c.padding*2-v,1)});f()}else{i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)});y.prop=0;b(y).animate({prop:1},{duration:c.changeSpeed,easing:c.easingChange,step:M,complete:f})}})}else{g.css("opacity",1);if(c.transitionIn=="elastic"){k=Q();i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)}).html(m.contents());g.css(k).show();if(c.opacity)l.opacity=
0;y.prop=0;b(y).animate({prop:1},{duration:c.speedIn,easing:c.easingIn,step:M,complete:L})}else{i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*2,1),height:Math.max(l.height-c.padding*2-v,1)}).html(m.contents());g.css(l).fadeIn(c.transitionIn=="none"?0:c.speedIn,L)}}},F=function(){m.width(e.width);m.height(e.height);if(e.width=="auto")e.width=m.width();if(e.height=="auto")e.height=m.height();N()},Z=function(){h=true;e.width=s.width;e.height=s.height;b("<img />").attr({id:"fancybox-img",
src:s.src,alt:e.title}).appendTo(m);N()},C=function(){J();var a=q[p],d,f,o,t,w;e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));o=a.title||b(a).title||e.title||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(o===""&&e.orig)o=e.orig.attr("alt");d=a.nodeName&&/^(?:javascript|#)/i.test(a.href)?e.href||null:e.href||a.href||null;if(e.type){f=e.type;if(!d)d=e.content}else if(e.content)f="html";else if(d)if(d.match(G))f=
"image";else if(d.match(S))f="swf";else if(b(a).hasClass("iframe"))f="iframe";else if(d.match(/#/)){a=d.substr(d.indexOf("#"));f=b(a).length>0?"inline":"ajax"}else f="ajax";else f="inline";e.type=f;e.href=d;e.title=o;if(e.autoDimensions&&e.type!=="iframe"&&e.type!=="swf"){e.width="auto";e.height="auto"}if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=false;e.enableEscapeButton=false;e.showCloseButton=false}if(b.isFunction(e.onStart))if(e.onStart(q,p,e)===false){h=false;
return}m.css("padding",20+e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(i.children())});switch(f){case "html":m.html(e.content);F();break;case "inline":b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(i.children())}).bind("fancybox-cancel",function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity();
s=new Image;s.onerror=function(){P()};s.onload=function(){s.onerror=null;s.onload=null;Z()};s.src=d;break;case "swf":t='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+e.width+'" height="'+e.height+'"><param name="movie" value="'+d+'"></param>';w="";b.each(e.swf,function(r,R){t+='<param name="'+r+'" value="'+R+'"></param>';w+=" "+r+'="'+R+'"'});t+='<embed src="'+d+'" type="application/x-shockwave-flash" width="'+e.width+'" height="'+e.height+'"'+w+"></embed></object>";m.html(t);
F();break;case "ajax":a=d.split("#",2);f=e.ajax.data||{};if(a.length>1){d=a[0];if(typeof f=="string")f+="&selector="+a[1];else f.selector=a[1]}h=false;b.fancybox.showActivity();E=b.ajax(b.extend(e.ajax,{url:d,data:f,error:P,success:function(r){if(E.status==200){m.html(r);F()}}}));break;case "iframe":b('<iframe id="fancybox-frame" name="fancybox-frame'+(new Date).getTime()+'" frameborder="0" hspace="0" scrolling="'+e.scrolling+'" src="'+e.href+'"></iframe>').appendTo(m);N();break}},$=function(){if(u.is(":visible")){b("div",
u).css("top",I*-40+"px");I=(I+1)%12}else clearInterval(H)},aa=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('<div id="fancybox-tmp"></div>'),u=b('<div id="fancybox-loading"><div></div></div>'),x=b('<div id="fancybox-overlay"></div>'),g=b('<div id="fancybox-wrap"></div>'));if(!b.support.opacity){g.addClass("fancybox-ie");u.addClass("fancybox-ie")}D=b('<div id="fancybox-outer"></div>').append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>').appendTo(g);
D.append(i=b('<div id="fancybox-inner"></div>'),z=b('<a id="fancybox-close"></a>'),A=b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),B=b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));z.click(b.fancybox.close);u.click(b.fancybox.cancel);A.click(function(a){a.preventDefault();b.fancybox.prev()});B.click(function(a){a.preventDefault();b.fancybox.next()});if(O){x.get(0).style.setExpression("height",
"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");u.get(0).style.setExpression("top","(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");D.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>')}}};
b.fn.fancybox=function(a){b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(d){d.preventDefault();if(!h){h=true;b(this).blur();q=[];p=0;d=b(this).attr("rel")||"";if(!d||d==""||d==="nofollow")q.push(this);else{q=b("a[rel="+d+"], area[rel="+d+"]");p=q.index(this)}C();return false}});return this};b.fancybox=function(a,d){if(!h){h=true;d=typeof d!=="undefined"?d:{};q=[];p=d.index||0;if(b.isArray(a)){for(var f=0,o=a.length;f<o;f++)if(typeof a[f]==
"object")b(a[f]).data("fancybox",b.extend({},d,a[f]));else a[f]=b({}).data("fancybox",b.extend({content:a[f]},d));q=jQuery.merge(q,a)}else{if(typeof a=="object")b(a).data("fancybox",b.extend({},d,a));else a=b({}).data("fancybox",b.extend({content:a},d));q.push(a)}if(p>q.length||p<0)p=0;C()}};b.fancybox.showActivity=function(){clearInterval(H);u.show();H=setInterval($,66)};b.fancybox.hideActivity=function(){u.hide()};b.fancybox.next=function(){return b.fancybox.pos(n+1)};b.fancybox.prev=function(){return b.fancybox.pos(n-
1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a,10);if(a>-1&&j.length>a){p=a;C()}if(c.cyclic&&j.length>1&&a<0){p=j.length-1;C()}if(c.cyclic&&j.length>1&&a>=j.length){p=0;C()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");J();e&&b.isFunction(e.onCancel)&&e.onCancel(q,p,e);h=false}};b.fancybox.close=function(){function a(){x.fadeOut("fast");g.hide();b.event.trigger("fancybox-cleanup");i.empty();b.isFunction(c.onClosed)&&c.onClosed(j,n,c);j=e=[];n=p=0;c=e={};h=false}
if(!(h||g.is(":hidden"))){h=true;if(c&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){h=false;return}J();b(z.add(A).add(B)).hide();b("#fancybox-title").remove();g.add(i).add(x).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");i.css("overflow","hidden");if(c.transitionOut=="elastic"){k=Q();var d=g.position();l={top:d.top,left:d.left,width:g.width(),height:g.height()};if(c.opacity)l.opacity=1;y.prop=1;b(y).animate({prop:0},{duration:c.speedOut,easing:c.easingOut,
step:M,complete:a})}else g.fadeOut(c.transitionOut=="none"?0:c.speedOut,a)}};b.fancybox.resize=function(){var a,d;if(!(h||g.is(":hidden"))){h=true;a=i.wrapInner("<div style='overflow:auto'></div>").children();d=a.height();g.css({height:d+c.padding*2+v});i.css({height:d});a.replaceWith(a.children());b.fancybox.center()}};b.fancybox.center=function(){h=true;var a=K(),d=c.margin,f={};f.top=a[3]+(a[1]-(g.height()-v+40))*0.5;f.left=a[2]+(a[0]-(g.width()+40))*0.5;f.top=Math.max(a[3]+d,f.top);f.left=Math.max(a[2]+
d,f.left);g.css(f);h=false};b.fn.fancybox.defaults={padding:10,margin:20,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.3,overlayColor:"#666",titleShow:true,titlePosition:"outside",titleFormat:null,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast",
easingIn:"swing",easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,onStart:null,onCancel:null,onComplete:null,onCleanup:null,onClosed:null};b(document).ready(function(){aa()})})(jQuery);
*/

/***********************************************************************************************
 *********************************************************************************************** 
 CORE.JS
 **********************************************************************************************
***********************************************************************************************/

var neo = neo ? neo : new Object();
var SE = SE ? SE : new Object();

neo.cc = "gb";
neo.lc = "en";
neo.isRtl = false;
neo.emailp = /^([a-zA-Z0-9])+([\._-]?[a-zA-Z0-9])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+$/;

/**
 *
 * @param obj
 */
function selectNavigation(obj){
    if (obj.options[obj.selectedIndex].value != "#" && obj.options[obj.selectedIndex].value != "-1") {
        location = obj.options[obj.selectedIndex].value;
    }
}

/**
 * Function used for selection of county on corporate pages
 */
function showCountriesDropDown(){
    var selects = jQuery("select[name='country']");
    for (var i = 0; i < selects.length; i++) {
        document.getElementById(selects[i].getAttribute("cdd")).style.display = "none";
        selects[i].style.display = "none";
    }
    var regionSelect = document.getElementById('region');
    var countrySelectCDD = document.getElementById('country_cDD');
    
    var region = regionSelect.options[regionSelect.selectedIndex].value;
    
    if (region != '-1' && region != '0') {
        countrySelectCDD.style.display = "none";
        document.getElementById('country_' + region + '_cDD').style.display = "block";
    }
    else {
        countrySelectCDD.style.display = "block";
    }
}

/**
 *  Used by Integrated Campaign page on Community section
 */
function setUpIntegratedCampaign(url,width,height){
    var iFrameHtml = "<iframe width='"+width+"' scrolling='no' height='"+height+"' frameborder='0' style='border: 0px none ;' marginheight='0' marginwidth='0' id='container' src='" + url + "'></iframe>";
    jQuery("#pageContent .neoWrapper").css("display", "none");
    jQuery("#pageContent").append("<div id='mediaSpaceContener'>" + iFrameHtml + "</div>");
}

/**
 * Generates list of layers to be launched by the url
 * from campaign Carousel on community page and
 * rich media Carousel on PHP. Called on document ready.
 */
function generateRestorLayerByUrlList(){
    var as = jQuery(".carouselWrapper");
    as.each(function(){
        jQuery(this).find(".carouselItem").each(function(){
            var cName = jQuery(this).parent().parent().parent().attr("name");
            var params = eval("(" + jQuery(this).attr('params') + ")");
            if (cName == "campaignCarousel" && params.type == "layered") {
                popup.createLayerByUrlList(params.id.toLowerCase(), params.url, "enhancedpresentation", params.width, params.height);
            }
            if (cName == "richMediaCarousel") {
                popup.createLayerByUrlList(params.idCont, params.contentUrl, params.popupType, params.width, params.height, params.extraParams);
            }
        });
    });
    popup.restoreLayerByUrl();
}

/*------------------------------*/
/*      PROTOTYPES              */
/*------------------------------*/

/**
* Returns true if the searchValue is present in String object else
* returns false
*
* @param {String} search String to search
* @return {Boolean}
*/
String.prototype.contains = function(searchValue) {
    return this.indexOf(searchValue) != -1;
};

/**
* Shortens the text to at most length characters. Adds "..." at the end of
* the string in case it is cut. Attempts to cut at word boundaries. 
*
* @param {Number} length The length to which the string should be cut
* @param {String} replace Ellepsis to be appended. Default is ...
* @return {String}
*/
String.prototype.cut = function(length, replace) {
    var _replace = "...";
    if (this.length > length) {
        var maxLength = length - 3;
        var i = this.lastIndexOf(' ', maxLength);
        if (i == -1) {
            i = maxLength;
        }
        if (replace != undefined) {
            _replace = replace;
        }
        return this.substring(0, i) + _replace;
    }
    return this;
};

/**
 * Shortens the string to the word count provided
 * Add "..." after truncating the string.
 * 
 * @param {Number} count Number of words to display
 * @return {String}
 */
String.prototype.cutByWords = function(count) {
    var strArray = this.split(" ", count);
    if (strArray.length >= count) {
        var newStr = "";
        for (i = 0; i < strArray.length; i++) {
            newStr += strArray[i] + " ";
        }
        newStr = newStr + "...";
        return newStr;
    }
    return this.toString();
};

/**
* Returns the string value trimed 
*
* @return {String}
*/
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
};

/**
 * 
 * Remove special symbols
 * @return The escaped string
 * 
 */
String.prototype.removeSpecialSymbols = function(){
    var text = this;
    text = text.replaceAll("&trade;", "");
    text = text.replaceAll("&copy;", "");
    text = text.replaceAll("&reg;", "");
    text = text.replaceAll("&amp;", "");
    text = text.replaceAll("â„¢", "");
    text = text.replaceAll("trade;", "");
    text = text.replaceAll("\u2122", "");
    
    return text;
}

/**
 * 
 * @param {Object} strToFind String to be replaced
 * @param {Object} strToReplace  String to be replaced with
 * @return The escaped string
 */
String.prototype.replaceAll = function(strToFind, strToReplace){
    var text = this;
    var i = this.indexOf(strToFind);
    while (i > -1) {
        text = text.replace(strToFind, strToReplace);
        i = text.indexOf(strToFind);
    }
    
    return text;
}

/**
 * 
 */
String.prototype.isEmpty = function(){
    var text = this;
    if (text.trim().length == 0) {
        return true;
    }
    return false;
}

/**
 * 
 * @param {Object} obj
 */
if (!Array.indexOf) {
    Array.prototype.indexOf = function(obj){
        for (var i = 0; i < this.length; i++) {
            if (this[i] == obj) {
                return i;
            }
        }
        return -1;
    }
}

/**
 * @return returns week of the date
 */
Date.prototype.getWeek = function() { 
	var dayone = new Date(this.getFullYear(), 0, 1);
	return Math.ceil((((this - dayone) / 86400000) + dayone.getDay() + 1) / 7);
} 


/**
* Create a new instance of URL.
*
* @classDescription This class creates a new URL.
* @constructor
* @param {String} url URL string    
*/

neo.URL = function(url) {
    this.url = url;
};

/** 
* Appends parameters to the URL  
* @param {JSON} params JSON
*/
neo.URL.prototype.append = function(params) {
    var param, q = [];
    for (param in params) {
        q[q.length] = param + '=' + params[param];
    }
    if (this.url.indexOf("?") != -1) {
        var urlParts = this.url.split("?");
        var qsParts = urlParts[1].split("&");
        for (var i = 0; i < qsParts.length; i++) {
            q[q.length] = qsParts[i];
        }
        this.url = urlParts[0];
    }
    q.sort();
    this.url += "?" + q.join("&");
};

neo.URL.prototype.getURL = function() {
    return this.url;
};

neo.URL.prototype.toString = neo.URL.prototype.getURL;

/**
 * Creates dynamic script tag that loads JSON
 *
 */
neo.DynamicScript = function(url) {
    this.url = url.toString();
    this.obj;
};

neo.DynamicScript.prototype.add = function(elm) {
    this.obj = document.createElement("script");
    this.obj.setAttribute("type", "text/javascript");
    this.obj.setAttribute("charset", "utf-8");
    this.obj.setAttribute("src", this.url);
    if (elm == undefined) {
        var head = document.getElementsByTagName("head").item(0);
        head.appendChild(this.obj);
    } else {
        elm.innerHTML = "";
        elm.appendChild(this.obj);
    }
};

/*------------------------------*/
/*      GLOBAL FUNCTION         */
/*------------------------------*/

/**
 *  Function for launching overlay within page
 */
neo.openLayer = function (href, width, height, name, chromeless, type) {
    var _chromeless = (chromeless != undefined) ? chromeless : false;
    var _type = (type != undefined) ? type : "enhancedpresentation";
    neo.Core.openLayer(href, width, height, name, _chromeless, _type);
};


SE = {
    /**
     * Creates namespace or appends to an existing namespace
     * @param {String/Object} target dot separated stirng/object
     * @param {Object} source methods/properties to append
     */
    namespace: function(target, source, overwrite){
        return SE.Namespace.append(typeof target == 'string' ? SE.Namespace.register(target) : target, source, overwrite);
    },
    
    textResource: {},
    
    /**
     * Checks if a String is whitespace, empty ("") or null
     * @param {String} string the String to check, may be null
     * @return {boolean} true if the String is null, empty or whitespace
     */
    isBlank: function(string){
        return (string == null || jQuery.trim(string).length == 0);
    },
	
	isIE6: (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7),
	
	isIE7: (jQuery.browser.msie && parseInt(jQuery.browser.version) == 7),
	
	isIE8: (jQuery.browser.msie && parseInt(jQuery.browser.version) == 8)
};

SE.Namespace = {};
SE.Namespace = {
    append: function(target, source, overwrite){
        for (var key in source) {
            if (overwrite || typeof target[key] === 'undefined') {
                target[key] = source[key];
            }
        }
        return target;
    },
    register: function(ns){
        var root = window.SE;
        var nsParts = ns.split(".");
        for (var i = 0; i < nsParts.length; i++) {
            var nsPart = nsParts[i];
            if (typeof root[nsPart] === "undefined") 
                root[nsPart] = {};
            
            root = root[nsParts[i]];
        }
        
        return root;
    }
};

/* ----- */

neo.Core = neo.Core ? neo.Core : new Object();
neo.Core = {
    prepareHeaderFooter: function() {
        this.prepareSearch();
        neo.TopNavHover.prepare();
        try {
            jQuery("#neoHeader img").ifixpng();
        } catch (e) {
        }
    },
    preparePage: function() {
        this.prepareCufon();
        neo.SubNavHover.prepare();
        jQuery("body").bind("neoDropDownLoaded", function() {
            neo.Core.displayLocationByRegionSelector();
            neo.Core.prepareLocationByRegionSelector();
        });
        this.prepareSpec();
        this.setLocationCookie();
        neo.JSTabs.initialize();
        neo.JSTabs.prepareJSTabLinks();
        neo.LHP.prepareLhpCards();
        if (!jQuery(".carouselWrapper").hasClass("deferInitialize")) {
            if (!jQuery(".carouselContainer").hasClass("cyclic"))
                neo.Carousel.initialize();
            else
                neo.cyclicCarousel.initialize();
        }
        neo.ToolTip.init();
        this.prepareShareThisPage();
        this.prepareShareThisPageLinks();
        this.fixPng();
        SE.AuxiliaryNav.shopTool.create();
        SE.LazyLoad.init();
        SE.FaceBook.parseFB();
    },
    evalJS: function() {
        neo.Core.prepareCufon();
        SE.AuxiliaryNav.shopTool.bindEvents();
    },
    prepareShareThisPage: function() {
        jQuery(".shareThisPage-layer").appendTo("body");

        jQuery(".shareThisPage img").each(function() {
            jQuery(this).hover(function() {
                var offset = jQuery(this).offset();
                var offsetTop = (Math.round(offset.top)) + jQuery(this).height();
                var scrollTOffset = neo.Utils.getScrollY();

                if ((offsetTop - scrollTOffset) + jQuery(".shareThisPage-layer").height() > jQuery(window).height()) {
                    offsetTop = (offsetTop - jQuery(".shareThisPage-layer").height()) - jQuery(this).height();
                    if (jQuery(this).hasClass("share-footer")) {

                        offsetTop = offsetTop + 10;
                    }
                }

                jQuery(".shareThisPage-layer").css({
                    "display": "block",
                    "top": (offsetTop - 10) + "px",
                    "left": (Math.round(offset.left) - 175) + "px"
                });
            }, function() {
                jQuery(".shareThisPage-layer").css({
                    "display": "none"
                });
            });
        });

        jQuery(".shareThisPage-layer").each(function() {
            jQuery(this).hover(function() {
                jQuery(this).css({
                    "display": "block"
                });
            }, function() {
                jQuery(this).css({
                    "display": "none"
                });
            });
        });
    },
    prepareShareThisPageLinks: function() {
        jQuery(".shareThisPage-layer span a").each(function() {
            var str = this.href;
            if (str.match(/TITLE/g)) {
                str = (str.replace("TITLE", document.title));
            }
            if (str.match(/URL/g)) {
                str = (str.replace("URL", location.href));
            }
            if (str.match(/ABSTRACT/g)) {
                str = (str.replace("ABSTRACT", document.title));
            }
            this.href = str
        });
    },
    prepareSearch: function() {
        jQuery(".searchBox input").each(function() {
            jQuery(this).data("value", jQuery(this).attr("value"));
        });
        jQuery(".searchBox input").bind("click", function() {
            if (jQuery(this).attr("value") == jQuery(this).data("value")) {
                jQuery(this).attr("value", "");
            }
        });
        jQuery(".searchBox input").bind("blur", function() {
            if (jQuery(this).attr("value") == "") {
                jQuery(this).attr("value", jQuery(this).data("value"));
            }
        });
    },
    prepareLocationByRegionSelector: function() {
        jQuery(".js-locationByRegion-selector select#region").bind("change", neo.Core.displayLocationByRegionSelector);
        jQuery(".js-locationByRegion-selector select[name='country']").bind("change", function() {
            var val = this.options[this.selectedIndex].value;
            if (val == -1)
                return;
            val = val.split("-");
            // SET COOKIE
            setLastCountryCookie(val[1] + "," + val[0]);
            var url = jQuery(this).attr("target");
            var external = this.options[this.selectedIndex].id;
            if(external != null && external =="externallink"){
                window.location = val;            	
            }else if (url.indexOf("?") == -1) {
                window.location = url + '?cc=' + val[1].toLowerCase() + '&lc=' + val[0].toLowerCase();
            }
            else {
                window.location = url + '&cc=' + val[1].toLowerCase() + '&lc=' + val[0].toLowerCase();
            }
        });
    },
    displayLocationByRegionSelector: function() {
        jQuery(".js-locationByRegion-selector select[name='country']").each(function() {
            jQuery("#" + jQuery(this).attr("cdd")).hide();
            jQuery(this).hide();
        });
        var region = jQuery(".js-locationByRegion-selector select#region  option:selected").val();
        if (region != '-1' && region != '0') {
            jQuery("#" + jQuery("#country").attr("cdd")).hide();
            jQuery("#" + jQuery("#country_" + region).attr("cdd")).show();
        }
        else {
            jQuery("#" + jQuery("#country").attr("cdd")).show();
        }
    },
    prepareSpec: function() {
        jQuery('.js-spec h2 a').unbind('click').click(function() {
            jQuery(this).parent().parent().toggleClass('open-spec');
            jQuery(this).blur();

            //Currently used only on mobile phones PHP - Specifications
            if (jQuery(this).parent().parent().hasClass("spec-wrapper-accordian")) {
                jQuery(this).parent().parent().find(".spec-container").each(function() {
                       //IE 7 issues 
                        jQuery(this).animate({
                            opacity: 'toggle',
                            height: 'toggle'
                        }, jQuery(this).height() * 4, "easeInOutQuad");
                    
                });
            }

            return false;
        });

        jQuery(".spec-wrapper-accordian:eq(0) h2 a").trigger("click");
    },
    prepareCufon: function() {
        /* Remove after Cufon upgrade */
        if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) == 9) {
            Cufon.set('engine', 'canvas');
        }
        try {
            if (this.isCufonAble()) {
                jQuery(".cufon-h1, .cufon-h2, .cufon-h3, .cufon-p, h1, h2.pageHeader2, body.shopping .enticerContent h2, #global-container h2, #global-container h3, #global-container h4").not("#card4 h1, .left_column h1, .right_column h1, .enticerQuart h2, .card h1, #lhp-main-content h1", "#topNavigation li div a").each(function() {
                    Cufon.set('fontFamily', 'AmericanTypewriterSE').replace(jQuery(this), {
                        hover: true
                    });
                });
                jQuery("#topNavigation").children("li").each(function() {
                    if (!jQuery(this).hasClass("firstNode")) {
                        Cufon.set('fontFamily', 'AmericanTypewriterSE').replace(jQuery(this).children("a"), {
                            hover: true
                        });
                    }
                });
                jQuery(".cufon-journal").each(function() {
                    Cufon.set('fontFamily', 'journal').replace(jQuery(this), {
                        hover: true
                    });
                });
                Cufon.now();
            }
            else {
                if (neo.Tools.getParam("lc") == "zh") {
                    Cufon.set('fontFamily', 'AmericanTypewriterSE').replace("#php-container .cufon-h1", {
                        hover: true
                    });
                }
            }
        }
        catch (err) {
        }
    },
    isCufonAble: function() {
        var lc = neo.lc;
        var noCufonArr = ["he", "zh", "th", "el", "ar", "vi", "ko", "fa"];
        for (var x in noCufonArr) {
            if (lc.toLowerCase() == noCufonArr[x]) {
                return false;
            }
        }
        return true;
    },
    useJournalFont: function() {
        var lc = neo.lc;
        var noJournalArr = ["he", "zh", "th", "el", "ar", "vi", "ru","fa", "bg" , "hr" , "cs" ,"hu" ,"lt", "lv", "pl", "ro", "tr", "sk", "sr", "uk"];
        for (var x in noJournalArr) {
            if (lc.toLowerCase() == noJournalArr[x]) {
                return false;
            }
        }
        return true;
    },
    prepareTopNav: function() {
        var blColorOn = "#999";
        var brColorOn = "#aaa";
        var blColorOff = "#ccc";
        var brColorOff = "#fff";
        if (neo.isRtl) {
            blColorOn = "#aaa";
            brColorOn = "#999";
            blColorOff = "#fff";
            brColorOff = "#ccc";
        }

        jQuery('#topNavigation li a').hover(function() {
            jQuery(this).stop().animate({
                borderLeftColor: blColorOn,
                borderRightColor: brColorOn
            }, 200, 'linear');
        }, function() {
            jQuery(this).stop().animate({
                borderLeftColor: blColorOff,
                borderRightColor: brColorOff
            }, 300, 'swing');
        });
        jQuery('#topNavigation li a').bind("mousedown click", function() {
            this.blur();
        });
    },
    highlightTopNav: function(type, node) {
        var blColorOn = "#999";
        var brColorOn = "#aaa";
        var blColorOff = "#ccc";
        var brColorOff = "#fff";
        if (neo.isRtl) {
            blColorOn = "#aaa";
            brColorOn = "#999";
            blColorOff = "#fff";
            brColorOff = "#ccc";
        }
        switch (type) {
            case "mouseover":
                var c = "#" + neo.Theme.get(neo.Theme.currentTheme()).value;
                if (neo.Core.isCufonAble() && (typeof Cufon == "function")) {
                    Cufon.replace(jQuery(node), {
                        color: c,
                        fontFamily: "AmericanTypewriterSE"
                    });
                }
                jQuery(node).css({
                    "padding": "3px 19px 1px 21px"
                });
                try {
                    jQuery(node).stop().animate({
                        borderLeftColor: blColorOn,
                        borderRightColor: brColorOn
                    }, 200, 'linear');
                } catch (e) {

                }
                break;
            case "mouseout":
                if (neo.Core.isCufonAble() && (typeof Cufon == "function")) {
                    if (!jQuery(node).parent().hasClass("activeNode") && !jQuery(node).parent().hasClass("activeNode-subsite")) {
                        Cufon.replace(jQuery(node), {
                            color: "#666666",
                            fontFamily : "AmericanTypewriterSE"
                        });
                    }
                }
                jQuery(node).css({
                    "padding": "2px 20px"
                });
                try {
                    jQuery(node).stop().animate({
                        borderLeftColor: blColorOff,
                        borderRightColor: brColorOff
                    }, 300, 'swing');
                } catch (e) {

                }
                break;
            default:
                break;
        }
    },
    isRtlLanguage: function() {
        var lc = neo.lc;
        return (lc == "ar" || lc == "he");
    },
    setLocationCookie: function() {
        var now = new Date();
        now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 90);
        var _cc = "";
        var _lc = "";
        var _cwsLocation = _cc.toLowerCase() + "," + _lc.toLowerCase();
       /* if (neo.Cookie.get("cwslocation") != _cwsLocation) {
            neo.Cookie.set('cwslocation', _cwsLocation, now, "/", '', '');
        }*/
    },
    addToBookmark: function() {
        if (document.all) {
            window.external.AddFavorite(location.href, document.title);
        }
        else
        if (window.sidebar) {
            window.sidebar.addPanel(document.title, location.href, '');
        }
    },
    openLayer: function(href, width, height, name, chromeless, type) {
        if (typeof popup == "undefined") {
            neo.Tools.loadJSFile("/cws/js/popupLayerFunctions.js", "js", {
                callback: "neo.Core.openLayer('" + href + "'," + width + "," + height + ",'" + name + "'," + chromeless + ",'" + type + "')",
                methodToCheck: "popup.openLayer"
            });
        }
        else {
            if (chromeless) {
                popup.openLayerTransparent(name, href, type, width, height, "", "", "", false);
            }
            else {
                popup.openLayer(name, href, type, width, height, "", "", "", false);
            }
        }
    },
    openPopup: function(url, name, params) {
        var newWindow = window.open(url, name, params);
        newWindow.focus();
        newWindow;
    },
    /*
     * fix png issue in IE 6
     */
    fixPng: function() {
        try {
            jQuery.ifixpng("/cws/images/spacer.gif");
            jQuery("img").each(function() {
                jQuery(this).ifixpng();
            });
        } catch(e) {

        }
    }
};

neo.Theme = neo.Theme ? neo.Theme : {};
neo.Theme = {
    colorList: ["orange", "blue", "red", "lime", "cherry", "purple", "xperiablue"],
    colors: {
        "orange": {
            name: 'orange',
            value: 'EC7100',
            accentValue: '773B00'
        },
        "blue": {
            name: 'blue',
            value: '00A8B5',
            accentValue: '005960'
        },
        "red": {
            name: 'red',
            value: 'D4041D',
            accentValue: '500000'
        },
        "lime": {
            name: 'lime',
            value: '65BB10',
            accentValue: '206000'
        },
        "cherry": {
            name: 'cherry',
            value: 'CE0057',
            accentValue: '7F0036'
        },
        "purple": {
            name: 'purple',
            value: '993399',
            accentValue: '390049'
        },
        "xperiablue": {
            name: 'xperiablue',
            value: '294ea2',
            accentValue: '1A3166'
        }
    },
    newTheme: "",
    /*
     * Returns current theme class of the page
     * if not set returns "purple"
     */
    currentTheme: function() {
        var tCurrent = this.hasTheme();
        return tCurrent ? tCurrent : "purple";
    },
    /*
     * Returns the theme object
     * @param tName theme color name
     */
    get: function(tName) {
        return neo.Theme.colors[tName];
    },
    set: function(tName) {
        var tClass = this.hasTheme();
        if (tClass) {
            jQuery("body").removeClass(tClass);
        }
        jQuery("body").addClass(tName);
    },
    setRandom: function() {
        this.set(this.newTheme.name);
    },
    selectNewTheme: function() {
        var rand = Math.floor(Math.random() * this.colorList.length);
        var c = this.colors[this.colorList[rand]];
        this.newTheme = c;
    },
    hasTheme: function() {
        var v = false;
        for (x in this.colorList) {
            if (jQuery("body").hasClass(this.colorList[x])) {
                v = this.colorList[x];
                break;
            }
        }
        return v;
    }
};
neo.Theme.selectNewTheme();

document.write('<style>.js-tab-content{display:none;_height:300px;}</style>');
/** 
* JS based tabs for dynamic loading of content using AJAX 
* HTML structure for tabs:
* <ul class="tab-menu js-tabmenu">
*   <li id="js-overview"><a href="/cws/products/mobilephones/phpoverview/aino?cc=se&amp;lc=sv">ï¿½versikt<span></span></a></li>
*   <li id="js-features_and_specifications"><a href="/cws/products/mobilephones/featuresandspecifications/aino?cc=se&amp;lc=sv">Features and Specifications<span></span></a></li>
* </ul>
* Uses the anchor links to fetch the content
*/
neo.JSTabs = {
    newview: "",
    isDirect: false,
    defaultPageTitle : document.title,  
    params: {
        track: true,
        holder: ".js-tab-content",
        sMark: "js-ajax-tabview-start",
        eMark: "js-ajax-tabview-end"
    },
    initialize: function() {
        if (jQuery(".js-tabmenu div a, .js-tabmenu li a").length > 0) {
            dhtmlHistory.addListener(neo.JSTabs.JSTabHistoryChange);
        }

        neo.JSTabs.prepare();

        if (jQuery("#js-" + neo.Tools.hash().view + " a").length !== 0) {
            // Check for first tab loading twice
            if (jQuery(".js-tabmenu li:first-child").attr("id").split("-")[1] != neo.Tools.hash().view) {
                jQuery(".js-tab-content").empty();
                jQuery(".js-tab-content").show();
                this.isDirect = true;
                this.prepareToLoadJSTabs();
            }
            else {
                jQuery(".js-tab-content").show();
                if(jQuery.browser.msie){
                    setTimeout(function(){
                        document.title = neo.JSTabs.defaultPageTitle;
                    }, 10000);
                }   
            }
        }
        else {
            jQuery(".js-tab-content").show();
        }
    },
    /**
     * Bind event to tabs
     */
    prepare: function() {
        jQuery(".js-tabmenu").not(".js-tabmenu.neocontrol-initialized").each(function() {
            if (jQuery(this).attr("params") !== undefined) {
                neo.JSTabs.params = neo.Tools.evalString(jQuery(this).attr("params"));
            }

            jQuery(this).find("a").each(function() {
                //Set attributes
                jQuery(this).attr({
                    track: neo.JSTabs.params.track,
                    holder: neo.JSTabs.params.holder,
                    smark: "<!--" + neo.JSTabs.params.sMark + "-->",
                    emark: "<!--" + neo.JSTabs.params.eMark + "-->"
                }
                    //Bind events
                        ).unbind("click").bind("click", function() {
                    neo.JSTabs.prepareToLoadJSTabs(jQuery(this));
                    jQuery(this).blur();
                    jQuery("body").trigger("onJSTabLoadStart");
                    return false;
                });
            });

            jQuery(this).addClass("neocontrol-initialized")
        });
    },
    onLoadHandler: function() {
        neo.Core.prepareCufon();
        neo.CustomDropDown.init();
        SE.AuxiliaryNav.shopTool.bindEvents();
        neo.JSTabs.prepareJSTabLinks();
        neo.JSTabs.prepare();
    },
    /**
     * Prepars tab
     * @param {Object} el HTML element
     */
    prepareToLoadJSTabs: function(el) {
        if (!el)
            var el = jQuery("#js-" + neo.Tools.hash().view + " a");
        var href;
        if (jQuery(el).length !== 0) {
            href = jQuery(el).attr("href");
        }
        else {
            el = jQuery(jQuery(".js-tabmenu div, .js-tabmenu li").get(0)).find("a");
            href = jQuery(jQuery(".js-tabmenu div, .js-tabmenu li").get(0)).find("a").attr("href");
        }

        //Highlight clicked tab
        neo.JSTabs.changeJSTab(jQuery(el));

        //Set scroll position to tab top position
        jQuery('html, body').animate({scrollTop: jQuery(el).offset().top - 50}, 600);

        //Load the tab content
        this.loadJSTabContent(el, eval(jQuery(el).attr("track")));
    },
    changeJSTab: function(el) {
        jQuery(el).parent().parent().children().each(function() {
            if (jQuery(this).hasClass('highlighted-selected-tab')) {
                jQuery(this).removeClass('highlighted-selected-tab');
            }
            jQuery(this).removeClass('selected-tab');
        });
        if (jQuery(el).parent().hasClass('highlighted-tab')) {
            jQuery(el).parent().addClass('highlighted-selected-tab');
        }
        else {
            jQuery(el).parent().addClass('selected-tab');
        }
    },
    prepareJSTabLinks: function() {
        jQuery('.js-tablink').unbind("click").click(function() {
            jQuery(this).attr({
                track: false,
                holder: neo.JSTabs.params.holder,
                smark: "<!--" + neo.JSTabs.params.sMark + "-->",
                emark: "<!--" + neo.JSTabs.params.eMark + "-->"
            });
            jQuery().scrollTo(300, 600);
            neo.JSTabs.loadJSTabContent(jQuery(this), false, true);
            return false;
        });
    },
    loadJSTabContent: function(el, setView, isTabLink) {
        jQuery.ajax({
            type: "GET",
            url: jQuery(el).attr("href"),
            beforeSend: function() {
                if (neo.JSTabs.isDirect) {
                    neo.Preloader.create(jQuery(el).attr("holder"));
                    neo.JSTabs.isDirect = false;
                }
                else {
                    neo.Preloader.createFloating(jQuery(el).attr("holder"));
                }
            },
            success: function(xml) {
                neo.Preloader.remove();
                var str = xml.toString();
                neo.JSTabs.setTabContent(el, str);
                if (setView) {
                    var st = setTimeout(function() {
                        neo.JSTabs.setView(el);
                    }, 400);
                }
               if (jQuery.browser.msie){  //settimeout - workaournd for ie7 & IE8
                   setTimeout(function() {
                    neo.JSTabs.setPageTitle(str);
                    }, 1800);
               }   
               else{
                   setTimeout(function() {
                       neo.JSTabs.setPageTitle(str);
                   }, 1000);
               }   

                //Trigger the tab load event
                jQuery("body").trigger("onJSTabLoad", [xml]);
            }
        });
    },
    setTabContent: function(el, str) {
        jQuery(jQuery(el).attr("holder")).html(str.substring(str.indexOf(jQuery(el).attr("smark")), str.indexOf(jQuery(el).attr("emark"))));

        //fix for png in ie 6
        if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) < 7) {
            jQuery(".js-tab-content img").load(function() {
                jQuery(this).ifixpng();
            });
        }
    },
    setPageTitle: function(str) {
        var s = str.indexOf("<title>");
        var e = str.indexOf("</title>");
        document.title = str.substring(s + 7, e);
    },
    setView: function(el) {
        var url = window.location.href.split("#")[0];
        var view = jQuery(el).parent().attr("id").split("-")[1];

        neo.JSTabs.newview = view;

        if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) < 8) {
            document.frames("DhtmlHistoryFrame").location.href = "/cws/js/blank.html?view=" + view;
            
        }
        else {
            window.location.href = url + "#view=" + view;
        }
        jQuery("body").trigger("onTabViewChange", [view]);
    },
    JSTabHistoryChange: function() {
        //popup up layer check
        if (neo.Tools.hash().layerid || window.location.hash == "#a")
            return;
        if (neo.Tools.hash().view != neo.JSTabs.newview) {
            neo.JSTabs.prepareToLoadJSTabs();
        }
    },
    setStatisticsPropValues: function(response, propArr){
        if(typeof s_gi === "function"){
            s = s_gi(s_account);    
        }
		
		//reset values
		s["products"] = "";
		s["events"] = "";
		s["eVar6"] = "";
		s["prop6"] = "";
		s["prop14"] = "";
		s["prop33"] = "";
		
		//fetch new page values
        $(response).filter("script").each(function(){
            var text = $(this).html();
            if (text.indexOf("s.server") > 0) {
                var arr = text.split(";");
                for (x = 0; x < arr.length; x++) {
                    //Remove line breaks and spaces
                    var arrItem = arr[x].replace(/(\r\n|\n|\r)/gm,"").trim();                  
                    var arr2 = arrItem.split("=");
                    //Get property name
                    var prop = arr2[0].trim().substr(2);
                    //Check if property needs to be set
                    if(propArr.indexOf(prop) != -1){
                        //Get property value
                        var propValue = arr2[1].trim().replace(/\'/gi, "");
                        //Set property value
                        s[prop] = propValue;
                    }
                }
                return;
            }
        });
    }
};

/**
 * Preloader animation
 */
neo.Preloader = {
    create: function(elToAppend) {
        var el = document.createElement("div");
        el.id = "preloader-container";
        var el2 = document.createElement("span");
        el2.id = "preloader-ani";
        el.appendChild(el2);
        jQuery(elToAppend).empty();
        jQuery(el).appendTo(jQuery(elToAppend));
        this.embedFlash("preloader-ani");
        return el;
    },
    createFloating: function(elToAppend) {
        if (jQuery(elToAppend).css("position") != "absolute" || jQuery(elToAppend).css("position") != "relative") {
            jQuery(elToAppend).css("position", "relative");
        }
        jQuery(elToAppend).append("<div id='preloader-wrapper'></div>");
        var wr = jQuery("#preloader-wrapper");
        jQuery(wr).css({
            "display": "none"
        });

        var el = this.create(wr);

        //create background
        var bg = document.createElement("div");
        jQuery(bg).addClass("preloader-bg");

        jQuery(bg).appendTo(jQuery(wr));

        jQuery(el).appendTo(jQuery(wr));
        jQuery(el).addClass("floating");


        var st = setTimeout(function() {
            try {
                jQuery(wr).css({
                    "display": "block"
                });
                jQuery(el).css("left", ((jQuery(el).parent().outerWidth() - jQuery(el).outerWidth())) / 2);
                jQuery(bg).css({
                    "width": jQuery(elToAppend).outerWidth(),
                    "height": jQuery(elToAppend).outerHeight(),
                    "opacity": 0
                });

                jQuery(bg).fadeTo("slow", 0.6);
            } catch(e) {

            }

        }, 200);
    },
    remove: function(el) {
        if (el) {
            jQuery(el).find("#preloader-container, #preloader-wrapper").remove();
        }
        else {
            jQuery("#preloader-container, #preloader-wrapper").remove();
        }
    },
    embedFlash: function(id) {
        var flashvars = {};
        flashvars.themeColor = neo.Theme.get(neo.Theme.currentTheme()).value;
        var params = {};
        params.menu = "false";
        params.scale = "noscale";
        params.allowscriptaccess = "sameDomain";
        params.wmode = "transparent";
        var attributes = {};
        swfobject.embedSWF("/cws/flash/preloader.swf", id, "50", "50", "9.0.0", false, flashvars, params, attributes)
    }
};

neo.Tools = neo.Tools ? neo.Tools : new Object();
neo.Tools = {
    /**
     *  Loads JS File
     *  @param filename
     *  @param filetype
     *  @param params
     */
    loadJSFile: function(filename, filetype, params) {
        if (filetype == "js") {
            var fileref = document.createElement('script');
            fileref.setAttribute("type", "text/javascript");
            fileref.setAttribute("src", filename);
            document.getElementsByTagName("head")[0].appendChild(fileref);
            if (params) {
                fileref.onload = function() {
                    neo.Tools.onFunctionAvailable(params.callback, params.methodToCheck)
                };
                //IE 6 & 7
                fileref.onreadystatechange = function() {
                    if (this.readyState == "loaded") {
                        neo.Tools.onFunctionAvailable(params.callback, params.methodToCheck)
                    }
                };
            }
        }
    },
    onFunctionAvailable: function(callback, method) {
        if (typeof(eval(method)) === "function") {
            eval(callback);
        }
        else {
            setTimeout(function() {
                neo.Tools.onFunctionAvailable(callback, method);
            }),50
        }
    },
    hash: function() {
        var vars = window.location.hash.substring(1).split(";");
        var hash = new Array();
        for (var x = 0; x < vars.length; x++) {
            hash[vars[x].split("=")[0]] = vars[x].split("=")[1];
        }
        return hash;
    },
    dateToString: function(date) {
        var today_date = new Date();
        var publish_date = new Date(date);
        var diffMin = today_date.getMinutes() - publish_date.getMinutes();
        var diffHours = today_date.getHours() - publish_date.getHours();

        var diffDays = today_date.getDate() - publish_date.getDate();
        var diffWeek = diffDays / 7;
        var diffMonth = today_date.getMonth() - publish_date.getMonth();
        var diffYears = today_date.getFullYear() - publish_date.getFullYear();

        if (diffYears == 0) {
            if (diffMonth == 0) {
                if (diffDays == 0) {
                    if (diffHours == 0) {
                        if (diffMin < 60 && diffMin > 1) {
                            date = diffMin + " Minutes ago"
                        }
                        else {
                            date = "1 Minute ago";
                        }
                    }
                    else
                    if (diffHours == 1) {
                        date = diffHours + " hour ago"
                    }
                    else {
                        date = diffHours + "hours ago"
                    }
                }
                else
                if (diffDays == 1) {
                    date = "Yesterday"
                }
                else
                if (diffDays < 7) {
                    date = diffDays + " Days ago"
                }

                else {
                    if (diffDays > 6 && diffDays < 13) {
                        date = "Last Week"
                    }
                    else {
                        date = Math.floor(diffDays / 7) + " Weeks ago"
                    }
                }
            }
            else
            if (diffMonth == 1) {
                date = "Last Month"
            }
            else {
                date = diffMonth + " Months ago"
            }
        }
        else
        if (diffYears == 1) {
            date = "Last year";
        }
        else {
            date = diffYears + " Years ago"
        }
        return date;
    },
    alterImgSize: function(_id, widthSize, heightSize) {
        var img_width;
        var imgTag = document.getElementById(_id).getElementsByTagName('img');
        for (var m = 0; m < imgTag.length; m++) {
            var Wspace = (widthSize - (imgTag[m].width)) / 2;
            var Hspace = (heightSize - (imgTag[m].height)) / 2;
            if (Wspace > 0) {
                imgTag[m].style.marginLeft = Wspace + "px";
            }
            if (Hspace > 0) {
                imgTag[m].style.marginTop = Hspace + "px";
            }
        }
    },
    evalString: function(str) {
        return eval("(" + str + ")");
    },
    getParam: function(paramName, url) {
        var docLoc = url != undefined ? url : document.location.href;
        var indexOfHash = docLoc.indexOf('#');
        if (indexOfHash != -1) {
            docLoc = docLoc.substr(0, indexOfHash);
        }
        var qString = '';
        var params = new Array();

        if (docLoc.contains("?")) {
            qString = docLoc.split("?");
            qString = qString[1];
        }
        if (qString.contains("&")) {
            params = qString.split("&");
        }
        else
        if (qString.contains("=")) {
            params.push(qString);
        }
        for (var i = 0; i < params.length; i++) {
            param = params[i].split("=");
            if (param[0] == paramName) {
                return param[1];
            }
        }
        return '';
    },
    alignLi: function(UlClass) {
        var LiContent;
        var totalLi;
        var cnt = 0;

        totalLi = jQuery("." + UlClass + " li").length;
        var tempDiv = jQuery("<div class='tmpDiv'></div>");
        var section0 = jQuery("<div class='section0'></div>");
        var section1 = jQuery("<div class='section1'></div>");
        for (var i = 0; i < totalLi; i++) {
            LiContent = jQuery("." + UlClass + " li:eq(" + (i) + ")").text();
            if (LiContent.match(/\S/g) != null) {
                tempDiv.append("<li>" + jQuery("." + UlClass + " li:eq(" + (i) + ")").html() + "</li>");
                cnt++;
                /*
                 if(i%2==0){
                 section0.append("<li>"+jQuery("."+UlClass+" li:eq("+(i)+")").html()+"</li>");
                 }
                 else{
                 section1.append("<li>"+jQuery("."+UlClass+" li:eq("+(i)+")").html()+"</li>");
                 }*/
            }
        }
        tempDiv.prependTo("." + UlClass);
        for (var i = 0; i < cnt; i++) {
            if (i % 2 == 0) {
                section0.append("<li>" + jQuery(".tmpDiv li:eq(" + (i) + ")").html() + "</li>");
            }
            else {
                section1.append("<li>" + jQuery(".tmpDiv li:eq(" + (i) + ")").html() + "</li>");
            }
        }
        jQuery("." + UlClass).html("");
        section0.prependTo("." + UlClass);
        section1.prependTo("." + UlClass);
    },
    /*
     * Use to set equal height to HTML elements
     * @param el jquery object
     * Sample usage - neo.Tools.setSameHeight(jQuery(".promo-deals-collection .box .promo-deals-content div"));
     */
    setSameHeight: function(el) {
        var tallest = 0;
        jQuery(el).each(function() {
            var thisHeight = jQuery(this).height();
            if (thisHeight > tallest) {
                tallest = thisHeight;
            }
        });

        // set each items height to use the tallest value found
        jQuery(el).each(function() {
            jQuery(this).height(tallest);
        });
    }
};

/*
 * Local Home Page
 */
neo.LHP = neo.LHP ? neo.LHP : new Object();
neo.LHP = {
    prepareLhpCards: function() {
        jQuery(".lhpCards").find("a").each(function() {
            if (jQuery(this).attr("target") == "_layer") {
                jQuery(this).click(function() {
                    var href = jQuery(this).attr("href");
                    var params = eval("(" + jQuery(this).attr('params') + ")");
                    neo.LHP.openCardLayer(href, params.width, params.height);
                    this.blur();
                    return false;
                });
            }
        });
    },
    openCardLayer: function(href, width, height) {
        if (typeof popup == "undefined") {
            neo.Tools.loadJSFile("/cws/js/popupLayerFunctions.js", "js", {
                callback: "neo.LHP.openCardLayer('" + href + "'," + width + "," + height + ")",
                methodToCheck: "popup.openLayer"
            });
        }
        else {
            popup.openLayer("lhpcard", href, "enhancedpresentation", width, height, "", "", "", false);
        }
    }
};

/*
 * Carousel
 */
neo.Carousel = neo.Carousel ? neo.Carousel : new Object();
neo.Carousel = {
    carouselIntervals: {},
    continousCarousels: {},
    initialize: function(el) {
        var as = (el != undefined) ? jQuery(el) : jQuery(".carouselWrapper").not(".carouselWrapper.deferInitialize, .carouselWrapper.carousel-initialized");
        as.each(function() {
            if (jQuery(this).hasClass("hCarousel")) {
                jQuery(this).data("vOrient", false);
            }
            else
            if (jQuery(this).hasClass("vCarousel")) {
                jQuery(this).data("vOrient", true);
            }
            jQuery(this).find(".carouselItem").each(function() {
                jQuery(this).click(function(event) {
                    neo.Carousel.navigateToUrl(event)
                });

                // Position the image vertically middle
                jQuery(this).children("img").each(function() {
                    jQuery(this).load(function() {
                        neo.Carousel.middleImage(jQuery(this).parent(), jQuery(this));
                    });
                });

            });

            var num = jQuery(this).parent().find('.carouselItem').not(jQuery(this).parent().find('.carouselItem.disabled')).length;
            var size = neo.Carousel.getSize(jQuery(this), jQuery(this).find('.carouselItem')[0]);
            if (!jQuery(this).data("vOrient"))
                jQuery(this).parent().find(".carouselContainer").css("width", Math.round(size * num));
            jQuery(this).data("isCyclic", jQuery(this).hasClass("cyclic"));
            jQuery(this).data("itemSize", size);
            jQuery(this).data("itemCount", num);
            jQuery(this).data("curItem", 0);
            jQuery(this).data("clipperSize", neo.Carousel.getSize(jQuery(this), jQuery(this).find(".carouselClipper")));
            jQuery(this).data("paging", jQuery(this).hasClass("js-paging"));

            neo.Carousel.resetButtons(this);
            if (jQuery(this).data("paging") && !jQuery(this).hasClass("carousel-initialized")) {
                neo.Carousel.setPaging(this);
                neo.Carousel.doPaging(this);
            }
            var cont = jQuery(this).find(".carouselContainer");

            // Set interval for continous carousel
            // TODO: fix for multiple continous carousel on a page
            if (jQuery(cont).hasClass("continous") && jQuery(cont).hasClass("autoAdvance")) {
                var rand = Math.floor(Math.random() * 1234567890);
                jQuery(this).data("intervalId", rand);
                neo.Carousel.continousCarousels[rand] = jQuery(this);

                var params = neo.Tools.evalString(jQuery(cont).attr("params"));
                neo.Carousel.carouselIntervals[rand] = setInterval(function() {
                    neo.Carousel.autoAdvance(neo.Carousel.continousCarousels[rand]);
                }, params.speed);

                jQuery(this).hover(function() {
                    clearInterval(neo.Carousel.carouselIntervals[rand]);
                }, function() {
                    neo.Carousel.carouselIntervals[rand] = setInterval(function() {
                        neo.Carousel.autoAdvance(neo.Carousel.continousCarousels[rand]);
                    }, params.speed);
                });
            }

            jQuery(this).addClass("carousel-initialized");
        });
        neo.Carousel.bindEventsToButtons();
    },
    next: function(e) {
        var p = jQuery(this).parent();
        var i = jQuery(p).data("curItem");
        var c = jQuery(p).find(".carouselContainer");
        if (neo.Carousel.hasNext(p)) {
            jQuery(p).data("curItem", --i);
            neo.Carousel.animate(jQuery(c), (i * jQuery(p).data("itemSize")), jQuery(this).parent().data("vOrient"));
        }
        else if (jQuery(".carouselContainer").hasClass("continous")) {
            var i = 1;
            jQuery(p).data("curItem", --i);
            neo.Carousel.animate(jQuery(c), (i * jQuery(p).data("itemSize")), jQuery(this).parent().data("vOrient"));
        }
        else if (jQuery(p).data("isCyclic")) {
            if (jQuery(e.currentTarget).hasClass("disable")) return false;

            //Animate to position value
            var v;

            jQuery(c).each(function() {
                if (neo.isRtl) {
                    //Clone all the carousel items
                    jQuery.each(jQuery.makeArray(jQuery(this).find(".carouselItem")).reverse(), function() {
                        jQuery(c).prepend(jQuery(this).clone());
                    });

                    jQuery(c).css({
                        "width" : jQuery(c).outerWidth() * 2,
                        "right" : -(jQuery(p).data("itemSize") * (jQuery(p).data("itemCount") - 1))
                    });

                    v = parseInt(jQuery(c).css("right")) - jQuery(p).data("itemSize");
                } else {
                    jQuery.each(jQuery(c).find(".carouselItem"), function() {
                        jQuery(c).append(jQuery(this).clone());
                    });

                    //Set the width of the container to
                    //double the size
                    jQuery(c).css({
                        "width" : jQuery(c).outerWidth() * 2
                    });

                    v = parseInt(jQuery(c).css("left")) - jQuery(c).find(".carouselItem:eq(0)").outerWidth();
                }
            });

            neo.__elm = jQuery(p);

            //Animate the carousel by one position
            //to show the first element
            neo.Carousel.animate(jQuery(c), v, jQuery(this).parent().data("vOrient"), function() {
                //callback function
                neo.Carousel.clean(jQuery(neo.__elm));
                neo.Carousel.reset(jQuery(neo.__elm));
            });
        }

        if (jQuery(p).data("paging"))
            neo.Carousel.doPaging(p);

        if (!jQuery(p).data("isCyclic")) neo.Carousel.resetButtons(p);
    },
    previous: function(e) {
        var p = jQuery(this).parent();
        var i = jQuery(p).data("curItem");
        var c = jQuery(p).find(".carouselContainer");
        if (neo.Carousel.hasPrevious(p)) {
            jQuery(p).data("curItem", ++i);
            neo.Carousel.animate(jQuery(p).find(".carouselContainer"), (i * jQuery(p).data("itemSize")), jQuery(this).parent().data("vOrient"));
        }
        else if (jQuery(p).data("isCyclic")) {
            if (jQuery(e.currentTarget).hasClass("disable")) return false;

            //Animate to position value
            var v;
            jQuery(c).each(function() {
                if (neo.isRtl) {
                    //Clone all the carousel items
                    jQuery.each(jQuery(this).find(".carouselItem"), function() {
                        jQuery(c).append(jQuery(this).clone());
                    });

                    //Set the width of the container to
                    //double the size
                    jQuery(this).css({
                        "width" : jQuery(c).outerWidth() * 2,
                        "right" : -(jQuery(p).data("itemSize") * jQuery(p).data("itemCount"))
                    });

                    v = parseInt(jQuery(c).css("right")) + jQuery(p).data("itemSize");
                } else {
                    //Clone all the carousel items
                    jQuery.each(jQuery.makeArray(jQuery(this).find(".carouselItem")).reverse(), function() {
                        jQuery(c).prepend(jQuery(this).clone());
                    });

                    //Set the width of the container to
                    //double the size
                    jQuery(this).css({
                        "width" : jQuery(c).outerWidth() * 2,
                        "left" : - (jQuery(p).data("itemSize") * jQuery(p).data("itemCount"))
                    });

                    v = (parseInt(jQuery(c).css("left")) + jQuery(p).data("itemSize"));
                }
            });

            //Keep ref to elm for callback function
            neo.__elm = jQuery(p);

            //Animate the carousel by one position
            neo.Carousel.animate(jQuery(c), v, jQuery(this).parent().data("vOrient"), function() {
                neo.Carousel.clean(jQuery(neo.__elm), true);
                neo.Carousel.reset(jQuery(neo.__elm), true);
            });
        }

        //Update paging
        if (jQuery(p).data("paging"))
            neo.Carousel.doPaging(p);

        //Reset navigation buttons
        if (!jQuery(p).data("isCyclic")) neo.Carousel.resetButtons(p);
    },
    animate: function(obj, v, vOrient, callback) {
        if (vOrient) {
            jQuery(obj).animate({
                top: v + 'px'
            }, 500);
        }
        else {
            if (neo.Tools.getParam('lc') == 'he' || neo.Tools.getParam('lc') == 'ar') {
                jQuery(obj).animate({
                    right: v + 'px'
                }, 500, "swing", callback);
            }
            else {
                jQuery(obj).animate({
                    left: v + 'px'
                }, 500, "swing", callback);
            }
        }
    },
    getSize: function(p, el) {
        var size = jQuery(el).outerWidth(true);
        if (jQuery(p).data("vOrient"))
            var size = jQuery(el).outerHeight(true);
        return size;
    },
    hasPrevious: function(p) {
        var i = jQuery(p).data("curItem");
        return (i < 0)
    },
    hasNext: function(p) {
        var i = jQuery(p).data("curItem");
        return (i * jQuery(p).data("itemSize") > ((jQuery(p).data("itemSize") * jQuery(p).data("itemCount")) - jQuery(p).data("clipperSize")) * -1)
    },
    middleImage: function(parent, img) {
        var p_height = jQuery(parent).height();
        var img_height = jQuery(img).height();
        var p_width = jQuery(parent).width();
        var img_width = jQuery(img).width();
        if (img_height < p_height) {
            jQuery(img).css({
                "marginTop": ((p_height - img_height) / 2) + "px"
            });
        }
        if (img_width < p_width) {
            jQuery(img).css({
                "marginLeft": ((p_width - img_width) / 2) + "px"
            });
        }
    },
    resetButtons: function(el) {
        jQuery(el).find(".carouselNext, .carouselPrevious").removeClass("active");
        if (jQuery(el).data("isCyclic")) {
            if (jQuery(el).data("itemCount") > 1) {
                jQuery(el).find(".carouselNext, .carouselPrevious").removeClass("disable").addClass("enable");
            }
        }
        else {
            if (!neo.Carousel.hasPrevious(el) && neo.Carousel.hasNext(el)) {
                jQuery(el).find(".carouselPrevious").addClass("disable");
                jQuery(el).find(".carouselPrevious").removeClass("enable");
                jQuery(el).find(".carouselNext").addClass("enable");
                jQuery(el).find(".carouselNext").removeClass("disable");
            }
            if (neo.Carousel.hasPrevious(el) && !neo.Carousel.hasNext(el)) {
                jQuery(el).find(".carouselPrevious").removeClass("disable");
                jQuery(el).find(".carouselPrevious").addClass("enable");
                jQuery(el).find(".carouselNext").removeClass("enable");
                jQuery(el).find(".carouselNext").addClass("disable");
            }
            if (neo.Carousel.hasPrevious(el) && neo.Carousel.hasNext(el)) {
                jQuery(el).find(".carouselNext, .carouselPrevious").removeClass("disable");
                jQuery(el).find(".carouselNext, .carouselPrevious").addClass("enable");
            }
            if (!neo.Carousel.hasPrevious(el) && !neo.Carousel.hasNext(el)) {
                jQuery(el).find(".carouselNext, .carouselPrevious").addClass("disable");
                jQuery(el).find(".carouselNext, .carouselPrevious").removeClass("enable");
            }
        }
    },
    setPaging: function(el) {
        jQuery(el).each(function() {
            var elPaging = jQuery(el).find("#carouselPaging");
            var c = neo.isRtl ? jQuery(this).find(".carouselItem").length - 1 : 0;
            jQuery(this).find(".carouselItem").each(function() {
                jQuery(elPaging).append("<span cnt=" + c + "></span>");
                neo.isRtl ? c-- : c++;
            });
        });

        jQuery("#carouselPaging span").each(function() {
            jQuery(this).bind("click", function() {
                var p = jQuery(this).parent().parent();
                jQuery(p).data("curItem", -jQuery(this).attr("cnt"));
                neo.Carousel.animate(jQuery(p).find(".carouselContainer"), (jQuery(p).data("curItem") * jQuery(p).data("itemSize")), jQuery(p).data("vOrient"));
                neo.Carousel.doPaging(p);
                neo.Carousel.resetButtons(p);
            });
        });
    },
    doPaging: function(el) {
        var items = jQuery(el).find("#carouselPaging span");
        var curItem = jQuery(el).data("curItem");
        jQuery.each(items, function(i, item) {
            jQuery(item).removeClass("current");
            if (jQuery(item).attr("cnt") == curItem * -1) {
                jQuery(item).addClass("current");
            }
        });
    },
    bindEventsToButtons: function() {
        jQuery(".carouselPrevious").unbind("click", neo.Carousel.previous);
        jQuery(".carouselPrevious").bind("click", neo.Carousel.previous);
        jQuery(".carouselNext").unbind("click", neo.Carousel.next);
        jQuery(".carouselNext").bind("click", neo.Carousel.next);

        jQuery(".carouselPrevious, .carouselNext").bind("mouseover", function(e) {
            if (jQuery(this).hasClass("disable") == false) {
                jQuery(this).addClass("hover");
            }
        });
        jQuery(".carouselPrevious, .carouselNext").bind("click", function(e) {
            if (jQuery(this).hasClass("disable") == false) {
                jQuery(this).removeClass("active");
                jQuery(this).addClass("hover");
            }
        });
        jQuery(".carouselPrevious, .carouselNext").bind("mousedown", function(e) {
            if (jQuery(this).hasClass("disable") == false) {
                jQuery(this).removeClass("hover");
                jQuery(this).addClass("active");
            }
        });
        jQuery(".carouselPrevious, .carouselNext").bind("mouseout", function(e) {
            if (jQuery(this).hasClass("disable") == false) {
                jQuery(this).removeClass("hover");
                jQuery(this).addClass("enable");
            }
        });
    },
    autoAdvance: function(el) {
        jQuery(el).parent().find(".carouselNext").trigger("click");
    },
    reset: function(el, previous) {
        if (previous) {
            jQuery(el).data("curItem", - (jQuery(el).data("itemCount") - 1));
            jQuery(el).find(".carouselContainer").each(function() {
                jQuery(this).width(jQuery(el).data("itemCount") * jQuery(el).data("itemSize"));
                if (!neo.isRtl) jQuery(this).css("left", - ((jQuery(el).data("itemCount") - 1) * jQuery(el).data("itemSize")));
            });
        }
        else {
            jQuery(el).data("curItem", 0);
            jQuery(el).find(".carouselContainer").each(function() {
                jQuery(this).width(jQuery(el).data("itemCount") * jQuery(el).data("itemSize"));
                neo.isRtl ? jQuery(this).css("right", 0) : jQuery(this).css("left", 0)
            });
        }
        if (jQuery(el).data("paging"))
            neo.Carousel.doPaging(el);
    },
    clean: function(el, previous) {
        if (previous) {
            jQuery(el).find(".carouselItem:gt(" + (jQuery(el).data("itemCount") - 1) + ")").each(function() {
                jQuery(this).remove();
            });
        } else {
            jQuery(el).find(".carouselItem:lt(" + jQuery(el).data("itemCount") + ")").each(function() {
                jQuery(this).remove();
            });
        }
    },
    navigateToUrl: function(e) {
        switch (jQuery(e.currentTarget).parent().parent().parent().attr("name")) {
            case "campaignCarousel":
                neo.Carousel.navigateToCampaignUrl(e.currentTarget);
                break;
            case "richMediaCarousel":
                neo.Carousel.navigateToRichMediaUrl(e.currentTarget);
                break;
            case "colorPickerCarousel":
                SE.products.colorPicker.setProductColor(e.currentTarget);
                break;
            default:
            //
        }
    },
    navigateToCampaignUrl: function(el) {
        var params = eval("(" + jQuery(el).attr('params') + ")");
        switch (params.type) {
            case "standalone":
                window.open(params.url, "campaign");
                break;
            case "layered":
                popup.openLayer(params.id, params.url, "enhancedpresentation", params.width, params.height, "", "", "", false);
                break;
            default:
                window.location = params.url;
        }
    },
    navigateToRichMediaUrl: function(el) {
        var params = eval("(" + jQuery(el).attr('params') + ")");
        popup.openLayer(params.idCont, params.contentUrl, params.popupType, params.width, params.height, params.statPr, params.statTl, params.extraParams, false);
    }
};

neo.cyclicCarousel = neo.cyclicCarousel ? neo.cyclicCarousel : new Object();
neo.cyclicCarousel = {
    intervalID: 0,
    initialize: function() {
        jQuery(".carouselContainer").css({
            "left": "-410px"
        });
        var as = jQuery(".carouselWrapper");
        as.each(function() {
            if (jQuery(this).hasClass("hCarousel")) {
                jQuery(this).data("vOrient", false);
            }
            else
            if (jQuery(this).hasClass("vCarousel")) {
                jQuery(this).data("vOrient", true);
            }
            jQuery(this).find(".carouselItem").each(function() {
                jQuery(this).click(function(event) {
                    neo.Carousel.navigateToUrl(event)
                });
            });


            var num = jQuery(this).parent().find('.carouselItem').length;
            var size = neo.Carousel.getSize(jQuery(this), jQuery(this).find('.carouselItem')[0]);
            if (!jQuery(this).data("vOrient"))
                jQuery(this).parent().find(".carouselContainer").css("width", Math.round(size * num));
            jQuery(this).data("itemSize", size);
            jQuery(this).data("itemCount", num);
            jQuery(this).data("curItem", 0);
            jQuery(this).data("clipperSize", neo.Carousel.getSize(jQuery(this), jQuery(this).find(".carouselClipper")));
            var itemsArray = new Array();
            for (var i = 0; i < jQuery(".carouselContainer .carouselItem").length; i++) {
                if (i != 0)
                    itemsArray[i] = jQuery(".carouselContainer .carouselItem").get(i - 1);
                else
                    itemsArray[i] = jQuery(".carouselContainer .carouselItem").get(jQuery(".carouselContainer .carouselItem").length - 1);
            }
            jQuery(".carouselContainer").html(itemsArray);
            jQuery(this).data("itemArray", itemsArray);
        });
        jQuery(as).find(".carouselNext, .carouselPrevious").removeClass("disable");
        neo.cyclicCarousel.bindEventsToButtons();
        if (jQuery(".carouselContainer").hasClass("cyclic") && jQuery(".carouselContainer").hasClass("autoAdvance"))
            intervalID = setInterval(neo.cyclicCarousel.autoAdvance, 6000);
    },
    bindEventsToButtons: function() {

        jQuery(".carouselPrevious").bind("click", neo.cyclicCarousel.previous);
        jQuery(".carouselNext").bind("click", neo.cyclicCarousel.next);

        jQuery(".carouselPrevious, .carouselNext").bind("mouseover", function(e) {
            if (jQuery(this).hasClass("disable") == false) {
                jQuery(this).addClass("hover");
            }
        });
        jQuery(".carouselPrevious, .carouselNext").bind("click", function(e) {
            if (jQuery(this).hasClass("disable") == false) {
                jQuery(this).removeClass("active");
                jQuery(this).addClass("hover");
            }
        });
        jQuery(".carouselPrevious, .carouselNext").bind("mousedown", function(e) {
            if (jQuery(this).hasClass("disable") == false) {
                jQuery(this).removeClass("hover");
                jQuery(this).addClass("active");
            }
        });
        jQuery(".carouselPrevious, .carouselNext").bind("mouseout", function(e) {
            if (jQuery(this).hasClass("disable") == false) {
                jQuery(this).removeClass("hover");
            }
        });
        if (jQuery(".carouselContainer").hasClass("cyclic") && jQuery(".carouselContainer").hasClass("autoAdvance"))
            jQuery(".carouselWrapper").hover(function() {
                clearInterval(intervalID);
            }, function() {
                intervalID = setInterval(neo.cyclicCarousel.autoAdvance, 6000);
            });

    },
    next: function() {
        var p = jQuery(this).parent();
        var arrayItem = jQuery(p).data("itemArray");
        jQuery(".carouselContainer").animate({
            left: -820 + 'px'
        }, 500, null, function() {
            var temp = arrayItem.shift();
            arrayItem.push(temp);
            jQuery(".carouselContainer").html(arrayItem);
            jQuery(".carouselContainer").css({
                "left": "-410px"
            });
        });
    },
    previous: function() {
        var p = jQuery(this).parent();
        var arrayItem = jQuery(p).data("itemArray");
        jQuery(".carouselContainer").animate({
            left: 0 + 'px'
        }, 500, null, function() {
            var temp = arrayItem.pop();
            arrayItem.unshift(temp);
            jQuery(".carouselContainer").html(arrayItem);
            jQuery(".carouselContainer").css({
                "left": "-410px"
            });
        });
    },
    autoAdvance: function() {
        jQuery(".carouselNext").trigger("click");
    }

};

/*
 *  Shows Balloon tooltip.
 *  Works on all elemnets with class 'js-tooltip'.
 *  Gets text from the 'title' attribute.
 */
neo.ToolTip = neo.ToolTip ? neo.ToolTip : new Object();
neo.ToolTip = {
    init: function() {
        jQuery(".js-tooltip").bind("mouseover", function(e) {
            e.stopImmediatePropagation();
            if (!document.getElementById('toolTip')) {
                var html = '<div id="toolTip">';
                html += '<div id="toolTip_t"><span></span></div>';
                html += '<div id="toolTip_r"><span></span></div>';
                html += '<div id="toolTip_b"><span></span></div>';
                html += '<div id="toolTip_l"><span></span></div>';
                html += '<div id="toolTip_tl"><span></span></div>';
                html += '<div id="toolTip_tr"><span></span></div>';
                html += '<div id="toolTip_bl"><span></span></div>';
                html += '<div id="toolTip_br"><span></span></div>';
                html += '<div id="toolTip_arrow"><span></span></div>';
                html += '<div id="toolTip_txt"></div>';
                html += '</div>';
                jQuery("body").append(html);
            }
            if (jQuery(this).data("tooltip") === undefined) {
                jQuery(this).data("tooltip", {
                    text: jQuery(this).attr("title")
                });
                jQuery(this).attr("title", "");
            }
            neo.ToolTip.show(e, jQuery(this));
        });
        jQuery(".js-tooltip").bind("mousemove", function(e) {
            e.stopImmediatePropagation();
            neo.ToolTip.move({event: e, elm: jQuery("#toolTip"), forElm: jQuery(this), pos: 'mouse', arrowElm: jQuery("#toolTip_arrow")});
        });
        jQuery(".js-tooltip").bind("mouseout", function(e) {
            e.stopImmediatePropagation();
            jQuery("#toolTip").css({
                "visibility": "hidden",
                "left": -100,
                "top": -100
            });
            jQuery("#toolTip #toolTip_txt").text("");
            jQuery("#toolTip #toolTip_txt").css({
                "white-space": "nowrap",
                "width": "auto",
                "height": "auto"
            });
            jQuery("#toolTip_arrow").css("left", 20);
        });
    },
    show: function(e, forElm) {
        var tt = jQuery('#toolTip');
        var txt = jQuery('#toolTip #toolTip_txt');

        jQuery(txt).text(jQuery(e.currentTarget).data("tooltip").text);

        if (jQuery(txt).outerWidth() > 300) {
            jQuery(txt).css({
                'white-space': 'normal',
                'width': 300
            });
        }

        jQuery("#toolTip #toolTip_t, #toolTip #toolTip_b").width(jQuery(txt).outerWidth());
        jQuery("#toolTip #toolTip_r, #toolTip #toolTip_l").height(jQuery(txt).outerHeight());
        jQuery(tt).css({
            'width': jQuery(txt).outerWidth() + 15,
            'height': jQuery(txt).outerHeight() + 16
        });

        neo.ToolTip.move({event: e, elm: jQuery("#toolTip"), forElm: forElm, pos: 'mouse', arrowElm: jQuery("#toolTip_arrow")});
        jQuery(tt).css('visibility', 'visible');
    },
    /**
     * Sets position of the tooltip
     * @param {Object} params
     * elm - Tooltip element
     * forElm - Tooltip to be shown for
     * pos - mouse - moves with the mouse
     *
     */
    move: function(params) {
        var lPos = 0;
        var tPos = 0;
        var st = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
        //Tooltip elm position/size
        var tWidth = params.elm.outerWidth();
        var tHeight = params.elm.outerHeight();
        //For element position/size
        var elmTop = Math.floor(params.forElm.offset().top);
        var elmLeft = Math.floor(params.forElm.offset().left);
        var elmWidth = params.forElm.outerWidth();
        var elmHeight = params.forElm.outerHeight();
        //Calculate position
        if (params.pos !== undefined && params.pos == "mouse") {
            //Check if arrow is available
            var arrowLeft = (params.arrowElm.length > 0) ? params.arrowElm.position().left : 0;
            lPos = params.event.clientX - arrowLeft < 0 ? 0 : params.event.clientX - arrowLeft;

            if (lPos + tWidth > jQuery(window).width()) {
                var diff = (lPos + tWidth) - jQuery(window).width();
                lPos -= diff;
                params.arrowElm.css({
                    "left": arrowLeft + diff
                });
            }
            tPos = (params.event.clientY - (tHeight + 10)) + st;
        }

        else {
            //Left position
            if (typeof params.hPos == "string") {
                switch (params.hPos) {
                    case "left":
                        //TODO
                        break;
                    case "center":
                        lPos = (elmLeft + (elmWidth / 2)) - (tWidth / 2);
                        break;
                    case "right":
                        //TODO
                        break;
                    default:
                }
            }
            else {
                lPos = (elmLeft + params.hPos) - (tWidth / 2);
            }
            //Top position
            if (typeof params.vPos == "string") {
                switch (params.vPos) {
                    case "top":
                        tPos = elmTop - tHeight;
                        break;
                    case "bottom":
                        tPos = elmTop + elmHeight;
                        break;
                    default:
                }
            }
            else {
                tPos = (elmTop - tHeight) + params.vPos;
            }
        }
        //Set position
        params.elm.css({
            "top": tPos,
            "left": lPos
        });
    }
};

/*
 *  Cookie functions
 */
neo.Cookie = neo.Cookie ? neo.Cookie : new Object();
neo.Cookie = {
    set: function(name, value, expires, path, domain, secure) {
        document.cookie = escape(name) + '=' + escape(value) +
                (expires ? '; EXPIRES=' + expires.toGMTString() : '') +
                (path ? '; PATH=' + path : '; PATH=/') +
                (domain ? '; DOMAIN=' + domain : '') +
                (secure ? '; SECURE' : '');
    },
    clear: function(name, value, path, domain, secure) {
        var dx = new Date(2000, 1, 1);
        neo.Cookie.set(name, value, dx, path, domain, secure);
    },
    get: function(name) {
        if (document.cookie.length > 0) {
            var start = document.cookie.indexOf(name + "=");
            if (start != -1) {
                start = start + name.length + 1;
                var end = document.cookie.indexOf(";", start);
                if (end == -1)
                    end = document.cookie.length;
                return unescape(document.cookie.substring(start, end));
            }
        }
        return "";
    }
};

// Second level navigation Hover
neo.TopNavHover = neo.TopNavHover ? neo.TopNavHover : new Object();
neo.TopNavHover = {
    st: null,
    curActive: "",
    delayTimeout: null,
    delay: 400,
    prepare: function() {
        jQuery("#topNavigation li, .search-auxiliary-nav ul li").not("#topNavigation li.firstNode").each(function() {
            var hasHover = false;

            jQuery(this).append("<span></span>");

            jQuery(this).children("span").css({
                "display": "block",
                "position": "absolute",
                "top": "0px",
                "left": "0px",
                "background": "url(/cws/images/spacer.gif)",
                "width": jQuery(this).outerWidth(),
                "height": jQuery(this).outerHeight(),
                "margin": "0px",
                "cursor": "pointer",
				"z-index": 1
            });

            var hoverid = "";

            
            if (jQuery(this).attr("params") != undefined) {
                var params = neo.Tools.evalString(jQuery(this).attr("params"));
                
                hoverid = neo.Tools.getParam("nav", params.navUrl) + "_hover";
                jQuery(this).attr("topnavh", hoverid);
                
                if (params.navUrl.indexOf("/cws/auxrelatedcontent") != -1) {
                    SE.AuxiliaryNav.relatedConentTool.name = neo.Tools.getParam("nav", params.navUrl);
                }
                
                jQuery(this).addClass("js-topnav-hover-nav");
                
				if (params.navUrl.indexOf("/cws/auxshoptool") != -1) {
                    jQuery(this).addClass("shop-cart-btn");
                    jQuery(this).append("<div class='number'></div>");
                }
                neo.TopNavHover.loadContent(jQuery(this), "extended", hoverid);
            }
            else {
                if (jQuery(this).hasClass("js-topnav-hover-menu")) {
                    hoverid = "topnav_" + Math.floor(Math.random() * 1234567890);
                    neo.TopNavHover.addHoverDiv(hoverid);
                    neo.TopNavHover.loadContent(jQuery(this).attr("id"), "simple", hoverid);
                    
                    jQuery(this).attr("topnavh", hoverid);
                    
                }
            }
        });
				
        jQuery("#topNavigation li").not("#topNavigation li.firstNode").children("span").each(function() {
            jQuery(this).bind("click", function() {
                var a = jQuery(this).siblings("a");
                var href = jQuery(a).attr("href");
                var target = jQuery(a).attr("target");
                if (target == "_blank") {
                    window.open(href);
                }
                else if (target == "_layer") {
                    neo.openLayer(href, Number(jQuery(a).attr("layerwidth")), Number(jQuery(a).attr("layerheight")), jQuery(a).attr("layername"), false);
                }
                else {
                    window.location = href;
                }
            });
            jQuery(this).bind("mouseover", function(){
                var el = jQuery(this);
                if (jQuery(this).parent().hasClass("js-topnav-hover-menu")) {
                    clearTimeout(neo.TopNavHover.st);
                }
                neo.TopNavHover.delayTimeout = setTimeout(function(){
                    neo.TopNavHover.onMouseHandler(el);
                    neo.Core.highlightTopNav("mouseover", el.siblings("a"));
					
					SE.Shopping.initiateCartIcon();
                }, neo.TopNavHover.delay);
            });
            jQuery(this).bind("mouseleave", function() {
                clearTimeout(neo.TopNavHover.delayTimeout);
                neo.TopNavHover.close(neo.TopNavHover.getCloseDelay(jQuery(this)));
            });
        });

        //Attach events to Auxiliary navigation
        jQuery("#rightLinks li.js-topnav-hover-nav").children("span").each(function() {
			var isShop = jQuery(this).parent().hasClass('shop-cart-btn');
			
			//Shop cart
			if(isShop) {
                jQuery(this).bind({
                    mouseover: function(){
                        var parent = jQuery(this).parent(), id = parent.attr("id"), position = jQuery("#" + id).offset();
                        
                        jQuery("#" + id + "_hover").addClass('shopContainer').css(position);
                        neo.TopNavHover.onMouseHandler(jQuery(this));
                        neo.Core.highlightTopNav("mouseover", jQuery(this).siblings("a"));
                        SE.Shopping.initiateCartIcon();
                    },
                    
                    click: function(){
						var itemCount = jQuery(".shop-cart-btn").children("div.number").html();
                        if (itemCount != 0)	{
							 SE.Shopping.initiateCheckout();
						}
                    },
                    
                    mouseleave: function(){
						neo.TopNavHover.close(neo.TopNavHover.getCloseDelay(jQuery(this)));
                    }
                });
			}
			else {
				jQuery(this).bind({
					click: function(){
						neo.TopNavHover.onMouseHandler(jQuery(this));
						neo.Core.highlightTopNav("mouseover", jQuery(this).siblings("a"));
					},
					
					mouseleave: function(){
						neo.TopNavHover.close(neo.TopNavHover.getCloseDelay(jQuery(this)));	
					}
	            });
			}
        });
    },
    onMouseHandler: function(el) {
        var parentEl = jQuery(el).parent();
        var siblingEl = jQuery(el).siblings("a");

        //Handle element with secondary navigation
        if (jQuery(parentEl).attr("topnavh") != undefined) {
            clearTimeout(neo.TopNavHover.st);

            var hoverId = jQuery(parentEl).attr("topnavh");
            var hoverMenu = jQuery("#" + hoverId);

            //Set hover mask to hide the bottom border
            jQuery(hoverMenu).find("#hoverMask").css({
                "left": jQuery(parentEl).offset().left + 1,
                "width": jQuery(parentEl).outerWidth(true) - 2
            });

            //Set white hover class
			var itemCount = jQuery(".shop-cart-btn").children("div.number").html();

			if (itemCount != 0)
			{
				jQuery(siblingEl).addClass("hover-white");
			}
         		
			
	
            neo.TopNavHover.curActive = hoverId;
            neo.TopNavHover.show(jQuery(hoverMenu));
        }
        //Handle element without secondary navigation
        else {
            //Set basic hover class
            jQuery(siblingEl).addClass("hover");

            //Attach event for mouseout
            jQuery(el).bind("mouseout", function() {
                jQuery(siblingEl).removeClass("hover");
                neo.Core.highlightTopNav("mouseout", jQuery(siblingEl));
            });
        }
    },
    loadContent: function(id, view, hoverid){
        if (view == "simple") {
            var url = new neo.URL("/cws/includes/header");
            url.append({
                "view": "hover",
                "cc": neo.cc,
                "lc": neo.lc,
                "link": id
            });
            jQuery.ajax({
                type: "GET",
                url: url.toString(),
                beforeSend: function(){
                },
                success: function(xml){
                    var str = xml.toString();
                    //if (str.length > 0) {
                    neo.TopNavHover.setContent(str, view, hoverid);
                    //}
                }
            });
        }
        else if (view == "extended") {
            var params = neo.Tools.evalString(jQuery(id).attr("params"));
            var url = new neo.URL(params.navUrl);
            url.append({
                "theme": neo.Theme.currentTheme(),
                "c": "?"
            });
            var ds = new neo.DynamicScript(url);
            ds.add();
        }
    },
    navCallback: function(json) {
        var id = json.nav + "_hover";
        neo.TopNavHover.addHoverDiv(id);
        neo.TopNavHover.setContent(json, "extended", id);
        if (json.nav == SE.AuxiliaryNav.relatedConentTool.name) {
            SE.AuxiliaryNav.relatedConentTool.init();
        }
    },
    setContent: function(data, view, hoverid){
        var el = jQuery("#" + hoverid);
        jQuery(el).removeClass("simple").removeClass("extended").addClass(view);
        
        if (view == "simple") {
            jQuery(el).find(".neoWrapper").html(data);
        }
        else if (view == "extended") {
            jQuery(el).find(".neoWrapper").append(data.html.toString());
            if (data.header != undefined) {
                if (jQuery(el).find(".neoWrapper").find(".first").length) {
                    jQuery(el).find(".neoWrapper").find(".first").prepend(data.header.toString());
                }
                else {
                    jQuery(el).find(".neoWrapper").prepend(data.header.toString());
                }
            }
        }
        
        var dls = jQuery(el).find("dl");
        if (jQuery(el).find("#nav-carousel").length > 0) {
            jQuery(el).removeClass("no-promotion-view");
            jQuery.each(dls, function(i, item){
                if (i == 3) {
                    jQuery(item).after("<span class='clear-float'></span>");
                }
            });
        }
        else {
            jQuery(el).addClass("no-promotion-view");
            jQuery.each(dls, function(i, item){
                if (i == 4) {
                    jQuery(item).after("<span class='clear-float'></span>");
                }
            });
        }
        neo.TopNavHover.highlightLink();
        neo.Carousel.initialize();
        neo.CustomDropDown.init();
        jQuery(el).find(".customDropDownControl").bind("click, mouseover", function(event, el){
            neo.TopNavHover.customDDHandler(el);
        })
    },
    show: function(el) {
        //Hide all topnav hover divs
        jQuery(".topnav-hover-wrapper").css({
            "visibility": "hidden"
        });

        //Show the corresponding topnav hover div
        jQuery(el).css({
            "visibility": "visible"
        });

        //Remove highlight of topnav tabs
        jQuery("#topNavigation li.js-topnav-hover-menu a, #topNavigation li.js-topnav-hover-nav a, #rightLinks li ul li a").each(function() {
            if (jQuery(this).parent().attr("topnavh") != neo.TopNavHover.curActive) {
                jQuery(this).removeClass("hover-white");
                neo.Core.highlightTopNav("mouseout", jQuery(this));
            }
        });

        //Handle customdropdown in the hover menu
        jQuery("#customDDShim, #customDDOptions").live("mouseover", function(event, el) {
            neo.TopNavHover.customDDHandler(el);
        });
    },
    close: function(delay) {
        neo.TopNavHover.st = setTimeout(function() {
            jQuery(".topnav-hover-wrapper").removeClass("topnav-hover-active").css("visibility", "hidden");

            jQuery("#topNavigation li.js-topnav-hover-menu a, #topNavigation li.js-topnav-hover-nav a, #rightLinks li ul li a").each(function() {
                jQuery(this).removeClass("hover-white");
                if(jQuery(this).parent().hasClass("shop-cart-btn")){
                    SE.Shopping.initiateCartIcon();
                }                
                neo.Core.highlightTopNav("mouseout", jQuery(this));
            });

            //jQuery("#customDDShim, #customDDOptions").unbind("mouseover");
            neo.TopNavHover.curActive = "";
        }, delay);

    },
    highlightLink: function() {
        var llink = window.location;
        jQuery(".topnav-hover-wrapper").find("a").each(function() {
            if (llink.toString().indexOf(jQuery(this).attr("href")) != -1) {
                jQuery(this).parent().addClass("current-node");
                jQuery(this).bind("click", function() {
                    jQuery(this).blur();
                    return false;
                })
            }
        })
    },
    customDDHandler: function(el) {
        clearTimeout(neo.TopNavHover.st);
        jQuery(el).css({
            "visibility": "visible"
        });
    },
    addHoverDiv: function(id) {
        jQuery("body").not("body.popupLayout").append("<div class='topnav-hover-wrapper' id='" + id + "' class='cols_2'><div id='topnav-hover-inner'><div class='neoWrapper'><!-- --></div><span id='hoverMask'></span></div></div>");

        //Attach events
        jQuery("#" + id).unbind("mouseover").bind("mouseover", function(e) {
            clearTimeout(neo.TopNavHover.st);
            jQuery(this).css("visibility", "visible");
        });
        jQuery("#" + id).unbind("mouseleave").bind("mouseleave", function(e) {
            neo.TopNavHover.close(neo.TopNavHover.getCloseDelay(jQuery(this)));
        });
    },
	getCloseDelay: function(el){
		var isCartButton = jQuery(el).hasClass("shopContainer") || jQuery(el).parent().hasClass("shop-cart-btn");
		
		return isCartButton ? 5000 : 200;
	}
};

/*
 * Third level navigation Hover
 */
neo.SubNavHover = neo.SubNavHover ? neo.SubNavHover : new Object();
neo.SubNavHover = {
    prepare: function() {
        jQuery("#subsite-nav > li").bind("mouseover", function(event) {
            if (jQuery(this).find("ul").length > 0) {
                jQuery(this).find("ul").css("display", "block");
            }
            jQuery(this).addClass("hover");
        });
        jQuery("#subsite-nav > li").bind("mouseout", function(event) {
            jQuery(this).find("ul").css("display", "none");
            jQuery(this).removeClass("hover");
            jQuery(this).children("a").removeClass("down-arrow");
        });
        jQuery("#subsite-nav > li.js-hashover").each(function() {
            if (jQuery(this).find("ul").length > 0) {
                jQuery(this).children("a").append("<span class='down-arrow'><img src='/cws/images/spacer.gif' width='15' height='15' /></span>");
            }
        });
    }
};

/*
 * Auxlilary navigation
 */
SE.AuxiliaryNav = SE.AuxiliaryNav ? SE.AuxiliaryNav : new Object();
SE.AuxiliaryNav = {
    relatedConentTool: {
        name: "",
        init: function() {
            var _id = "#" + SE.AuxiliaryNav.relatedConentTool.name + "_hover";
            var _wrapper = jQuery(_id).find("#topnav-hover-inner").find(".neoWrapper");
            var _yuifirst;
            var _yuilast;
            jQuery(_wrapper).append("<div id=\"topnav-hover-splitter\" class=\"yui-ge columns-75-25 grid-row topnav-hover-splitter\"><div class=\"yui-u first\"></div><div class=\"yui-u last\"></div></div>");
            _yuifirst = jQuery(_wrapper).find(".yui-u.first");
            _yuilast = jQuery(_wrapper).find(".yui-u.last");

            if (jQuery(_wrapper).children("h2").length > 0)
                jQuery(_yuifirst).append(jQuery(_wrapper).children("h2"));
            if (jQuery(_wrapper).children("dl").length > 0)
                jQuery(_yuifirst).append(jQuery(_wrapper).children("dl"));
            if (jQuery(_wrapper).children("#nav-carousel").length > 0)
                jQuery(_yuilast).append(jQuery(_wrapper).children("#nav-carousel"));
        }
    },
    shopTool: {
        cartTimeoutTime: 0,
        cartTimeout: null,
        cartJson: {},
        create: function(){
            if (neo.Cookie.get("cwscartactivitytime") == null) {
                neo.Cookie.set("cwscartactivitytime", 0, "", "/", "", "");
            }
            if (neo.Cookie.get(neo.cc + neo.lc + "cwscart") == null) {
                neo.Cookie.set(neo.cc + neo.lc + "cwscart", " ", "", "/", "", "");
            }
            else {
                if (neo.Cookie.get(neo.cc + neo.lc + "cwscart").length > 1) {
                    this.cartJson = neo.Tools.evalString(neo.Cookie.get(neo.cc + neo.lc + "cwscart"));
                }
            }
            
            jQuery("body").trigger("onAddToCart");
        },
        add: function(item, description, type, qty){
            if (SE.Shopping.check() === true) {           
                this.update("add", item, description, type, qty);
                eshopAddToCartOmnitureStatistics(item);
            }
        },
        minus: function(item) {
            this.update("minus", item, "", "");
        },
        remove: function(item) {
            this.update("remove", item, "", "");
        },
        update: function(update, item, description, type, qty){
        
            if (neo.Cookie.get(neo.cc + neo.lc + "cwscart").length > 1) {
                this.cartJson = neo.Tools.evalString(neo.Cookie.get(neo.cc + neo.lc + "cwscart"));
            }
            
            if (update == "remove") {
                if (this.cartJson[item] != undefined) {
                    //this.cartJson[item] = null;
                    delete this.cartJson[item];
                }
            }
            else if (update == "add") {
                if (this.cartJson[item] == undefined) {
                    this.cartJson[item] = {};
                    this.cartJson[item].q = 0;
                    this.cartJson[item].desc = description;
                    this.cartJson[item].type = type;
                }
                this.cartJson[item].q += qty;
            }
            else if (update == "minus" && this.cartJson[item] != undefined) {
                if (this.cartJson[item].q > 0) {
                
                    this.cartJson[item].q -= qty;
                }
                else {
                    this.remove(item);
                }
            }
            
            this.setCartCookie();
            this.setCartActivity();
            
            jQuery("body").trigger("onAddToCart");
        },
        setCartCookie: function(){
            //stringify json
            var st = JSON.stringify(this.cartJson);
            //set cookie
            currentDate = new Date;
            currentDate.setDate(currentDate.getDate() + 365);
            var splitted = document.domain.split('.');
            var broken = splitted.slice(1, splitted.length);
            var domain_name = broken.join('.');
            neo.Cookie.set(neo.cc + neo.lc + "cwscart", st, currentDate, "/", domain_name, "");
        },
        updateDisplay: function(){
            var _html = "";
            var _carthtml = "";
            var j = SE.AuxiliaryNav.shopTool.cartJson;
            var _qn = 0;
            for (var x in j) {
                if (j[x].q > 0) {
                    _qn = _qn + j[x].q;
                }
            }
            jQuery("#rightLinks li ul li.shop-cart-btn").each(function(){
                jQuery(this).children("div.number").html(_qn);
                SE.Shopping.initiateCartIcon();
            });
        },
        bindEvents: function() {
            jQuery(".js-addToCart").unbind().bind("click", function() {
                var params = neo.Tools.evalString(jQuery(this).attr("params"));
                SE.AuxiliaryNav.shopTool.add(params.name, params.img, params.price);
                return false;
            });
            jQuery(".js-minusQ").unbind().bind("click", function() {
                var params = neo.Tools.evalString(jQuery(this).attr("params"));
                SE.AuxiliaryNav.shopTool.minus(params.name);
                return false;
            });
            jQuery(".js-removeFCart").unbind().bind("click", function() {
                var params = neo.Tools.evalString(jQuery(this).attr("params"));
                SE.AuxiliaryNav.shopTool.remove(params.guid);
                return false;
            });
        },
        setCartActivity: function() {
            var now = new Date();
            neo.Cookie.set("cwscartactivitytime", now.getTime(), "", "/", "", "");
           // this.setCartTimer();
        }
    }
};

/*
 * FaceBook widgets
 */
SE.FaceBook = SE.FaceBook ? SE.FaceBook : new Object();
SE.FaceBook = {
    values: {
        linkName: "",
        linkNameProduct: "",
        category: ""
    },
    parseFB: function(){
        if (typeof FB === "object") {
            FB.XFBML.parse();
        }
    },
    statisticsTracking: function(href){
        var linkName = this.values.linkName;
        var category = this.values.category;
        
        if (href.trim() == "http://www.facebook.com/sonyericsson") {
            if (typeof generateOmnitureStatForClick === "function") {
                generateOmnitureStatForClick(linkName, category, 'linkView');
            }
        }
        else {
            if (window.catalogue != undefined) {
                linkName = this.values.linkNameProduct + " : " + catalogue.ui.getProductNameForStatistics(href);
            }
            else 
                if (SE.products != undefined) {
                    linkName = this.values.linkNameProduct;
                }
            
            if (typeof generateOmnitureStatForClick2 === "function") {
                generateOmnitureStatForClick2(linkName, this.values.linkNameProduct);
            }
        }
    },
    add: function(elm, params){
        var type = params.type;
        switch (type) {
            case "like":
                jQuery(elm).html('<fb:like href="' + params.href + '" width="' + params.width + '" height="' + params.height + '" show_faces="' + params.faces + '" font="arial"></fb:like>');
                break;
            default:
            //
        }
        this.parseFB();
    }
};

SE.Paging = function(list, itemsPerPage, pagingContainer) {
    this.list = list;
    this.records = this.list.length;
    this.itemsPerPage = itemsPerPage;
    this.pagingContainer = pagingContainer;
    this.pages = 0;
    this.currentPage = 1;
    this.pagingSet = {};
    this.animate = false;

    /**
     *
     * @param {Object} pageNumber
     */
    this.init = function(pageNumber) {
        //Hide all records
        $(this.list).hide();

        //Calculate number of pages available
        this.pages = Math.ceil(this.records / this.itemsPerPage);

        //Generate paging set
        var fromIndex = 0;
        var toIndex = 0;
        for (var x = 1; x <= this.pages; x++) {
            toIndex = (x == this.pages) ? this.records - 1 : fromIndex + (this.itemsPerPage - 1);
            this.pagingSet[x] = [fromIndex, toIndex];
            fromIndex = toIndex + 1;
        }

        //Store paging object
        $(this.pagingContainer).data("pagingObj", this);

        //Bind event - next link
        $(this.pagingContainer).find("a.paging-next").click(function() {
            $(this).parent().data("pagingObj").next();
        });

        //Bind event - previous link
        $(this.pagingContainer).find("a.paging-previous").click(function() {
            $(this).parent().data("pagingObj").previous();
        });

        this.showPage(pageNumber);
    };

    /**
     *
     * @param {Object} pageNumber
     */
    this.showPage = function(pageNumber) {
        if (this.animate) {
            $(this.list).fadeIn("slow");
        }
        $(this.list).hide();
        for (var x = this.pagingSet[pageNumber][0]; x <= (this.records > this.pagingSet[pageNumber][1] ? this.pagingSet[pageNumber][1] : this.records - 1); x++) {
            $($(this.list).get(x)).show();
        }
        this.currentPage = pageNumber;
        this.showRecords();
        this.updateNav();
    };
    this.next = function() {
        if (this.hasNext()) {
            this.showPage(this.currentPage + 1);
        }
    };
    this.previous = function() {
        if (this.hasPrevious()) {
            this.showPage(this.currentPage - 1);
        }
    };
    this.hasNext = function() {
        return (this.currentPage < this.pages);
    };
    this.hasPrevious = function() {
        return (this.currentPage > 1);
    };
    /**
     * Update ui
     */

    this.showRecords = function() {
        $(this.pagingContainer).find("span").html((this.pagingSet[this.currentPage][0] + 1) + " - " + (this.records < this.itemsPerPage ? this.records : (this.pagingSet[this.currentPage][1] + 1)) + "&nbsp;" + ((SE.textResource.of != undefined) ? SE.textResource.of : "of") + "&nbsp;" + this.records + "&nbsp;")
    };
    this.updateNav = function() {
        this.hasNext() ? $(this.pagingContainer).find("a.paging-next").show() : $(this.pagingContainer).find("a.paging-next").hide();
        this.hasPrevious() ? $(this.pagingContainer).find("a.paging-previous").show() : $(this.pagingContainer).find("a.paging-previous").hide();
    }
};

/**
 * Lazy loading of images
 * Picks images with class 'lazy-load'
 * URL of images should be set in 'url' attribute
 * 'src' attribute should not be set
 */
SE.LazyLoad = SE.LazyLoad ? SE.LazyLoad : new Object();
SE.LazyLoad = {
    timeout:null,
    init: function() {
        jQuery(window).scroll(function() {
            clearTimeout(SE.LazyLoad.timeout);
            SE.LazyLoad.timeout = setTimeout("SE.LazyLoad.check()", 500);
        });
        SE.LazyLoad.check();
    },
    check: function() {
        jQuery("img.lazy-load").each(function() {
            if (SE.LazyLoad.isSeen(jQuery(this))) {
                jQuery(this).load(function(e) {
                    jQuery(e.target).ifixpng();
                });
                jQuery(this).attr("src", jQuery(this).attr("url")).removeAttr("url").removeClass("lazy-load");
            }
        });
    },
    isSeen: function(elm) {
        if (jQuery(window).scrollTop() + jQuery(window).height() > jQuery(elm).offset().top && jQuery(elm).offset().top > jQuery(window).scrollTop()) {
            return true;
        } else {
            return false;
        }
    }
};



// Set GLOBAL params
neo.cc = neo.Tools.getParam("cc");
neo.lc = neo.Tools.getParam("lc");
neo.isRtl = neo.Core.isRtlLanguage();

// Document onload functions
jQuery(document).ready(function(){
    //Register events
    jQuery("body").bind("onJSTabLoad", neo.JSTabs.onLoadHandler);
    jQuery("body").bind("onAddToCart", SE.AuxiliaryNav.shopTool.updateDisplay);
    
    //Prepare
    neo.Core.prepareHeaderFooter();
    neo.Core.preparePage();
});


//Creating list of products in second level media library
SE.corporateZone = {
    formGroup: function() {
        jQuery("ul#productList > li").hide();
        var alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
        var items = SE.corporateZone.checkAvialable();
        jQuery("ul#productList").attr("rel", items.toString());
        for (var i = 0; i < alphabets.length; i++) {
            if (i == 0) {
                jQuery('<span style="float: left; color: #65BB10; font-weight: bold;">Jump To:</span> <ul id="alphabets"></ul><span style="float: left; margin-left: 0; color: #65BB10; font-weight: bold;" class="nav-links"><a href="javascript: void(0)" id="back" style="background:transparent url(/cws/images/bronze/link_arrow_small_lime_rtl.gif) no-repeat scroll left center; padding-left: 10px;">back</a> | <a href="javascript: void(0)" id="next" class="more-arrow-small">next</a></span>').insertAfter("ul#productList");
            }
            if ((jQuery("ul#productList").attr("rel")).indexOf(alphabets[i]) > -1) {
                jQuery("ul#alphabets").append('<li><a href="javascript: void(0)">' + alphabets[i] + '</a></li>');
            }
            else {
                jQuery("ul#alphabets").append('<li><span>' + alphabets[i] + '</span></li>');
            }
        }

        jQuery("#back").css({
            "visibility": "hidden"
        });
        var firstElem = SE.corporateZone.checkFirstElem();
        SE.corporateZone.showGroup(firstElem);
    },
    showGroup: function(obj) {
        jQuery("li > a", jQuery(obj).parents("ul")).each(function() {
            jQuery(this).css({
                "text-decoration": "none",
                "cursor": "pointer"
            });
            jQuery(this).bind("click", function() {
                SE.corporateZone.showGroup(this);
                jQuery().scrollTo(300, 600)
            });
        });
        jQuery(obj).css({
            "text-decoration": "underline",
            "cursor": "default"
        }).unbind("click");
        var alpha = (jQuery(obj).text()).substr(0, 1).toLowerCase();
        window.location.hash = alpha;
        jQuery("ul#productList > li").each(function() {
            var textVal = jQuery(this).text();
            var initialAlpha = textVal.substr(0, 1).toLowerCase();
            if (initialAlpha == alpha) {
                jQuery(this).show("fast");
            }
            else
                jQuery(this).hide();
        });

        if ((jQuery("ul#productList").attr("rel")).charAt((jQuery("ul#productList").attr("rel").indexOf(alpha)) - 2) == "") {
            jQuery("#back").css({
                "visibility": "hidden"
            });
        }
        else {
            jQuery("#back").css({
                "visibility": "visible"
            });
        }

        if ((jQuery("ul#productList").attr("rel")).charAt((jQuery("ul#productList").attr("rel").indexOf(alpha)) + 2) == "") {
            jQuery("#next").css({
                "visibility": "hidden"
            });
        }
        else {
            jQuery("#next").css({
                "visibility": "visible"
            });
        }

        jQuery("#next, #back").unbind("click").bind("click", function() {
            SE.corporateZone.navEvents(alpha, this)
        });
    },
    checkAvialable: function() {
        var containingAlpha = [];
        var arrayForSort = [];
        var temp;
        jQuery("ul#productList").parents(".product-phone.media-library-second-level").css("height", "auto");
        jQuery("ul#productList > li").each(function() {
            arrayForSort.push(jQuery(this).text());
        });
        arrayForSort = arrayForSort.sort();
        for (var k = 0; k < arrayForSort.length; k++) {
            var textVal = arrayForSort[k];
            var initialAlpha = textVal.substr(0, 1).toLowerCase();
            if (initialAlpha != temp) {
                containingAlpha.push(initialAlpha);
                temp = initialAlpha;
            }
        }
        return containingAlpha;
    },
    navEvents: function(currentAlpha, obj) {
        jQuery().scrollTo(300, 600);
        var jumpAlpha;
        if (jQuery(obj).attr("id") == "back") {
            jumpAlpha = (jQuery("ul#productList").attr("rel")).charAt((jQuery("ul#productList").attr("rel").indexOf(currentAlpha)) - 2);
            if ((jQuery("ul#productList").attr("rel")).charAt((jQuery("ul#productList").attr("rel").indexOf(jumpAlpha)) - 2) == "") {
                jQuery(obj).css({
                    "visibility": "hidden"
                });
            }
            else {
                jQuery(obj).css({
                    "visibility": "visible"
                });
                jQuery("#next").css({
                    "visibility": "visible"
                });
            }

        }
        else {
            jumpAlpha = (jQuery("ul#productList").attr("rel")).charAt((jQuery("ul#productList").attr("rel").indexOf(currentAlpha)) + 2);
            if ((jQuery("ul#productList").attr("rel")).charAt((jQuery("ul#productList").attr("rel").indexOf(jumpAlpha)) + 2) == "") {
                jQuery(obj).css({
                    "visibility": "hidden"
                });
            }
            else {
                jQuery(obj).css({
                    "visibility": "visible"
                });
                jQuery("#back").css({
                    "visibility": "visible"
                });
            }

        }
        jQuery("#alphabets li").each(function() {
            if (jQuery(this).text() == jumpAlpha) {
                jQuery("a", jQuery(this)).trigger("click");
            }
        });
    },
    checkFirstElem: function(){
        var urlAlpha = window.location.hash.substr(1, 1);
        if (urlAlpha != "") {
            for (var i = 0; i < jQuery("#alphabets li").length; i++) {
                if (jQuery(jQuery("#alphabets li").get(i).childNodes[0]).text() == urlAlpha) 
                    return jQuery("#alphabets li").get(i).childNodes[0];
            }
        }
        else {
            for (var i = 0; i < jQuery("#alphabets li").length; i++) {
                if (jQuery("#alphabets li").get(i).childNodes[0].nodeName.toLowerCase() === "a") 
                    return jQuery("#alphabets li").get(i).childNodes[0];
            }
        }
    }
};

//Deprecated
//Use instead neo.Core.fixPng()
function enablePngImages(method){
    method = method || 'auto';
    if (jQuery.browser.msie) 
        if (parseInt(jQuery.browser.version, 10) < 7) {
            jQuery("img").each(function(){
                if (isPng(this.src)) {
                    jQuery(this).css({
                        "filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='" + method + "')"
                    });
                    this.src = "/cws/images/cws/see_the_phone_spacer.gif";
                }
            });
        }
}

function isPng(imgUrl){
    return imgUrl.toLowerCase().lastIndexOf(".png") != -1 || imgUrl.toLowerCase().lastIndexOf("format=png") != -1;
}

//Deprecated
//Use instead neo.Theme.setRandom()
function switchAltBrandStyles(){
    neo.Theme.setRandom();
}

//Deprecated
//Use instead neo.Theme.hasTheme()
function hasBrandStyleClass(){
    return neo.Theme.hasTheme();
}

//Deprecated
//Use instead neo.Theme.currentTheme()
function getBrandStyleClass(){
    return neo.Theme.currentTheme();
}

//Deprecated
//Use instead neo.openLayer()
function openLayer(href, width, height, name, chromeless, type){
    neo.openLayer(href, width, height, name, chromeless, type);
}

//Deprecated
//Use instead neo.Tools.getParam()
function getParam(paramName){
    return neo.Tools.getParam(paramName);
}

//Deprecated
//Use instead neo.isRtl
function isRtl(){
    return neo.isRtl;
}

//Intergrated Shopping
var recommendedValue="";
SE.Shopping = SE.Shopping ? SE.Shopping : new Object();
SE.Shopping = {
    fallBackUrl:"",
    fromFallBack:false, 
	getSalesItemsDone: false,
	getRecommendedItemsDone: false,
    setfallBackOptions: function(buyNowUrl){
        fallBackUrl = buyNowUrl;
        fromFallBack = true;
    },
    setEshopBackOptions: function(){
        fromFallBack = false;
    },
    buyNowDeliveryOption: function(data){
        var _html = "";
        jQuery.each(data.storeInfo.deliveryMethods, function(i, val){
            var split_val = val.deliveryName.split(":");
            var deliveryName = split_val[0] + "<br />" + split_val[1];
            var deliveryNameAndCost = "<li>" + deliveryName + " " + val.deliveryCost + "</li>";
            _html += deliveryNameAndCost;
        });
        jQuery("#deliveryOption").html(_html);
    },
    buyNowSalesItemInfo: function(data){
        if (data.salesItems.length > 0) {
            if (fromFallBack == true) {
                var splitCurrentUrl = fallBackUrl.split("?");
                var finalfallBackUrl = new neo.URL(splitCurrentUrl[0]);
                finalfallBackUrl.append({
                    "cc": neo.cc,
                    "lc": neo.lc
                });
                jQuery("#js-buy_now a").attr("href", finalfallBackUrl).trigger("click");
                fromFallBack = false;
            }
            else {
                SE.Shopping.getSalesItems(data);
            }
        }
        else {
            jQuery("#fallBackDiv").css({
                "display": "block"
            });
            
            if (typeof statForPHPTabView === "function") {
                statForPHPTabView();
            }
        }
    },
    getSalesItems: function(data){
        if (data.salesItems != undefined && data.salesItems.length > 0) {
            recommendedValue = data.recommendationSetId;
            var featuredProductHTML = "";
            var _html = "";
            jQuery.each(data.salesItems, function(i, val){
                if (i == 0) {
                    featuredProductHTML += "<div class='buy-now-product-beauty-shot'><img class='product-image' src=" + val.imageFeatureUrl + "></div>";
                    featuredProductHTML += "<div class='buy-now-product-information'>";
                    featuredProductHTML += "<h2><div class='title' style='display:inline'>" + val.title + "</div>";
                    if (val.strikeThroughPrice) {
                        featuredProductHTML += "<strong><span>" + onSale + "</span></strong>";
                    }
                    featuredProductHTML += "</h2><p>" + val.description + "</p>";
                    featuredProductHTML += "<div class='bn-buy-now-product-box'><p class='bn-buy-now-product-box-title'><strong>" + whatInBox + "</strong></p><ul>" + SE.Shopping.getWhatInTheBox(val.inTheBox) + "</ul></div><div class='clear-both'></div>";
                    featuredProductHTML += "</div>";
                    
                    featuredProductHTML += "<div class='buy-now-promoted-price-holder'>";
                    featuredProductHTML += "<strong>" + buyIt + "</strong>";
                    
                    featuredProductHTML += "<div class='bn-price'>" + SE.Shopping.splitPriceInfo(val.priceWithCurrency) + "<span class='additional-info'>";
                    if (val.strikeThroughPrice) {
                        featuredProductHTML += "<span class='original-price'>" + was + " <strike> " + val.strikeThroughPrice + " </strike></span>&nbsp;";
                    }
                    featuredProductHTML += " (" + addInfo + ") </span></div>";
                    featuredProductHTML += "<p class='bn-product-status'>" + dispatchDuration + "</p>";
                    featuredProductHTML += "<ul class='bn-cart-actions'><li class='quantity'>" + qty + "</li><li class='minus disabled'><a href='javascript:void(0)'></a></li><li class='quantity-field'><input type='text' value='1' readonly='readonly' /></li><li class='plus'><a href='javascript:void(0)'></a></li><li class='add-to-cart'><a href='javascript:void(0)' class='ctaPrimary' rel='add-to-cart' id='" + val.code + "' ><span>" + addToCart + "</span></a></li></ul></div><div class='buy-now-promoted-image-holder'></div>";
                }
                else {
                    jQuery(".bn-recommendations-header").show();
                    _html += "<div id=product" + i + " class='bn-other-package'>";
                    _html += "<div class='bn-other-package-bs'><img class='product-image' src=" + val.imageUrl + "></div>";
                    _html += "<h2><div class='title' style='display:inline'>" + val.title + "</div>";
                    if (val.strikeThroughPrice) {
                        _html += "<strong><span>" + onSale + "</span></strong>";
                    }
                    _html += "</h2><p>" + val.description + "</p>";
                    _html += "<div class='bn-buy-now-product-box'>";
                    _html += "<p class='bn-buy-now-product-box-title'><strong>" + whatInBox + "</strong></p><ul>" + SE.Shopping.getWhatInTheBox(val.inTheBox) + "</ul></div>";
                    _html += "<div class='buy-now-promoted-price-holder'>";
                    _html += "<strong>" + buyIt + "</strong>";
                    _html += "<div class='bn-price'>" + SE.Shopping.splitPriceInfo(val.priceWithCurrency) + "<span class='additional-info'>";
                    if (val.strikeThroughPrice) {
                        _html += "<span class='original-price'>" + was + " <strike> " + val.strikeThroughPrice + " </strike></span>&nbsp;";
                    }
                    _html += " (" + addInfo + ") </span></div>";
                    _html += "<p class='bn-product-status'>" + dispatchDuration + "</p>";
                    _html += "<ul class='bn-cart-actions'><li class='quantity'>" + qty + "</li><li class='minus disabled'><a href='javascript:void(0)'></a></li><li class='quantity-field'><input type='text' value='1' readonly='readonly' /></li><li class='plus'><a href=''></a></li><li class='add-to-cart'><a href='javascript:void(0)' class='ctaPrimary' id='" + val.code + "' ><span>" + addToCart + "</span></a></li></ul></div><div class='clear-both'></div>";
                    _html += "</div>";
                    
                }
            });
            jQuery("#buy-now-promoted").append(featuredProductHTML);
            jQuery("#product-listing").html(_html);
            
            if (recommendedValue != "") {
                var newURL = getSalesItemUrl + recommendedValue + "&callback=SE.Shopping.getRecommendedItems";
                var elm = document.getElementById("recommendedUrlContainer");
                var ds = new neo.DynamicScript(newURL);
                ds.add(elm);
            }
            else {
                BuyNowExtrasPresenter.setup();
                cart.init();
            }
        }
        else {
            jQuery("#out-of-stock").show();
        }
		
		this.getSalesItemsDone = true;
    },
    getRecommendedItems: function(data){
        if (data.salesItems != undefined && data.salesItems.length > 0) {
            jQuery('.bn-recommendations-extras-header').show();
            jQuery('.bn-extras-carousel').show();
            var cnt = 1;
            var dataArr = data.salesItems;
            for (x = 0; x < dataArr.length; x = x + 3) {
                var div = jQuery("<div class='page-content-" + cnt + "'>").appendTo('.bn-extras-carousel-content');
                div.append(SE.Shopping.buyNowGetSIs(data, x));
                cnt++;
            }

           if (jQuery(".page-content-2").length >= 0) {
                jQuery(".page-content-1").attr('rel', 'active');
			}
			if (jQuery(".page-content-2").length == 0) {
         		jQuery(".bn-extras-carousel").addClass("scrollLock")
            }

            BuyNowExtrasPresenter.setup();
            cart.init();
        }
        else {
            BuyNowExtrasPresenter.setup();
            cart.init();
            jQuery(".bn-recommendations-extras-header").css({
                "display": "none"
            })
            jQuery(".bn-extras-carousel").hide();
        }
		
		this.getRecommendedItemsDone = true;
    },
    buyNowGetSIs: function(data, from){
        var _html = "<ul>";
        var to = from + 2;
        for (var x = from; x <= to; x++) {
            if (x > data.salesItems.length - 1) {
                break;
            }
            else {
                var node = data.salesItems[x];
                var _target_url = SE.Shopping.fetchTargetUrl(node.cwsExternalId);
                _html += "<li class='bn-extras-carousel-item'  id='bn-extras-carousel-item" + x + "'>";
                _html += "<span class='imgContainer'><img class='product-image' src=" + node.imageUrl + " alt=''/></span>";
                _html += "<h3><a href='" + _target_url + "'>" + node.title + "</a></h3>";
                _html += "<p class='description'>" + (node.description).cut(103, '...<a href="' + _target_url + '">' + readMore + '</a>') + "</p>";
                _html += "<p class='bn-price'>" + SE.Shopping.splitPriceInfo(node.priceWithCurrency) + "<span class='additional-info'> (" + addInfo + ") </span></p>";
                _html += "<p class='add-to-cart recommendedExtras'><a id='" + node.code + "'class='ctaPrimary' href='javascript:void(0)'><span>" + addToCart + "</span></a></p>";
                _html += "</li>";
                _html += "<li class='dividers'></li>";
            }
        }
        return _html + "</ul>";
    },
    price: function(str){
        var p = {};
        var splitter = ".";
        if (str.match(",")) {
            splitter = ",";
        }
        var patt1 = /(\d+)+(.)+(\d+)|(\d+)+(,)+(\d+)|(\d+)/g;
        var numericVal = str.match(patt1);
        var newNumericValue = numericVal.toString();
        newNumericValue = newNumericValue.split(splitter);
        if (newNumericValue[1] == undefined) {
            newNumericValue[1] = "00";
        }
        var currencySigns = str.split(numericVal);
        
        p.amount = newNumericValue[0];
        p.decimal = newNumericValue[1];
        p.sign1 = currencySigns[0];
        p.sign2 = currencySigns[1];
        p.splitter = splitter;
        
        return p;
    },
    splitPriceInfo: function(str, type, star){
        var finalValue = "";
        var _star = star ? "*" : "";
        var p = this.price(str.trim());
        
        if (!SE.isBlank(type) && type == "one") {
            finalValue = "<sup>" + p.sign1 + "</sup>" + p.amount + "<sup>" + p.splitter + p.decimal + _star + p.sign2 + "</sup>";
        }
        else {
            finalValue = "<span class='currency'>" + p.sign1 + "</span><em>" + p.amount + "</em><span class='currency'>" + p.splitter + p.decimal + _star + p.sign2 + "</span>";
        }
        return finalValue;
    },
    productsFromPriceListing: function(data){
        jQuery.each(data.productsFromPriceListing, function(i, val){
            var id = val.cwsExternalId.toLowerCase().replace(/\./gi, "-");
            if ((jQuery("." + id).length) > 0) {
                var from = "";
                if ((jQuery("#product-list").length) > 0) {
                    url = jQuery("." + id).find(".action-button a").attr("href");
                    url = url.replace("=overview", "=buy_now");
                    var buyNowLink = "<a class='js-buy-now' href='" + url + "'>" + SE.textResource.buyNow + "</a>"
                }
                else {
                    var buyNowLink = "";
                    if ((jQuery("#compatible-accessories").length) > 0) {
                        from = "<span>" + SE.textResource.from + " </span>";
                    }
                }
                
                jQuery("." + id).find(".info-box-inner").html("<strong>" + from + SE.Shopping.splitPriceInfo(val.fromPriceWithCurrency, "one", true) + "</strong>" + buyNowLink);
            }
        });
    },
    check: function(){
        var cookieEnabled = (navigator.cookieEnabled) ? true : false;
        if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
            document.cookie = "gotCookies";
            cookieEnabled = (document.cookie.indexOf("gotCookies") != -1) ? true : false;
        }
        return (cookieEnabled);
    },
    initiateCartIcon: function(){
        var itemCount = jQuery(".shop-cart-btn").children("div.number").html(),
			container = jQuery(".shopContainer"),
			btn = jQuery(".shop-cart-btn");
			btn.children("span").css("cursor", "pointer");			
        if (itemCount == 0) {
            //jQuery(".shop-cart-btn").children("a").removeClass("hover-white");
            btn.children("div.number").hide();
            container.find("#emptyCart").show();
            container.find("#qtyCart").hide();
			btn.children("span").css("cursor", "auto");
        }
        else if (itemCount == 1) {
            btn.children("a").addClass("hover-white")
            btn.children("div").addClass("number").show();
            container.find("#emptyCart").hide();
            container.find("#qtyCart").show().children("span.qtyCount").html(itemCount);
            container.find(".qtyItem").show();
            container.find(".qtyItems").hide();
        }
        else if ((itemCount >= 2) && (itemCount <= 99)) {
            btn.children("a").addClass("hover-white")
            btn.children("div").addClass("number").show();
            container.find("#emptyCart").hide();
            container.find("#qtyCart").show().children("span.qtyCount").html(itemCount);
            container.find(".qtyItem").hide();
            container.find(".qtyItems").show();
        }
        else if (itemCount >= 100) {
            btn.children("a").addClass("hover-white")
            btn.children("div.number").hide();
            container.find("#emptyCart").hide();
            container.find("#qtyCart").show().children("span.qtyCount").html("");
            container.find(".qtyItem").hide();
            container.find(".qtyItems").show();
        }
    },
    fetchTargetUrl: function(externalId){
        var targetUrl = "";
        var url = new neo.URL("/cws/common/urlgenerator");
        url.append({
            "cc": neo.cc,
            "lc": neo.lc,
            "externalId": externalId
        });
        jQuery.ajax({
            type: "GET",
            async: false,
            url: url.toString(),
            beforeSend: function(){
            },
            success: function(xml){
                targetUrl = xml.toString();
            }
        });
        return targetUrl;
    },
    ctaCheckout: function(){
        var frm = document.getElementById("CTA_frm");
        var a_div = document.getElementById("CTA_div");
        var t = "";
        if (neo.Cookie.get(neo.cc + neo.lc + "cwscart") != null && neo.Cookie.get(neo.cc + neo.lc + "cwscart") != "") {
            var j = neo.Tools.evalString(neo.Cookie.get(neo.cc + neo.lc + "cwscart"));
            for (var x in j) {
                if (j[x].q > 0) {
                    t = t + "<input type='hidden' name='sku' value='" + x + ":" + j[x].q + "'>";
                }
            }
        }
        a_div.innerHTML = t;
        frm.submit();
    },
    initiateCheckout: function(){
        var frm = document.getElementById("shopping_cart_frm");
        var a_div = document.getElementById("sku_div");
        var t = "";
        if (neo.Cookie.get(neo.cc + neo.lc + "cwscart") != null && neo.Cookie.get(neo.cc + neo.lc + "cwscart") != "") {
            var j = neo.Tools.evalString(neo.Cookie.get(neo.cc + neo.lc + "cwscart"));
            for (var x in j) {
                if (j[x].q > 0) {
                    t = t + "<input type='hidden' name='sku' value='" + x + ":" + j[x].q + "'>";
                }
            }
            a_div.innerHTML = t;
            frm.submit();
        }
    },
    scrollToSupportModule: function(){
        var offset = jQuery("#bn-support-module").offset();
        window.scrollTo(0, offset.top - 50);
    },
    getWhatInTheBox: function(str){
        var _htmlLeftSide = "<ul class='buy-now-package-contents'>"
        var _htmlRightSide = "<ul class='buy-now-package-contents-right'>"
        var newStr = str.split("|");
        for (i = 0; i < newStr.length; i++) {
            if (i % 2 == 0) {
                _htmlLeftSide += "<li>" + newStr[i] + "</li>"
            }
            else {
                _htmlRightSide += "<li>" + newStr[i] + "</li>"
            }
        }
        _htmlLeftSide = _htmlLeftSide + "</ul>"
        _htmlRightSide = _htmlRightSide + "</ul>"
        var _html = _htmlLeftSide + _htmlRightSide;
        return _html;
    }
}

