
$(document).ready(function () {
    $(document).bind('contextmenu', function (e) {
        return (e.ctrlKey && e.shiftKey)
    })
});
var projectid = location.pathname.split('/')[1],
    cookieName = 'pageView',
    firstName = 'first',
    pageview = getCookie(cookieName) || 0,
    iframe = (top.location != self.location),
    firstvisit = (getCookie(firstName) || setCookie(firstName, new Date().getTime(), 30));
if (parseInt(firstvisit, 10) < new Date(2011, 0, 22, 22, 15, 0).getTime()) {
    deleteAllCookies();
    pageview = 0;
    firstvisit = setCookie(firstName, new Date().getTime(), 30)
}
setCookie(cookieName, ++pageview, 7);

function setCookie(cookieName, value, daysToExpire, path, domain, secure) {
    var expiryDate;
    if (daysToExpire) {
        expiryDate = new Date();
        expiryDate.setTime(expiryDate.getTime() + (daysToExpire * 8.64e7))
    }
    document.cookie = cookieName + '=' + (value.toString()) + (daysToExpire ? ';expires=' + expiryDate.toGMTString() : '') + ';path=' + (path ? path : '/' + projectid) + (domain ? ';domain=' + domain : '') + (secure ? ';secure' : '');
    return getCookie(cookieName)
}
function getCookie(cookieName) {
    var cookiePattern = new RegExp('(^|;)[ ]*' + cookieName + '=([^;]*)'),
        cookieMatch = cookiePattern.exec(document.cookie);
    return cookieMatch ? (cookieMatch[2]) : 0
}
function deleteAllCookies(cookieName) {
    var cookies = document.cookie.split(';');
    for (i = 0; i < cookies.length; i++) {
        name = $.trim(cookies[i].split('=')[0]);
        setCookie(name, -1, -1)
    }
}
function colorboxCSS() {
    $('head').append('<link id="colorboxCSS" href="libs/colorbox.css" rel="stylesheet">')
}
function colorbox(html, callback, options) {
    opts = {
        html: html,
        opacity: 0.5,
        innerHeight: 200,
        scrolling: false,
        transition: "none"
    };
    $.extend(opts, options);
    setTimeout(function () {
        $.getScript('libs/jquery.colorbox.js', function () {
            $.colorbox(opts);
            $('#colorbox').delegate('.colorboxclose', 'click', function () {
                $.colorbox.close();
                return false
            });
            callback()
        })
    }, 1000)
}
