$(this).ready(function() { 
    $('a[@rel*=lightbox]').lightbox({
        overlayOpacity:             0.5,
		fileLoadingImage :          xopiePath + "js/jquery.lightbox/images/loading.gif",
		fileBottomNavCloseImage :   xopiePath + "js/jquery.lightbox/images/closelabel.gif"
    });

    $("#q").change(function() {
        $(this).attr("changed", true);
    });

    $("#q").focus(function() {
        if (!$(this).attr("changed")) { $(this).val("");}
    });

	if ($("#supportNav .languageSelection ul").length) {
		$("#supportNav .languageSelection ul a[class!=active]").each(function(i) {
			$(this).parent().hide();
		});
		
		$("#supportNav .languageSelection ul").mouseover(function() {
			$(this).find("li").css("display", "list-item");
			$(this).parents(".languageSelection").addClass("open");
		});

		$("#supportNav .languageSelection ul").mouseout(function() {
			$("#supportNav .languageSelection a[class!=active]").each(function(i) {
				$(this).parent().css("display", "none");
			});

			$(this).removeClass("open");
		});

		$(window).resize(function(){
			initLSPos();
		});

		initLSPos();
	}
});

function initLSPos() {
	$("#supportNav .languageSelection ul").css("top", $("#supportNav .languageSelection img.dummy").offset().top + "px");
	$("#supportNav .languageSelection ul").css("left", ($("#supportNav .languageSelection img.dummy").offset().left + $("#supportNav .languageSelection img.dummy").width() - $("#supportNav .languageSelection ul").width()) + "px");
}

function expandct(sId, e) {
    $("#" + sId).css("overflow-y", "hidden");
    $("#" + sId).css("height", "auto");
    $("#" + sId + "_expand").hide();
    $("#" + sId + "_collapse").show();
    if (e) { e.cancelBubble=true;e.returnValue=false;return false; }
}

function collapsect(sId, e) {
    $("#" + sId).css("overflow-y", "hidden");
    $("#" + sId).css("height", "100px");
    $("#" + sId + "_expand").show();
    $("#" + sId + "_collapse").hide();
    if (e) { e.cancelBubble=true;e.returnValue=false;return false; }
}

function initFaqs() {
    var fnToogle = function(e) {
        if ($(this).parents(".faqItem").find(".faqAnswer:hidden").length) {
            $(".faqAnswer").slideUp(300);
            $(this).parents(".faqItem").find(".faqAnswer").slideDown(400);
        }

        if (e) { e.cancelBubble=true;e.returnValue=false;return false; }
    };
   
    $(".faqQuestion a").each(function (i) {
        $(this).parents(".faqItem").find(".faqAnswer").hide();
        $(this).click(fnToogle);
    });
}