﻿window.USG = {

};

// Page Name = "USG.BoostR.UI.Web.Employers.Controls.MyVacancies.ascx"
var prevHeader = null;
var vardefaultdiv = null;
var vardefaultheader = null;

function PopupWindowWithParam(URL, wd, ht, resize, scroll) {
    var features = "width=" + wd + ",height=" + ht + ",resizable=" + resize + ",scrollbars=" + scroll;
    window.open(URL, "winName", features);
}

function PopupWindow(URL) {
    window.open(URL, "winName", "width=400,height=400,resizable=0,scrollbars=1");
}
// Function to toggle display of any block. It taks parameters in pair
// odd parameters id of OBJECT and even parameters PROPERTY of display style. 
function ShowHide() {
    var args = ShowHide.arguments;
    var len = args.length;
    for (var i = 0; i < len; i = i + 2) {
        if (document.getElementById(args[i])) {
            document.getElementById(args[i]).style.display = args[i + 1];
        }
    }
}

// Function to toggle the Header CSS. It taks three parameters
// objId - Header container DIV; newCSSClass - css class to apply; oldCSSClass - css class to replace 
function ToggleHeaderCSS(objId, newCSSClass, oldCSSClass) {
    objHeader = document.getElementById(objId + "H3");
    if (null != prevHeader)
        prevHeader.className = oldCSSClass;
    objHeader.className = newCSSClass;
    prevHeader = objHeader;
}

// Function to toggle the language details
// checkboxObj - clicked Checkbox passed as THIS; divId - Dependent DIV of which visibility toggles. 
function ShowHideLanguages(checkboxId, divId) {
    checkboxObj = document.getElementById(checkboxId);
    if (!checkboxObj.checked) {
        ShowHide(divId, 'none');
    }
    else {
        ShowHide(divId, 'block');
    }
}

// Function to assign value to hidden field
// objId - ID of the hidden field; val - Value to be assined to hidden field. 
function AssignValue(objId, val, bool) {
    if (bool) {
        if (document.getElementById(objId).value == "") {
            document.getElementById(objId).value = val;
        }
    }
    else {
        document.getElementById(objId).value = val;
    }

}

// Function to Toggle the panel/div
// objId - ID of the div. Can take multiple IDs separated by comma; 
function ToggleVisibility() {
    var args = ToggleVisibility.arguments;
    var len = args.length;

    for (var i = 0; i < len; i++) {
        var obj = document.getElementById(args[i]);
        var visibility = (obj.style.display == 'block') ? 'none' : 'block';
        ShowHide(args[i], visibility);
    }
}

// Function to change the inner HTML of a label.
// webClient - ID of the div. Can take multiple IDs separated by comma; 	
function WebClientExtension(webClient, objId) {
    var text;
    switch (webClient.toString().toLowerCase()) {
        case "yahoo": text = "@yahoo.com"; break;
        case "msn": text = "@hotmail.com"; break;
        case "gmail": text = "@gmail.com"; break;
        default: text = ""; break;
    }
    document.getElementById(objId).innerHTML = text;
}

// Function to change visibility of sections based on selection.
// selectedItemValue - Value of the selected radio button; divId1 and divId2 - Two dependent DIV ids.
function ToggleViewEmpReg(selectedItemValue, divId1, divId1Sub1, divId1Sub2, divId2) {
    switch (selectedItemValue.toString().toLowerCase()) {

        case "free": ShowHide(divId1, 'none', divId2, 'none'); break;
        case "searchonly": ShowHide(divId1, 'block', divId1Sub1, 'block', divId1Sub2, 'none', divId2, 'block'); break;
        case "placingvacancies": ShowHide(divId1, 'block', divId1Sub1, 'none', divId1Sub2, 'block', divId2, 'none'); break;
        default: break;
    }
}

// Function to populate values based on selection.
// chkBoxId - Id of the selected checkbox; ASSIGN txtSAddress = txtPAddress
function CopyAddress(chkBoxId, txtStreetAddress, txtPostCode, txtCity, ddlCountry, txtPAddress, txtPPostCode, txtPCity, ddlPCountry, txtTelephoneNumber, txtPTelephone) {
    var mylist = document.getElementById(ddlCountry);
    var mylist1 = document.getElementById(ddlPCountry);
    if ((document.getElementById(chkBoxId).checked)) {
        document.getElementById(txtPAddress).value = document.getElementById(txtStreetAddress).value;
        document.getElementById(txtPPostCode).value = document.getElementById(txtPostCode).value;
        document.getElementById(txtPCity).value = document.getElementById(txtCity).value;
        mylist1.selectedIndex = mylist.selectedIndex;
        document.getElementById(txtPTelephone).value = document.getElementById(txtTelephoneNumber).value
    }
}

function ShowSendMessage(controlId, show) {
    var control = document.getElementById(controlId);
    control.style.display = (show) ? "block" : "none";
}

//page Name ="USG.BoostR.UI.Web.Home.Controls.ModifyPersonalInfo.ascx"
function HideModalPopup(control) {
    //document.getElementById('<%= pnlVerifyPassword.ClientID %>').style.display="none";
    control.Hide();
}

function ShowModalPopup(objId) {
    document.getElementById(objId).click();
    //popupPassword.Show();
}


// InfoCaster stuff
function DisplayTooltip(tooltip, target, big) {
    var position = target.offset();
    var width = target.width();
    var left = position.left + width;
    var top = position.top;
    if (left < 150)
        left = 150
    if (big)
        top = top - 130;
    tooltip.css({ "left": left + "px", "top": top - 30 + "px" });

    $("#footerwrapper ~ #" + tooltip.parent().attr("id")).remove();
    var parent = tooltip.parent();
    parent.remove().insertAfter("#footerwrapper");
}

var originalLeft;
var isOverOptionsEl = false;
var isOverEl = false;
function AttachAssistOptions(elements, optionsSelector, childSelector) {
    elements.each(function(i) {
        var $this = $(this);
        var $optionsElement = $($this.find("~ " + optionsSelector)[0]);
        var $childElement = $optionsElement.find(childSelector);
        originalLeft = $childElement.css("left");
        var position = $this.position();
        var width = $this.width();
        var left = position.left + width;
        var top = position.top + 10;
        $optionsElement.css({ "left": left - $optionsElement.width() + "px", "top": top + "px", "height": $this.height() + "px" });

        $this.hover(
				function() {
				    isOverEl = true;
				    if (parseInt($childElement.css("left")) == parseInt(originalLeft)) {
				        animateMouseover($childElement, true);
				    }
				},
				function() {
				    isOverEl = false;
				    setTimeout(function() {
				        if (parseInt($childElement.css("left")) == parseInt(originalLeft) - parseInt($childElement.width()) && !isOverOptionsEl) {
				            animateMouseover($childElement, false);
				        }
				    }, 100);
				}
			);
        $optionsElement.hover(
				function() {
				    isOverOptionsEl = true;
				},
				function() {
				    isOverOptionsEl = false;
				    setTimeout(function() {
				        if (!isOverEl) {
				            animateMouseover($childElement, false);
				        }
				    }, 100);
				}
			);
    });
}

var contentDiv, oddLis, evenLis, aniMs, stepHeight, targetElement, timer;
var isActive = new Array();
var timerPauseMs = 8000;
var clicked = false;
var loading;
function LoadWhoosj(targetSelector, anMs) {
    if (anMs === undefined)
        aniMs = 400;
    else
        aniMs = anMs;
    targetElement = $(targetSelector);
    var target = targetElement.find("ul");
    contentDiv = targetElement.find("div.content");
    var top = 5;

    evenLis = target.find("li:even"); // The normal li's
    oddLis = target.find("li:odd"); // The slide-in li's

    loading = $("div#whoosj-loading");

    stepHeight = contentDiv.find("div:first").height();
    contentDiv.css({ "top": stepHeight, "display": "block" });

    var position = targetElement.position();
    var backgroundBorder = $("div#background-border");
    backgroundBorder.css({ "top": position.top, "left": position.left });

    for (i = 0; i < evenLis.length; i++) {
        isActive[i] = false;
    }

    oddLis.each(function(ix, el) {
        el = $(el);
        var elHeight = el.height();
        el.css("top", top + "px");
        top -= 4;
        top += elHeight;
    });
    evenLis.each(function(ix, el) {
        el = $(el);
        el.click(function() {
            clicked = true;
            clearTimeout(timer);
            loading.stop().css("display", "none");
            var active = -1;
            for (i = 0; i < isActive.length; i++) {
                if (isActive[i]) {
                    active = i;
                    isActive[i] = false;
                    break;
                }
            }
            if (active > -1)
                WhoosjAnimate($(oddLis[active]), active, false, aniMs);
            WhoosjAnimate($(oddLis[ix]), ix, true, aniMs);
            isActive[ix] = true;
        });
    });

    targetElement.mouseenter(function() {
        clearTimeout(timer);
        loading.stop().css("width", 0);
    });

    targetElement.mouseleave(function() {
        if (!clicked) {
            timer = setTimeout(function() { StartWhoosjTimer(); }, timerPauseMs);
            loading.animate(
						{ width: '940' },
						timerPauseMs - 100,
						'linear'
					);
        }
    });

    StartWhoosjTimer();
}

function StartWhoosjTimer() {
    var active = -1;
    for (i = 0; i < isActive.length; i++) {
        if (isActive[i]) {
            active = i;
            isActive[i] = false;
            break;
        }
    }
    if (active > -1)
        WhoosjAnimate($(oddLis[active]), active, false, aniMs);
    active++;
    if (active >= isActive.length)
        active = 0;
    WhoosjAnimate($(oddLis[active]), active, true, aniMs);
    isActive[active] = true;
    loading.animate(
				{ width: '940' },
				timerPauseMs - 100,
				'linear'
			);
    timer = setTimeout(function() { StartWhoosjTimer(); }, timerPauseMs);
}

function WhoosjAnimate(el, index, isStartAni, aniMs) {
    loading.stop().css("width", 0);
    var right = '-6';
    if (!isStartAni)
        right = '-340';
    el.stop().animate(
				{ right: right },
				aniMs
			);
    var top = -index * stepHeight;
    if (isStartAni) {
        contentDiv.animate(
					{ top: top },
					aniMs
				);
    }
}

function expandCollapse(expandText, collapseText, collapseCount, collapseFrom) {
    $("div#filters div.filter ul").each(function() {
        $this = $(this);
        if ($this.find("li").length > collapseCount) {
            $this.find("li:gt(" + (collapseFrom - 1) + ")").each(function() {
                $(this).css("display", "none");
            });
            var newLi = $("<li class=\"newli\"><a class=\"expand asc b4\">" + expandText + "</a></li>");
            $this.append(newLi);
            newLi.click(function() {
                $(this).parent("ul").find("li:gt(" + (collapseFrom - 1) + ")").each(function() {
                    $this = $(this);
                    if ($this.hasClass("newli")) {
                        if ($this.find("a").hasClass("desc"))
                            $this.find("a").text(expandText).removeClass("desc").addClass("asc");
                        else
                            $this.find("a").text(collapseText).removeClass("asc").addClass("desc");
                    }
                    else {
                        if ($this.css("display") == "none")
                            $this.css("display", "block");
                        else
                            $this.css("display", "none");
                    }
                });
            });
        }
    });
}

function animateMouseover(el, start) {
    var op = "+";
    if (start)
        op = "-";
    op += "=" + el.width();
    el.stop().animate({ left: op }, { duration: 500, queue: false });
}

function confirmDelete(msg) {
    val = (confirm(msg)) ? true : false;
    return val;
}
//Functions related to boostr match
function collapseAllMatch() {
    document.getElementById("divProfessionalBoosterMatch").style.display = "none";
    document.getElementById("headerBoosterProfesional").className = "collapsed";
    document.getElementById("divVacancyBoosterMatch").style.display = "none";
    document.getElementById("headerBoosterVacancy").className = "collapsed";
    document.getElementById("divGroupBoosterMatch").style.display = "none";
    document.getElementById("headerBoosterGroup").className = "collapsed";
}

function showDefaultMatch() {
    collapseAllMatch();
    document.getElementById(vardefaultdiv).style.display = "block";
    document.getElementById(vardefaultheader).className = "expanded";
}

function showHideBoosterMatchContent(divID, headerid) {
    if (vardefaultheader != null) {
        if ((headerid == "") || (headerid == vardefaultheader))
            showDefaultMatch();
        else if (headerid != vardefaultheader) {
            if (document.getElementById(divID).style.display == "none") {
                collapseAllMatch();
                document.getElementById(divID).style.display = "block";
                document.getElementById(headerid).className = "expanded";
            }
        }
        else {
            showDefaultMatch();
        }
    }
}

function ShowHideSearchCriteria() {


    var myList = document.getElementById("ctl00_ContentPlaceHolder1_AdvancedSearch_ddlSearchCriteria");
    //switch(myList.options[myList.selectedIndex].value){
    switch (myList.value) {
        case "Professional":
            ShowHide("ctl00_ContentPlaceHolder1_AdvancedSearch_divProfessionals", "block", "ctl00_ContentPlaceHolder1_AdvancedSearch_divGroup", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divVacancies", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divEmployers", "none");
            break;
        case "Group":
            ShowHide("ctl00_ContentPlaceHolder1_AdvancedSearch_divProfessionals", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divGroup", "block", "ctl00_ContentPlaceHolder1_AdvancedSearch_divVacancies", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divEmployers", "none");
            break;
        case "3":
            ShowHide("ctl00_ContentPlaceHolder1_AdvancedSearch_divProfessionals", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divGroup", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divVacancies", "block", "ctl00_ContentPlaceHolder1_AdvancedSearch_divEmployers", "none");
            break;
        case "4":
            ShowHide("ctl00_ContentPlaceHolder1_AdvancedSearch_divProfessionals", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divGroup", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divVacancies", "none", "ctl00_ContentPlaceHolder1_AdvancedSearch_divEmployers", "block");
            break;
        default:
            break;
    }
}

function showHideEducationLevel() {

    var myList = document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabTrainingEduSkills_EducationDetails_ddlLevel");

    if ((myList.options[myList.selectedIndex].value) == "70") {
        document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabTrainingEduSkills_EducationDetails_divHigherEducation").style.display = "none";
        document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabTrainingEduSkills_EducationDetails_divSecondaryEducation").style.display = "block";
    }
    else if ((myList.options[myList.selectedIndex].value) == "") { }
    else {
        document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabTrainingEduSkills_EducationDetails_divHigherEducation").style.display = "block";
        document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabTrainingEduSkills_EducationDetails_divSecondaryEducation").style.display = "none";
    }
    myList.className = "long";
    try {
        document.getElementById("ctl00_body_validationSummary").innerHTML = "";
    } catch (e) { };
}


function checkAll() {
    for (var i = 0; i < document.forms[0].elements.length; i++) {
        var obj = document.forms[0].elements[i];
        if ((obj.className != 'allbox') && (obj.type == 'checkbox'))
            obj.checked = document.forms[0].allbox.checked;
    }
}

function getElementsByClassName(oElm, strTagName, strClassName) {
    var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for (var i = 0; i < arrElements.length; i++) {
        oElement = arrElements[i];
        if (oRegExp.test(oElement.className)) {
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}

function disableDropdownList() {
    if ((document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabWorkExperience_WorkExperience_chkWorkingTill").checked)) {
        document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabWorkExperience_WorkExperience_ddlWorkedTillMonth").style.display = 'none';
        document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabWorkExperience_WorkExperience_ddlWorkedTillYear").style.display = 'none';
    }
    else {
        document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabWorkExperience_WorkExperience_ddlWorkedTillMonth").style.display = '';
        document.getElementById("ctl00_ContentPlaceHolder1_tabContainer_tabWorkExperience_WorkExperience_ddlWorkedTillYear").style.display = '';
    }
}

function UpdatePostBackViewState(id) {
    document.getElementById(id).value = true;
}

function addEvent(elm, evType, fn) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener) {
        elm.addEventListener(evType, fn, false);
        return true;
    } else if (elm.attachEvent) {
        var r = elm.attachEvent('on' + evType, fn);
        return r;
    } else {
        alert('Handler could not be added');
    }
}


function getElementsByClass(searchClass, node, tag) {
    var classElements = new Array();
    if (node == null)
        node = document;
    if (tag == null)
        tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
        if (pattern.test(els[i].className)) {
            classElements[j] = els[i];
            j++;
        }
    }
    return classElements;
}

function aceFixShow(sender, args) {
    var list = sender.get_completionList();

    // find or create iframe
    var id = list.id + "_iframe";
    var iframe = document.getElementById(id);
    if (null === iframe) {
        iframe = document.createElement("iframe");
        iframe.id = id;
        list.parentNode.appendChild(iframe);
    }

    list.style.zIndex = 100;

    iframe.style.position = "absolute";
    iframe.style.border = 0;
    iframe.style.width = list.offsetWidth;
    iframe.style.height = list.offsetHeight;
    iframe.style.top = list.style.top;
    iframe.style.left = list.style.left.replace("px", "") - 1 + "px";
    iframe.style.zIndex = list.style.zIndex - 1;
    iframe.style.display = "block";

    if (jQuery.browser.msie) {
        var owner = "";
        try {
            owner = list.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
            if ("cv-block-0" == owner || "cv-block-1" == owner) {
                owner = list.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
            }
        } catch (ex) { }

        if ("" != owner && ("cv-workexperience" == owner || "cv-education" == owner || "cv-ambition" == owner)) {
            $(list).parent().parent().parent().nextAll(".field-row").find(".field-data").css("visibility", "hidden");
            $(list).parent().parent().nextAll(".field-row").find(".field-data").css("visibility", "hidden");
        }
    }
}

function aceFixHide(sender, args) {
    var id = sender.get_completionList().id + "_iframe";
    var iframe = document.getElementById(id);
    iframe.style.display = "none";


    if (jQuery.browser.msie) {
        var list = sender.get_completionList();
        var owner = "";
        try {
            owner = list.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
            if ("cv-block-0" == owner || "cv-block-1" == owner) {
                owner = list.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id;
            }
        } catch (ex) { }

        if ("" != owner && ("cv-workexperience" == owner || "cv-education" == owner || "cv-ambition" == owner)) {
            $(list).parent().parent().parent().nextAll(".field-row").find(".field-data").css("visibility", "");
            $(list).parent().parent().nextAll(".field-row").find(".field-data").css("visibility", "");
        }
    }
}

function collapsiblePanelToggle(header) {
    var contentid = $(header).next().attr('id');
    var show = 'none' == $(header).next().css('display');

    collapsiblePanelSet($(header), show);
    if (show) {
        $(header).next().show("slow");
    }
    else {
        $(header).next().hide("slow");
    }
    $.cookie('dashboard_show_' + $(header).parent().attr('id'), (show ? 'true' : 'false'), { expires: 360 });
}

function collapsiblePanelSet($header, show) {
    if (show) {
        $header.children('span:last').css('display', 'block');
        $header.children('span:first').css('display', 'none');
        $header.parent().parent().removeClass('collapsed');
    }
    else {
        $header.children('span:last').css('display', 'none');
        $header.children('span:first').css('display', 'block');
        $header.parent().parent().addClass('collapsed');
    }
}

function showErrors() {
    try {
        var objArray = $('input.error, span.error-select, textarea.error'); // textbox, datepicker
        if (objArray.length > 0) {
            objArray.css('border-color', '#ff0000');
            objArray.parent().css('background', 'url(/web/static/images/buttons/exclamation.gif) no-repeat right center');
            objArray.parent().parent().children('label').attr('style', 'color:#ff0000 !important');
        }
    } catch (Error) { }
}

// Navigation submenu's
$(function() {
    $('#app-navigation ul').superfish({
        delay: 500,                            // one second delay on mouseout 
        animation: { opacity: 'show', height: 'show' },  // fade-in and slide-down animation 
        speed: 'fast',                          // faster animation speed 
        autoArrows: false,                           // disable generation of arrow mark-up 
        dropShadows: false                            // disable drop shadows 
    });
    $('#app-navigation ul ul').bgiframe().append('<li class="last"></li>');
    $('#search-popup').bgiframe();
    $('#search-popup').wrapInner('<div class="content"></div>').append('<span class="bottom"></span>');
    $('#footer ul li:last-child').addClass('last');

    showErrors();
});


(function($) {

    var Ikki = {
        init: function() {
            TabController.init();
        }
    }

    TabController = {
        // init, caled by Ikki.init
        init: function() {
            this.positionPointer();
        },

        positionPointer: function() {
            var pointer = $('.tab-navigation .pointer');
            if (pointer.length > 0) {
                var current = $('.tab-navigation .current');
                var offset = current[0].offsetLeft;
                var w = current.width();
                var position = offset + w / 2 - 6;
                pointer.css('left', position + 'px');
            }
        }

    }




    /**
    *	Init ondomcontent
    *	--------------------------
    */

    $(function() {
        Ikki.init();
    });

})(jQuery)

$(function() {
    jQuery.map($('.collapsible'), function(elm) {
        var show = $.cookie('dashboard_show_' + elm.id);
        if (show == null) show = 'true';

        if ('true' != show) collapsiblePanelToggle($(elm).children('h2'));
        collapsiblePanelSet($(elm).children('h2'), 'true' == show);

        $(elm).children('h2').bind('click', function(e) {
            collapsiblePanelToggle(this);
        });

    });

    jQuery.map($('.collapsible-h3'), function(elm) {
        var show = 'false';

        if ('true' != show) collapsiblePanelToggle($(elm).children('h3'));
        collapsiblePanelSet($(elm).children('h3'), 'true' == show);

        $(elm).children('h3').bind('click', function(e) {
            collapsiblePanelToggle(this);
        });

    });

});

// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function(x, t, b, c, d) {
    return -c * ((t = t / d - 1) * t * t * t - 1) + b;
};

jQuery(function($) {
    if (0 < $('.image-scroller').length) {

        $('.image-scroller .sideways-scroller .prev').hide();
        $('.image-scroller .sideways-scroller .next').hide();

        // bug in jquery 1.3.2, selector :has :gt returns 0 items
        //		$('.image-scroller:has(.sections li:gt(2))').find('.next').show();
        $('.image-scroller .sideways-scroller').each(function() {

            if (-1 < this.parentNode.className.indexOf("-small")) {
                if (1 < $(this).find(".sections li").size()) $(this).find('.next').show();
            } else if (-1 < this.parentNode.className.indexOf("-big")) {
                if (4 < $(this).find(".sections li").size()) $(this).find('.next').show();
            } else {
                if (3 < $(this).find(".sections li").size()) $(this).find('.next').show();
            }
        });

        loadContent($($('.image-scroller-big')[1]).find(".sections li"));

        jQuery.map($('#interview-scroller .sections li:lt(5)'), loadContent);
        jQuery.map($('#company-scroller .sections li:lt(5)'), loadContent);
        jQuery.map($('#company-scroller-big .sections li:lt(8)'), loadContent);
        jQuery.map($('#department-scroller-big .sections li:lt(8)'), loadContent);
        jQuery.map($('#CV-scrollerManager .sections li:lt(5)'), loadContent);
        jQuery.map($('#CV-scrollerProfessional .sections li:lt(5)'), loadContent);
        jQuery.map($('#CV-scrollerArtist .sections li:lt(5)'), loadContent);
        jQuery.map($('#company-scroller-small .sections-small li:lt(3)'), loadContent);
        jQuery.map($('#group-scroller .sections li:lt(5)'), loadContent);

        $('#company-scroller, #group-scroller, #CV-scroller, #CV-scrollerManager, #CV-scrollerProfessional, #CV-scrollerArtist').serialScroll({
            target: '.sections',
            items: 'li',
            prev: 'img.prev',
            next: 'img.next',
            axis: 'xy',
            navigation: '#navigation li a',
            duration: 700,
            force: true,
            exclude: 2,
            cycle: false,
            step: 2,
            lazy: true,

            onBefore: function(e, elem, $pane, $items, pos) {
                // hide arrows at limits
                var $prev = $pane.parent().find('.prev'),
						$next = $pane.parent().find('.next');

                $prev.add($next).show();
                if (pos == 0)
                    $prev.hide();
                else if (pos == $items.length - 1 - 2) // 2 == exclude setting
                    $next.hide();

                var $tofill1 = jQuery(elem).next().next().next();
                loadContent($tofill1);

                var $tofill2 = $tofill1.next();
                loadContent($tofill2);

                e.preventDefault();
                if (this.blur)
                    this.blur();
            },
            onAfter: function(elem) {
                //'this' is the element being scrolled ($pane) not jqueryfied
            }
        });


        $('#interview-scroller').serialScroll({
            target: '.sections',
            items: 'li',
            prev: 'img.prev',
            next: 'img.next',
            axis: 'xy',
            navigation: '#navigation li a',
            duration: 700,
            force: true,
            exclude: 2,
            cycle: false,
            step: 2,
            lazy: true,

            onBefore: function(e, elem, $pane, $items, pos) {
                // hide arrows at limits
                var $prev = $pane.parent().find('.prev'),
						$next = $pane.parent().find('.next');

                $prev.add($next).show();
                if (pos == 0)
                    $prev.hide();
                else if (pos == $items.length - 1 - 2) // 2 == exclude setting
                    $next.hide();

                var $tofill1 = jQuery(elem).next().next().next();
                loadContent($tofill1);

                var $tofill2 = $tofill1.next();
                loadContent($tofill2);

                e.preventDefault();
                if (this.blur)
                    this.blur();
            },
            onAfter: function(elem) {
                //'this' is the element being scrolled ($pane) not jqueryfied
            }
        });

        $('#company-scroller-small').serialScroll({
            target: '.sections-small',
            items: 'li',
            prev: 'img.prev',
            next: 'img.next',
            axis: 'xy',
            navigation: '#navigation li a',
            duration: 700,
            force: true,
            exclude: 0,
            cycle: false,
            step: 1,
            lazy: true,

            onBefore: function(e, elem, $pane, $items, pos) {
                // hide arrows at limits
                var $prev = $pane.parent().find('.prev'),
						$next = $pane.parent().find('.next');

                $prev.add($next).show();
                if (pos == 0)
                    $prev.hide();
                else if (pos == $items.length - 1)
                    $next.hide();

                var $tofill1 = jQuery(elem).next();
                loadContent($tofill1);

                var $tofill2 = $tofill1.next();
                loadContent($tofill2);

                e.preventDefault();
                if (this.blur)
                    this.blur();
            },
            onAfter: function(elem) {
                //'this' is the element being scrolled ($pane) not jqueryfied
            }
        });


        $('.image-scroller-big').serialScroll({
            target: '.sections',
            items: 'li',
            prev: 'img.prev',
            next: 'img.next',
            axis: 'xy',
            navigation: '#navigation li a',
            duration: 700,
            force: true,
            exclude: 3,
            cycle: false,
            step: 3,
            lazy: true,

            onBefore: function(e, elem, $pane, $items, pos) {
                // hide arrows at limits
                var $prev = $pane.parent().find('.prev'),
						$next = $pane.parent().find('.next');

                $prev.add($next).show();
                if (pos == 0)
                    $prev.hide();
                else if (pos == $items.length - 1 - 3) // 3 == exclude setting
                    $next.hide();

                var $tofill1 = jQuery(elem).next().next().next();
                loadContent($tofill1);

                var $tofill2 = $tofill1.next();
                loadContent($tofill2);

                e.preventDefault();
                if (this.blur)
                    this.blur();
            },
            onAfter: function(elem) {
                //'this' is the element being scrolled ($pane) not jqueryfied
            }
        });
    }
});

function loadContent(elem) {
    var $elem = $(elem);

    if (null != $elem.html() && 1 == $elem.children().length) {
        var url = "";

        if ("company-scroller" == $elem.parent().parent().parent().parent().attr("id")) {
            url = '/Web/Companies/CompanyPreview.aspx?id=' + $elem.children('p').html();
        } else if ("group-scroller" == $elem.parent().parent().parent().parent().attr("id")) {
            url = '/Web/Groups/GroupPreview.aspx?id=' + $elem.children('p').html();
        } else if ("company-scroller-small" == $elem.parent().parent().parent().parent().attr("id")) {
            url = '/Web/Companies/CompanyPreview.aspx?id=' + $elem.children('p').html();
        } else if ("company-scroller-big" == $elem.parent().parent().parent().parent().attr("id")) {
            url = '/Web/Companies/CompanyPreview.aspx?id=' + $elem.children('p').html();
        } else if ("CV-scroller" == $elem.parent().parent().parent().parent().attr("id") || "CV-scrollerManager" == $elem.parent().parent().parent().parent().attr("id") || "CV-scrollerProfessional" == $elem.parent().parent().parent().parent().attr("id") || "CV-scrollerArtist" == $elem.parent().parent().parent().parent().attr("id")) {
            url = '/Web/Members/CVPreview.aspx?id=' + $elem.children('p').html();
        } else if ("department-scroller-big" == $elem.parent().parent().parent().parent().attr("id")) {
            url = '/Web/Companies/CompanyPreview.aspx?id=' + $elem.children('p').html();
        } else {
            url = '/Web/Groups/InterviewPreview.aspx?id=' + $elem.children('p').html();
        }

        $.ajax({ url: url, cache: false, success: function(html) { $elem.html(html); } });
    }
}

$(function() {
    $('.search-box').keypress(function(e, keyCode) {
        keyCode = keyCode || e.keyCode;
        if (13 == keyCode) {
            ShowSearchResults();
        }
    });
});

//function txtSearch_keypress(evnt) {
//    var evt = window.event ? window.event : evnt;
//    var keycode = evt.charCode || evt.keyCode || evt.which;

//    alert(keycode);
//    if (13 == keycode) {
//        ShowSearchResults();
//    }

//}

$(function() {
    $(".delete").click(function() {
        var msg = $(this).attr("rel");
        if (undefined == msg || "" == msg) msg = "Weet je het zeker?";
        if (!confirm(msg)) return false;
    });
});

$(function() {
    if (0 < $(".ajax-tabs").size()) {
        $(".ajax-tabs").tabs();
        $(".ajax-tabs .pointer").css("left", $(".ajax-tabs .current a").position().left + ($(".ajax-tabs .current a").width() / 2));

        $(".ajax-tabs ul li a").unbind("click").click(function() {
            $(this).parent().parent().find("a").removeClass("NoLink");
            $(this).parent().parent().find("li").removeClass("current");

            $(this).addClass("NoLink");
            $(this).parent().addClass("current");

            $(this).parent().parent().parent().find(".pointer").css("left", $(this).parent().position().left + ($(this).width() / 2));
        });
    }
});