//<!-- Copyright 2005-6 v1.0. Jacqueline Choo                                -->
//<!-- Please see www.invertigo-studios.com for TOU before using            -->
//<!-- Use of minor portions of this script is permissible if properly 
//     attributed(ie. must include, minimally, my name & uri). 
//     Copying wholesale or of large portions is disallowed.  -->

// global busy variable:

hkppcg_website_busy_loading = true;



/* menu dropdown from: http://www.htmldog.com/articles/suckerfish/dropdowns/  */

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);







//----------------------------------------------------------------------------
// General utility functions.
// Copyright 2000-2004 by Mike Hall.
// See http://www.brainjar.com for terms of use.
//----------------------------------------------------------------------------


function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}


/*********************j************************/

function zeroPadIntToStr (jNumber) {
try { 
   jNumber = Math.floor(jNumber);
   if (jNumber >=0) {return ((jNumber < 10) ? '0' : '') + jNumber;}
   else {window.status = "error. number is negative"}
   }
catch (err) {
   window.status = "zeropad error: " + err + " Likely not a number. Tell the webmaster she screwed up"
   }

}


/*j*****

CSS toggle F(x)

******/

//spaghetti cannibalized from http://www.alistapart.com/articles/alternate/
// adapted version breaks if 
//   a) the variable stylesheets are not sequential in the HTML doc
//   b) the variable stylesheets do not occur after all persistent stylesheets.
// i is the starting index of the variable css's: jg_minCSSindex

function toggleActiveStyleSheet(what) {
  var i, a, jChangeToThisCSS;

   if (jg_cssChanging == false) {
    
     jg_cssChanging = true;

     if (what == '') {
   
       jChangeToThisCSS = jg_active_stylesheet_index +1;

// artificial stylesheet loop
       jChangeToThisCSS = (jChangeToThisCSS > jg_maxCSSindex) ? jg_minCSSindex : jChangeToThisCSS;

        for(i=jg_minCSSindex; ((a = document.getElementsByTagName("link")[i]) && (i <= jg_maxCSSindex)); i++) {

            a.disabled = true;
            if(i == jChangeToThisCSS) {
            a.disabled = false;
            jg_active_stylesheet_index = jChangeToThisCSS;         

            }
        }
     }
     else {
        for(i=jg_minCSSindex; ((a = document.getElementsByTagName("link")[i]) && (i <= jg_maxCSSindex)); i++) {
            a.disabled = true;
            if(a.title == what) {
              a.disabled = false;
             jg_active_stylesheet_index = i;         
            }
        }
     }
     jg_cssChanging = false;
   } //css changing check for weirda$$ browsers.
}



function getActiveStyleSheet() {
  var i, a;

 for(i=jg_minCSSindex; ((a = document.getElementsByTagName("link")[i]) && (i <= jg_maxCSSindex)); i++) {

    if(
     (a.getAttribute("rel").indexOf("style") != -1) && 
     (a.getAttribute("title")!='') && 
      (!a.disabled)
      ){return i; } 
  }
  return null;

}



/*j*****

DEBUG F(x)s

******/


function test(){






window.status="hahaha!!!!";
}


/*j*****

COOKIE F(x)s

******/


function cookieRedirect(){
  // examine cookie['ipsTOUv']'s value
  // if cookie exists && is current, stay 
     //else load /index.html
  // /index.html handles the cookie maintenance.
   
var j = readCookie("ipsTOUv");

  if ((j == hkppcTOUversion)){
    }
    else
     {
         if (document.location) {
            document.location = jgAddy;
         }
         else {
            if (document.location.href) document.location.href = jgAddy;
         }
     }
  
}



/*j************

debugging

******/


function jtest(){

}



/*j*****

INIT F(x)s

******/








/* general init */




function hkppcInit() {
  //global variables


 jg_website_busy_loading = false;


}
