﻿var baseURL = '/';
var swfDir = '/swf/';
//
var app_profile = 'app/profile';
//
var app_login = 'app/login';
//
var app_workout = 'app/myworkout';
//
var app_addrecommend = 'app/addrecommend';
//
var app_courselist_recommend = 'app/courselist/recommend/';
var app_courselist_favorite = 'app/courselist/favorite/';
var app_courselist_event = 'app/courselist/event/';
var app_courselist_pref = 'app/courselist/pref/';
var app_courselist_keyword = 'app/courselist/keyword/';
//
var app_course = 'app/course/';
var app_add_favorite = 'app/html/addfavorite/';
//
var app_news = 'feed/news.xml';
//
var app_demo = 'demo/demo_run.xml';
////////////////////////////////////////////////////////////////////////////
var isIE = (document.documentElement.getAttribute ("style") == document.documentElement.style);
////////////////////////////////////////////////////////////////////////////
//
var type_profile = 'profile';
var type_login = 'login';
var type_workout_myworkout = 'myworkout';
var type_addrecommend = 'addrecommend';
//
var type_course_recommend = 'recommend';
var type_course_favorite = 'favorite';
var type_course_event = 'event';
var type_course_pref = 'pref';
var type_course_keyword = 'keyword';
//
var type_course_course = 'course';
var type_addfavorite = 'addfavorite';
//
var type_news = 'news';
//
var type_demo = 'app_demo'
//
//////////////////////////////////////
//
var glob_category;
var glob_type;
var glob_coursetype;
//
var glob_totalpage = 0;
var glob_nowpage = 1;
var glob_pageNum = 5;
//
var maxLength_Title = 20;
//var maxLength_Dist = 3;
//
var courseListMaxNum = 5;
//
//////////////////////////////////////
var globNum = 0;
var idNum = 0;
var initClassNum = 0
//
var checkGlbNum = 0;
var leg_Nm_Div = 0;
var leg_MyChild = 0;
//
var clsCnt = 0;
//
var myObj;
var objobj;
var claStr = 'entry';
var claStr_Choice = 'entry-choice';
var claStr_Hover = 'entry-hover';
//
var entryArray = new Array ();
//
//////////////////////////////////////
var myObj;
var objobj;
//
////////////////////////////////////////////////////////////////////////////
var return_url_API = function (str)
{
    //
    switch (str)
    {
        case type_profile :
        returnVal = app_profile;
        break;
        case type_login :
        returnVal = app_login;
        break;
        case type_workout_myworkout :
        returnVal = app_workout;
        break;
        case type_addrecommend :
        returnVal = app_addrecommend;
        break;
        case type_course_recommend :
        returnVal = app_courselist_recommend;
        break;
        case type_course_favorite :
        returnVal = app_courselist_favorite;
        break;
        case type_course_event :
        returnVal = app_courselist_event;
        break;
        case type_course_pref :
        returnVal = app_courselist_pref;
        break;
        case type_course_keyword :
        returnVal = app_courselist_keyword;
        break;
        case type_course_course :
        returnVal = app_course;
        break;
        case type_addfavorite :
        returnVal = app_add_favorite;
        break;
        case type_news :
        returnVal = app_news;
        break;
        case type_demo :
        returnVal = app_demo;
        break;
        default :
        returnVal = app_courselist_recommend;
        break;
    }
    //
    returnVal = baseURL + returnVal;
    //
    return returnVal
}
////////////////////////////////////////////////////////////////////////////
var setInnnnerHTML = function (targetID, setHTML)
{
    if (document.getElementById)
    {
        document.getElementById (targetID).innerHTML = setHTML;
    } else if (document.all)
    {
        document.all (targetID).innerHTML = setHTML;
    } else
    {
        with (document.Layers [targetID].document)
        {
            open ();
            write (setHTML);
            close ();
        }
    }
}
/////////////////////////////////////////////////////////////////////////////
var setActiveTab = function (str, flg)
{
    var tagetID;
    var tagetHTML;
    //
    switch (str)
    {
        case "recommend" :
        tagetID = "cn-course";
            tagetHTML = "<strong><a href=\"/myworkout/course.html\">auおすすめコース</a></strong>";
        break;
        case "event" :
        tagetID = "cn-event";
            tagetHTML = "<strong><a href=\"/myworkout/course_event.html\">大会マップ</a></strong>";
        break;
        case "favorite" :
        tagetID = "cn-favorite";
            tagetHTML = "<strong><a href=\"/myworkout/course_favorite.html\">お気に入りコース</a></strong>";
        break;
        default :
        tagetID = null;
        tagetHTML = null;
        break;
    }
    //
    setInnnnerHTML (tagetID, tagetHTML);
}
/////////////////////////////////////////////////////////////////////////////
var viewDetal = function (category, num)
{
    detailURL = baseURL + "myworkout/course_detail.html";
    //
    location.href = detailURL + "?/" + category + "/" + glob_coursetype + "/1/" + num;
}
/////////////////////////////////////////////////////////////////////////////
var getOut = function ()
{
    var URL = "/";
    location.href = URL;
}
/////////////////////////////////////////////////////////////////////////////
/*-------------------------
Rollover
-------------------------*/
conf = {
       className : 'rollover',
       postfix : '_sw'
};
function setMouseOverImages() {
       $A(document.getElementsByClassName(conf.className)).each(function (node){
               node.onmouseout = changeSrcFunction(node.src);
               node.onmouseover =
                changeSrcFunction(node.src.replace(/(\.gif|\.jpg|\.png)/, conf.postfix+"$1"));
       });
}
function changeSrcFunction(data){
       return function(){ this.src = data; }
}
Event.observe(window, 'load', setMouseOverImages, false);



/*-------------------------
Pop up
-------------------------*/
function puWindow(url,nam,wid,hei,prop){
    var offset = 100;
    var w = window.screen.width;
    var h = window.screen.height;
    var l = (w-wid)/2;
    var t = ((h-hei)/2)-offset;
    sty = prop;
    sty+= ",width=";
    sty+= wid;
    sty+= ",height=";
    sty+= hei;
    sty+= ",left=";
    sty+= l;
    sty+= ",top=";
    sty+= t;
    window.open(url,nam,sty);
}

function popup0(url,nam,wid,hei){
    prop = "status=no,scrollbars=no,resizable=no";
    puWindow(url,nam,wid,hei,prop);
}

function popup1(url,nam,wid,hei){
    prop = "status=yes,scrollbars=yes,resizable=yes";
    puWindow(url,nam,wid,hei,prop);
}

// minmax.js: make IE5+/Win support CSS min/max-width/height
// version 1.0, 08-Aug-2003
// written by Andrew Clover <and@doxdesk.com>, use freely
/*@cc_on
@if (@_win32 && @_jscript_version>4)

var minmax_elements;

minmax_props= new Array(
new Array('min-width', 'minWidth'),
new Array('max-width', 'maxWidth'),
new Array('min-height','minHeight'),
new Array('max-height','maxHeight')
);

// Binding. Called on all new elements. If <body>, initialise; check all
// elements for minmax properties

function minmax_bind(el) {
var i, em, ms;
var st= el.style, cs= el.currentStyle;

if (minmax_elements==window.undefined) {
// initialise when body element has turned up, but only on IE
if (!document.body || !document.body.currentStyle) return;
minmax_elements= new Array();
window.attachEvent('onresize', minmax_delayout);
// make font size listener
em= document.createElement('div');
em.setAttribute('id', 'minmax_em');
em.style.position= 'absolute'; em.style.visibility= 'hidden';
em.style.fontSize= 'xx-large'; em.style.height= '5em';
em.style.top='-5em'; em.style.left= '0';

if (typeof em.style.setExpression == "function") {
em.style.setExpression('width', 'minmax_checkFont()');
document.body.insertBefore(em, document.body.firstChild);
}
}

// transform hyphenated properties the browser has not caught to camelCase
for (i= minmax_props.length; i-->0;)
if (cs[minmax_props[i][0]])
st[minmax_props[i][1]]= cs[minmax_props[i][0]];
// add element with properties to list, store optimal size values
for (i= minmax_props.length; i-->0;) {
ms= cs[minmax_props[i][1]];
if (ms && ms!='auto' && ms!='none' && ms!='0' && ms!='') {
st.minmaxWidth= cs.width; st.minmaxHeight= cs.height;
minmax_elements[minmax_elements.length]= el;
// will need a layout later
minmax_delayout();
break;
} }
}

// check for font size changes

var minmax_fontsize= 0;
function minmax_checkFont() {
var fs= document.getElementById('minmax_em').offsetHeight;
if (minmax_fontsize!=fs && minmax_fontsize!=0)
minmax_delayout();
minmax_fontsize= fs;
return '5em';
}

// Layout. Called after window and font size-change. Go through elements we
// picked out earlier and set their size to the minimum, maximum and optimum,
// choosing whichever is appropriate

// Request re-layout at next available moment
var minmax_delaying= false;
function minmax_delayout() {
if (minmax_delaying) return;
minmax_delaying= true;
window.setTimeout(minmax_layout, 0);
}

function minmax_stopdelaying() {
minmax_delaying= false;
}

function minmax_layout() {
window.setTimeout(minmax_stopdelaying, 100);
var i, el, st, cs, optimal, inrange;
for (i= minmax_elements.length; i-->0;) {
el= minmax_elements[i]; st= el.style; cs= el.currentStyle;

// horizontal size bounding
st.width= st.minmaxWidth; optimal= el.offsetWidth;
inrange= true;
if (inrange && cs.minWidth && cs.minWidth!='0' && cs.minWidth!='auto' && cs.minWidth!='') {
st.width= cs.minWidth;
inrange= (el.offsetWidth<optimal);
}
if (inrange && cs.maxWidth && cs.maxWidth!='none' && cs.maxWidth!='auto' && cs.maxWidth!='') {
st.width= cs.maxWidth;
inrange= (el.offsetWidth>optimal);
}
if (inrange) st.width= st.minmaxWidth;

// vertical size bounding
st.height= st.minmaxHeight; optimal= el.offsetHeight;
inrange= true;
if (inrange && cs.minHeight && cs.minHeight!='0' && cs.minHeight!='auto' && cs.minHeight!='') {
st.height= cs.minHeight;
inrange= (el.offsetHeight<optimal);
}
if (inrange && cs.maxHeight && cs.maxHeight!='none' && cs.maxHeight!='auto' && cs.maxHeight!='') {
st.height= cs.maxHeight;
inrange= (el.offsetHeight>optimal);
}
if (inrange) st.height= st.minmaxHeight;
}
}

// Scanning. Check document every so often until it has finished loading. Do
// nothing until <body> arrives, then call main init. Pass any new elements
// found on each scan to be bound

var minmax_SCANDELAY= 500;

function minmax_scan() {
var el;
for (var i= 0; i<document.all.length; i++) {
el= document.all[i];
if (!el.minmax_bound) {
el.minmax_bound= true;
minmax_bind(el);
} }
}

var minmax_scanner;
function minmax_stop() {
window.clearInterval(minmax_scanner);
minmax_scan();
}

minmax_scan();
minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY);
window.attachEvent('onload', minmax_stop);

@end @*/

