var EP = function () {
    return {
        open_window: function (url, w, h) {
            window.open(url, 'win', 'toolbar=no,width=' + w + ',height=' + h + ',directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes');
        },
        clear_frame: function (frameid) {
            try {
                document.getElementById(frameid).contentWindow.document.body.innerHTML = "";
            } catch (E) {
            }
        },
        send_mail: function (name, senddata, callback) {
            var r = false;
            $.ajax({
                type: "POST",
                url: "/communicator/sendmail/" + name,
                cache: false,
                data: senddata,
                dataType: "json",
                success: function (data) {
                    r = data;
                    if (callback) callback(r);
                }
            });
            return r;
        },
        resize_image: function (sel, maxw, maxh) {
            var ph = $(sel);
            var cw = Math.floor($(sel).width());
            var ch = Math.floor($(sel).height());
            var ww = Math.floor(maxw) / cw;
            var wh = Math.floor(maxh) / ch;
            if (cw > maxw && ww <= wh) {
                ph.width(maxw);
            }
            if (ch > maxh && wh < ww) {
                ph.height(maxh);
            }
        }
    };
} ();
(function ($) {
    // common jq fns
    $.fn.addItemToStringArray = function (s, d) {
        if (s == "") return;
        if (!s) return;
        if (!d) d = ",";
        var val = $(this).val();
        var stmp = d + val + d;
        if (stmp.indexOf(d + s + d) == -1) {
            if (val != "") val += d;
            val += s;
        }
        $(this).val(val);
    };
    $.fn.removeItemFromStringArray = function (s, d) {
        if (!s) return;
        if (!d) d = ",";
        var arr = $(this).val().split(d);
        for (i = 0; i < arr.length; i++) {
            if (s == arr[i]) arr.splice(i, 1);
        }
        var snew = arr.join(d);
        $(this).val(snew);
    };
    $.fn.isValidList = function (el) {
        var o = $(this);
        if (el) o = el;
        if (o.parent().find(".requiredmessage").size() == 0) {
            o.parent().append("<div class=requiredmessage></div>");
        }
        o.parent().find(".requiredmessage").hide();
        o.removeClass("required");
        if (o.attr("required") === "false")
            return true;
        if (o.find(":checked").size() == 0) {
            o.addClass("required");
            var rm = o.attr("requiredmessage");
            if (rm == undefined) rm = "";
            o.parent().find(".requiredmessage").text(rm);
            o.parent().find(".requiredmessage").show();
            return false;
        } else {
            return true;
        }
    };
    $.fn.isValidElement = function (el) {
        var o = $(this);
        if (el) o = el;
        if (o.parent().find(".requiredmessage").size() == 0) {
            o.parent().append("<div class=requiredmessage></div>");
        }
        o.parent().find(".requiredmessage").hide();
        o.removeClass("required");
        if (o.attr("maxlength")) {
            var ml = parseInt(o.attr("maxlength"));
            if (o.val().length > ml && ml > 0) {
                o.parent().find(".requiredmessage").text(o.attr("maxlength") + " characters allowed.");
                o.parent().find(".requiredmessage").show();
                o.addClass("required");
                return false;
            }
        }
        if (o.attr("valtype")) {
            if (!o.epIsValidExtended(o.attr("valtype"), o.attr("minlength"))) {
                var msg = "";
                if (o.attr("valtype") == "phone") msg = "Please enter a valid phone number";
                o.parent().find(".requiredmessage").text(msg);
                o.parent().find(".requiredmessage").show();
                o.addClass("required");
                return false;
            }
        }
        if (o.attr("required") === "false")
            return true;
        var isv = true;
        if (o.is(":checkbox") && o.attr("checked") == false) {
            isv = false;
        } else if (o.val() == "") {
            isv = false;
        } else {
            return true;
        }
        if (!isv) {
            o.addClass("required");
            var rm = o.attr("requiredmessage");
            if (rm == undefined) rm = "";
            o.parent().find(".requiredmessage").text(rm);
            o.parent().find(".requiredmessage").show();
            return false;
        }
        return isv;
    };
    $.fn.epIsValidExtended = function (valtype, minlen) {
        if (valtype == "phone") {
            var v = $(this).val();
            if (v == "") return true;
            var b = /[a-zA-Z]/.test(v);
            v = v.replace(/-/, "").replace(/\./, "");
            if (minlen && v.length < minlen) return false;
            if (!b) {
                return /\d{4}/.test(v);
            }
            return false;
        }
    };
    $.fn.doWordCount = function (suppressCount) {
        var o = $(this);
        if (o.parent().find(".wordcountmessage").size() == 0) {
            o.parent().append("<div class=wordcountmessage>Words: <span class=wc_words></span>,&nbsp;Characters: <span class=wc_chars></span></div>");
        }
        var txt = o.val();
        var len = txt.length;
        if (!suppressCount) {
            var words = txt.split(' ');
            var wc = 0;
            for (var i = 0; i < words.length; i++) {
                if (words[i] != "") wc++;
            }
            o.parent().find(".wc_words").text(wc);
        }
        o.parent().find(".wc_chars").text(len);
    };
})(jQuery);
function validateURL(sentUrl) {
    if (/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(sentUrl)) { return true; } else { return false; }
}
function closeError(slide) { if (slide) { $(".error,.sterror,#validationMessage,#validationMessage2").slideUp(); } else { $(".error,.sterror,#validationMessage,#validationMessage2").hide(); } }
(function ($) {
    $.setupEpValForm = function (t, p) {
        p = $.extend({
            errorMessageElement: false,
            invalidMessage: "Please complete all of the required fields.",
            showAlert: true,
            buttonSelector: false,
            invalidCallback: false
        }, p);
        if (t.frm) return false;
        var f = {
            checkvalid: function () {
                closeError(false);
                var b = true;
                if (p.errorMessageElement) $(p.errorMessageElement).text("");
                /*$("input:text").each(function() {
                var thisLabel = $(this).parent().parent().find(".rlbl");
                if ($(thisLabel).text().toLowerCase() == "linkedin" && $(this).val().length > 1) {
                if (!validateURL($(this).val())) {
                p.invalidMessage = "LinkedIn does not appear to be a valid URL."
                b = false;
                }
                } else if ($(thisLabel).text().toLowerCase() == "twitter" && $(this).val().length > 1) {
                if (!validateURL($(this).val())) {
                p.invalidMessage = "Twitter does not appear to be a valid URL."
                b = false;
                }
                } else if ($(thisLabel).text().toLowerCase() == "facebook" && $(this).val().length > 1) {
                if (!validateURL($(this).val())) {
                p.invalidMessage = "Facebook does not appear to be a valid URL."
                b = false;
                }
                } else if ($(thisLabel).text().toLowerCase() == "blog" && $(this).val().length > 1) {
                if (!validateURL($(this).val())) {
                p.invalidMessage = "Blog does not appear to be a valid URL."
                b = false;
                }
                }
                });*/
                $("[required]").each(function () {
                    if ($(this).find(":radio,:checkbox").size() > 0) {
                        if (!$(this).isValidList()) {
                            b = false;
                        }
                    } else if ($(this).is(":checkbox")) {
                        if (!$(this).isValidElement()) {
                            b = false;
                        }
                    } else {
                        if (!$(this).isValidElement()) {
                            b = false;
                        }
                    }
                });
                if (!b) {
                    if (p.errorMessageElement) {
                        $(p.errorMessageElement).html("<a href='javascript:closeError(true)' class='button_close'></a>" + p.invalidMessage).css({ "display": "block" }).hide();
                        $(p.errorMessageElement).slideDown();
                        var h = $(p.errorMessageElement).height();
                        try { $(window).scrollTo($(".error"), 250); }
                        catch (ex) { }
                        try { $(window).scrollTo($("#validationMessage2"), 250); }
                        catch (ex) { }
                    }
                }
                return b;
            },
            isvalid: function () {
                var b = f.checkvalid();
                var msg = p.invalidMessage;
                if (b) msg = "";
                if ($("#iagree").size() > 0) {
                    if ($("#iagree:checked").size() == 0) {
                        b = false;
                        if (msg != '') msg += "\n";
                        msg += "Please agree to the Terms and Conditions.";
                    }
                }
                if (!b) {
                    if (p.showAlert) {
                        $(p.errorMessageElement).html("<a href='javascript:closeError(true)' class='button_close'></a>" + msg).css({ "display": "block" }).hide();
                        $(p.errorMessageElement).slideDown();
                    }
                    if (p.invalidCallback) {
                        p.invalidCallback();
                    }
                }
                return b;
            },
            init: function () {
                $(t).find("[wordcount='true']").keyup(function (e) {
                    if (e.which == 13) {
                        return false;
                    } else if (e.which == 32) {
                        $(this).doWordCount();
                    } else {
                        $(this).doWordCount(false);
                    }
                }).change(function () {
                    $(this).doWordCount();
                }).each(function () {
                    $(this).doWordCount();
                });
                $(t).find("[required]").each(function () {
                    if ($(this).is("select,:text,textarea")) {
                        $(this).change(function () {
                            $(this).isValidElement();
                        });
                    } else if ($(this).is(":checkbox")) {
                        $(this).click(function () {
                            $(this).isValidElement();
                        });
                    } else if ($(this).find(":radio,:checkbox").size() > 0) {
                        var list = $(this);
                        list.find(":radio,:checkbox").click(function () {
                            $(this).isValidList(list);
                        });
                    }
                });
                if (p.buttonSelector) {
                    var tmp = {
                        click: $(p.buttonSelector).attr("onclick")
                    };
                    $(p.buttonSelector).removeAttr("onclick");
                    $(p.buttonSelector).bind('click', function () {
                        var b = f.isvalid();
                        if (!b) return false;
                        try {
                            tmp.click();
                        } catch (E) { }
                    });
                } else {
                    if ($(t).is("form")) $(t).submit(f.isvalid);
                }
            }
        };
        if (!t.frm) {
            f.init();
            t.frm = f;
        }
    };
    $.fn.epvalidate = function (p) {
        return this.each(function () {
            $.setupEpValForm(this, p);
        });
    }; //end epvalidate
})(jQuery);
(function ($) {
    $.setETabs = function (t, a, p) {
        if (a) {
            if (a == 'select') {
                t.etab.select(p);
            }
        }
        if (t.etab) return false; //return if already exist
        p = $.extend({
            callback: false
        }, p);
        var c = {
            hidetabs: function () {
                $(t).find(" > .tabarea").hide();
                $(t).find("ul.tabs:first li").removeClass("selected");
            },
            select: function (idx) {
                c.hidetabs();
                var el = $(t).find("ul.tabs:first li").eq(idx);
                if (el) {
                    $(el).addClass("selected");
                    var h = $(el).find("a").attr("href");
                    $(h).show();
                }
            },
            init: function () {
                c.select(0);
                $(t).find("ul.tabs:first li").each(function (idx) {
                    $(this).find("a").click(function () {
                        c.select(idx);
                        return false;
                    });
                    $(this).hover(
function () {
    $(this).addClass("hover");
},
function () {
    $(this).removeClass("hover");
}
);
                });
            }
        };
        if (!t.etab) {
            c.init();
            t.etab = c;
        }
    };
    $.fn.epTabs = function (a, p) {
        return this.each(function () {
            $.setETabs(this, a, p);
        });
    };
})(jQuery);
(function ($) {
    $.setEPop = function (t, p) {
        if (t.epop) return false; //return if already exist
        p = $.extend({
            callback: false,
            oleft: 0,
            appPath: "/"
        }, p);
        // define clist
        var c = {
            setHtml: function (s) {
                $(t).find(".content").html(s);
            },
            setPosition: function (el, left, top) {
                var os = $(el).offset();
                var lt = p.oleft + ($(el).width() + 20);
                var tp = os.top - ($(t).height() / 2);
                if (left) lt = left;
                if (top) tp = top;
                $(t).css("left", lt).css("top", tp);
            },
            fetchContent: function (el, curl, left, top) {
                c.setHtml("");
                $.ajax({
                    type: "GET",
                    url: curl,
                    cache: false,
                    dataType: "html",
                    success: function (data) {
                        c.setHtml(data);
                        if (el) {
                            c.setPosition(el, left, top);
                        }
                        $(t).show();
                        if (p.callback) p.callback();
                    }
                });
            },
            showPopup: function (el, s, url, left, top) {
                var html = "";
                if (url) {
                    c.fetchContent(el, url, left, top);
                } else {
                    c.setHtml(s);
                    if (el) {
                        c.setPosition(el, left, top);
                    }
                    $(t).show();
                    if (p.callback) p.callback();
                }
            },
            hidePopup: function () {
                $(t).hide();
            },
            reset: function () {
                c.setHtml("");
                c.hidePopup();
            },
            init: function () {
                $(document.body).click(function () {
                    c.reset();
                });
            }
        };
        if (!t.epop) {
            c.init();
            t.epop = c;
        }
    }
    $.fn.epPopupize = function (p) {
        return this.each(function () {
            $.setEPop(this, p);
        });
    };
    $.fn.epShowPop = function (el, s, url, left, top) {
        return this.each(function () {
            if (this.epop) this.epop.showPopup(el, s, url, left, top);
        });
    };
})(jQuery);

function win1() {
       window.open("/cft","Window1","menubar=no,width=980,height=700,toolbar=no,scrollbars=yes");
    }

function winReg() {
       window.open("http://stage.infosalons.com.au/Teched2011","Window2","menubar=no,width=980,height=700,toolbar=no,scrollbars=yes");
    }

function winHotelInfo() {
       window.open("http://stage.infosalons.com.au/Teched2011/hotelInfo.asp","Window3","menubar=no,width=980,height=700,toolbar=no,scrollbars=yes");
    }

//detect browser
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
 var ieversion = new Number(RegExp.$1); // capture x.x portion and store as a number
  if (ieversion<=6){
       alert("This site is optimised for Internet Explorer 9. Experience a more beautiful web with Internet Explorer 9. Download now.");
       window.location("http://windows.microsoft.com/en-au/internet-explorer/products/ie/home");
   }
}
