if (typeof com === "undefined") {
    var com = {}
}
if (typeof com.aol === "undefined") {
    com.aol = {}
}
if (typeof com.aol.video === "undefined") {
    com.aol.video = {}
}
if (typeof com.aol.video.portal === "undefined") {
    com.aol.video.portal = {}
}
jQuery.noConflict();
com.aol.video.portal.Init = function () {
    com.aol.video.portal.searchMoreState = false;
    com.aol.video.portal.searchHeadState = false;
    com.aol.video.portal.searchFootState = false;
	com.aol.video.portal.searchFootStateInitial = false;
    com.aol.video.portal.userHeadInput = false;
    com.aol.video.portal.userFootInput = false;
    com.aol.video.portal.UI.onLoad();
    jQuery(document.body).click(com.aol.video.portal.Events.defaultClick);
    jQuery(".surrogate .thumbnail").mouseenter(com.aol.video.portal.Events.fadeIn);
    jQuery(".surrogate .thumbnail").mouseleave(com.aol.video.portal.Events.fadeOut);
    jQuery("#aolVideo #GH_search_field").focus(com.aol.video.portal.Events.inputHeadClear);
    jQuery("#aolVideo #GH_search_field").blur(com.aol.video.portal.Events.inputHeadText);
    jQuery("#aolVideo #GH_search_field").keypress(com.aol.video.portal.Events.inputHeadEnter);
    jQuery("#topfQuery2").focus(com.aol.video.portal.Events.inputFootClear);
    jQuery("#topfQuery2").blur(com.aol.video.portal.Events.inputFootText);
    jQuery("#topfQuery2").keypress(com.aol.video.portal.Events.inputFootEnter);
    jQuery(".searchNav .more, .searchMore .close").click(com.aol.video.portal.Events.toggleSearchMore);
    jQuery(".videoSearch .channel").click(com.aol.video.portal.Events.searchMoreChannel);
    jQuery(".userInfo .feedback a").click(com.aol.video.portal.Events.feedback);
    jQuery("#signDiv").click(com.aol.video.portal.Events.signIn);
    jQuery(".userInfo .signOut a").click(com.aol.video.portal.Events.signOut);
    jQuery(".videoSearch .searchButton").mouseover(com.aol.video.portal.Events.searchGlow);
    jQuery(".videoSearch .searchButton").mouseout(com.aol.video.portal.Events.searchGlow);
    jQuery(".blueButton").mouseover(com.aol.video.portal.Events.buttonGlow);
    jQuery(".blueButton").mouseout(com.aol.video.portal.Events.buttonGlow)
};
com.aol.video.portal.UI = {
    onLoad: function () {
        boxHeight = jQuery("div.videoBody").height();
        dlModuleHeight = jQuery("div.dlModule").height();
        showCaseHeight = boxHeight - dlModuleHeight;
        jQuery("div.showCase").height(showCaseHeight);
        jQuery("div.videoBody").height(boxHeight);
        artImageURL = com.aol.video.portal.artURL + "/common/img/";
        jQuery(".metaLayer .curveTop").attr({
            style: "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',src='" + artImageURL + "popup_top.png');"
        });
        jQuery(".metaLayer .curveBottom").attr({
            style: "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',src='" + artImageURL + "popup_bottom.png');"
        });
        jQuery(".metaLayer .metaInner").attr({
            style: "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingmethod='scale',src='" + artImageURL + "popup_middle.png');"
        });
        jQuery("#topfQuery2").attr("value", com.aol.video.portal.searchText);
        if (isSearchPage == "true") {
			jQuery("#GH_search_field").attr("value", com.aol.video.portal.searchText);
            com.aol.video.portal.userHeadInput = true;
            com.aol.video.portal.userFootInput = true;
            com.aol.video.portal.searchHeadState = true;
            com.aol.video.portal.searchFootState = true
        }
		simPlyHeight = jQuery(".simplifiedPlayer").height();
		jQuery(".simplifiedPlayer").height(simPlyHeight + 10);
    }
};
com.aol.video.portal.Events = {
    defaultClick: function () {
        if (com.aol.video.portal.searchMoreState) {
            jQuery(".videoSearch .searchMore").hide()
        }
    },
    fadeIn: function () {
        currentId = jQuery(this).attr("id");
        com.aol.video.portal.surDelay = setTimeout("jQuery('#'+currentId+' .metaLayer').fadeIn('medium')", 250)
    },
    fadeOut: function () {
        clearTimeout(com.aol.video.portal.surDelay);
        jQuery("#" + currentId + " .metaLayer").fadeOut("medium")
    },
    inputHeadClear: function () {
        if (!com.aol.video.portal.searchHeadState) {
            jQuery(this).attr({
                value: ""
            })
        }
    },
    inputHeadText: function (a) {
        if (!com.aol.video.portal.searchHeadState) {
            jQuery(this).attr("value", com.aol.video.portal.searchText)
        }
    },
    inputHeadEnter: function () {
        com.aol.video.portal.searchHeadState = true;
        com.aol.video.portal.userHeadInput = true
    },
    inputFootClear: function () {
        if (!com.aol.video.portal.searchFootState) {
            jQuery(this).attr({
                value: ""
            })
        }
		else{
			if(isSearchPage == "true" && !com.aol.video.portal.searchFootStateInitial){
				 jQuery(this).attr({
	                value: ""
	            });
				com.aol.video.portal.searchFootStateInitial = true;
			}
		}
    },
    inputFootText: function () {
        if (!com.aol.video.portal.searchFootState) {
            jQuery(this).attr("value", com.aol.video.portal.searchText)
        }
    },
    inputFootEnter: function () {
        com.aol.video.portal.searchFootState = true;
        com.aol.video.portal.userFootInput = true
    },
    toggleSearchMore: function () {
        jQuery(".videoSearch .searchMore").toggle(1, com.aol.video.portal.Events.toggleState)
    },
    feedback: function () {
        return fBo("avp1")
    },
    signIn: function () {
        vid_SignInWidget(Utils.p_o("userInfo"), "", lu, 0, 0, "bredcrumb")
    },
    signOut: function () {
        vid_SignInWidget(Utils.p_o("userInfo"), "", logouturl, 0, 0, "bredcrumb")
    },
    toggleState: function () {
        com.aol.video.portal.searchMoreState = true
    },
    searchGlow: function () {
        jQuery(this).toggleClass("searchGlow")
    },
    buttonGlow: function () {
        jQuery(this).toggleClass("buttonGlow")
    },
    searchMoreChannel: function () {
        channelId = jQuery(this).attr("id");
        if (channelId == "searchWeb") {
            setSrch(this, "http://search.aol.com/aol/search?invocationType=hdvideo&query=")
        } else {
            if (channelId == "searchImage") {
                return srchSub("154")
            } else {
                if (channelId == "searchNews") {
                    return srchSub("153")
                } else {
                    if (channelId == "searchLocal") {
                        return srchSub("416")
                    } else {
                        if (channelId == "searchJobs") {
                            return srchSub("417")
                        } else {
                            if (channelId == "searchMap") {
                                return srchSub("418")
                            } else {
                                if (channelId == "searchMovie") {
                                    return srchSub("419")
                                } else {
                                    if (channelId == "searchMusic") {
                                        return srchSub("420")
                                    } else {
                                        if (channelId == "searchPersonal") {
                                            return srchSub("421")
                                        } else {
                                            if (channelId == "searchShopping") {
                                                return srchSub("157")
                                            } else {
                                                if (channelId == "searchTravel") {
                                                    return srchSub("423")
                                                } else {
                                                    if (channelId == "searchYellow") {
                                                        return srchSub("424")
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    urlRedirect: function (a) {
        window.location = a
    }
};
