function CookieUtil(){
}
CookieUtil.setCookie = function(key, value, expireDays){
        var str = "";
        var expires = "";
        if (expireDays){
                var date = new Date();
                date.setTime(date.getTime()+(expireDays*24*60*60*1000));
                expires = "; expires=" + date.toGMTString();
        }
        str = key + "=" + value + expires + "; path=/;";
        document.cookie = str;
}
CookieUtil.getCookie = function(key){
        var str = null;
        var a = document.cookie.split(";");
        var keyEq = key + "=";
        for(var i=0; i<a.length; i++){
                var c = a[i];
                while (c.charAt(0)==' ') c = c.substring(1, c.length); // strip white space
                if(c.indexOf(keyEq) == 0){
                        str = c.substring(keyEq.length, c.length);
                        break;
                }
        }
        return str;
}
CookieUtil.getParams=function() {
    var args =new Array(10);
    if (location.search.length <= 1) return args;
    var pairs = location.search.substring(1).split("&");
    for (var i=0; i < pairs.length; ++i) {
            var param=pairs[i].split("=");
            if (param.length < 2 ) {
              continue;
            }
            if( param[1].length==0 ){
                    continue;
            }
            args[param[0]]=param[1];

    }
    return args;
}

CookieUtil.deleteCookie = function(key){
        CookieUtil.setCookie(key, "" , -1);
}
CookieUtil.isChecked=function(){

		var backURL='http://macross.jp/pc/index.html';
		var correctURL1='http://macross.jp/';
		var correctURL2='http://www.macrossf.com/';

        var cookie=CookieUtil.getCookie( "check" );
        var ref=document.referrer;
        var isOK=false;
        if( ref ){
                if( ref.indexOf( correctURL1 )==0 ||
                        ref.indexOf( correctURL2 )==0
                 ){
                        isOK=true;
                }else{
                        isOK=false;
                }
        }
        if( cookie != null || isOK==true ){
                isOK=true;
        }else{
                var args=CookieUtil.getParams();
                if( args ){
                        if( args['c']=='x' ){
                                isOK=true;
                        }else{
                                isOK=false;
                        }
                }
        }
        if( isOK==false ){
                document.location.href=backURL;
        }
}
 
CookieUtil.isChecked();