/*! Copyright 2009 The Knot, Inc. All rights reserved. */

/*  Common TK.com javascript function - create 1/2009 - Jason Sirota 
//#region denotes the beginning of a section of the code, use Visual Studio Macros to collapse sections
http://blog.devarchive.net/2008/04/using-region-directive-with-javascript.html
*/
/*for JSLint include the browser exceptions window and escape*/
/*global window,document,escape,unescape,Image */

//#region Global Variables
var popUpExpDays = 9999;
var popUpExp = new Date();
var membExpDays = 1;
var membExp = new Date();
var menuList = ["droppc", "dropge", "droprw", "dropac", "dropfa", "dropbe", "dropmm", "dropgg", "drophm"];
var navNames = ["pc", "ge", "rw", "ac", "fa", "be", "mm", "gg", "hm"];
var timer = 'null';
var thisServer = window.location.hostname;
var theDate = new Date();
var iv_javascript = false;
//#endregion

//#region js file version
var hasFile = function(fileName) { return (fileName == "theknot.common.js"); }
//#endregion

//#region DOM Helper Functions 

/* */
var addOnLoad = function(myfunc) {
    if (window.addEventListener) {
        window.addEventListener('load', myfunc, false);
    } else if (document.addEventListener) {
        document.addEventListener('load', myfunc, false);
    } else if (window.attachEvent) {
        window.attachEvent('onload', myfunc);
    }
};

var dom_include = function(url) {
    document.write('<scr' + 'ipt src="' + url + '" language="javascript"></scr' + 'ipt>');
};

// ### gets an array of objects that match the input start element, tag name, and class name
// Ways of calling the function are:
// To get all a elements in the document with a "info-links" class. 
// getElementsByClassName(document, "a", "info-links"); 
// To get all div elements within the element named "container", with a "col" and a "left" class. 
// getElementsByClassName(document.getElementById("container"), "div", ["col", "left"]); 
var dom_getElementsByClassName = function(oElm, strTagName, oClassNames) {
    var arrElements = (strTagName == "*" && document.all) ? document.all :
    oElm.getElementsByTagName(strTagName);
    var arrReturnElements = [];
    var arrRegExpClassNames = [];
    if (typeof oClassNames == "object") {
        for (var i = 0; i < oClassNames.length; i++) {
            arrRegExpClassNames.push(new RegExp("(^|\\s)" +
            oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
        }
    }
    else {
        arrRegExpClassNames.push(new RegExp("(^|\\s)" +
        oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
    }
    var oElement;
    var bMatchesAll;
    for (var j = 0; j < arrElements.length; j++) {
        oElement = arrElements[j];
        bMatchesAll = true;
        for (var k = 0; k < arrRegExpClassNames.length; k++) {
            if (!arrRegExpClassNames[k].test(oElement.className)) {
                bMatchesAll = false;
                break;
            }
        }
        if (bMatchesAll) {
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements);
};

var dom_addClassName = function(oElm, strClassName) {
    var strCurrentClass = oElm.className;
    if (!new RegExp(strClassName, "i").test(strCurrentClass)) {
        oElm.className = strCurrentClass + ((strCurrentClass.length > 0) ? " " : "") + strClassName;
    }
};

var dom_removeClassName = function(oElm, strClassName) {
    var oClassToRemove = new RegExp((strClassName + "\s?"), "i");
    oElm.className = oElm.className.replace(oClassToRemove, "").replace(/^\s?|\s?$/g, "");
};



var dom_hasClassName = function(oElm, strClassName) {
    return oElm.className.match(new RegExp('(\\s|^)' + strClassName + '(\\s|$)'));
};

//#endregion

//#region Window Functions (popups, redirects, dropdowns)

/* */
var openPopup = function(url, w, h, resize, scroll, wname) {
    // place this in onclick or href:  "javascript:open_popup('[url]','[width of window]','[height of window]','[resize option]','[scroll opiton]','[windowname]');"
    wname = (wname === null) ? "popwin" : wname.replace(new RegExp(/ /g), "");
    scroll = ((scroll === null) || (scroll === '') || (scroll == 1) || (scroll == '1')) ? 'yes' : 'no';
    resize = ((resize === null) || (resize === '') || (resize == 1) || (resize == '1')) ? 'yes' : 'no';
    var properties = "toolbar=0,scrollbars=" + scroll + ",location=0,statusbar=1,menubar=0,resizable=" + resize;
    properties += ",width=" + w + ",height=" + h;

    var child = window.open(url, wname, properties);
    child.focus();
    return child;
};

/* */
var openUrl = function(url) {
    window.location = url;
};

/* */
var openParentSite = function(url) {
    if (window.parent && window.parent.opener) {
        if (url !== "") {
            window.parent.opener.location = url;
        }
        window.parent.opener.focus();
    }
};

/* */
/* <form><select name="mySelect" onChange="goSelect(this);">[options]</select>[submit]</form>*/
var goSelect = function(thisselect) {
    if (thisselect.selectedIndex > 0) {
        var url = thisselect.options[thisselect.selectedIndex].value;
        if (url !== '') {
            window.location = url;
        }
    }
};

/* */
var chooseFrame = function(thisselect) {
    var url = "";
    if (thisselect.selectedIndex > 0) {
        if (thisselect.options[thisselect.selectedIndex].value.indexOf("http://", 0) != -1) {
            url = thisselect.options[thisselect.selectedIndex].value;
            if (url !== "") { window.parent.location = url; }
        }
        else {
            url = thisselect.options[thisselect.selectedIndex].value;
            if (url !== "") { window.location = url; }
        }
    }
};

/* */
var gotoUrl = function() {
    goSelect(document.formname.selectname);
    return false;
};

/* Dynamic Pull-Down Linking outside of an iFrame - target = new */
/* <form><select name="menu" onchange="frameSelect(this.form)">[options]</select>[submit]</form> */
var frameSelect = function(form) {
    var myindex = form.menu.selectedIndex;
    if (form.menu.options[myindex].value != "0") {
        window.open(form.menu.options[myindex].value, "newframe");
    }
};

/* Dynamic Pull-Down Linking outside of an iFrame - target = top */
/* <form><select name="iframemenu" onchange="iframeSelect(this.form)">[options]</select>[submit]</form> */
var iframeSelect = function(form) {
    var myindex = form.iframemenu.selectedIndex;
    if (form.iframemenu.options[myindex].value != "0") {
        window.open(form.iframemenu.options[myindex].value, "_top");
    }
};

/* */
var openPopUnder = function(url) {
    var random_num = Math.random() * 4;
    var window_num = Math.round(random_num);
    if (url !== "") {
        pu = window.open(url, "popunderwin", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width=450,height=275,left=230,top=205,screenX=230,screenY=205");
        pu.blur();
        window.focus();
        return pu;
    }
    // Have Holiday Popup show up 50% of time. (Numbers 0, 3 and 4 are generated 50% of the time, so give them to the Regular 4-Product Pop-up.  Each pop-up gets 50%.)
    //pu = window.open("registrypop.shtml","popunderwin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width=450,height=275,left=230,top=205,screenX=230,screenY=205");
    //pu = window.open("weddingpop.shtml","popunderwin","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width=450,height=275,left=230,top=205,screenX=230,screenY=205");
    //pu.blur();
    //window.focus(); 
    return null;
};

/* */
var galleryResultsPop = function(url) {
    var gallerypop = window.open(url, "gallerypop", "toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=0,resizable=y,width=560,height=520");
    if (window.navigator.appVersion.substring(0, 1) >= 3) {
        gallerypop.focus();
    }
    return gallerypop;
};

var createBookmarkLink = function() {
    var title = document.title;
    var url = window.location.href;
    if (window.sidebar) { // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url, "");
    } else if (window.external) { // IE Favorite
        window.external.AddFavorite(url, title);
    }
    else if (window.opera && window.print) { // Opera Hotlist
        return true;
    }
};

//#endregion

//#region Image Helpers (swaps)

/*  Used with onmouseover and onmouseout to swap images on rollover */
/*  There were 2 forms of swap in the original files, 
one with "img" name and one with "id", this handles both types */
var swap = function(id, url) {
    //test by ID first
    var img = document.getElementById(id);
    //if not by ID and document.images exist, test by image name
    if (!img && document.images) { img = document.images[id]; }
    if (img) { img.src = url; }
};

/* Input Button Rollovers */
/* <input hoversrc="[image]"> */
var swapInputButtons = function() {
    var MWJ_img_cache = {};
    var f1 = function() { this.src = this.rootsrc; };
    var f2 = function() { this.src = this.hoversrc; };
    var f3 = function(e) {
        e = e ? e : window.event;
        if (e.button > 1 || e.which > 1) { return; }
        this.src = this.activesrc;
    };
    var f4 = function(e) {
        e = e ? e : window.event;
        if (e.button > 1 || e.which > 1) { return; }
        this.src = this.hoversrc ? this.hoversrc : this.rootsrc;
    };
    for (var i = 0; i < 2; i++) {
        var ar = i ? (document.getElementsByTagName ? document.getElementsByTagName('input') : (document.all ? document.all.tags('INPUT') : [])) : document.images;
        for (var x = 0; ar[x]; x++) {
            var im = ar[x];
            if (im.getAttribute) { im.hoversrc = im.getAttribute('hoversrc'); im.activesrc = im.getAttribute('activesrc'); }
            if (im.hoversrc || im.activesrc) {
                if (!MWJ_img_cache[im.src]) { MWJ_img_cache[im.src] = new Image(); MWJ_img_cache[im.src].src = im.src; }
                im.rootsrc = im.src;
                im.onmouseout = f1;
            }
            if (im.hoversrc) {
                if (!MWJ_img_cache[im.hoversrc]) { MWJ_img_cache[im.hoversrc] = new Image(); MWJ_img_cache[im.hoversrc].src = im.hoversrc; }
                im.onmouseover = f2;
            }
            if (im.activesrc) {
                if (!MWJ_img_cache[im.activesrc]) { MWJ_img_cache[im.activesrc] = new Image(); MWJ_img_cache[im.activesrc].src = im.activesrc; }
                im.onmousedown = f3;
                im.onmouseup = f4;
            }
        }
    }
};

/* SlideShows */
/* Put this code in the page:
<a href="#" onClick="toggle('div1',1); toggle('div2',0); toggle('div3',0); return false;"><img src="image" border="0"></a>*/
var swapSlideShow = function(id, fff) {
    if (fff == "1") {
        if (document.layers) { document.layers['' + id + ''].visibility = "show"; }
        else if (document.all) { document.all['' + id + ''].style.visibility = "visible"; }
        else if (document.getElementById) { document.getElementById('' + id + '').style.visibility = "visible"; }
    } else if (fff == "0") {
        if (document.layers) { document.layers['' + id + ''].visibility = "hide"; }
        else if (document.all) { document.all['' + id + ''].style.visibility = "hidden"; }
        else if (document.getElementById) { document.getElementById('' + id + '').style.visibility = "hidden"; }
    }
};

/* Image Precaching */
var setImagePrecache = function() {
    if (document.images) {
        // create "normal" Image object, populate with and set URLs for the "normal" images
        var navimgurl = "http://images.theknot.com/topnav/";
        var imagesNormal = {};

        // create "on" Image object, populate with and set URLs for the "on" images
        var imagesOn = {};

        // create "over" Image object, populate with and set URLs for the "over" images
        var imagesOver = {};
    }
};

/* corrects PNG images to get PNG transparency to work in IE */
var correctPNG = function() {
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])

    if ((version < 7) && (document.body.filters)) {
        for (var i = 0; i < document.images.length; i++) {
            var img = document.images[i]
            var imgName = img.src.toUpperCase()
            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                img.outerHTML = strNewHTML
                i = i - 1
            }
        }
    }

};

var fixExternalLinks = function() {
    var objLinks = document.getElementsByTagName('a');
    for (var iCounter = 0; iCounter < objLinks.length; iCounter++) {
        if (objLinks[iCounter].getAttribute('href') && objLinks[iCounter].getAttribute('rel') == 'external') {
            objLinks[iCounter].setAttribute('target', '_blank');
        }
        else if (objLinks[iCounter].getAttribute('href') && objLinks[iCounter].getAttribute('rel') == 'top') {
            objLinks[iCounter].setAttribute('target', '_top');
        }
    }
};

//#endregion

//#region Menu/Tab Helper Functions

/* */
var hideMenus = function() {
    for (var i = 0; i < menuList.length; i++) {
        var el = document.getElementById(menuList[i])
        if (el) {
            el.style.visibility = 'hidden';
        }
    }
};

/* */
var showMenu = function(MenuName) {
    //alert(MenuName);
    window.clearTimeout(timer);
    hideMenus();
    var el = document.getElementById(MenuName);
    if (el) { el.style.visibility = 'visible'; }
};

/* */
var overLayer = function() {
    window.clearTimeout(timer);
};

/* */
var outLayer = function() {
    window.clearTimeout(timer);
    timer = window.setTimeout(hideMenus, 300);
};

var toggleMainNav = function(oThisMenuLink) {
    var oThisMenuLinksArrowImageArray = oThisMenuLink.parentNode.getElementsByTagName("img");
    var oThisMenuLinksArrowImage = oThisMenuLinksArrowImageArray[0];
    var oThisParentContainer = oThisMenuLink.parentNode.parentNode;
    var arrNavDivs = dom_getElementsByClassName(document, 'div', 'mainnav_mainlevel');

    // close all other submenus
    /*
    for (var i=0; i<arrNavDivs.length; i++)
    {
    if (arrNavDivs[i] !== oThisParentContainer)
    {
    dom_removeClassName(arrNavDivs[i], 'onstate');
    }
    }	
    */

    // open or close (toggle) proper submenu (and title text for arrow image)
    if (!dom_hasClassName(oThisParentContainer, 'onstate')) {
        dom_addClassName(oThisParentContainer, 'onstate');
        oThisMenuLinksArrowImage.setAttribute('alt', 'click to hide');
        oThisMenuLinksArrowImage.setAttribute('title', 'click to hide');
    }
    else {
        dom_removeClassName(oThisParentContainer, 'onstate');
        oThisMenuLinksArrowImage.setAttribute('alt', 'click to expand');
        oThisMenuLinksArrowImage.setAttribute('title', 'click to expand');
    }
};

// toggle for tab content boxes
var toggleTabContent = function(oThisMenuLink, iTabContentId) {
    var oThisContentDiv = document.getElementById('tabcontent_' + iTabContentId);
    var arrMenuLinks = dom_getElementsByClassName(document, 'a', 'tabbedboxmenulink');
    var arrContentDivs = dom_getElementsByClassName(document, 'div', 'tabbedboxcontent');

    // close all other content boxes
    for (var i = 0; i < arrContentDivs.length; i++) {
        if (arrContentDivs[i] !== oThisContentDiv) {
            dom_removeClassName(arrContentDivs[i], 'onstate');
        }
    }

    // open or close (toggle) proper content box
    if (!dom_hasClassName(oThisContentDiv, 'onstate')) {
        dom_addClassName(oThisContentDiv, 'onstate');
    }

    // close all other tab links
    for (var j = 0; j < arrMenuLinks.length; j++) {
        if (arrMenuLinks[j] !== oThisMenuLink) {
            dom_removeClassName(arrMenuLinks[j], 'onstate');
        }
    }

    // open or close (toggle) proper tab link
    if (!dom_hasClassName(oThisMenuLink, 'onstate')) {
        dom_addClassName(oThisMenuLink, 'onstate');
    }

    return false;
};


//#endregion


//#region Date Helper Functions

/* */
var getDayString = function(num) {
    var day;
    var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    day = ((num >= 0) || (num < 7)) ? days[num] : "Invalid Day";
    return day;
};

/* */
var getMonthString = function(num) {
    var month;
    var months = ["Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"];

    month = ((num >= 0) || (num < 12)) ? months[num] : "Invalid Month";
    return month;
};
//#endregion

//#region Cookie Helper Functions (getCookie, setCookie)

/* */
var getCookieVal = function(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1) { endstr = document.cookie.length; }
    return unescape(document.cookie.substring(offset, endstr));
};

/* */
var getCookie = function(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;

    while (i < clen) {
        var j = i + alen;

        if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i === 0) { break; }
    }

    return null;
};

/* */
var setCookieWithExpires = function(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires = " + new Date(expires).toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain = " + domain : "") +
		((secure) ? "; secure" : "");
};

/* */
var setCookie = function(name, value, expires, path, domain, secure) {
    expires = expires ? membExp.toGMTString() : "";
    setCookieWithExpires(name, value, expires, path, domain, secure);
};

/* */
var deleteCookie = function(name, path, domain) {
    if (getCookie(name)) {
        setCookieWithExpires(name, "", "Thu, 01-Jan-1970 00:00:01 GMT", path, domain, false);
    }
};

/* */
var fixCookieDate = function(date) {
    var base = new Date(0);
    var skew = base.getTime(); // dawn of (Unix) time - should be 0

    if (skew > 0) { // Except on the Mac
        date.setTime(date.getTime() - skew);
    }
};

/* Cookie Object */
var Cookie = {
    set: function(name, value, daysToExpire, domain) {
        var expire = '';
        var theDomain = '';
        if (daysToExpire !== undefined) {
            var d = new Date();
            d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
            expire = '; expires=' + d.toGMTString();
        }
        if (domain !== undefined) {
            theDomain = '; domain=' + domain;
        }
        return (document.cookie = escape(name) + '=' + escape(value || '') + expire + theDomain + '; path=/');
    },
    get: function(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') {
                c = c.substring(1, c.length);
            }
            if (c.indexOf(nameEQ) === 0) {
                return c.substring(nameEQ.length, c.length);
            }
        }
        return null;
    }
};


/* Popup Cookie Functions */
/* Put this code in the page:
<script language="javascript" type="text/javascript"> 
var page="pagename.html";
var windowprops = " width=x, height=y, location=no, toolbar=no, menubar=no, scrollbars=1, resizable=1";
var cookiecount = "new value";
window.onload=checkCount; 
</script>*/
/*global page,windowprops,cookiecount */

/* */
var setPopupCookieCount = function() {
    var count = getCookie(cookiecount);
    if (count === null) {
        setCookieWithExpires(cookiecount, '1'); return 1;
    } else {
        var newcount = parseInt(count, null) + 1;
        deleteCookie(cookiecount);
        setCookieWithExpires(cookiecount, newcount, popUpExp);
        return count;
    }
};

/* */
var getPopupCookieCount = function() {
    var count = getCookie(cookiecount);
    if (count === null || popUpExpDays == -1) {
        count = 1;
        setCookieWithExpires(cookiecount, count, popUpExp);
        window.open(page, "", windowprops);
    } else {
        count++;
        setCookieWithExpires(cookiecount, count, popUpExp);
    }
};

var setPopupCookieDate = function() {
    if (popUpExp) {
        popUpExp.setTime(popUpExp.getTime() + (popUpExpDays * 24 * 60 * 60 * 1000));
    }
};


/* Membership Cookies */

/* */
var isMainWindow = function() {
    return (window.self == window.top);
};

/* */
var LZ = function(x) {
    return (x < 0 || x >= 10 ? "" : "0") + x;
};

/* */
var getMemberinfo = function(property) {
    var propertyvalue = "";
    var memberinfo = "";
    var startpos = 0;
    var endpos = 0;

    if (window.location.hostname.substr(0, 3) == 'dev') {
        memberinfo = getCookie('memberinfo_dev');
    } else {
        memberinfo = getCookie('memberinfo');
    }

    if (memberinfo !== null && memberinfo !== '' && memberinfo.indexOf('^' + property + '~') != -1) {
        startpos = memberinfo.indexOf('^' + property + '~');
        if (startpos != -1) {
            startpos += property.length + 2;
            endpos = memberinfo.indexOf('^', startpos);

            if (endpos != -1) {
                propertyvalue = memberinfo.substring(startpos, endpos);
                propertyvalue = unescape(propertyvalue);
            }
        }
    }

    if (memberinfo !== null && memberinfo !== '' && memberinfo.indexOf('|' + property + '^') != -1) {
        startpos = memberinfo.indexOf('|' + property + '^');
        if (startpos != -1) {
            startpos += property.length + 2;
            endpos = memberinfo.indexOf('|', startpos);

            if (endpos != -1) {
                propertyvalue = memberinfo.substring(startpos, endpos);
                propertyvalue = unescape(propertyvalue);
            }
        }
    }

    return propertyvalue;
};

/* */
var setMembershipCookieDate = function() {
    fixCookieDate(membExp);
    membExp.setTime(membExp.getTime() + (membExpDays * 24 * 60 * 60 * 1000));
};

/* */
var checkDate = function() {
    if (!isMainWindow()) { return; }

    var lastdate = Cookie.get('dateshown');
    var nestredirected = Cookie.get('newnest');
    var weddingdate = getMemberinfo("weddingdate");
    var todayTime = new Date();
    // Redirect to the Nest if wedding date has passed	
    if (weddingdate !== null && parseInt(weddingdate, null) < parseInt(todayTime.getFullYear() + LZ(todayTime.getMonth() + 1) + LZ(todayTime.getDate()) + '', null) && nestredirected != "true") {
        Cookie.set('newnest', 'true', (365 * 900), 'theknot.com');
        if (null !== Cookie.get('newnest') && window.location.href.indexOf('thenest.com') < 0) { //PREVENT INFINITE REDIRECT
            window.location = "http://www.thenest.com";
            window.open('http://www.theknot.com/email_thenest_pop.html', 'thenest', "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width=400,height=300,left=400,top=400,screenX=400,screenY=510");
        }
        return;
    }

    if (lastdate != membExp.getDate()) {
        showUnload = true;
    }
};

/* */
var checkMemberCookie = function() {
    var membercookie;
    membercookie = getCookie('member');
    if (membercookie === null) {
        return false;
    } else {
        return true;
    }
};


//#endregion

//#region Partner Functions 

/* ivillage partnership tracking */
var trackiVillage = function() {
    if (iv_javascript === null) {
        iv_javascript = true;
        if (getCookie('Partner') == '6') {
            var iv_hideTacoda = true;
            document.write("<script type='text/javascript' src='http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/includes/iv_header.js'></script>");
            document.write("<script type='text/javascript' src='http://a820.g.akamai.net/f/820/822/1d/i.ivillage.com/includes/iv_footer.js'></script>");
        }
    }
};

var technologyPopQuiz = function() {
    // If you're logged in, then pop
    if (getCookie('memberinfo')) {
        openPopup("http://www.theknot.com/popquiz.html?SID=S179", "470", "540", '0', '1', 'quiz');
    }
};

//deactivated Liberty Travel popup - Cody Clayton
var libertyTravelPop = function() { return false; };
var header = function(domain) { return false; }; //partners content removed
var footer = function(domain) { return false; }; //partners content removed

//#endregion

//#region Backwards Compatibility Aliases - DO NOT USE - DEPRECATED

var open_popup = function(url, w, h, resize, scroll, wname) { openPopup(url, w, h, resize, scroll, wname); };
var gotoSite = function(site) { openParentSite(site); };
var redirthp = function(thisarea) { openUrl(thisarea); };
var amt = function() { setPopupCookieCount(); };
var checkCount = function() { getPopupCookieCount(); };
var getPopupCookie = function(name) { getCookie(name); };
var setPopupCookie = function(name, value, expires, path, domain, secure) { setCookieWithExpires(name, value, expires, path, domain, secure); };
var deletePopupCookie = function(name) { deleteCookie(name); };
var toggle = function(id, fff) { swapSlideShow(id, fff); };
var popTool = function(poptoolurl) { openPopup(poptoolurl, "600", "550", "1", "1", "poptool_local"); };
var setCookie2 = function(name, value, expires, path, domain, secure) { setCookieWithExpires(name, value, expires, path, domain, secure); };
var popunder = function() { openPopUnder(); };

//#region Function Calls (Constructor)

var main = function() {
    swapInputButtons();
    setImagePrecache();
    setMembershipCookieDate();
    setPopupCookieDate();
    trackiVillage();
    fixExternalLinks();
    correctPNG();

    //expire old cookies:
    deleteCookie('membernote', '/', window.location.hostname);
    deleteCookie('__qca', '/', '.theknot.com');
    deleteCookie('__qcb', '/', '.theknot.com');
    deleteCookie('__qca', '/', '.thenest.com');
    deleteCookie('__qcb', '/', '.thenest.com');
    deleteCookie('dateshown', '/', window.location.hostname);

    deleteCookie('__utmc', '/', 'talk.theknot.com');
    deleteCookie('__utmz', '/', 'talk.theknot.com');
    deleteCookie('__utma', '/', 'talk.theknot.com');
    deleteCookie('__utmb', '/', 'talk.theknot.com');

    deleteCookie('__utmc', '/', 'boards.thenest.com');
    deleteCookie('__utmz', '/', 'boards.thenest.com');
    deleteCookie('__utma', '/', 'boards.thenest.com');
    deleteCookie('__utmb', '/', 'boards.thenest.com');
};

addOnLoad(main);

//#endregion 

//login.js - converted - JGS - 1/5/2009
//global.js - converted - JGS - 1/5/2009
//common/weddings.js - converted - JGS 1/5/2009
//partners.js - converted - JGS - 1/5/2009
//weddings.js - converted - JGS - 1/5/2009
//app_functions.js - converted - JGS - 1/6/2009
//externallinks.js - converted - JGS - 1/6/2009
//fixit.js - REMOVED - JGS - 1/6/2008