
var pageName = "index.shtml";

function itemData(title, desc, imgArray){
  this.title = title;
  this.desc = desc;
  this.imgArray = imgArray;
};

function itemImg(isrc,width,height){
 this.isrc = isrc;
 this.width = width;
 this.height = height;
}


function getVarFromURL(uri_string){

  var returnArray= new Array();

  function parseArray(matchString){
    regexp=/([\S]+)=([\S]+)/i;
    regexp.exec(matchString);
     this.variable=RegExp.$1;
     this.value=RegExp.$2;
  };

 matchArray = uri_string.match(/[^\?|&]+=[^&]+/gi);

 if(matchArray){
     for(var icount=0; icount<matchArray.length; icount++){
       returnArray[icount]=new parseArray(matchArray[icount]);
     };
 } else returnArray = false; 
                                
 return returnArray;

};


function getCurrentPage(){

  var cur_page = 0;

  a = getVarFromURL(document.location.href);

  if(a){

     for(i=0; i<a.length; i++){
       if(a[i].variable == "page"){ cur_page = parseInt(a[i].value); } ;
     }

  };

  return cur_page;

};

function newWindow(num){
 if(DataArray[num].imgArray[1]){
  title = DataArray[num].title;
  DA = DataArray[num].imgArray[1];
    width = DA.width;
    height = DA.height;
    isrc = DA.isrc;

    properties = "width=" + ( width + 25) + ",height=" + ( height + 25 ) + ",menubar=yes,status=yes,resizable=yes"

    nw = window.open("","",properties);
    nwd = nw.document;
    nwd.open();
      nwd.writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>');
      nwd.writeln('<title>' + title + '</title>');
      nwd.writeln('</head><body bgcolor="#ffffff"><table border="0" cellpadding="0" cellspacing="0" width="100%" style="height:100%"><tr><td align="center">');
      nwd.writeln('<img src="' + imgUrl + isrc + '" width="' + width + '" height="' + height + '" alt="' + title + '">');
      nwd.writeln('</td></tr></table></body></html>');
    nwd.close();
 }
 else{ return false };
}

function drawLogos(){

  var startitem = getCurrentPage();

  startitem *= itemPerPage;

  if(startitem < 0 || startitem >= DataArray.length){ startitem = 0; };

  enditem = (DataArray.length - startitem < itemPerPage)? DataArray.length : startitem + itemPerPage ;

  document.writeln('<table border="0" cellpadding="4" cellspacing="0" width="100%"><tr><td><img src="/img/sp.gif" width="1" height="1" alt=""></td></tr>');

  for(i=startitem; i<enditem; i++){

    title = DataArray[i].title;

    desc = DataArray[i].desc;

     document.writeln('<tr><td bgcolor="#125fae"><span class="wh4"><b class="yel">&nbsp;'+title+'</b></span></td></tr>')

     document.writeln('<tr><td><table border="0" cellpadding="2" cellspacing="6" width="100%">');

      var DA = DataArray[i].imgArray[0];

      isrc = DA.isrc;
      width = DA.width;
      height = DA.height;

      document.writeln('<tr valign="top">');
        document.write('<td><a href="#" onclick="javascript:newWindow(' + i + ')">')
        document.write('<img src="'+ imgUrl + isrc +'" width="'+width+'" height="'+height+'" border="1" vspace="4" alt="' + title + '"><br>');
        document.writeln('</a></td>');
        document.writeln('<td width="100%"><span class="nt">' + desc + '</span></td>');
      document.writeln('</tr>');

    document.writeln('</table></td></tr>');

  };

  document.writeln('<tr><td><img src="/img/sp.gif" width="1" height="1" alt=""></td></tr></table>');

};

function drawPager(){
  var cur_page = getCurrentPage();
  if(cur_page * itemPerPage >= DataArray.length){ cur_page = 0;};

  var maxPageCount = Math.ceil(DataArray.length/itemPerPage);

  if(cur_page!=0){
    document.write('<a href="' + pageName + '?page='+(cur_page-1)+'">&#171;&nbsp;Previous<\/a>&nbsp;|');
  }

  for(i=0; i < maxPageCount; i++){
   if(i==cur_page){
      document.write(" <b>[ "+(i+1)+" ]</b> ");
   }else{
      document.write(' <a href="' + pageName + '?page='+i+'">[ '+(i+1)+' ]<\/a> ');
   };

   if((i+1) < maxPageCount){ document.write(" | ")};
  };

  if((cur_page+1) * itemPerPage < DataArray.length){
    document.write('|&nbsp;<a href="' + pageName + '?page='+(cur_page+1)+'">Next&nbsp;&#187;<\/a>');
  }

};
