<!--
var prog = new Array();     // program id
var video = new Array();    // video file name
var linkId = new Array();   // file link id, e.g. api_video_X.htm
var title = new Array();    // full title
var stitle = new Array();   // short title
var image = new Array();    // image
var hasGB = new Array();    // image

function registerProg(p, v, t, s, i, has_gb) {
    var curIdx = prog.length;
    prog[curIdx] = p;
    video[curIdx] = v;
    linkId[curIdx] = parseInt(p)-1;
    title[curIdx] = t;
    stitle[curIdx] = s;
    image[curIdx] =i ;
    hasGB[curIdx] = has_gb ;
}

//
// actually register the programs
//
registerProg("01","api01_e_BB","Don't sell Hong Kong down the river.<br> Keep away from pirated goods.","Don't sell Hong Kong down the ...","api01.jpg",false);
registerProg("02","api02_e_BB","Keep away from pirated goods.<br> Don't finance crime.","Keep away from pirated goods...","api02.jpg",false);
registerProg("03","api03_e_BB","You are what you wear.<br> Get real.","You are what you wear. Get real...","api03.jpg",false);
registerProg("04","api04_e_BB","Creativity．Intellectual Property．Wealth","Creativity．Intellectual Property...","api04.jpg",false);
registerProg("05","api05_e_BB","Don't use pirated software today not even once.","Don't use pirated software today...","api05.jpg",false);
registerProg("06","api06_e_BB","No Fakes Pledge","No Fakes Pledge","api06.jpg",true);
registerProg("07","api07_e_BB","Shop for Real","Shop for Real","api07.jpg",true);
registerProg("8","api08_e_BB","Mission to Stop Piracy","Mission to Stop Piracy","api08.gif",true); // use gif instead of jpg
registerProg("9","api09_e_BB","Help creative industries prosper","Help creative industries prosper","api09.jpg",true);
registerProg("10","api10_e_BB","Don't infringe copyright while photocopying","Don't infringe copyright while...","api10.jpg",true);
registerProg("11","api11_e_BB","No illegal file-sharing","No illegal file-sharing","api11.jpg",true);
registerProg("12","api12_e_BB","Don't use pirated software for business","Don't use pirated software for...","api12.jpg",true);
registerProg("13","api13_e_BB","Creativity originates from daily life","Creativity originates from ...","api13.jpg",true);
registerProg("14","api14_e_BB","Keep your design confidential before registration","Keep your design confidential ...","api14.jpg",true);
registerProg("15","api15_e_BB","Keep your invention confidential","Keep your invention confidential...","api15.jpg",true);
registerProg("16","api16_e_BB","Enhance your goodwill by registering your trademark","Enhance your goodwill by ...","api16.jpg",true);
registerProg("17","api17_e_BB","Trademark registration and company registration","Trademark registration and ...","api17.jpg",true);
registerProg("18","api18_e_BB","IP legislation between HK & Mainland China","IP legislation between HK ...","api18.jpg",true);
registerProg("19","api19_e_BB","Anti-Internet Piracy<br>Parents Version","Anti-Internet Piracy-Parents Ver","api19.jpg",false);
registerProg("20","api20_e_BB","Anti-Internet Piracy<br>Teens Version","Anti-Internet Piracy-Teens Ver","api20.jpg",false);
registerProg("21","api21_e_BB","Reward Scheme to Combat Illegal Use of Software in Business","Reward Scheme to ...","api12.jpg",false); // 21 and 12 same pic
registerProg("22","api22_e_BB","Copyright (Amendment) Ordinance 2007 - Anti-circumvention","Copyright (Amendment) ...","api22.jpg",false);
registerProg("23","api23_e_BB","Software Asset Management Consultancy Programme","Software Asset Management ...","api23.jpg",false);
registerProg("24","api24_e_BB","'No Fakes Pledge' Scheme 2008","'No Fakes Pledge' Scheme 2008","api24.jpg",true);
registerProg("25","api25_e_BB","Anti-camcording in Cinemas","Anti-camcording in Cinemas","api25.jpg",false);
registerProg("26","api_26_e_BB","Differences between trademark registration and company registration","Differences between...","api26.jpg",true);
registerProg("27","api_27_e_BB","Territorial limitation of IP protection","Territorial limitation...","api27.jpg",true);
registerProg("28","api_28_e_BB","Overview of Intellectual Capital Management","Overview of Intellectual...","api28.jpg",true);
registerProg("29","api_29_e_BB","Registered design protection in Hong Kong","Registered design protection...","api29.jpg",true);
registerProg("30","api30_e_BB","Protect Intellectual Property Rights together ","Protect Intellectual Property...","api30_e.jpg",false);
registerProg("31","api31_e_bb","Respect Intellectual Property Rights on Internet","Respect Intellectual Property...","api31.jpg",true);
registerProg("32","api32e_bb","Anti-Software piracy in business","Anti-Software piracy in business","api32.jpg",false);
registerProg("33","api33e_bb","Don't sell counterfeits and pirated goods over the Internet","Don't sell counterfeits and pirated goods over the Internet","api33.jpg",false);
registerProg("34","api34_e","To get the real deal, look for the “No Fakes” logo","To get the real deal, look for the “No Fakes” logo","api34.jpg",false);

// end register

// calculate which one to display according to my page number

var pageView = 6 ;
var lastPage = Math.ceil(prog.length/pageView);
// var p = gup("p");                               // get page number
// if (p=="" || p != parseInt(p) || p<=0) p = 1;
// else if (p>lastPage) p = lastPage;              // someone give a large p

var myLoc = window.location.href;
var idx = myLoc.lastIndexOf("/");
myLoc = myLoc.substring(++idx);

var s = myLoc;
idx = s.indexOf("_cat");
if (idx>0) {                    // a cat file, must be api_cat[_X].htm
    s = s.substring(idx+4);
    if (s==".htm") p = 1;       // page 1 for root page
    else {                      // it must be _X.htm
        idx = s.indexOf(".");
        s = s.substring(1, idx);
        p = parseInt(s);
        if (isNaN(p)) p = 1;
        else if (p<=0) p = 1;
        else if (p>lastPage) p = lastPage;      // someone give a large p
    }
    // calculate other indexes
    var max = p * pageView;
    var start = prog.length-max+pageView - 1;
    if (p<lastPage) {                               // simple case
        var end = prog.length - max;
        var lastPage = (max==prog.length);
    } else {                                        // last page
        var end = 0;
        var lastPage = true;
    }
} else {                                        // a content file, must be api_video[_X].htm
    s = s.substring("api_video".length);        // skip "api_video" part
    if (s==".htm") id = 0;      // default to item 0
    else {                      // it must be _X.htm
        idx = s.indexOf(".");
        s = s.substring(1, idx);
        id = parseInt(s);
        if (isNaN(id)) id = 0;
        else if (id<0) id = 0;
        else if (id>=prog.length) id = prog.length-1;      // someone give a large id
        else {      // lookup using linkId table
            for (i=0; i<prog.length; i++) if (linkId[i]==id) break;
            if (i!=prog.length) id = i;
            else id=0;
        }
    }
}


//-->

