﻿var ntv7={};
ntv7.home_path="http://www.ntv7.jp";
//ntv7.search_path="http://www.ntv7.jp/search/script.cgi?";
ntv7.search_path="http://www.ntv7.jp/search/search.cgi?";
ntv7.no_image_path="http://img.itoyokado.jp/common/img_mb/noimg.gif";
ntv7.win = function(path){ window.open(ntv7.home_path+encodeURI(path), '_ntv7').focus(); }
ntv7.XmlNodeValue = function(elements, tagName){
    var value = "";
    try{var obj = elements.getElementsByTagName(tagName);if(obj != null){value = obj.item(0).firstChild.nodeValue;}}
    catch(e){}
    return value;
}
ntv7.XmlNodeToInt = function(elements, tagName){
    var value = ntv7.XmlNodeValue(elements, tagName);
    if(value==null){return 0;}
    if(isNaN(value)){return null;}
    return parseInt(value);
}
ntv7.XmlNodeToDate = function(elements, tagName){
    var value = ntv7.XmlNodeValue(elements, tagName);
    if(value==null){return null;}
    var values = value.split(" ");
    if(values.length>0){value = values[0].replace(/-/g, "/");}
    return value;
}
ntv7.Stations = function(){
    var valueList = new Array("NTV", "TBS", "CX", "EX", "TX", "NHK", "教育");
    var fullTextList = new Array("日本テレビ", "TBSテレビ", "フジテレビ", "テレビ朝日", "テレビ東京", "NHK総合", "NHK教育");
    var shortTextList = new Array("日テレ", "TBS", "フジ", "テレ朝", "テレ東", "NHK総合", "NHK教育");
    this.value = function(index){return valueList[index];};
    this.fullText = function(index){return fullTextList[index];};
    this.shortText = function(index){return shortTextList[index];};
    this.length = valueList.length;
    this.fullTextOf = function(value){var text="";for(i=0; i<valueList.length; i++){if(valueList[i]==value){text=fullTextList[i];break;}}return text;};
    this.shortTextOf = function(value){var text="";for(i=0; i<valueList.length; i++){if(valueList[i]==value){text=shortTextList[i];break;}}return text;};
    this.indexOf = function(value){var index=0;for(i=0; i<valueList.length; i++){if(valueList[i]==value){index=i;break;}}return index;};
}
ntv7.SummaryGroups = function()
{
    var valueList = new Array("1", "3", "4", "5", "2");
    var textList = new Array("売上ランキング", "男女別ランキング", "世代別別ランキング", "地域別ランキング", "予約ランキング");
    var pageList = new Array("sales.html", "sex.html", "age.html", "area.html", "reserved.html");

    this.value = function(index){return valueList[index];};
    this.text = function(index){return textList[index];};
    this.length = valueList.length;
    this.textOf = function(value){var text="";for(i=0; i<valueList.length; i++){if(valueList[i]==value){text=textList[i];break;}}return text;};
    this.indexOf = function(value){var index=0;for(i=0; i<valueList.length; i++){if(valueList[i]==value){index=i;break;}}return index;};
    this.urlOf = function(value){
        var text="";
        for(i=0; i<valueList.length; i++){
            if(valueList[i]==value){
                text = "/shop/ranking/"+pageList[i];
                break;
            }
        }
        return text;
    };
}
ntv7.Summary = function(){
    var valueList = new Array("daily", "weekly", "monthly");
    var textList = new Array("デイリー", "ウィークリー", "マンスリー");
    var commentList = new Array("毎日更新", "毎週月曜日更新", "毎月１日更新");

    this.value = function(index){return valueList[index];};
    this.text = function(index){return textList[index];};
    this.comment = function(index){return commentList[index];};
    this.length = valueList.length;
    this.textOf = function(value){var text="";for(i=0; i<valueList.length; i++){if(valueList[i]==value){text=textList[i];break;}}return text;};
    this.indexOf = function(value){var index=0;for(i=0; i<valueList.length; i++){if(valueList[i]==value){index=i;break;}}return index;};
}
ntv7.getProgramListPath = function(id, date){

    var path="/program/list.php?";

    if(isNaN(id)){
        path += "name="+encodeURI(id);
    }
    else
    {
        path += "id="+id;
    }

    path+="&date="+date;
    
    return path;
}

