﻿

/* Easy Cookie stuff start*/
EasyCookie=(function(){var EPOCH='Thu, 01-Jan-1970 00:00:01 GMT',RATIO=1000*60*60*24,KEYS=['expires','path','domain'],esc=escape,un=unescape,doc=document,me;var get_now=function(){var r=new Date();r.setTime(r.getTime());return r;}
var cookify=function(c_key,c_val){var i,key,val,r=[],opt=(arguments.length>2)?arguments[2]:{};r.push(esc(c_key)+'='+esc(c_val));for(i=0;i<KEYS.length;i++){key=KEYS[i];if(val=opt[key])
r.push(key+'='+val);}
if(opt.secure)
r.push('secure');return r.join('; ');}
var alive=function(){var k='__EC_TEST__',v=new Date();v=v.toGMTString();this.set(k,v);this.enabled=(this.remove(k)==v);return this.enabled;}
me={set:function(key,val){var opt=(arguments.length>2)?arguments[2]:{},now=get_now(),expire_at,cfg={};if(opt.expires){opt.expires*=RATIO;cfg.expires=new Date(now.getTime()+opt.expires);cfg.expires=cfg.expires.toGMTString();}
var keys=['path','domain','secure'];for(i=0;i<keys.length;i++)
if(opt[keys[i]])
cfg[keys[i]]=opt[keys[i]];var r=cookify(key,val,cfg);doc.cookie=r;return val;},has:function(key){key=esc(key);var c=doc.cookie,ofs=c.indexOf(key+'='),len=ofs+key.length+1,sub=c.substring(0,key.length);return((!ofs&&key!=sub)||ofs<0)?false:true;},get:function(key){key=esc(key);var c=doc.cookie,ofs=c.indexOf(key+'='),len=ofs+key.length+1,sub=c.substring(0,key.length),end;if((!ofs&&key!=sub)||ofs<0)
return null;end=c.indexOf(';',len);if(end<0)
end=c.length;return un(c.substring(len,end));},remove:function(k){var r=me.get(k),opt={expires:EPOCH};doc.cookie=cookify(k,'',opt);return r;},keys:function(){var c=doc.cookie,ps=c.split('; '),i,p,r=[];for(i=0;i<ps.length;i++){p=ps[i].split('=');r.push(un(p[0]));}
return r;},all:function(){var c=doc.cookie,ps=c.split('; '),i,p,r=[];for(i=0;i<ps.length;i++){p=ps[i].split('=');r.push([un(p[0]),un(p[1])]);}
return r;},version:'0.2.1',enabled:false};me.enabled=alive.call(me);return me;}());
/*Easy Cookie end*/


function submitAspForm() {
    $('#aspnetForm').submit();
}

function initCityPreferenceSelect() {
    $('#city_preference_selection').change(submitAspForm);    
}

function styleDropDowns() {
    $('select').selectbox();
}

/* init city preference select on dom ready*/
$(initCityPreferenceSelect);


/* style selects on dom ready*/
$(styleDropDowns);


/*login box stuff*/
var $sweetInsiderBox = $("#sweet_insider");


/* start random selection for Subscriber Box */
function random_subscriber_box() {
   


    var length = $("#sweet_insider .subscriber").length;
    if (length > 0) {
        var ran = Math.floor(Math.random() * length) + 1;

        $("#sweet_insider .subscriber:nth-child(" + ran + ")").slideDown(1000);
        $("#sweet_insider .subscriber:nth-child(" + ran + ") a.login").eq(0).click(showHola);
        $("#sweet_insider .subscriber:nth-child(" + ran + ")").addClass('is_active');
        $("#sweet_insider .subscriber:nth-child(" + ran + ") a.subscribe_link").bind('click', function(e) {
            Page_ClientValidate('subscribe_' + ran);
            if (Page_IsValid) {

                $('#sweet_insider .close').click();


                var modal = $('#sweet_insider');
                var emailModalOpen;


                function checkMask() {
                    emailModalOpen = (modal.css('z-index') !== 'auto');
                    if (!emailModalOpen) {

                        var ol = $("#subscribe_modal").data("overlay");

                        if (ol) {
                            ol.load();
                        }

                        $('#subscribe_modal').overlay({

                            // some mask tweaks suitable for modal dialogs
                            mask: {
                                color: '#ebecff',
                                loadSpeed: 200,
                                opacity: 0.7
                            },

                            closeOnClick: false,

                            oneInstance: false,

                            onBeforeLoad: function() {

                                if ($('#sub_iframe').length === 0 || $('#sub_iframe').length === 1) {
                                    var hf_subscriber = $('#sweet_insider .subscriber.is_active .subscribe_abstract');
                                    var subscribe_abstract = hf_subscriber.html();
                                    if (subscribe_abstract.trim() != '') {
                                        pageTracker._trackEvent('Subscriber box', 'submit', subscribe_abstract.trim());
                                    }
                                    // grab wrapper element inside content
                                    var wrap = this.getOverlay().find(".contentWrap");
                                    if ($('#sub_iframe').length === 0) {
                                        var iframe = document.createElement("iframe");
                                        iframe.id = "sub_iframe";
                                        iframe.scrolling = "no";
                                        iframe.src = "/subscribe/?framed=true&email=" + $("#sweet_insider .subscriber.is_active .subscribe_textbox").val() + "&rurl=" + window.location;
                                        iframe.width = "526px";
                                        iframe.height = "425px";
                                        iframe.style.border = "solid 1px #CCCCCC";
                                        iframe.style.backgroundColor = "#CCCCCC";
                                        // load the page specified in the trigger
                                        wrap.append(iframe);
                                    }
                                    else if ($('#sub_iframe').length === 1) {
                                        //wrap.innerHTML = '';
                                        var tmp = $get('sub_iframe');
                                        tmp.src = "/subscribe/?framed=true&email=" + $("#sweet_insider .subscriber.is_active .subscribe_textbox").val() + "&rurl=" + window.location;
                                    }
                                }
                            },

                            load: true

                        });
                    } else {
                        setTimeout(checkMask, 0);
                    }
                }

                checkMask();

            }




            e.preventDefault();
        });


        $("#sweet_insider .subscriber:nth-child(" + ran + ") input[type='text'][id$='_txt_subscriber']").keydown(function(e) {
            if (e.keyCode === 13) {
                //add one to nth child because close link is added as a child
                $("#sweet_insider .subscriber.is_active a.subscribe_link").click();
                return false;
            }
        });
    } else {
    showHola();
}

}
$(random_subscriber_box);

function closeSubscribeOverlay() {
    $("#subscribe_modal .close").click();

}


function showHola() {
    //hide insider and show hola on callback
    $sweetInsiderBox.slideUp(1000, function() { $("#login_hola").slideDown(1000); });
}

/* city preference prompt stuff */
var $cityPrefPopup = $("#city_popup");


function toggleCityPopup(evt) {
    if ($("#city_popup:visible").length > 0) {
        $cityPrefPopup.fadeOut(500,function () {showCityPopup(evt);});
    }
    else {
        showCityPopup(evt);
    }
    return false;
}

function showCityPopup(evt) {
    
    var $tar = $(evt.target);
    
    var $sectionName = $cityPrefPopup.find(".section_name_holder");
    $sectionName.eq(0).html($tar.html());
    $sectionName.eq(1).html($tar.html());
    
    var $pickCanada = $cityPrefPopup.find("#pick_canada");
    if ($tar.hasClass("select_cityonly")) {
        $pickCanada.hide();
        $("#msg_city").hide();
        $("#msg_city_only").show();
        $("#pick_or").hide();
    }
    else {
        $pickCanada.show();
        $("#msg_city_only").hide();
        $("#msg_city").show();
        $("#pick_or").show();
        $pickCanada.click(function () {
                                        window.location = evt.target.href + "?city_pref=canada";  
                                      });
    }
    var $pickCity = $cityPrefPopup.find("#pick_city");
    $pickCity.change(function () {
                                    if ($pickCity.attr("value") !== "") {
                                        window.location = evt.target.href + "?city_pref=" + $pickCity.attr("value");
                                    }
                                 })
    var p = $tar.position();
    var topPos = Math.round( (p.top + ($tar.height() / 2)) - ($cityPrefPopup.height() / 2) );
    $cityPrefPopup.find(".close_popup").click(closeCityPopup);
    $cityPrefPopup.css({top:topPos + "px"});
    $cityPrefPopup.fadeIn(500);
    return false;
}

function closeCityPopup() {
    $cityPrefPopup.fadeOut(500);
}

function initCityPrefPopup() {
    var cityPreference = EasyCookie.get('city_preference');
    if (cityPreference !== null) {
        if (cityPreference === "canada" || cityPreference === "toute+la+province") {
            $(".select_cityonly").click(toggleCityPopup);
       }
    }
    else {
        $(".select_cityonly").click(toggleCityPopup);
        $(".select_city").click(toggleCityPopup);
    }
}

$(initCityPrefPopup);
/* end city preference prompt stuff */


/* start random selection for Inside Sweetspot Today */
function randomInsideSweetspotToday() {
    var length = $("#inside_sweetlife #inside_sweetlife_top p").length;
    if (length > 0) {
        var ran = Math.floor(Math.random() * length) + 1;
        $("#inside_sweetlife #inside_sweetlife_top p:nth-child(" + ran + ")").show();
    }
}
$(randomInsideSweetspotToday);

/*some stuff for fancy looking dropdowns*/
function makeRaisePopulatedFireOnce()
{
    if (typeof AjaxControlToolkit !== 'undefined') {
        if (AjaxControlToolkit.CascadingDropDownBehavior) {
            AjaxControlToolkit.CascadingDropDownBehavior.prototype._setOptions = function(list, inInit, gettingList) {

                if (!this.get_isInitialized()) {
                    return;
                }

                var e = this.get_element();
                // Remove existing contents
                this._clearItems();

                // Populate prompt text (if available) 
                var headerText;
                var headerValue = "";
                if (gettingList && this._loadingText) {
                    headerText = this._loadingText;
                    if (this._selectedValue) {
                        headerValue = this._selectedValue;
                    }
                } else if (!gettingList && list && (0 == list.length) && (null != this._emptyText)) {
                    headerText = this._emptyText;
                    if (this._emptyValue) {
                        headerValue = this._emptyValue;
                    }
                } else if (this._promptText) {
                    headerText = this._promptText;
                    if (this._promptValue) {
                        headerValue = this._promptValue;
                    }
                }
                if (headerText) {
                    var optionElement = new Option(headerText, headerValue);
                    e.options[e.options.length] = optionElement;
                }

                // Add each item to the DropDownList, selecting the previously selected item
                var selectedValueOption = null;
                var defaultIndex = -1;

                if (list) {
                    for (i = 0; i < list.length; i++) {
                        var listItemName = list[i].name;
                        var listItemValue = list[i].value;

                        if (list[i].isDefaultValue) {
                            defaultIndex = i;
                            if (this._promptText) {
                                // bump the index if there's a prompt item in the list.
                                //
                                defaultIndex++;
                            }
                        }

                        var optionElement = new Option(listItemName, listItemValue);
                        if (listItemValue == this._selectedValue) {
                            selectedValueOption = optionElement;
                        }

                        e.options[e.options.length] = optionElement;
                    }
                    if (selectedValueOption) {
                        selectedValueOption.selected = true;
                    }
                }

                // if we didn't match the selected value, and we found a default
                // item, select that one.
                //
                if (selectedValueOption) {
                    // Call set_SelectedValue to store the text as well
                    this.set_SelectedValue(e.options[e.selectedIndex].value, e.options[e.selectedIndex].text);
                } else if (!selectedValueOption && defaultIndex != -1) {
                    e.options[defaultIndex].selected = true;
                    this.set_SelectedValue(e.options[defaultIndex].value, e.options[defaultIndex].text);
                } else if (!inInit && !selectedValueOption && !gettingList && !this._promptText && (e.options.length > 0)) {
                    // If no prompt text or default item, select the first item
                    this.set_SelectedValue(e.options[0].value, e.options[0].text);
                } else if (!inInit && !selectedValueOption && !gettingList) {
                    this.set_SelectedValue('', '');
                }

                if (e.childDropDown && !gettingList) {
                    for (i = 0; i < e.childDropDown.length; i++) {
                        e.childDropDown[i]._onParentChange();
                    }
                }
                else {
                    if (list && (Sys.Browser.agent !== Sys.Browser.Safari) && (Sys.Browser.agent !== Sys.Browser.Opera)) {
                        // Fire the onchange event for the control to notify any listeners of the change
                        if (document.createEvent) {
                            var onchangeEvent = document.createEvent('HTMLEvents');
                            onchangeEvent.initEvent('change', true, false);
                            this.get_element().dispatchEvent(onchangeEvent);
                        } else if (document.createEventObject) {
                            this.get_element().fireEvent('onchange');
                        }
                    }
                }

                // Disable the control if loading/prompt text is present and an empty list was populated
                if (this._loadingText || this._promptText || this._emptyText) {
                    e.disabled = !list || (0 == list.length);
                }

                //want this to just once, not sure if this has any other unanticipate consequences
                if (!gettingList) {
                    this.raisePopulated(Sys.EventArgs.Empty);
                }
            };
        }
    }

           
            
}
$(makeRaisePopulatedFireOnce);


function fancyCascade(parentId, behaveId, ddlId, clientStateId) {
    var ddlSubCatSide = $find(behaveId);
    //alert('find');
     $('#' + parentId).change(function(){
         ddlSubCatSide._onParentChange(null, true);
        
    });
    
    $('#' + ddlId).change(function(){
         var ddlVal = $(this).val();
         $('#' + clientStateId).val(ddlVal + ':::' + ddlVal);
        
    });

    ddlSubCatSide.add_populated(function(o, evtArgs)
    {
        var id = o.get_element().id;
        var i = '#' + id + '_input';

        $('#' + id + '_input_div').remove();
        $('#' + id + '_outer_div').remove();
        $('#' + id + '_inner_div').remove();
        $('#' + id + '_input').remove();
        $('#' + id + '_container').remove();
        $('#' + id + '_ddlleft').remove();
        $('#' + id).selectbox();
    });
    
    //for webkit
    //$('#' + parentId).val('');
    $('#' + parentId).change();
    
}

/*end dropdown stuff*/

/*textarea maxlength taken from PPK (quirksmode.org)*/

var W3CDOM = document.createElement && document.getElementsByTagName;



function setMaxLength() {
	if (!W3CDOM) return;
	var textareas = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<textareas.length;i++) {
		if (textareas[i].getAttribute('maxlength')) {
			var counterClone = counter.cloneNode(true);
			counterClone.innerHTML = '<span>0</span>/'+textareas[i].getAttribute('maxlength');
			textareas[i].parentNode.insertBefore(counterClone,textareas[i].nextSibling);
			textareas[i].relatedElement = counterClone.getElementsByTagName('span')[0];
			textareas[i].onkeyup = textareas[i].onchange = checkMaxLength;
			textareas[i].onkeyup();
			textareas[i].onkeydown = imposeMaxLength;
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
//	if (currentLength > maxLength)
//		this.relatedElement.className = 'toomuch';
//	else
//		this.relatedElement.className = '';	
	this.relatedElement.firstChild.nodeValue = currentLength;
}

function imposeMaxLength(e){
    var evt = e || window.event;
    var specialKeys = [3,6,8,9,13,16,17,18,19,20,27,33,34,35,36,37,38,39,40,44,45,46];
    var specialKeyPressed = false;
    for(var i=0; i < specialKeys.length; i++) {
        if(evt.keyCode == specialKeys[i]) {
         specialKeyPressed = true;
        }
    }
    if(!specialKeyPressed) {
        return (this.value.length < this.getAttribute('maxlength'));
    } else {
        return true;
    }
}

/*comscore*/
function loadComscoreScript() {
    var cs = document.createElement('script');
    cs.type = 'text/javascript';
    cs.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js";
    //flag to indicate whether scripts "load" has fired before  "readystatechange"
    cs.onloadDone = false;

    //function to be called after the beacon script is loaded
    function comscoreTrack() {
        COMSCORE.beacon({
            c1: 2,
            c2: 3005682,
            c3: "",
            c4: "",
            c5: "",
            c6: "",
            c15: ""
        });
    }

    cs.onload = function() {
        cs.onloadDone = true;
        comscoreTrack();
    };
    cs.onreadystatechange = function() {
        if (('loaded' === cs.readyState || 'complete' === cs.readyState) && !cs.onloadDone) {
            cs.onloadDone = true;
            comscoreTrack();
        }
    };
    
    document.getElementById('comscore').appendChild(cs);
}


$(loadComscoreScript);


$(function(){$('body').trigger('loadAds');});
 
 function iResize(fid,h,sz) {
	var iFrame1 = document.getElementById(fid);

    switch(sz) {
        case '728x90':
            h = 90;
            break;
         case '300x250':
            h = 250;
            break;
         case '160x600':
            h = 600;
            break;
         case '300x250,300x600':
            if (Math.abs(h - 250) > Math.abs(h - 600)) {
                h = 600;
            } else {
                h = 250;
            }
            break;
    }
    
	iFrame1.style.height = h + 'px';

}


function changeParentUrl(url) {
    if ($.browser.msie) {
        //make ie pass referrer info
        var referLink = document.createElement('a');
        referLink.href = url;
        document.body.appendChild(referLink);
        referLink.click();
    } else {
        window.location = url;
    }
}

function setWindowName(value) {
    window.name = value;
}

//register popup
function initRegisterPopup() {
    $("#register_btn").overlay({

        // some mask tweaks suitable for modal dialogs
        mask: {
            color: '#ebecff',
            loadSpeed: 200,
            opacity: 0.7
        },
        
        oneInstance: false,
        
        closeOnClick: false,

        onBeforeLoad: function()
        {
            if ($('#reg_iframe').length === 0)
            {
                // grab wrapper element inside content
                var wrap = this.getOverlay().find(".contentWrap");

                var iframe = document.createElement("iframe");
                iframe.id = "reg_iframe";
                iframe.src = this.getTrigger().attr("href") + "?framed=true&rurl=" + escape(window.location);
                iframe.width = "543px";
                iframe.height = "550px";
                iframe.style.border = "solid 1px #CCCCCC";

                // load the page specified in the trigger
                wrap.append(iframe);
            }
        }
    });


    var oldLoginStyle;


    function restorHola() {
        $("#login_hola img.close").hide();
        $("#login_hola").removeClass("corner_login");
    }

    $("#login_hola img.close").click(function() {
        $("#login_hola").slideUp(1000, restorHola);
        
        return false;
    });


    $("#login_btn").click(function() {
        var loginBox = $("#login_hola");
    
        function showInCorner() {
            $("#login_hola img.close").show();
            
            oldLoginStyle = loginBox.attr("style");
            loginBox.addClass("corner_login");
            loginBox.slideDown(1000);
        }
        
        if (loginBox.css('display') === 'none') {
            showInCorner();
        } else {
            $("#login_hola").slideUp(750, function() {  $sweetInsiderBox.slideDown(750,showInCorner); });
        }
        
        return false;

    });

    $("#sweet_insider .subscriber_bottom a.login").unbind('click');
    $("#sweet_insider .subscriber_bottom a.login").click(function() {
        $("#login_hola").slideUp(750, function() {
            restorHola();
            showHola();
        });

    });

    $("#reg_now").overlay({

        // some mask tweaks suitable for modal dialogs
        mask: {
            color: '#ebecff',
            loadSpeed: 200,
            opacity: 0.7
        },

        closeOnClick: false,

        oneInstance: false,

        onBeforeLoad: function() {
            restorHola();
            $("#login_hola").hide();
            if ($('#reg_iframe').length === 0) {
                // grab wrapper element inside content
                var wrap = this.getOverlay().find(".contentWrap");

                var iframe = document.createElement("iframe");
                iframe.id = "reg_iframe";
                iframe.src = this.getTrigger().attr("href") + "?framed=true&rurl=" + window.location;
                iframe.width = "543px";
                iframe.height = "600px";
                iframe.style.border = "solid 1px #666";

                // load the page specified in the trigger
                wrap.append(iframe);
            }
        }
    });

}
$(initRegisterPopup);


function closeRegisterOverlay() {
    //de-authorize app
    FB.api("/me/permissions", "delete", function (response) { });
    $("#reg .close").click();

}

function scrollRegistrationIframeToBottom() {
    var ifr = $("#reg_iframe")[0];
    ifr.contentWindow.scrollTo(0, ifr.contentWindow.document.body.scrollHeight);
}

function initInlineSubscribeLinks() {
    var si = $('#sweet_insider');
    var sc = $('.subscribe_container');
    var containerVisible = sc.is(":visible");
    var siWidth = si.width();

    $(".sub_now").live('click', function(e) {
    e.preventDefault();

    var ol = $("#sweet_insider").data("overlay");

    if (ol) {
        ol.load();
    }

        $("#sweet_insider").overlay({

            mask: {
                color: '#ebecff',
                loadSpeed: 200,
                opacity: 0.7
            },

            closeOnClick: false,

            oneInstance: false,

            onBeforeLoad: function() {

                $('.subscriber_bottom *:not(.subscribe_link, .subscribe_link img)').hide();

                if (!containerVisible) {
                    sc.show();
                    siWidth = si.width();
                }
                si.css('width', siWidth);
                si.addClass('show_close');
            },

            onClose: function() {
                si.attr('style', '');

                if (!containerVisible) {
                    sc.hide();
                }
                $('.subscriber_bottom *').show();
                si.removeClass('show_close');
            },

            load: true
        });

    });


}

$(initInlineSubscribeLinks);


function popupCampaign() {
    var qs = window.location.search;

    var showCakePopup = false;

    if (qs.indexOf("pop=cake") !== -1) {
        showCakePopup = true;
    }
    
    if (window.location.host.indexOf("sweetspotqc") !== -1) {
        showCakePopup = false;
    }


    if (showCakePopup && qs.indexOf("framed=true") === -1) {
        $('#cake_subscribe_modal').overlay({

            // some mask tweaks suitable for modal dialogs
            mask: {
                color: '#ebecff',
                loadSpeed: 200,
                opacity: 0.7
            },

            closeOnClick: false,

            oneInstance: false,

            onBeforeLoad: function()
            {
                // grab wrapper element inside content
                var wrap = this.getOverlay().find(".contentWrap");
                var iframe = document.createElement("iframe");
                iframe.id = "cake_sub_iframe";
                iframe.scrolling = "no";
                iframe.src = "/cake_subscribe/?framed=true&rurl=" + window.location;
                iframe.width = "526px";
                iframe.height = "430px";
                iframe.style.border = "solid 1px #CCCCCC";
                iframe.style.backgroundColor = "#CCCCCC";
                // load the page specified in the trigger
                wrap.append(iframe);
            },

            onLoad: function()
            {

                EasyCookie.set('cake_popup_date', popupDate, { expires: 300 });
            },

            load: true

        });
        
    }
    
}

$(popupCampaign);

function popupRegistration() {
    var qs = window.location.search;

    if (qs.indexOf("pop=reg") !== -1) {
        var registerPopupLinks = $('a[rel="#reg"]');

        if (registerPopupLinks.length > 0) {
            registerPopupLinks.eq(0).click();
        }
    }
}

$(popupRegistration);

function popupSubscribe() {
    var qs = window.location.search;

    if (qs.indexOf("pop=up") !== -1) {
        $('<a class="sub_now" style="display:none" href="#">pop</a>').appendTo('body').click();
        
    }
}

$(popupSubscribe);

// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License

function parseUri(str) {
    var o = parseUri.options,
		m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i = 14;

    while (i--) uri[o.key[i]] = m[i] || "";

    uri[o.q.name] = {};
    uri[o.key[12]].replace(o.q.parser, function($0, $1, $2) {
        if ($1) uri[o.q.name][$1] = $2;
    });

    return uri;
};

parseUri.options = {
    strictMode: false,
    key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
    q: {
        name: "queryKey",
        parser: /(?:^|&)([^&=]*)=?([^&]*)/g
    },
    parser: {
        strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
        loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
    }
};

//notify script manager that script has been loaded
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
