$(document).ready(function () {
        if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {
            $('ul.sf-menu').superfish({
                delay: 400,
                animation: {
                    height: 'show'
                },
                speed: 275
            })
        } else {
            $('ul.sf-menu').supersubs({
                minWidth: 12,
                maxWidth: 27,
                extraWidth: 0
            }).superfish({
                delay: 400,
                animation: {
                    height: 'show'
                },
                speed: 275
            })
        }
        var overlayColor = $('#fancy_overlay').css('background-color') || '#2c2c2c';
        $("a.zoom").fancybox({
            'padding': 12,
            'overlayOpacity': 0.2,
            'overlayColor': overlayColor,
            'zoomSpeedIn': 500,
            'zoomSpeedOut': 500,
            'callbackOnShow': modalStart
        });
        $("a.login").fancybox({
            'padding': 12,
            'overlayOpacity': 0.2,
            'overlayColor': overlayColor,
            'showCloseButton': false,
            'frameWidth': 400,
            'frameHeight': 208,
            'hideOnContentClick': false,
            'callbackOnShow': modalStart
        });
        $('.topReveal').click(function () {
            $('#ContentPanel').slideToggle(800, 'easeOutQuart');
            $.scrollTo('#ContentPanel');
            return false
        });
        $("a.img").hover(function () {
            if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 8) {
                $(this).stop(false, true).toggleClass('imgHover')
            } else {
                $(this).stop(false, true).toggleClass('imgHover', 200)
            }
        });
        $.fn.cluetip.defaults.cluetipClass = 'skinned';
        $.fn.cluetip.defaults.cluezIndex = 1234;
        $.fn.cluetip.defaults.dropShadow = false;
        $.fn.cluetip.defaults.topOffset = 35;
        $.fn.cluetip.defaults.fx = {
            open: 'fadeIn',
            openSpeed: '100'
        };
        $.fn.cluetip.defaults.hoverIntent = {
            sensitivity: 3,
            interval: 100,
            timeout: 80
        };
        $.fn.cluetip.defaults.onShow = function (ct, c) {
            if ($('#cluetip-inner').html() == '') {
                (jQuery.browser.msie) ? $('#cluetip').addClass('ieFix') : $('#cluetip').addClass('mozFix')
            } else {
                (jQuery.browser.msie) ? $('#cluetip').removeClass('ieFix') : $('#cluetip').removeClass('mozFix')
            }
        };
        $('a[title != ""], .tip').cluetip({
            showtitle: false,
            arrows: true,
            splitTitle: '|'
        });
        $('.tipInclude').cluetip({
            attribute: 'rel',
            showtitle: false,
            arrows: true
        });
        $("input[type='text']:not(.noStyle), input[type='password']:not(.noStyle)").each(function () {
            $(this).addClass('textInput')
        });
        $(window).scroll(function () {
            ribbonPosition()
        });
        ribbonPosition();
        $("label.overlabel").overlabel();
        $.localScroll();
        searchInputEffect();
        buttonStyles();
        if (!jQuery.browser.msie) {
            $("a.img, div.img, .textInput, input[type='text'], input[type='password'], textarea").addClass('rounded');
            roundCorners();
        }
    
});

function validateLoad() {
  //  document.body.style.visibility = (document.domain.toString() != 'para.llel.us') ? 'hidden' : 'visible'
}
function modalStart() {
    Cufon.replace('.fancy_title > div');
    $('#fancy_inner').addClass('rounded');
    roundCorners()
}
function ribbonPosition() {
    var t = $(window).scrollTop();
    var h = $(window).height();
    var offset = $(window).height() / 25;
    var zoneSize = $(window).height() / 3;
    var zoneOne = t + zoneSize + offset;
    var zoneTwo = t + zoneSize * 2 - offset;
    $(".ribbon .wrapAround").each(function () {
        var obj = $(this);
        var objH = obj.height();
        var offset = obj.offset();
        if (offset.top + objH <= zoneOne) {
            $(this).css('background-position', '0 0')
        } else if (offset.top >= zoneTwo) {
            $(this).css('background-position', '0 -104px')
        } else {
            $(this).css('background-position', '0 -52px')
        }
    })
}
function searchInputEffect() {
    var searchFocus = false,
        searchHover = false,
        searchCtnr = $('#Search');
    searchInput = $('#SearchInput'), searchSubmit = $('#SearchSubmit');
    searchCtnr.hover(function () {
        if (!searchFocus) $(this).addClass('searchHover');
        searchHover = true
    }, function () {
        if (!searchFocus) $(this).removeClass('searchHover');
        searchHover = false
    }).mousedown(function () {
        if (!searchFocus) $(this).removeClass('searchHover').addClass('searchActive')
    }).mouseup(function () {
        searchInput.focus();
        searchSubmit.show();
        searchFocus = true
    });
    searchInput.blur(function () {
        if (!searchHover) {
            searchCtnr.removeClass('searchActive');
            searchSubmit.hide();
            searchFocus = false
        }
    })
}
function buttonStyles() {
    $("button:not(:has(span),.noStyle), input[type='submit']:not(.noStyle), input[type='button']:not(.noStyle)").each(function () {
        var b = $(this),
            tt = b.html() || b.val();
        if (!b.html()) {
            b = ($(this).attr('type') == 'submit') ? $('<button type="submit">') : $('<button>');
            b.insertAfter(this).addClass(this.className).attr('id', this.id);
            $(this).remove();
        }
        b.text('').addClass('btn').append($('<span>').html(tt));
    });
    var styledButtons = $('.btn');
    if (jQuery.browser.mozilla || jQuery.browser.webkit) {
        styledButtons.children("span").css("margin-top", "-1px")
    }
    styledButtons.hover(function () {
        $(this).addClass('submitBtnHover')
    }, function () {
        $(this).removeClass('submitBtnHover')
    })
}
function roundCorners() {
    $('.rounded, .ui-corner-all').css({
        '-moz-border-radius': '4px',
        '-webkit-border-radius': '4px',
        'border-radius': '4px'
    })
}
Cufon.replace('h1, h2, h3, h4, h5, h6, .fancy_title div');
/*
switch (parseInt(skin)) {
case 2:
    Cufon.replace('.headline')('.ribbon span', {
        hover: true,
        textShadow: '-1px -1px rgba(238, 152, 15, 0.9)'
    });
    break;
case 3:
    Cufon.replace('.headline')('.ribbon span', {
        hover: true,
        textShadow: '-1px -1px rgba(0, 0, 0, 0.3)'
    });
    break;
case 4:
    Cufon.replace('.headline')('.ribbon span', {
        hover: true,
        textShadow: '-1px -1px rgba(136, 78, 43, 0.6)'
    });
    break;
default:
    Cufon.replace('.headline', {
        textShadow: '1px 1px rgba(255, 255, 255, 1)'
    })('.ribbon span', {
        hover: true,
        textShadow: '-1px -1px rgba(0, 0, 0, 0.4)'
    })
}
*/

//cookie plugin
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

