/* SWFObject v2.2 <http://code.google.com/p/swfobject/> is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> */
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();

if(typeof com=="undefined"){var com=new Object();}if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.createElement||!document.getElementById){return;}this.DETECT_KEY=_b?_b:"detectflash";this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();this.useExpressInstall=_7;if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);if(c){this.addParam("bgcolor",c);}var q=_8?_8:"high";this.addParam("quality",q);var _d=(_9)?_9:window.location;this.setAttribute("xiRedirectUrl",_d);this.setAttribute("redirectUrl","");if(_a){this.setAttribute("redirectUrl",_a);}};com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},createParamTag:function(n,v){var p=document.createElement("param");p.setAttribute("name",n);p.setAttribute("value",v);return p;},getVariablePairs:function(){var _19=new Array();var key;var _1b=this.getVariables();for(key in _1b){_19.push(key+"="+_1b[key]);}return _19;},getFlashHTML:function(){var _1c="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}_1c="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";_1c+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1d=this.getParams();_1d["instanceOf"]=null;for(var key in _1d){_1c+=[key]+"=\""+_1d[key]+"\" ";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_1c+="flashvars=\""+_1f+"\"";}_1c+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}_1c="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";_1c+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _20=this.getParams();for(var key in _20){_1c+="<param name=\""+key+"\" value=\""+_20[key]+"\" />";}var _22=this.getVariablePairs().join("&");if(_22.length>0){_1c+="<param name=\"flashvars\" value=\""+_22+"\" />";}_1c+="</object>";}return _1c;},write:function(_23){if(this.useExpressInstall){var _24=new com.deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}else{this.setAttribute("doExpressInstall",false);}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _23=="string")?document.getElementById(_23):_23;if(typeof n!='undefined'){n.innerHTML=this.getFlashHTML();}else{document.writeln(this.getFlashHTML());}}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};function tiiVBGetFlashVersionExists(){var result=true;try{var dontcare=tiiVBGetFlashVersion(3);}catch(e){result=false}return result;}com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){var _28=new com.deconcept.PlayerVersion(0,0,0);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_28=new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{try{if(!tiiVBGetFlashVersionExists()){var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");for(var i=3;axo!=null;i++){axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);_28=new com.deconcept.PlayerVersion([i,0,0]);}}else{var versionStr="";for(var i=25;i>0;i--){var tempStr=tiiVBGetFlashVersion(i);if(tempStr!=""){versionStr=tempStr;break;}}if(versionStr!=""){var splits=versionStr.split(" ");var splits2=splits[1].split(",");_28=new com.deconcept.PlayerVersion([splits2[0],splits2[1],splits2[2]]);}}}catch(e){}if(_26&&_28.major>_26.major){return _28;}if(!_26||((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major)||_28.major!=6||_27){try{_28=new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}catch(e){}}}return _28;};com.deconcept.PlayerVersion=function(_2c){this.major=parseInt(_2c[0])||0;this.minor=parseInt(_2c[1])||0;this.rev=parseInt(_2c[2])||0;};com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};com.deconcept.util={getRequestParameter:function(_2e){var q=document.location.search||document.location.hash;if(q){var _30=q.indexOf(_2e+"=");var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;if(q.length>1&&_30>-1){return q.substring(q.indexOf("=",_30)+1,_31);}}return"";},removeChildren:function(n){while(n.hasChildNodes()){n.removeChild(n.firstChild);}}};if(Array.prototype.push==null){Array.prototype.push=function(_33){this[this.length]=_33;return this.length;};}var getQueryParamValue=com.deconcept.util.getRequestParameter;var SWFObject=com.deconcept.FlashObject;var PlayerVersion=com.deconcept.PlayerVersion;

// fixes IE background flickering
try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}

// ### Array Helper Functions ###

function tiiArrayContains (array, value) {
    if (array != null) {
        var al = array.length;
        for (var i = 0; i < al; i++) {
            if (array[i] == value) return true;
        }
    }
    return false;
}

// ### Key=Value; Functions ###

function tiiHashKeys(string) {
    var keys = null;
    if (string != null) {
        var hash = string.split(';');
        var hl = hash.length - 1;
        if(hl > 0){
            keys = new Array();
            for(var i = 0; i < hl; i++){
                var data = hash[i].split('=');
                keys[i] = data[0].replace(' ', '');
            }
        }
    }
    return keys;
}

function tiiHashGet(string, key) {
    var value = null;
    if (string != null) {
        var keyStart = key + '=';
        var offset = string.indexOf(keyStart);
        if (offset != -1) {
            offset += keyStart.length;
            var end = string.indexOf(';', offset);
            if (end == -1) {
                end = string.length;
            }
            value = string.substring(offset, end);
        }
    }
    return value;
}

function tiiHashSet(string, key, value) {
    var string = tiiHashDelete(string, key);
    var newValue = key + '=' + value + ';';
    if (string != null) newValue = newValue + string;
    return newValue;
}

function tiiHashDelete(string, key) {
    var oldValue = tiiHashGet(string, key);
    var newString = string;
    if (oldValue != null) {
        var search = key + '=';
        var start = string.indexOf(search);
        var offset = start + search.length;
        var end = string.indexOf(';', offset) + 1;
        if (end == -1) end = string.length;
        newString = string.slice(0,start) + string.slice(end,string.length);
        return newString;

    }
    return newString;
}

function tiiGetQueryParamValue(param) {
    var startIndex;
    var endIndex;
    var valueStart;

    var qs = document.location.search;
    var detectIndex = qs.indexOf( "?" + param + "=" );
    var detectIndex2 = qs.indexOf( "&" + param + "=" );
    var key = "&" + param + "=";
    var keylen = key.length;

    if (qs.length > 1) {
        if (detectIndex != -1) {
            startIndex = detectIndex;
        } else if (detectIndex2 != -1) {
            startIndex = detectIndex2;
        } else {
            return null;
        }

        valueStart = startIndex + keylen;

        if (qs.indexOf("&", valueStart) != -1) {
            endIndex = qs.indexOf("&", startIndex + 1)
        } else {
            endIndex = qs.length
        }

        return (qs.substring(qs.indexOf("=", startIndex) + 1, endIndex));
    }

    return null;
}

// ### Date/Time Functions ###

function tiiDateGetOffsetMinutes(minutes)	{ var today = new Date(); return today.getTime() + (60000) * minutes;}
function tiiDateGetOffsetHours(hours)		{ var today = new Date(); return today.getTime() + (3600000) * hours; }
function tiiDateGetOffsetDays(days)			{ var today = new Date(); return today.getTime() + (86400000) * days; }
function tiiDateGetOffsetWeeks(weeks)		{ var today = new Date(); return today.getTime() + (604800000) * weeks; }
function tiiDateGetOffsetMonths(months)		{ var today = new Date(); return today.getTime() + (259200000) * months; }
function tiiDateGetOffsetYears(years)		{ var today = new Date(); return today.getTime() + (31536000000) * years; }
// ### Core Cookie Functions ###

function tiiCookieExists(cookieName) {
    return tiiArrayContains(tiiCookieGet(), cookieName);
}

function tiiCookieGet(cookieName) {
    if (arguments.length == 0) {
        return tiiHashKeys(document.cookie);
    }

    var cookie = tiiHashGet(document.cookie, cookieName);
    if (cookie != null) cookie = unescape(cookie);
    return cookie;
}

function tiiCookieSet(cookieName, cookieValue, domain, path, expires, secure) {
    if (expires != null) {
        expire_date = new Date();
        expire_date.setTime(expires);
    }
    var curCookie = cookieName + '=' + escape(cookieValue)
        + ((expires) ? '; expires=' + expire_date.toGMTString() : '')
        + ((path) ? '; path=' + path : '')
        + ((domain) ? '; domain=' + domain : '')
        + ((secure) ? '; secure' : '');
    document.cookie = curCookie;
}

function tiiCookieSetUnescape(cookieName, cookieValue, domain, path, expires, secure) {
    if (expires != null) {
        expire_date = new Date();
        expire_date.setTime(expires);
    }
    var curCookie = cookieName + '=' + cookieValue
        + ((expires) ? '; expires=' + expire_date.toGMTString() : '')
        + ((path) ? '; path=' + path : '')
        + ((domain) ? '; domain=' + domain : '')
        + ((secure) ? '; secure' : '');
    document.cookie = curCookie;
}

function tiiCookieDelete(cookieName) {
    tiiCookieSet(cookieName, null, null, null, '', 0);
}

// ### Core Chip Functions ###
function tiiCookieChipGet(cookieName, chipName) {
    if (arguments.length == 1) {
        return tiiHashKeys(tiiCookieGet(cookieName));
    }
    return tiiHashGet(tiiCookieGet(cookieName), chipName);
}

function tiiCookieChipSet(cookieName, chipName, chipValue, domain, path, expire, secure) {
    var new_cookieValue = tiiHashSet(tiiCookieGet(cookieName), chipName, chipValue);
    tiiCookieSet(cookieName, new_cookieValue, domain, path, expire, secure);
}

function tiiCookieChipDelete(cookieName, chipName, domain, path, expire, secure) {
    var new_cookieValue = tiiHashDelete(tiiCookieGet(cookieName), chipName);
    if (new_cookieValue == null) new_cookieValue = '';
    tiiCookieSet(cookieName, new_cookieValue, domain, path, expire, secure);
}

// ### Permanent Cookie/Chip Functions ###
function tiiPermCookieChipGet(chipName) {
    return tiiCookieChipGet('tii_perm', chipName);
}

function tiiPermCookieChipSet(chipName, chipValue) {
    tiiCookieChipSet('tii_perm', chipName, chipValue, null, '/', tiiDateGetOffsetYears(2), 0);
}

function tiiPermCookieChipDelete(chipName) {
    tiiCookieChipDelete('tii_perm', chipName, null, '/', tiiDateGetOffsetYears(2), 0);
}

// ### Session Cookie/Chip Functions ###
function tiiSessCookieChipGet(chipName) {
    return tiiCookieChipGet('tii_sess', chipName);
}

function tiiSessCookieChipSet(chipName, chipValue) {
    tiiCookieChipSet('tii_sess', chipName, chipValue, null, '/', null, 0);
}

function tiiSessCookieChipDelete(chipName) {
    tiiCookieChipDelete('tii_sess', chipName, null, '/', null, 0);
}

/**
 * FlashObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 */
if(typeof com=="undefined"){var com=new Object();}
if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
//this.instanceof=null;
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
this.useExpressInstall=_7;
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}
};
com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},createParamTag:function(n,v){
var p=document.createElement("param");
p.setAttribute("name",n);
p.setAttribute("value",v);
return p;
},getVariablePairs:function(){
var _19=new Array();
var key;
var _1b=this.getVariables();
for(key in _1b){_19.push(key+"="+_1b[key]);}
return _19;
},getFlashHTML:function(){
var _1c="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");
}
_1c="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_1c+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1d=this.getParams();
_1d["instanceOf"]=null;
for(var key in _1d){_1c+=[key]+"=\""+_1d[key]+"\" ";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_1c+="flashvars=\""+_1f+"\"";}
_1c+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_1c="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_1c+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _20=this.getParams();
for(var key in _20){_1c+="<param name=\""+key+"\" value=\""+_20[key]+"\" />";}
var _22=this.getVariablePairs().join("&");
if(_22.length>0){_1c+="<param name=\"flashvars\" value=\""+_22+"\" />";
}_1c+="</object>";}
return _1c;
},write:function(_23){
if(this.useExpressInstall){
var _24=new com.deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}
}else{this.setAttribute("doExpressInstall",false);}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _23=="string")?document.getElementById(_23):_23;
if(typeof n != 'undefined'){
    n.innerHTML=this.getFlashHTML();
}else{
    document.writeln(this.getFlashHTML());
}
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};


function tiiVBGetFlashVersionExists() {
    var result = true;
    try {
        var dontcare = tiiVBGetFlashVersion( 3 ); 
    } catch(e) { result = false }
    
    
    return result;
}

com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){
    var _28 = new com.deconcept.PlayerVersion(0,0,0);
    if ( navigator.plugins && navigator.mimeTypes.length ){
        var x = navigator.plugins["Shockwave Flash"];
        if ( x && x.description ){
            _28 = new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));
        }
    } else {
        try {
            if ( ! tiiVBGetFlashVersionExists() ) {
                
                
                var axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" );
                for ( var i = 3; axo != null; i++ ) {
                    axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
                    _28 = new com.deconcept.PlayerVersion( [ i, 0, 0 ] );
                }
            } else {
                
                
                var versionStr = "";
                for ( var i = 25; i > 0 ; i-- ) {
                    var tempStr = tiiVBGetFlashVersion( i );
                    if ( tempStr != "" ) {
                        versionStr = tempStr;
                        break;
                    }
                }
                if ( versionStr != "" ) {
                    
                    var splits = versionStr.split(" ");
                    var splits2 = splits[1].split(",");
                    _28 = new com.deconcept.PlayerVersion( [ splits2[0], splits2[1], splits2[2] ] );
                }
            }
        } catch(e) {}
        if (_26&&_28.major>_26.major ){return _28;}
        if ( !_26 || ((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major) || _28.major != 6 || _27){
            try {
                _28 = new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
            } catch(e) {}
        }
    }

    
    return _28;
};

com.deconcept.PlayerVersion=function(_2c){
this.major=parseInt(_2c[0])||0;
this.minor=parseInt(_2c[1])||0;
this.rev=parseInt(_2c[2])||0;
};
com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;
};

com.deconcept.util={getRequestParameter:function(_2e){
var q=document.location.search||document.location.hash;
if(q){var _30=q.indexOf(_2e+"=");
var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;
if(q.length>1&&_30>-1){
return q.substring(q.indexOf("=",_30)+1,_31);}}return "";
},removeChildren:function(n){
while(n.hasChildNodes()){
n.removeChild(n.firstChild);}}};
if(Array.prototype.push==null){
Array.prototype.push=function(_33){
this[this.length]=_33;
return this.length;};}

var getQueryParamValue=com.deconcept.util.getRequestParameter;
var FlashObject=com.deconcept.FlashObject;
var PlayerVersion=com.deconcept.PlayerVersion;

function tiiGetFlashVersion() {
    var flashversion = 0;
    if (navigator.plugins && navigator.plugins.length) {
        var x = navigator.plugins["Shockwave Flash"];
        if(x){
            if (x.description) {
                var y = x.description;
                var flashFullDescriptionArray = y.split('.');
                var flashPartialDescriptionArray = flashFullDescriptionArray[0].split(' ');
                flashversion = flashPartialDescriptionArray[flashPartialDescriptionArray.length - 1];
            }
        }
    } else {
        result = false;
        for(var i = 15; i >= 3 && result != true; i--){
            execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
            flashversion = i;
        }
    }
    return flashversion;
}

function tiiDetectFlash(ver) {
    if (tiiGetFlashVersion() >= ver) {
        return true;
    } else {
        return false;
    }
}

 
/*-----------------------------------------------------------------------------*/
/* MB - 10/23/07 - Brightcove Wrapper / JavaScript support functions           */
/* Function: TiiBcLcDcTracker - Called by Brightcove Flash wrapper to notify   */ 
/* DoubleClick / DART that a Lightningcast ad was served                       */
/* Requirements: adsitename i.e. &adsitename=3745.mre needs to be passed to    */
/* the BC wrapper. If no adzone is specified the default value will be used    */
/*-----------------------------------------------------------------------------*/
function TiiBcLcDcTracker (omniAdSiteName,omniAdZone) {
    var defaultFlg = 'false';
    if (omniAdZone == 'default') {  
        omniAdZone = 'video_main_bc_lightningcast';
        defaultFlg = 'true';
    }    
    var bcLCDCTmpPixel = new Image();
    bcLCDCTmpPixel.src = 'http://ad.doubleclick.net/ad/'+omniAdSiteName+'/'+omniAdZone+';sz=1x1;ord='+Math.ceil(1+1E12*Math.random());
    return 'Tracking successful - adSiteName="'+omniAdSiteName+'" ,adZone="'+omniAdZone+ '" defaultFlg="'+defaultFlg+'"'; 
}    
             
function TiiBrightcovePlayer() {
    this.cfg = new Array();
    this.flashUrl = "/web/tii/shared/swf/BrightcoveWrapper.swf";
    this.flashUrl = "/shared/static/swf/BrightcoveWrapper.swf";
    this.bgcolor = "#ffffff";

    // Default cfg
    this.cfg["objectId"] = "bcVideoPlayer";
    this.cfg["divId"] = "";
    this.cfg["testmode"] = "";
    this.cfg["autostart"] = false;
    this.cfg["lctracking"] = "";
    this.cfg["adsitename"] = "";
    this.cfg["lcadzone"] = ""; 
    this.setParam = TiiBcSetParam;
    this.write = TiiBcWrite;
}

function TiiBcSetParam(key, value) {
    this.cfg[key] = value;
}

function TiiBcWrite() {
    var fo = new FlashObject(this.flashUrl, this.cfg["objectId"], this.cfg["width"], this.cfg["height"], 8, this.bgcolor);
    
    fo.addParam("allowScriptAccess", "always");
    fo.addParam("menu", "false");
    fo.addParam("quality", "high");
    fo.addParam("bgcolor", this.bgcolor);
    fo.addParam("loop", "false");
    fo.addParam("wmode", "opaque");

    fo.addVariable("account", this.cfg["account"]);
    fo.addVariable("channel", this.cfg["siteId"]);
    fo.addVariable("prop16", this.cfg["channel"]);

    fo.addVariable("playerwidth", this.cfg["width"]);
    fo.addVariable("playerheight", this.cfg["height"]);
    fo.addVariable("playerid", this.cfg["playerId"]);
    fo.addVariable("videoid", this.cfg["videoId"]);
    fo.addVariable("lineupid", this.cfg["lineupId"]);
    fo.addVariable("autostart", this.cfg["autostart"]);
    
    fo.addVariable("lctracking", this.cfg["lctracking"]); // MB - added 10/23/07
    fo.addVariable("adsitename", this.cfg["adsitename"]); // MB - added 10/23/07
    fo.addVariable("lcadzone", this.cfg["lcadzone"]);     // MB - added 10/23/07
    
    fo.addVariable("objectid", this.cfg["objectId"]);	
    fo.addVariable("adserverurl", this.cfg["adServerUrl"]);
    if (this.cfg["testmode"] != "") {
        fo.addVariable("testmode", this.cfg["testmode"]);	
    }
    
    fo.altTxt = "";

    if (this.cfg["divId"] != "") {
        fo.write(this.cfg["divId"]);
    } else {
        fo.write();
    }
}

function tiiQuigoSetEnabled(b) {
    _tiiQuigoEnabled = b;
}

function tiiQuigoIsEnabled() {
    if (typeof(_tiiQuigoEnabled) == "boolean") {
        return _tiiQuigoEnabled;
    }
    return true;
}

function tiiQuigoWriteAd(pid, placementId, zw, zh, ps) {
    if (tiiQuigoIsEnabled()) {
        qas_writeAd(placementId, pid, ps, zw, zh, 'ads.adsonar.com');
    }
}


function ajaxObj ()
{
    this.req = null;
    this.url = null;
    this.status = null;
    this.statusText = '';
    this.method = 'GET';
    this.async = true;
    this.dataPayload = null;
    this.readyState = null;
    this.responseText = null;
    this.responseXML = null;
    this.handleResp = null;
    this.responseFormat = 'text', // 'text', 'xml', 'object'
    this.mimeType = null;
    this.headers = [];
    this.init = function ()
    {
        var i = 0;
        var reqTry = [ 
            function() { return new XMLHttpRequest (); },
            function() { return new ActiveXObject ('Msxml2.XMLHTTP'); },
            function() { return new ActiveXObject ('Microsoft.XMLHTTP'); }];
            
        while (!this.req && (i < reqTry.length))
        {
            try
            {
                this.req = reqTry [i++] ();
            }
            catch (e) {}
        }
        return true;
    };
    this.doGet = function (url, handler, format)
    {
        this.url = url;
        this.handleResp = handler;
        this.responseFormat = format || 'text';
        this.doReq ();
    }
    this.doReq = function ()
    {
        if (!this.init ())
        {
            alert ('Could not create XMLHttpRequest object.');
            return;
        }
        this.req.open (this.method, this.url, this.async);
        if (this.mimeType)
        {
            try
            {
                req.overrideMimeType (this.mimeType);
            }
            catch (e)
            {
                // Couldn't override MIME type -- IE6 or Opera?
            }
        }
        var self = this; // Fix loss-of-scope in inner function
        this.req.onreadystatechange = function ()
        {
            var resp = null;
            if (self.req.readyState == 4)
            {
                switch (self.responseFormat)
                {
                    case 'text':
                        resp = self.req.responseText;
                        break;
                    case 'xml':
                        resp = self.req.responseXML;
                        break;
                    case 'object':
                        resp = req;
                        break;
                }
                if (self.req.status >= 200 && self.req.status <= 299)
                {
                    self.handleResp (resp);
                }
                else
                {
                    self.handleErr (resp);
                }
            }
        }
        this.req.send (this.postData);
    };
    this.setMimeType = function (mimeType)
    {
        this.mimeType = mimeType;
    };
    this.handleErr = function () {};
    this.abort = function ()
    {
        if (this.req)
        {
            this.req.onreadystatechange = function () {};
            this.req.abort ();
            this.req = null;
        }
    };
}/* Request controller for JSON-P access */
var $isrc =
{
    NAMESPACE : 'is_',
    CALLBACK_SUFFIX : 'CallbackFn',
    POLL_TIMEOUT : 10000,
    POLL_INTERVAL : 500,
    IS_OPERA : typeof window.opera != 'undefined',
    IS_IE : typeof document.all != 'undefined' && !this.IS_OPERA && navigator.vendor != 'KDE',
    domHook: null,
    isrs : new Array (),
    isrIndex : -1,
    hasBeenLoggedIn : false,
    setDomHook : function (init) { if (init) { document.write ('<div id="domHook"></div>'); } this.domHook = document.getElementById ('domHook'); },
    registerObj : function (obj) { this.isrs [++this.isrIndex] = obj; },
    getPrevObj : function (obj) { if (this.isrIndex > 0) { return this.isrs [this.isrIndex - 1]; }; return null; },
    clearObj : function (obj) { this.isrs [obj.index] = obj = null; }
};
$isrc.setDomHook (true);

/* Request object for JSON-P access */
function $isr ()
{
    $isrc.registerObj (this);
    var self = this;
    this.index = $isrc.isrIndex;
    this.script = document.createElement ('script');
    this.scriptCallback = $isrc.NAMESPACE + 'script' + this.index + $isrc.CALLBACK_SUFFIX,
    this.interval = null;
    this.loadSuccess = false;
    this.timeout = null;
    this.timedOut = false;
    this.prevObj = $isrc.getPrevObj ();
    this.data = null;
    this.getData = function (url, queryString, callback, callbackName)
    {
        if (!$isrc.domHook) { $isrc.setDomHook (false); }
        if (arguments.length > 0)
        {
            this.url = url;
            this.queryString = queryString;
            this.userCallback = callback;
            if (typeof callbackName != 'undefined' && callbackName) { this.scriptCallback = callbackName; }
        }
        if (typeof window [this.scriptCallback] != 'function')
        {
            window [this.scriptCallback] = function (jsonData)
            {
                if (!self.timedOut)
                {
                    clearTimeout ($isrc.isrs [self.index].timeout);
                    self.loadSuccess = true;
                    self.data = jsonData;
                    if (!$isrc.IS_IE) { $isrc.domHook.removeChild (self.script); }
                    self.userCallback.call ('', jsonData);
                }
            }
        }
        if (this.script.src == '')
        {
            this.script.src = this.url + '?callback=' + this.scriptCallback;
            if (typeof this.queryString != 'undefined' && this.queryString && this.queryString != '') { this.script.src += '&' + this.queryString; }
        }
        this.interval = setInterval (function ()
        {
            if (!self.prevObj || self.prevObj.loadSuccess || self.prevObj.timedOut)
            {
                clearInterval (self.interval);
                self.timeout = setTimeout (function ()
                {
                    self.timedOut = true;
                    if (!$isrc.IS_IE) { $isrc.domHook.removeChild (self.script); }
                    var callback = self.userCallback;
                    $isrc.clearObj (self);
                    self.userCallback.call ('', { error : 'Service not available' }, self.index);
                }, $isrc.POLL_TIMEOUT);
                $isrc.domHook.appendChild (self.script);
            }
        }, $isrc.POLL_INTERVAL);
    }
}

function tii_globalRecirc (rootId, toutClass, feedSrc, rulesSrc, useJSONP)
{
    var self = this;
    this.docRoot = null;
    this.touts = null;
    this.feedOrder = null;
    this.ajax = new ajaxObj ();
    this.ajax.setMimeType ('text/plain');
    if (typeof useJSONP != 'undefined' && useJSONP)	{ this.useJSONP = true; }
    else { this.useJSONP = false; }
    this.getFeeds = function ()
    {
        var nextFunction = function (data) { self.main (self.useJSONP ? data.content : data, rulesSrc); };
        if (this.useJSONP) { new $isr ().getData (feedSrc, '', nextFunction, 'recircData'); }
        else { this.ajax.doGet (feedSrc, nextFunction); }
    }
    this.main = function (data, rulesSrc)
    {
        var parseBuffer = document.createElement ('div');
        parseBuffer.innerHTML = data;
        var root = parseBuffer.getElementsByTagName ('div').item (0);
        this.docRoot = document.getElementById (rootId);
        if (root && this.docRoot)
        {
            var toutPattern = new RegExp (toutClass, 'i');
            this.touts = new Array ();
            var rootChildren = root.childNodes;
            var rootChildrenLength = rootChildren.length;
            var toutIndex = 0;
            for (var i = 0; i < rootChildrenLength; i++)
            {
                var rootChild = rootChildren.item (i);
                if (rootChild.nodeName == 'DIV' && toutPattern.test (rootChild.className))
                {
                    this.touts [toutIndex] = rootChild;
                    toutIndex++;
                }
            }
        }
        var nextFunction = function (rulesJSON) { self.setFeedOrder (rulesJSON); };
        if (this.useJSONP) { new $isr ().getData (rulesSrc, '', nextFunction, 'recircRules'); }
        else { this.ajax.doGet (rulesSrc, nextFunction); }
    }
    this.setFeedOrder = function (rulesJSON)
    {
        var feedRules = this.useJSONP ? rulesJSON : eval ('(' + rulesJSON + ')');
        var feedsNeeded = feedRules.feedsNeeded;
        var fixedIndices = feedRules.fixedIndices;
        var fixedIndicesLength = fixedIndices.length;
        var randomIndices = feedRules.randomIndices;
        var randomIndicesLength = randomIndices.length;
        if (fixedIndicesLength + randomIndicesLength != feedsNeeded)
        {
            alert ('The total number of fixed feeds and random feeds needed does not equal the total number of feeds needed.');
            return;
        }
        var feedInfo = feedRules.feedInfo;
        var feedInfoLength = feedInfo.length;
        var feedOrder = new Array ();
        var randomFeeds = new Array ();
        var randomIndex = 0;
        for (var i = 0; i < feedInfoLength; i++)
        {
            var feed = feedInfo [i];
            if (feed.fixed)
            {
                feedOrder [feed.index] = i;
            }
            else
            {
                var relativeWeight = (typeof feed.relativeWeight == 'undefined' || feed.relativeWeight == null) ? 1 : feed.relativeWeight;
                randomFeeds [randomIndex] = [i, relativeWeight * Math.random ()];
                randomIndex++;
            }
        }
        randomFeeds.sort (function (a, b) { return b [1] - a [1]; });
        for (var j = 0; j < randomIndicesLength; j++)
        {
            feedOrder [randomIndices [j]] = randomFeeds [j] [0];
        }
        this.feedOrder = feedOrder;
        this.attachFeeds ();
    }
    this.attachFeeds = function ()
    {
        if (this.feedOrder)
        {
            var feedOrderLength = this.feedOrder.length;
            for (var j = 0; j < feedOrderLength; j++)
            {
                this.docRoot.appendChild (this.touts [this.feedOrder [j]]);
            }
        }
    }
}




function tii_callFunctionOnWindowLoad (functionToCall)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener ('load', functionToCall, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener ('load', functionToCall, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent ('onload', functionToCall);
  }
  else
  {
    var oldFunctionToCall = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = functionToCall;
    }
    else
    {
      window.onload = function ()
      {
        oldFunctionToCall ();
        functionToCall ();
      };
    }
  }
}


function tii_callFunctionOnElementLoad (targetId, functionToCall)
{
    var myArguments = arguments;
    tii_callFunctionOnWindowLoad (function ()
        {
            window.loaded = true;
        });
    var targetElement = document.getElementById (targetId);
    if (targetElement == null && !window.loaded)
    {
        var pollingInterval = setInterval (function ()
            {
                if (window.loaded)
                {
                    clearInterval (pollingInterval);
                }
                targetElement = document.getElementById (targetId);
                if (targetElement != null)
                {
                    clearInterval (pollingInterval);
                    var argumentsTemp = new Array ();
                    var argumentsTempLength = myArguments.length - 2;
                    for (var i = 0; i < argumentsTempLength; i++)
                    {
                        argumentsTemp [i] = myArguments [i + 2];
                    }		
                    functionToCall.apply (this, argumentsTemp);
                }
            }, 10);
    }
}


function tii_addEventHandlerOnElementLoad (targetId, eventType, functionToCall, bubbleEventUpDOMTree)
{
    tii_callFunctionOnWindowLoad (function ()
        {
            window.loaded = true;
        });
    var targetElement = document.getElementById (targetId);
    if (targetElement == null && !window.loaded)
    {
        var pollingInterval = setInterval (function ()
            {
                if (window.loaded)
                {
                    clearInterval (pollingInterval);
                }
                targetElement = document.getElementById (targetId);
                if (targetElement != null)
                {
                    clearInterval (pollingInterval);
                    tii_addEventHandler (targetElement, eventType, functionToCall, bubbleEventUpDOMTree);
                }
            }, 10);
    }
}


function tii_addEventHandler (targetElement, eventType, functionToCall, bubbleEventUpDOMTree)
{
  if (!targetElement)
  {
      window.status = 'Warning: Tried to attach event to null object';
      return false;
  }
  if (typeof targetElement.addEventListener != 'undefined')
  {
    targetElement.addEventListener (eventType, functionToCall, bubbleEventUpDOMTree);
  }
  else if (typeof targetElement.attachEvent != 'undefined')
  {
    targetElement.attachEvent ('on' + eventType, functionToCall);
  }
  else
  {
    eventType = 'on' + eventType;
    if (typeof targetElement [eventType] == 'function')
    {
      var oldListener = targetElement [eventType];
      targetElement [eventType] = function ()
      {
        oldListener ();
        return functionToCall ();
      }
    }
    else
    {
      targetElement [eventType] = functionToCall;
    }
  }

  return true;
}



function tii_removeEventHandler (targetElement, eventType, functionToRemove, bubbleEventUpDOMTree)
{
  if (typeof targetElement.removeEventListener != "undefined")
  {
    targetElement.removeEventListener (eventType, functionToRemove, bubbleEventUpDOMTree);
  }
  else if (typeof targetElement.detachEvent != "undefined")
  {
    targetElement.detachEvent ("on" + eventType, functionToRemove);
  }
  else
  {
    targetElement ["on" + eventType] = null;
  }
  
  return true;
}

/* Begin KT */

var tii_pnav_branch;
var tii_pnav_previousLink;
var tii_pnav_previousLinkTracker;
var tii_pnav_dontResetCurrentLink = false;

function tii_pnav_initializeDropdownMenu (primaryNavId, hideOrShowMenuFunction, changeStateFunction)
{
  var isopera = typeof window.opera != 'undefined';
  var isie = typeof document.all != 'undefined'
    && !isopera && navigator.vendor != 'KDE';
  var issafari = navigator.vendor == 'Apple Computer, Inc.';

  if (typeof document.getElementById == 'undefined'
      || (issafari && typeof window.XMLHttpRequest == 'undefined')
      || (isie && typeof document.uniqueID == 'undefined'))
  {
    return;
  }
  
  var tree = document.getElementById (primaryNavId);
  if (tree)
  {
    tii_pnav_branch = tree;
    var items = tree.getElementsByTagName('li');
    for (var i = 0; i < items.length; i++)
    {
      tii_pnav_setDropdownTrigger (tree, items[i], primaryNavId, isie, hideOrShowMenuFunction, changeStateFunction);
    }

    if (!isopera)
    {
      tii_dom_removeWhitespaceTextNodes (tree);

      var keyevent = issafari || isie ? 'keydown' : 'keypress';
      tii_addEventHandler(document, keyevent, function(e)
      {
        var target = typeof e.target != 'undefined'
            ? e.target : e.srcElement;
        if (tree.contains(target) && target.getAttribute('href'))
        {
          /*
             keycode 27 = escape key
                     37 = left arrow key
                     38 = up arrow key
                     39 = right arrow key
                     40 = down arrow key
          */
          if (/^(27|37|38|39|40)$/.test(e.keyCode.toString()))
          {
            tii_pnav_setArrowKeyNavigation(tree, target, e.keyCode, isie, hideOrShowMenuFunction, changeStateFunction);

            if (typeof e.preventDefault != 'undefined')
            {
              e.preventDefault();
            }
            return false;
          }
        }
        return true;

      }, false);
    }
    
    if (!isie)
    {
      tree.contains = function (node)
      {
        if (node == null) { return false; }
        if (node == this) { return true; }
        else { return this.contains (node.parentNode); }
      };
    }
  }
}



function tii_pnav_setDropdownTrigger (tree, li, navid, isie, hideOrShowMenuFunction, changeStateFunction)
{
  var opentime, closetime;
  var a = li.getElementsByTagName('a')[0];
  var menu = li.getElementsByTagName('ul').length > 0
      ? li.getElementsByTagName('ul')[0] : li.parentNode.parentNode.id == navid
      ? li : null;
  var issub = li.parentNode.id == navid;
  
  tii_addEventHandler(a, 'focus', function(e)
  {
    clearTimeout(closetime);
    tii_pnav_resetPreviousLink (a, isie, hideOrShowMenuFunction, changeStateFunction);
    if (menu)
    {
      changeStateFunction.call (this, a.parentNode, false, 2);
      tii_pnav_makeMenuVisible (menu, issub, li, a, isie, hideOrShowMenuFunction, changeStateFunction);
    }
    else
    {
        var liGrandPar = li.parentNode.parentNode;
        changeStateFunction.call (this, a.parentNode, true, 2);
        changeStateFunction.call (this, liGrandPar, false, 1);
        var currentLi = a.parentNode;
        var currentPrimaryLi = tii_pnav_getPrimaryLi (a);
        var currentUl = currentLi.parentNode;
        var currentPrimaryA = currentPrimaryLi.firstChild;
        if (currentLi != currentPrimaryLi && currentUl.className == '')
        {
            tii_pnav_makeMenuVisible (currentUl, issub, currentPrimaryLi, currentPrimaryA, isie, hideOrShowMenuFunction, changeStateFunction);
            changeStateFunction.call (this, currentPrimaryLi, false, 1);
        }
    }
  }, false);

  tii_addEventHandler(a, 'blur', function(e)
  {
      if (a.className.indexOf ('lastpnitem') > -1 && tii_pnav_previousLinkTracker != null &&
          tii_pnav_previousLinkTracker.className.indexOf ('lastpnitem') < 0)
      {
          if (!tii_pnav_dontResetCurrentLink)
          {
              tii_pnav_resetCurrentLink (a, hideOrShowMenuFunction, changeStateFunction);
          }
      }
  }, false);
  
  tii_addEventHandler(li, 'mouseover', function(e)
  {
    if (tii_pnav_isUnwantedTextEvent ()) { return; }
    clearTimeout(closetime);
    if (tii_pnav_branch == li) { tii_pnav_branch = null; }

    var target = typeof e.target != 'undefined' ? e.target : window.event.srcElement;
    while (target.nodeName.toUpperCase() != 'LI')
    {
      target = target.parentNode;
    }
    if (target != li) { return; }

    tii_pnav_resetPreviousLink (a, isie, hideOrShowMenuFunction, changeStateFunction);

    if (menu)
    {
      changeStateFunction.call (this, a.parentNode, false, 2);
      opentime = window.setTimeout(function()
      {
        tii_pnav_makeMenuVisible (menu, issub, li, a, isie, hideOrShowMenuFunction, changeStateFunction);
      }, 1);
    }
    else
    {
        changeStateFunction.call (this, li.parentNode.parentNode, false, 1);
    }
  }, false);

  tii_addEventHandler(li, 'mouseout', function(e)
  {
    if (tii_pnav_isUnwantedTextEvent ()) { return; }

    var related = typeof e.relatedTarget != 'undefined' ? e.relatedTarget : window.event.toElement;
    if (!li.contains(related))
    {
      clearTimeout (opentime);
      tii_pnav_branch = li;
      if (menu)
      {
        changeStateFunction.call (this, a.parentNode, false, 0);
        closetime = window.setTimeout (function ()
        {
          tii_pnav_resetCurrentLink (a, hideOrShowMenuFunction, changeStateFunction);
        }, 1);
      }
      else
      {
        changeStateFunction.call (this, a.parentNode, true, 0);
      }	  
    }
  }, false);

  if (!isie)
  {
    li.contains = function(node)
    {
      if (node == null) { return false; }
      if (node == this) { return true; }
      else { return this.contains(node.parentNode); }
    };
  }
}

function tii_pnav_setArrowKeyNavigation (tree, link, keycode, isie, hideOrShowMenuFunction, changeStateFunction)
{
  var currentPrimaryLi = tii_pnav_getPrimaryLi (link);
  var openClosedPrimary = false;
 
  if (link.parentNode != currentPrimaryLi && link.parentNode.parentNode.className == '')
  {
      link = currentPrimaryLi.firstChild;
      openClosedPrimary = true;
  }

  var li = link.parentNode;
  var menu = li.getElementsByTagName('ul').length > 0
      ? li.getElementsByTagName('ul')[0] : null;
  var parent = li.parentNode;
  var isTopLevel = parent.parentNode == tree;

  if (menu)
  {
      changeStateFunction.call (this, li, false, 0);
  }
  else
  {
      changeStateFunction.call (this, li, true, 0);
  }

  if (link.className.indexOf ('lastpnitem') > -1)
  {
      tii_pnav_dontResetCurrentLink = true;
  }
  else
  {
      tii_pnav_dontResetCurrentLink = false;
  }
  
  switch (keycode)
  {
    case 27:
      tii_pnav_dontResetCurrentLink = false;
      tii_pnav_resetCurrentLink (link, hideOrShowMenuFunction, changeStateFunction);
      break;
      
    case 37:
      if (menu || isTopLevel)
      {
          tii_pnav_moveToPrevious (li);
      }
      else
      {
          tii_pnav_moveToPrevious (parent.parentNode);
      }
      break;

    case 38:
      if (menu || isTopLevel)
      {
        changeStateFunction.call (this, link.parentNode, false, 2);
      }
      else
      {
          if (li == li.parentNode.firstChild)
          {
            parent.parentNode.firstChild.focus ();
          }
          else
          {
            tii_pnav_moveToPrevious (li);
          }
      }
      break;

    case 39:
      if (menu || isTopLevel)
      {
          tii_pnav_moveToNext (li);
      }
      else
      {
          tii_pnav_moveToNext (parent.parentNode);
      }
      break;
      
    case 40:
      tii_pnav_dontResetCurrentLink = false;
      if (menu && openClosedPrimary)
      {
        openClosedPrimary = false;
        menu.parentNode.firstChild.focus ();
      }
      if (menu || isTopLevel)
      {
        menu.firstChild.firstChild.focus ();
      }
      else
      {
        tii_pnav_moveToNext (li);
      }
      break;
  }  
}

function tii_pnav_makeMenuVisible (menu, issub, li, a, isie, hideOrShowMenuFunction, changeStateFunction)
{
  if (typeof li.offsetLeft == 'undefined')
  {
      return;
  }

  changeStateFunction.call (this, a.parentNode, false, 2);

  hideOrShowMenuFunction (menu, false, li);
  menu.style.top = a.offsetHeight + 'px';
}

function tii_pnav_resetPreviousLink (a, isie, hideOrShowMenuFunction, changeStateFunction)
{
    if (tii_pnav_previousLink)
    {
        var prevLi = tii_pnav_previousLink.parentNode;
        var currentLi = a.parentNode;
        var prevPrimaryLi = tii_pnav_getPrimaryLi (tii_pnav_previousLink);
        var currentPrimaryLi = tii_pnav_getPrimaryLi (a);
        
        if (prevLi != prevPrimaryLi)
        {
            changeStateFunction.call (this, prevLi, true, 0);
        }
        
        var hideMenu = prevPrimaryLi != currentPrimaryLi || a == null;
        
        if (hideMenu || (prevLi != prevPrimaryLi && currentLi == currentPrimaryLi))
        {
            changeStateFunction.call (this, prevPrimaryLi, false, 0);

            if (hideMenu)
            {
                var ul = prevPrimaryLi.getElementsByTagName('ul').item (0);
                if (ul)
                {
                    hideOrShowMenuFunction (ul, true, null);
                }
            }
        }		
    }
    tii_pnav_previousLinkTracker = tii_pnav_previousLink;
    tii_pnav_previousLink = a;
}

function tii_pnav_resetCurrentLink (a, hideOrShowMenuFunction, changeStateFunction)
{
    var currentLi = a.parentNode;
    var currentPrimaryLi = tii_pnav_getPrimaryLi (a);
    changeStateFunction.call (this, currentPrimaryLi, false, 0);
    if (currentLi != currentPrimaryLi)
    {
        changeStateFunction.call (this, currentLi, true, 0);
    }
    
    var ul = currentPrimaryLi.getElementsByTagName('ul').item (0);
    if (ul)
    {
        closetime = window.setTimeout(function()
            {
                hideOrShowMenuFunction (ul, true, null);
            }, 1);
    }	
}

function tii_pnav_getPrimaryLi (a)
{
    if (a.parentNode.parentNode.parentNode.nodeName.toUpperCase ()== 'DIV')
    {
        return a.parentNode;
    }
    else
    {
        return a.parentNode.parentNode.parentNode;
    }
}

function tii_pnav_moveToPrevious (li)
{
      var previous = li.previousSibling;
      if (!previous)
      {
        previous = li.parentNode.childNodes
            [li.parentNode.childNodes.length - 1];
      }
      previous.firstChild.focus ();
}

function tii_pnav_moveToNext (li)
{
    var next = li.nextSibling;
    if (!next)
    {
      next = li.parentNode.childNodes.item (0);
    }
    next.firstChild.focus ();
};

function tii_pnav_isUnwantedTextEvent ()
{
  return (navigator.vendor == 'Apple Computer, Inc.'
      && (event.target == event.relatedTarget.parentNode
      || (event.eventPhase == 3
      && event.target.parentNode == event.relatedTarget)));
}
function tii_dom_createElement (nodeName, attributes)
{
    var isopera = typeof window.opera != 'undefined';
    var isie = typeof document.all != 'undefined'
        && !isopera && navigator.vendor != 'KDE';
        
    var newElement;
    try
    {
        newElement = document.createElement (nodeName);
    }
    catch (error)
    {
        return null;
    }
    
    var attributesLength = attributes.length;
    for (var i = 0; i < attributesLength; i++)
    {
        var attribute = attributes [i] [0];
        var value = attributes [i] [1];
        newElement.setAttribute (attribute, value);
        switch (attribute)
        {
            case 'id':
                newElement.id = value;
                break;
            case 'class':
                if (isie)
                {
                    newElement.setAttribute ('className', value);
                }
                newElement.className = value;
                break;
            case 'style':
                newElement.style.cssText = newElement.style.cssText + ' ' + value;
                break;
            case 'for':
                if (isie)
                {
                    newElement.setAttribute ('htmlFor', value);
                }
                newElement.htmlFor = value;
        }
    }
    
    return newElement;
}






/* End KT */






function tii_dom_createElement (nodeName, attributes)
{
    var isopera = typeof window.opera != 'undefined';
    var isie = typeof document.all != 'undefined'
        && !isopera && navigator.vendor != 'KDE';
        
    var newElement;
    try
    {
        newElement = document.createElement (nodeName);
    }
    catch (error)
    {
        return null;
    }
    
    var attributesLength = attributes.length;
    for (var i = 0; i < attributesLength; i++)
    {
        var attribute = attributes [i] [0];
        var value = attributes [i] [1];
        newElement.setAttribute (attribute, value);
        switch (attribute)
        {
            case 'id':
                newElement.id = value;
                break;
            case 'class':
                if (isie)
                {
                    newElement.setAttribute ('className', value);
                }
                newElement.className = value;
                break;
            case 'style':
                newElement.style.cssText = newElement.style.cssText + ' ' + value;
                break;
            case 'for':
                if (isie)
                {
                    newElement.setAttribute ('htmlFor', value);
                }
                newElement.htmlFor = value;
        }
    }
    
    return newElement;
}


function tii_dom_removeWhitespaceTextNodes (node)
{
  for (var x = 0; x < node.childNodes.length; x++)
  {
    var child = node.childNodes [x];
    if (child.nodeType == 3 && !/\S/.test (child.nodeValue))
    {
      node.removeChild (node.childNodes [x]);
      x--;
    }
    if (child.nodeType == 1)
    {
      tii_dom_removeWhitespaceTextNodes (child);
    }
  }
}

tii_callFunctionOnElementLoad('topnav2010', function ()
{
    tii_pnav_initializeDropdownMenu.apply (this, new Array ('topnav2010', instyle_pnav_hideMenuFunction, instyle_pnav_changeStatusFunction));
});




function instyle_pnav_hideMenuFunction (menu, hideElseShow, menuParent)
{
    if (hideElseShow)
    {
        menu.style.left = '-999px';
    }
    else
    {
        menu.style.left = (menuParent.offsetLeft - 1) + 'px';
    }
}

function instyle_pnav_changeStatusFunction (element, isADropdownItem, state)
{
    if (isADropdownItem)
    {
        switch (state)
        {
            case 0:
                element.className = '';
                break;
            case 2:
                element.className = 'active';
                break;
        }
    }
    else
    {
        var anchor = element.getElementsByTagName ('a').item (0);
        var em = element.getElementsByTagName ('em').item (0);
        switch (state)
        {
            case 0:
                element.style.visibility = 'visible';
                em.style.visibility = 'visible';
                break;
            case 1:
                element.style.visibility = 'visible';
                em.style.visibility = 'hidden';
                break;
            case 2:
                element.style.visibility = 'visible';
                em.style.visibility = 'hidden';
                break;
        }
    }
}

function initMakeThisHomepage(){
    var makeThisHomepage = document.getElementById("makeThisHomepage");
    if(document.all){
        makeThisHomepage.onclick = function(){
            this.style.behavior='url(#default#homepage)';
            //V6 Migration - hardcoding - sdalvi
            this.setHomePage('http://www.instyle.com');
            return false;
        }
    }else if(document.getElementById){
        makeThisHomepage.onclick = function(){
            alert('Drag the link onto your Home button to make this your Home Page.');
            return false;
        }
    }else{
        makeThisHomepage.onclick = function(){
            alert('Go to <i>Preferences</i> in the <i>Edit</i> Menu.<br />Choose <i>Navigator</i> from the list on the left.<br />Click on the <i>"Use Current Page"</i> button.');
            return false;
        }
    }
}
tii_callFunctionOnElementLoad('makeThisHomepage', initMakeThisHomepage);


function tii_stopDefaultAction (event)
{
    event.returnValue = false;
    if (typeof event.preventDefault != 'undefined')
    {
        event.preventDefault ();
    }
}





var tcdacmd="dt";

var macTest=(navigator.userAgent.toLowerCase().indexOf("macintosh") >= 0);

function IMArticle() {
    if (isInAolClient()) {
        document.location.href = "aol://9293::Here's something that may interest you from InStyle.com: <a href='" + document.location.href + "'>" + document.location.href + "</a>";
    } else {
        document.location.href = "aim:goim?message=Here's+something+that+may+interest+you+from+InStyle.com:+" + document.location.href;
    }
    return false;
}

function openWindow (url) {
    var argv = openWindow.arguments;
    var argc = argv.length;
    
    if (argc == 1) {
        var handle = window.open(url);
    } else if (argc == 2) {
        var handle = window.open(url,argv[1]);
    } else {
        var handle = window.open(url,argv[1],argv[2]);
    }
    
    handle.focus();
}

function showHeaderLogo(channelID) {

    if (channelID != 0) {
        document.getElementById('headerHomeLogo').src = "http://img2.timeinc.net/instyle/i/logo_channel.gif"
    }
    
    if (document.getElementById('headerChannelLogo' + channelID)) {
        document.getElementById('headerChannelLogo' + channelID).style.display = "";
    }

    return;
}


function showCenteredPopup(name, url, features, width, height) {
    
    // example usage:
    // showCenteredPopup("foo", "http://www.cnn.com", null, 640, 480);
    
    var top = (screen.height / 2) - height / 2;
    var left = (screen.width / 2) - width / 2;

    if (features == null || features == '') {
        features = "scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
    }

    window.open(url, name, features + ",top=" + top + ",left=" + left + ",width=" + width + ",height=" + height);

}

// this name is used as a target by links in popup windows
// that need to open in the main window
function nameThisWindow(winName) {
    if (window.opener) {
        window.opener.name=winName;
    } else {
        window.name=winName;
    }
}	

function showPopupBackButton() {
    if (history.length > 0) {
        document.write('<a href="javascript:history.back()"><img src="http://img2.timeinc.net/instyle/i/arrow_left.gif" alt="Back" border="0" style="vertical-align:middle" /> BACK</a>'); 
    }
}




var ie4Test=document.all&&(navigator.userAgent.toLowerCase().indexOf("msie") >= 0);
var dom=document.getElementById&&(navigator.userAgent.indexOf("Opera")==-1);
var macTest=(navigator.userAgent.toLowerCase().indexOf("macintosh") >= 0);
var firefoxTest=(navigator.userAgent.toLowerCase().indexOf("firefox") >= 0);
var ie      = 1;
var mac     = 2;
var firefox = 3; 
var other   = 4;

function isPrintWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}
 
function isEmailToFriend(ptitle,purl) {
    if(pageTitle == "") {
        var pageTitle = escape(self.document.title);
    } else {
        var pageTitle = escape(ptitle);
    }
    if(pageURL == "") {
        var pageURL   = escape(self.document.URL);
    } else {
        var pageURL   = escape(purl);
    }
    //V6 Migration - email server change - sdalvi 
    var formURL   = "http://cgi.instyle.com/cgi-bin/mail/mailurl2friend.cgi?url=" + pageURL + "&group=instyle&title=" + pageTitle + "&path=/instyle/mail/templates";
    window.open(formURL, "emailpop","height=500,width=435,resizable,scrollbars");
    return false;
}
 
function reloadOmniture(toPage) {
    var omnitureFrame = document.getElementById("pageCounter");
    if (omnitureFrame) {
        var frameSrc = omnitureFrame.src;
        var commaIndex = frameSrc.lastIndexOf(",");
        var underScoreIndex = frameSrc.lastIndexOf("_");
        if (commaIndex > -1 && underScoreIndex > -1) { 
            var currentNumber = frameSrc.substring(underScoreIndex + 1, commaIndex)
            var begURL = frameSrc.substring(0,underScoreIndex + 1);
            var endURL = frameSrc.substring(commaIndex, frameSrc.length);
            frameSrc = begURL.concat(toPage, endURL);
            omnitureFrame.src = frameSrc;
        }
    }
}

//track custom link for omniture. the following are the type of links
//-exit links: e
//-download: d
//-custom links: o 
function trackLink(lnkType, lnkObj, lnkName, account) {
    if (lnkType) {
        s_linkType = lnkType;
    }
    
    if (lnkName) {
        s_linkName = lnkName;
    }
    
    if (lnkObj) {
        s_lnk = s_co(lnkObj);
    }
    
    if (account) {
        if (typeof s_gs != "undefined") {
            s_gs(account);
        }
    }
    
    return;
    
}

function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}
//-->


siteId = "";
cmSiteId = "";

qs =document.location.href;

if(qs.indexOf("instyleweddings") >= 0){
    siteId = "3475.inw";
    cmSiteId = "cm.inw";
} else if( qs.indexOf("instyleyourlook") >= 0) {
    siteId = "3475.iyl";
    cmSiteId = "cm.iyl";
} else {
    siteId = "3475.ins";
    cmSiteId = "cm.ins";
}

        



    var adConfig = new TiiAdConfig(siteId);
    adConfig.setCmSitename(cmSiteId);
    
    if (location.search.indexOf("xid=cnn") >= 0) {
        adConfig.setPopups(false);
    }

    if (location.search.indexOf("google=yes") >= 0) {
        adConfig.setPopups(false);
    }

    if (location.search.indexOf("yahoo=yes") >= 0) {
        adConfig.setPopups(false);
    }
    // partner=yes is for CM popup control
    if (location.search.indexOf("partner=yes") >= 0) {
        adConfig.setPopups(false);
    }
// fixes IE background flickering
try {
    document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}



function adSetTarget() {} 
function htmlAdWH() {}
function adSetType() {} 



 
adConfig.setRevSciTracking(true);


adConfig.setTacodaTracking(false);

/* Search button will not work unless 3 or more characters are entered in search query -- endeca site search*/
tii_callFunctionOnWindowLoad (function() {
      var searchDivs = new Array();
      searchDivs.push(document.getElementById("sitesearch"));
      searchDivs.push(document.getElementById("searchagain"));
      for (var i=0; i < searchDivs.length; i++) {
            if (searchDivs[i]) {
                  try {
                        var form = searchDivs[i].getElementsByTagName("form")[0];
                        form.onsubmit = function(){
                              var inputs = form.getElementsByTagName("input");
                              for (var j=0; inputs[j]; j++) {
                                    if (inputs[j].getAttribute("type") == "text") {
                                          //if (inputs[j].value.length < 3) {
                                                //return false;
                                          //}
                                    }
                              }
                              return true;
                        }
                  } catch(e) {}
            }
      }
});

// browser detection js
var tii_detect = navigator.userAgent.toLowerCase();
var tii_OS,tii_browser,tii_version,tii_browserString;
var tii_variety = "";

var tii_macVersionArray = new Array();
var tii_windowsVersionArray = new Array();
var tii_usersArray = new Array();


var tii_upgradeLocation = "http://www.timeinc.net/web/upgrade/";

function tii_detectBrowserVersionOS(){

    if (tii_isClient('konqueror')) {
        tii_browser = "Konqueror";
        tii_OS = "Linux";
    } else if (tii_isClient('safari')) {
        tii_browser = "Safari";
        tii_OS = "Mac";
    } else if (tii_isClient('omniweb')) {
        tii_browser = "OmniWeb";
    } else if (tii_isClient('opera')) {
        tii_browser = "Opera";
    } else if (tii_isClient('webtv')) {
        tii_browser = "WebTV";
    } else if (tii_isClient('icab')) {
        tii_browser = "iCab";
    } else if (tii_isClient('msie')) {
        if (tii_isClient('aol')) {
            
            tii_isClient('msie');
            tii_variety = "AOL";
            tii_browser = "Internet Explorer";
        } else {
            
            tii_isClient('msie');
            tii_browser = "Internet Explorer";
        }
    } else if (!tii_isClient('compatible')) {
        if (tii_isClient('firefox')) {
            tii_browser = "Firefox";
        } else if ((tii_isClient('gecko'))&&(tii_detect.indexOf("netscape")==-1)) {
            
            tii_isClient('mozilla')
            tii_browser = "Mozilla";
        } else if (tii_isClient('aol')) {
            tii_variety = "AOL";
            tii_browser = "Netscape Navigator";
        } else {
            tii_browser = "Netscape Navigator";
        }
    } else {
        tii_browser = "An unknown tii_browser";
    }
    

    if (!tii_version){
        tii_version = tii_detect.substring(tii_place + tii_browserString.length,tii_detect.length)
        if (tii_browser=="Safari"){
            
            if (tii_version<100){
                tii_version=1.0;
            }else if (tii_version<125){
                tii_version=1.1;
            }else if (tii_version<312.1){
                tii_version=1.2;
            }else if (tii_version<412){
                tii_version=1.3;
            }else{
                tii_version=2;
            }
        } else if (tii_browser=="Netscape Navigator"){
            
            if(tii_isClient('netscape')){
                tii_detectSubstring = tii_detect.substring(tii_place + tii_browserString.length,tii_detect.length);
                if(tii_detectSubstring.indexOf("/")!=-1){
                    tii_version = tii_detect.substring(tii_detect.lastIndexOf("/")+1,tii_detect.length);
                } else {
                    tii_version = tii_detect.substring(tii_place + tii_browserString.length,tii_place + tii_browserString.length + 3);
                }
            }else if(tii_isClient('aol')){
                tii_detectSubstring = tii_detect.substring(tii_place + tii_browserString.length,tii_detect.length);
                if(tii_detectSubstring.indexOf("/")!=-1){
                    tii_version = tii_detect.substring(tii_place + tii_browserString.length + 1,tii_place + tii_browserString.length + 4);
                } else {
                    tii_version = tii_detect.substring(tii_place + tii_browserString.length,tii_place + tii_browserString.length + 3);
                }
            }else{
                tii_version = 4.7;
            }
        } else if ((tii_browser=="Internet Explorer")||(tii_browser=="Firefox")){
            
            tii_version = tii_detect.substring(tii_place + tii_browserString.length,tii_place + tii_browserString.length + 3);
        } else if (tii_browser=="Mozilla"){
            
            tii_version = tii_detect.substring(tii_detect.indexOf("rv:") + 3,tii_detect.indexOf("rv:") + 6);
        }

        tii_version = parseFloat(tii_version)
    }


    if (!tii_OS)
    {
        if (tii_isClient('linux')) tii_OS = "Linux";
        else if (tii_isClient('x11')) tii_OS = "Unix";
        else if (tii_isClient('mac')) tii_OS = "Mac"
        else if (tii_isClient('win')) tii_OS = "Windows"
        else tii_OS = "an unknown operating system";
    }
}



function tii_isClient(string)
{
    tii_place = tii_detect.indexOf(string) + 1;
    tii_browserString = string;
    return tii_place;
}


function tii_checkVersion() {
    tii_detectBrowserVersionOS();
    if(tii_OS=="Mac"){
        tii_usersArray = tii_macVersionArray;
    }else if(tii_OS=="Windows"){
        tii_usersArray = tii_windowsVersionArray;
    }
    if(((tii_usersArray[tii_browser]!=0)&&(tii_version<tii_usersArray[tii_browser]))||(tii_usersArray[tii_browser]==-1)){
        var tii_warningCookieValue = tii_warningCheckCookie();
        if (tii_warningCookieValue != "false") {
            window.location = tii_upgradeLocation + "?tii_location=" + window.location.toString();
        }
    }
}


function tii_warningCheckCookie() {
    var tii_cookies=document.cookie;
    var tii_prefix="showWarning=";
    var tii_start=tii_cookies.indexOf(tii_prefix);
    if (tii_start==-1){
        return null;
    }
    var tii_end=tii_cookies.indexOf(";",tii_start);
    if(tii_end==-1){
        tii_end=tii_cookies.length;
    }
    return unescape(tii_cookies.substring(tii_start+tii_prefix.length,tii_end));
}


function tii_warningSetCookie() {
    var tii_warningCookie = "showWarning=false";
    tii_warningCookie = tii_warningCookie + "; path=/;";
    document.cookie = tii_warningCookie;

    tii_windowLocation = window.location.search.toString();
    tii_windowLocation = tii_windowLocation.substring((tii_windowLocation.indexOf("tii_location=")+13),tii_windowLocation.length);
    window.location = tii_windowLocation;
}


function tii_addMacBrowser(browser,version){
    tii_macVersionArray[browser] = version;
}


function tii_addWindowsBrowser(browser,version){
    tii_windowsVersionArray[browser] = version;
}


function tii_setUpgradeLocation(path){
    tii_upgradeLocation = path;
}


function tii_returnBrowserDisplayString(){
    var tii_yourBrowser;
    if(tii_variety!=""){
        tii_yourBrowser = tii_variety + " using " + tii_browser + " " + tii_version + " on " + tii_OS;
    } else {
        tii_yourBrowser = tii_browser + " " + tii_version + " on " + tii_OS;
    }
    return tii_yourBrowser;
}


tii_addMacBrowser("Internet Explorer",-1);
tii_addMacBrowser("Netscape Navigator",7.2);
tii_addMacBrowser("Safari",1.2);
tii_addMacBrowser("Firefox",0);

tii_addWindowsBrowser("Internet Explorer",6);
tii_addWindowsBrowser("Netscape Navigator",7.2);
tii_addWindowsBrowser("Firefox",0);

tii_setUpgradeLocation("/instyle/browserUpgrade/0,,,00.html");


tii_checkVersion();


// partners code

    /*	recirculation feed functions	*/
    //	global variable initialization
    var MasterArray = new Array();
/* 	global Partner Recirc function */
    var PartnerRecirc = function() {
        var arr = MasterArray;
        var nextFeed;
        var recircCallback = function(pos) {
            if (!document.getElementById) return;
            if (!document.getElementById(pos.id)) return;
            divID = pos.name.replace(/\./,'').replace(/ /,'');
            if (pos.id == 'bottombeautyrecirc' || pos.id == 'bottomfashionrecirc' || pos.id == 'bottomcelebrityrecirc' || pos.id == 'bottomdesignercentralrecirc' || pos.id == 'partiesrecirc' || pos.id == 'bottomrecirc' || pos.id == 'bottomshoppingrecirc' || pos.id == 'starfinderbottomrecirc') {
                var 	tout = '1';
                var 	tout1 = tout - 1;
                var 	divHTML = '<div class="tout0' + tout + ' tout" id="tout' + tout1 +'">';
                divHTML += ' <h6 class="' + pos.clas;
                divHTML += '" title="From '+ pos.name;
                divHTML += '"><a href="' + pos.site;
                divHTML += '">From ' + pos.name;
                divHTML += '</a></h6>';
                divHTML += '	<div class="recirclinks">\n';
                divHTML += '		<ul>\n';
                for (li = 0; li < pos.display; li++) {
                    if (pos.response[0][li].title != '') {
                        divHTML += '			<li><a href="'+pos.response[0][li].url+'" target="_blank">'+pos.response[0][li].title+'</a></li>\n';
                    }
                }
                divHTML += '		</ul>\n';
                divHTML += '	</div>\n';
            } else {
                var	divHTML = '<div class="listtout clear">';	
                divHTML += '	<h6 class="'+ pos.clas +'" title="From '+ pos.name + '"><a href="' + pos.site + '">From ' + pos.name + '</a></h6>';
                divHTML += '	<div class="tout clear">\n';
                divHTML += '	<div class="recirclinks">\n';
                divHTML += '		<ul>\n';
                for (li = 0; li < pos.display; li++) {
                    if (pos.response[0][li].title != '') {
                        divHTML += '			<li><a href="'+pos.response[0][li].url+'" target="_blank">'+pos.response[0][li].title+'</a></li>\n';
                    }
                }
                divHTML += '		</ul>\n';
                divHTML += '	</div>\n';
                divHTML += '</div>\n';
                divHTML += '</div>\n';
            }
            divHTML = document.getElementById(pos.id).innerHTML + divHTML + '\n';
            //alert (divHTML);
            var parent = document.getElementById(pos.id);
                parent.innerHTML = divHTML;
            if (parent.className.indexOf('active') < 0) {parent.className = parent.className + ' active';};
        };
        var checkScript = function(pos) {
            var recircInt = setInterval(function() {
                var name = pos.name.replace(/\./,'').replace(/ /,'');
                if (feed) {
                    pos.response = new Array(feed);
                    feed = null; detachScript(name); pos.callback(pos);
                    //if(nextFeed < lastFeed) { getStarted(); };
                    if(nextFeed > 0) { getStarted(); };
                    clearInterval(recircInt);
                }
            },500);
        };
        var detachScript = function(name) {
            elem = document.getElementById('recirc'+name);
            elem.parentNode.removeChild(elem);
        };
        var attachScript = function(pos) {
            var name = pos.name.replace(/\./,'').replace(/ /,'');
            var script = document.createElement('script');
                script.setAttribute('type','text/javascript');
                script.setAttribute('language','javascript');
                script.setAttribute('id','recirc'+name);
                script.setAttribute('src',pos.json);
            document.body.appendChild(script);
            checkScript(pos);
        };
        var getStarted = function() {
            nextFeed--;
            if (document.getElementById(arr[nextFeed].id)) {
                arr[nextFeed].callback = (arr[nextFeed].callback) ? arr[nextFeed].callback : recircCallback;
                arr[nextFeed].display = (arr[nextFeed].display) ? arr[nextFeed].display : 3;
                arr[nextFeed].cta = (arr[nextFeed].cta) ? arr[nextFeed].cta : 'More news at '+arr[nextFeed].name;
                attachScript(arr[nextFeed]);
            } else {
                if(nextFeed > 0) { getStarted(); };
            }
        };
        var init = function() {
            if (arr.length > 0) {
                nextFeed = arr.length;
                getStarted();
            }
        };
        init();
    }

//	initialize Partner Recirc feeds on photo channel page
    var initializeGlobalRecirc = function() {
        if (!document.getElementById) return;
        if (!document.getElementsByTagName) return;
        var recircArray = {
            'recircs' : [ 
                {

                    'id'		: 'celebrityrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Fabsugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/fabsugar/feed.js',
                            'site' 		: 'http://www.fabsugar.com/',
                            'clas' 	: 'fabsugar'
                        },{
                            'name'  	: 'CNN',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/cnn/feed.js',
                            'site' 		: 'http://www.cnn.com',
                            'clas' 	: 'cnn'
                        },{
                            'name'  	: 'Daily Beast',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/dailybeast/feed.js',
                            'site' 		: 'http://www.thedailybeast.com/newsmaker/sexybeast/',
                            'clas' 	: 'sexybeast'
                        },{
                            'name'  	: 'Huffington Post',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/huffingtonpost/feed.js',
                            'site' 		: 'http://www.huffingtonpost.com/style/',
                            'clas' 	: 'huffpost'
                        }
                    ]
                    
                },				{

                    'id'		: 'celebrityrecirc1',
                    'type' 		: 'random',
                    'display'	: 1,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Fabsugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/fabsugar/feed.js',
                            'site' 		: 'http://www.fabsugar.com/',
                            'clas' 	: 'fabsugar'
                        },{
                            'name'  	: 'CNN',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/cnn/feed.js',
                            'site' 		: 'http://www.cnn.com',
                            'clas' 	: 'cnn'
                        },{
                            'name'  	: 'Daily Beast',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/dailybeast/feed.js',
                            'site' 		: 'http://www.thedailybeast.com/newsmaker/sexybeast/',
                            'clas' 	: 'sexybeast'
                        },{
                            'name'  	: 'Huffington Post',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/huffingtonpost/feed.js',
                            'site' 		: 'http://www.huffingtonpost.com/style/',
                            'clas' 	: 'huffpost'
                        }
                    ]
                    
                },{
                    'id'		: 'beautyrecirc',	
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'Bellasugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.bellasugar.com',
                            'clas' 	: 'bellasugar'
                        }
                    ]
                },{
                    'id'		: 'beautybbbrecirc',	
                    'display'	: 2,
                    'feed' 		: [
                        {
                            'name'  	: 'Bellasugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.bellasugar.com',
                            'clas' 	: 'bellasugar'
                        },{
                            'name'  	: 'StyleWatch',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/stylewatch/feed.js',
                            'site' 		: 'http://www.peoplestylewatch.com/people/stylewatch/',
                            'clas' 	: 'stylewatch'
                        }
                    ]
                },{	// example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                    'id'		: 'fashionrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Fabsugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/fabsugar/feed.js',
                            'site' 		: 'http://www.fabsugar.com',
                            'clas' 	: 'fabsugar'
                        },{
                            'name'  	: 'Stylelist',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/stylelist/feed.js',
                            'site' 		: 'http://www.stylelist.com',
                            'clas' 	: 'stylelist'
                        },{
                            'name'  	: 'Modelinia',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/modelinia/feed.js',
                            'site' 		: 'http://www.modelinia.com',
                            'clas' 	: 'modelinia'
                        }
                    ]
                },{	// example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                    'id'		: 'shoppingrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Bellasugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.bellasugar.com',
                            'clas' 	: 'bellasugar'
                        },{
                            'name'  	: 'Stylelist',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/stylelist/feed.js',
                            'site' 		: 'http://www.stylelist.com',
                            'clas' 	: 'stylelist'
                        }
                    ]
                },{	// example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                    'id'		: 'makeoverrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'Bellasugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.beallasugar.com',
                            'clas' 	: 'bellasugar'
                        },{
                            'name'  	: 'Stylelist',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/stylelist/feed.js',
                            'site' 		: 'http://www.stylelist.com',
                            'clas' 	: 'stylelist'
                        }
                    ]
                },{	// example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                    'id'		: 'designercentralrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'Modelinia',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/modelinia/feed.js',
                            'site' 		: 'http://www.modelinia.com',
                            'clas' 	: 'modelinia'
                        }
                    ]
                },{	// example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                    'id'		: 'recirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'Bellasugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.bellasugar.com',
                            'clas' 	: 'bellasugar'
                        },{
                            'name'  	: 'Stylelist',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/stylelist/feed.js',
                            'site' 		: 'http://www.stylelist.com',
                            'clas' 	: 'stylelist'
                        }
                    ]
                },{
                    'id'		: 'bottomcelebrityrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'CNN',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.cnn.com',
                            'clas' 	: 'cnn'
                        },{
                            'name'  	: 'Daily Beast',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/dailybeast/feed.js',
                            'site' 		: 'http://www.thedailybeast.com/newsmaker/sexybeast/',
                            'clas' 	: 'sexybeast'
                        }
                    ]
                    
                },{
                    'id'		: 'bottombeautyrecirc',	
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'Bellasugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.bellasugar.com',
                            'clas' 	: 'bellasugar'
                        }
                    ]
                },{	// example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                    'id'		: 'bottomfashionrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Fabsugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/fabsugar/feed.js',
                            'site' 		: 'http://www.fabsugar.com',
                            'clas' 	: 'fabsugar'
                        },{
                            'name'  	: 'Stylelist',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/stylelist/feed.js',
                            'site' 		: 'http://www.stylelist.com',
                            'clas' 	: 'stylelist'
                        },{
                            'name'  	: 'Modelinia',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/modelinia/feed.js',
                            'site' 		: 'http://www.modelinia.com',
                            'clas' 	: 'modelinia'
                        }
                    ]
                },{	//example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                    'id'		: 'bottomshoppingrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Bellasugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.bellasugar.com',
                            'clas' 	: 'bellasugar'
                        },{
                            'name'  	: 'Stylelist',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/stylelist/feed.js',
                            'site' 		: 'http://www.stylelist.com',
                            'clas' 	: 'stylelist'
                        }
                    ]
                },{	// example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                    'id'		: 'bottomdesignercentralrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'Modelinia',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/modelinia/feed.js',
                            'site' 		: 'http://www.modelinia.com',
                            'clas' 	: 'modelinia'
                        }
                    ]
                },{	// example of how to do random recircs in a single container; to randomize order, but show both, change 'display' to 2
                
                    'id'		: 'bottomrecirc',
                    'type' 		: 'random',
                    'display'	: 2,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'Bellasugar',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/bellasugar/feed.js',
                            'site' 		: 'http://www.bellasugar.com',
                            'clas' 	: 'bellasugar'
                        },{
                            'name'  	: 'Stylelist',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/stylelist/feed.js',
                            'site' 		: 'http://www.stylelist.com',
                            'clas' 	: 'stylelist'
                        }
                    ]
                },{
                    'id'		: 'partiesrecirc',
                    'type' 		: 'random',
                    'display'	: 3,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'CNN',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/cnn/feed.js',
                            'site' 		: 'http://www.cnn.com',
                            'clas' 	: 'cnn'
                        },{
                            'name'  	: 'Daily Beast',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/dailybeast/feed.js',
                            'site' 		: 'http://www.thedailybeast.com/newsmaker/sexybeast/',
                            'clas' 	: 'sexybeast'
                        },{
                            'name'  	: 'Huffington Post',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/huffingtonpost/feed.js',
                            'site' 		: 'http://www.huffingtonpost.com/style/',
                            'clas' 	: 'huffpost'
                        }
                    ]
                    
                },{
                    'id'		: 'starfinderbottomrecirc',
                    'type' 		: 'random',
                    'display'	: 3,
                    'feed' 		: [ 
                        {
                            'name'  	: 'Total Beauty',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/totalbeauty/feed.js',
                            'site' 		: 'http://www.totalbeauty.com/',
                            'clas' 	: 'totalbeauty'
                        },{
                            'name'  	: 'CNN',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/cnn/feed.js',
                            'site' 		: 'http://www.cnn.com',
                            'clas' 	: 'cnn'
                        },{
                            'name'  	: 'Daily Beast',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/dailybeast/feed.js',
                            'site' 		: 'http://www.thedailybeast.com/newsmaker/sexybeast/',
                            'clas' 	: 'sexybeast'
                        },{
                            'name'  	: 'Huffington Post',
                            'json' 		: 'http://www.instyle.com/instyle/static/json/huffingtonpost/feed.js',
                            'site' 		: 'http://www.huffingtonpost.com/style/',
                            'clas' 	: 'huffpost'
                        }
                    ]
                    
                }
            ]
        };
        for (var a = 0; a < recircArray.recircs.length; a++) {
            var tempArray = new Array(recircArray.recircs[a]);
            var last = tempArray[0].feed.length;
            if (tempArray[0].type && tempArray[0].type == 'random') { 
                tempArray[0].feed.sort(function() {return 0.5 - Math.random();}); 
                last = tempArray[0].display;
            }
            for (var f = 0; f < last; f++) {
                var ids = tempArray[0].id.split(',');
                var thisID = (ids.length > 1) ? ids[f] : tempArray[0].id;
                tempArray[0].feed[f].id = thisID;
                MasterArray.push(tempArray[0].feed[f]);
            }
        }
    }
    initializeGlobalRecirc();
//	start recirc feed process
    var startRecircFeeds = function() {
        var n = new PartnerRecirc();
    }
    
//	can list as many functions as you want and the loader below will load them as soon as the page is loaded
    var pageLoadFunctions = function() {
        startRecircFeeds();
        
        
//****  LOTD popup window hotfix for Safari bug --Alex 3/26/2010  ************************************************/
        if (document.getElementById('lotd2009') == null && document.getElementById('slide') != null) {
            //for easy access to classes
            document.getElementsByClassName = function(cl) {
                var retnode = [];
                var myclass = new RegExp('\\b'+cl+'\\b');
                var elem = this.getElementsByTagName('*');
                for (var i = 0; i < elem.length; i++) {
                    var classes = elem[i].className;
                    if (myclass.test(classes)) retnode.push(elem[i]);
                }
                return retnode;
            }
            //check to make *sure* this is the pop up window
            if (document.getElementsByClassName('photo').length == 1 && document.getElementsByClassName('photo')[0].firstChild.getAttribute("href") != '#') {
                //set target on photo link
                document.getElementsByClassName('photo')[0].firstChild.setAttribute('target', '_self');
                //set target on previous button
                if (document.getElementsByClassName('prev').length == 1) {
                    document.getElementsByClassName('prev')[0].firstChild.setAttribute('target', '_self');
                }
                //set target on next button
                if (document.getElementsByClassName('next').length == 1) {
                    document.getElementsByClassName('next')[0].firstChild.setAttribute('target', '_self');
                }
            }
        }
//****  end LOTD popup window hotfix  ****************************************************************************/
        
		// iPad optimizations
		if ((document.getElementById('home2010') != null) && ((navigator.userAgent.match('iPhone')) || (navigator.userAgent.match('iPad')) || (navigator.userAgent.match('iPod')) || (location.search.indexOf('ipad=true') > -1))) {
			var script = document.createElement('script');
			script.type = 'text/javascript';
			script.src = 'http://www.instyle.com/instyle/static/j/ipad/home.js';
			document.getElementsByTagName('head')[0].appendChild(script);
		}

		if ((navigator.userAgent.match('iPhone')) || (navigator.userAgent.match('iPad')) || (navigator.userAgent.match('iPod')) || (location.search.indexOf('ipad=true') > -1)) {
			var script = document.createElement('script');
			script.type = 'text/javascript';
			script.src = 'http://www.instyle.com/instyle/static/j/ipad/hideflashnojquery.js';
			document.getElementsByTagName('head')[0].appendChild(script);
		}

	}
    tii_callFunctionOnWindowLoad(pageLoadFunctions);

/*********************************************************************************************************/
/****  UNIVERSAL IS CLASS  ****/
/*********************************************************************************************************/
var IS = window.IS || [];


	
//**** gallery stitching starts ****************/
		if( typeof IS.Photo == "undefined" ) {
			IS.Photo = {};
		}
		IS.Photo = (function() {
		
			function getNextGallery() {
				$.getJSON( '/instyle/package/navigation/js/0,,' + IS.Photo.packageid + ',00.js', function( data ) {
					var galleries = [];
					$.each( data.galleries, function( i ) {
						galleries.push( data.galleries[i].id );
					});
					var pos = $.inArray( IS.Photo.galleryid	, galleries );
					if( galleries[pos + 1] ) {
						renderNextGallery( data.galleries[ pos + 1 ] );
					} else {
						renderNextGallery( data.galleries[ 0 ] );
					}
				});
			}

			
			function renderNextGallery( gallery ) {
				
				/* next links */
				$( 'li.nextgal' ).find( 'a' ).attr( 'href', gallery.url );
				
				/* next gallery thumbnail and text */
				var recirc = $( '<div class="nextrecirc clear">' +
						'<div class="imgcont">' +
							'<a href="' + gallery.url + '">' +
							'<img src="' + gallery.image + '" alt="' + gallery.title + '" width="75" height="75" border="0" />' +
							'<\/a>' +
						'<\/div>' +
						'<div class="txtcont">' +
							'Next Gallery: <a href="' + gallery.url + '">' + gallery.title + '<\/a>' +
							'&nbsp;<img src="http://img2.timeinc.net/instyle/static/2007/i/icon_arrow01.gif" alt="" width="4" height="7" border="0">' +
						'<\/div>' +
					'<\/div>'
				);
				
				var existingRecirc = $('.nextrecirc');
				
				if( existingRecirc.length ) {
					existingRecirc.replaceWith( recirc );
				} else {
					recirc.insertAfter( '.slideinfo .text' );
				}
				
				
			}
			
			return {
				stitch: function() {
					if( !IS.Photo.isStitched ) return;					
					getNextGallery();
				}
			}

			
			return {
				stitch: function() {
					if( !IS.Photo.isStitched ) return;
					getNextGallery();
				}
			}
		
		})();
		
//**** Gallery stitching ends **************************/

// start visual revenue **********************
	var _vrq = _vrq || [];
	_vrq.push(['id', 41]);
	_vrq.push(['automate', false]);
	_vrq.push(['track', function(){}]);
	(function(d, a){
		var s = d.createElement(a),
		x = d.getElementsByTagName(a)[0];
		s.async = true;
		s.src = 'http://a.visualrevenue.com/vrs.js';
		x.parentNode.insertBefore(s, x);
	})(document, 'script');
// end visual revenue **********************
