Ajax.Responders.register({
    onCreate: function(request) {
        request['timeoutId'] = window.setTimeout(
            function() {
                switch (request.transport.readyState) {
                    case 1: case 2: case 3:
                        request.transport.abort();
                        request.options['onFailure'](request.transport, request.json);
                    break;
                }
            },
            60000
        );
    },
    onComplete: function(request) {
        window.clearTimeout(request['timeoutId']);
    }
});

function cmsGetContent(id, url, pars, otheroptions){
    var options = {
        method:     'get',
        parameters: pars,
        onFailure: function(request) {
            $(id).innerHTML = '<!-- content-block request failed. [js] -->';
        }
    }
    Object.extend(options, otheroptions || {});
    var myAjax = new Ajax.Updater({success: id}, url, options);
}


var trackLabel = location.pathname; 

function gaTrack(link,category,action) {
	
	if(link != ""){
		/*try {
		_gaq.push(['_trackEvent', category, action, trackLabel]);
		setTimeout('document.location = "' + link.href + '"', 200);
		}
		catch(err){}*/
		document.location = link.href;
	}
	else {
		/*_gaq.push(['_trackEvent', category, action, trackLabel]);*/
	}
}

function inputIdAndPass(_id) {
	if(document.getElementById(_id).value == "") {
		document.getElementById(_id).style.backgroundPosition = "0px";
	}
}


function setReturnURL(authType,aptID) {
	var thisURL = location.href;
	var baseURL = "https://member.gungho.jp/front/guest/" + authType + ".aspx?aptid=" + aptID + "&.goeReturnUrl=";
	var matchPattern = /selfytown\/nologin.+/i;
	var selfyFlag = matchPattern.test(thisURL);

	if(selfyFlag){
		document.location = baseURL + "http%3a%2f%2fwww%2egungho%2ejp%2fselfytown%2f";
		//window.alert("this is Selfy!");
	}
	else if(thisURL!=undefined && thisURL!=""){
		document.location = baseURL + encodeURIComponent(thisURL);
	}
	else {
		document.location = baseURL + "http%3a%2f%2fwww%2egungho%2ejp%2f";
	}
}

