// Button Rollover Code
function rollOver(imgID, imgName) {
  if (navigator.appName== "Netscape" && parseInt(navigator.appVersion) >= 3)
    document.images[imgID].src = imgName;
  else if (navigator.appName != "Netscape" && parseInt(navigator.appVersion) >= 4) 
    document.images[imgID].src = imgName;
}

function validatePromoCode() {

  var errMessage = '';

  //Check that user has supplied all required info
  //
  promoFieldObj= document.getElementById('rvc_promocode');
  promoLabelObj= document.getElementById('promoCode');
  if (isBlank(promoFieldObj.value)) {
    errMessage = errMessage + '<li>Please supply a <strong>Promotion Code</strong>.</li>';
    promoLabelObj.className = 'formlabelalert';  
  }
  else {
    promoLabelObj.className = '';  
  }
  
  if (errMessage != '') {
    toggleBlanket('alert','<ul>' + errMessage + '</ul>','');
  }
  else {
    
    //  No errors, form is good to do, submit it.
    //
    toggleBlanket('applyingpromo','','');
    document.applyPromo.submit();
  }
}

function toggleBlanket(type, msg, url) {
  var blanket = document.getElementById(type + 'Blanket');
  var msgWrprObj = document.getElementById(type + 'MsgWrpr');

  if (blanket.className == 'displayNone') {

    // If IE6, hide all selection boxes.
    if (usingIE6())
      toggleAllSelects('hide');
 
    if (url != '' && url.length > 0) {
      var getTheATag = document.getElementById('linkYesProceed');
      getTheATag.setAttribute('href', url);
    }
    if (msg != '' && msg.length > 0) {
      document.getElementById(type + 'Message').innerHTML=msg;
    }
    blanket.className = 'displayBlock';
    msgWrprObj.className = 'displayBlock';
  } else {

    // If IE6, show all selection boxes.
    if (usingIE6())
      toggleAllSelects('show');

    blanket.className = 'displayNone';
    msgWrprObj.className = 'displayNone';
  }
}

function toggleDisplay(obj) {  
  if (getDisplay(obj) == 'block') {
    hideElement(obj);
  } else {
    showElement(obj);
  }
}
function usingIE6() {
  if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
    var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
    if (ieversion>=6 && ieversion<7 )
      return true;
    else
      return false;
  }
}
// Button Rollover Code
function rollOverNew(imgID, imgName) {
	document.getElementById(imgID).setAttribute('src', imgName);
}

function isBlank(val){
  if(val==null) {return true;}
  for(var i=0;i<val.length;i++) {
    if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
  }
  return true;
}

function isValidZipcode(zipcode) {

  // Check for correct zip code
  reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);

  if (!reZip.test(zipcode))
    return false;

  return true;

}

//function isValidPostalcode(postalcode) {
//  if (postalcode.length == 6 && postalcode.search(/^[AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy][0-9][AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvWwXxYyZz][0-9][AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvWwXxYyZz][0-9]$/) != -1)
//    return true;
//  else if (postalcode.length == 7 && postalcode.search(/^[AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvXxYy][0-9][AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvWwXxYyZz](-|\s)[0-9][AaBbCcEeGgHhJjKkLlMmNnPpRrSsTtVvWwXxYyZz][0-9]$/) != -1)
//    return true;
//  else
//    return false;
//
//  return true;
//}

function isValidPostalcode(postalcode) {
  if (postalcode.length == 6 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$/) != -1)
    return true;
  else if (postalcode.length == 7 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z](-|\s)\d[a-zA-Z]\d$/) != -1)
    return true;
  else
    return false;

  return true;
}

function isEmail(email, required) {
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.lastIndexOf("@") != email.indexOf("@")) {  // @ can't appear more than once
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789!#$%&'*+-/=?^_{|}~.@";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersonly(myfield, e, dec) {
 var key;
 var keychar;
		
 if (window.event) {
  key = window.event.keyCode;
 } else if (e) {
  key = e.which;
 } else {
  return true;
 }
		
 keychar = String.fromCharCode(key);
	
 // control keys
 if ((key==null) || (key==0) || (key==8) || (key==9) || (key==27) ) {
  return true;
 } else if ((("0123456789").indexOf(keychar) > -1)) {// numbers
  return true;
 } else {
  return false;
 }
}

function limitChars(myfield, e, charType) {
 var key;
 var keychar;

 digits = "0123456789";
 lowercase = "abcdefghijklmnopqrstuvwxyz";
 uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 decimal = digits + ".";
 lowerAlphaNumeric = lowercase + digits;
 upperAlphaNumeric = uppercase + digits;
 alphaNumeric = uppercase + lowercase + digits;
		
 if (window.event) {
  key = window.event.keyCode;
 } else if (e) {
  key = e.which;
 } else {
  return true;
 }
		
 keychar = String.fromCharCode(key);
	
 // control keys
 if ((key==null) || (key==0) || (key==8) || (key==9) || (key==27) ) {
  return true;
 } else if (((eval(charType)).indexOf(keychar) > -1)) {// numbers
  return true;
 } else {
  return false;
 }
}

function Left(str, n){
  if (n <= 0)
    return "";
  else if (n > String(str).length)
    return str;
  else
    return String(str).substring(0,n);
}

function Right(str, n){
  if (n <= 0)
    return "";
  else if (n > String(str).length)
    return str;
  else {
    var iLen = String(str).length;
    return String(str).substring(iLen, iLen - n);
  }
}

function Len(str){  
  return String(str).length;  
}

function showElement(ele) {
  obj = document.getElementById(ele).style;
  obj.display='block';
}

function hideElement(ele) {
  obj = document.getElementById(ele).style;
  obj.display='none';
}

var hiddenByToggleAllSelects = 1;
function setStateInput(inputPrefix) {

  var countryEle = document.getElementById(inputPrefix + 'country');
  
  switch (countryEle.value) {
    case "USA":
    case "Canada":
    case "Australia":
    case "Mexico":
      document.getElementById(inputPrefix + 'state_ddl').className = 'displayBlock';
      document.getElementById(inputPrefix + 'state_txt').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_txt').value = '';
      hiddenByToggleAllSelects = 1;
      break;
    default:
      document.getElementById(inputPrefix + 'state_txt').className = 'displayBlock';
      document.getElementById(inputPrefix + 'state_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_ddl').value = '';
      hiddenByToggleAllSelects = 0;
      break;
   } 
    
  return true;
}
function setStateInputNew(inputPrefix) {

  var countryEle = document.getElementById(inputPrefix + 'country');
  
  switch (countryEle.value) {
    case "USA":
      document.getElementById(inputPrefix + 'state_usa_ddl').className = 'displayBlock';
      document.getElementById(inputPrefix + 'state_canada_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_canada_ddl').value = '';
      document.getElementById(inputPrefix + 'state_australia_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_australia_ddl').value = '';
      document.getElementById(inputPrefix + 'state_mexico_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_mexico_ddl').value = '';
      document.getElementById(inputPrefix + 'state_txt').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_txt').value = '';
      hiddenByToggleAllSelects = 1;
      break;
    case "Canada":
      document.getElementById(inputPrefix + 'state_canada_ddl').className = 'displayBlock';
      document.getElementById(inputPrefix + 'state_usa_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_usa_ddl').value = '';
      document.getElementById(inputPrefix + 'state_australia_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_australia_ddl').value = '';
      document.getElementById(inputPrefix + 'state_mexico_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_mexico_ddl').value = '';
      document.getElementById(inputPrefix + 'state_txt').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_txt').value = '';
      hiddenByToggleAllSelects = 1;
      break;
    case "Australia":
      document.getElementById(inputPrefix + 'state_australia_ddl').className = 'displayBlock';
      document.getElementById(inputPrefix + 'state_usa_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_usa_ddl').value = '';
      document.getElementById(inputPrefix + 'state_canada_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_canada_ddl').value = '';
      document.getElementById(inputPrefix + 'state_mexico_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_mexico_ddl').value = '';
      document.getElementById(inputPrefix + 'state_txt').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_txt').value = '';
      hiddenByToggleAllSelects = 1;
      break;
    case "Mexico":
      document.getElementById(inputPrefix + 'state_mexico_ddl').className = 'displayBlock';
      document.getElementById(inputPrefix + 'state_usa_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_usa_ddl').value = '';
      document.getElementById(inputPrefix + 'state_canada_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_canada_ddl').value = '';
      document.getElementById(inputPrefix + 'state_australia_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_australia_ddl').value = '';
      document.getElementById(inputPrefix + 'state_txt').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_txt').value = '';
      hiddenByToggleAllSelects = 1;
      break;
    default:
      document.getElementById(inputPrefix + 'state_txt').className = 'displayBlock';
      document.getElementById(inputPrefix + 'state_usa_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_usa_ddl').value = '';
      document.getElementById(inputPrefix + 'state_canada_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_canada_ddl').value = '';
      document.getElementById(inputPrefix + 'state_australia_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_australia_ddl').value = '';
      document.getElementById(inputPrefix + 'state_mexico_ddl').className = 'displayNone';
      document.getElementById(inputPrefix + 'state_mexico_ddl').value = '';
      hiddenByToggleAllSelects = 0;
      break;
   } 
    
  return true;
}

function toggleAllSelects(action) {
  var x = document.getElementsByTagName("select");

  for (i = 0; i < x.length; i++) {
  
    var objID = x[i].id;
    
    // If State DropDown Field
    //
    if(objID.indexOf('state_ddl') > 0) {
      
      //alert(hiddenByToggleAllSelects + " " + objID + " " + objID.indexOf('state_ddl'));
    
      if (hiddenByToggleAllSelects) {
        if (action == 'show')
          x[i].className = 'displayBlock';
        else {
          x[i].className = 'displayNone';
          hiddenByToggleAllSelects = 1;
        }
      }
        
    } else {
   
      if (action == 'show')
        x[i].className = 'displayBlock';
      else
        x[i].className = 'displayNone';
   
    }       
  }
}

function popUpWindow(URL,W,H) 
{
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + W + ',height=' + H + ',left=487.5,top=350');");
}

function popupCenter(winname, url, winwidth, winheight, scrollbars, toolbars){

  var top   = (screen.availHeight - winheight - 29) / 2;
  var left  = (screen.availWidth - winwidth - 10) / 2;

  var urlPrefix = "";
  var winurl    = url;

  if (toolbars == "1")
	tbars = 1;
  else
	tbars = 0;

  var winopt    = "toolbar=" + tbars + ",location=0,directories=0,status=0,menubar=0,scrollbars=" + scrollbars + ",copyhistory=0,resizable=0,width="+winwidth+",height="+winheight+",left="+left+",top="+top;
  //alert(winopt);
  newwin = window.open(winurl,winname,winopt);

}

function noSpaces(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) ||
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if (((" ").indexOf(keychar) > -1))
   return false;

else
   return true;
}

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}
return true
}


function toggleObjects(hideObj, showObj) {
 
  if (document.getElementById) {
    document.getElementById(hideObj).style.display = 'none';
    document.getElementById(showObj).style.display = 'block';
  }
}


/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: David Leppek :: https://www.azcode.com/Mod10

Basically, the alorithum takes each digit, from right to left and muliplies each second
digit by two. If the multiple is two-digits long (i.e.: 6 * 2 = 12) the two digits of
the multiple are then added together for a new number (1 + 2 = 3). You then add up the 
string of numbers, both unaltered and new values and get a total sum. This sum is then
divided by 10 and the remainder should be zero if it is a valid credit card. Hense the
name Mod 10 or Modulus 10. */

function Mod10(ccNumb) {  // v2.0

  var valid = "0123456789"  // Valid digits in a credit card number
  var len = ccNumb.length;  // The length of the submitted cc number
  var iCCN = parseInt(ccNumb);  // integer of ccNumb
  var sCCN = ccNumb.toString();  // string of ccNumb
  sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
  var iTotal = 0;  // integer total set at zero
  var bNum = true;  // by default assume it is a number
  var bResult = false;  // by default assume it is NOT a valid cc
  var temp;  // temp variable for parsing string
  var calc;  // used for calculation of each digit

  // Determine if the ccNumb is in fact all numbers
  for (var j=0; j<len; j++) {
    temp = "" + sCCN.substring(j, j+1);
    if (valid.indexOf(temp) == "-1"){bNum = false;}
  }

  // if it is NOT a number, you can either alert to the fact, or just pass a failure
  if(!bNum){
    /*alert("Not a Number");*/bResult = false;
  }

  // Determine if it is the proper length 
  if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
    bResult = false;
  } else {  // ccNumb is a number and the proper length - let's see if it is a valid card number
    if(len >= 15){  // 15 or 16 for Amex or V/MC
      for(var i=len;i>0;i--){  // LOOP throught the digits of the card
        calc = parseInt(iCCN) % 10;  // right most digit
        calc = parseInt(calc);  // assure it is an integer
        iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
        i--;  // decrement the count - move to the next digit in the card
        iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
        calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
        calc = calc *2;                                 // multiply the digit by two
        // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
        // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
        switch(calc) {
          case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
          case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
          case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
          case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
          case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
          default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
        }                                               
        iCCN = iCCN / 10;  // subtracts right most digit from ccNum
        iTotal += calc;  // running total of the card number as we loop
      }  // END OF LOOP
      if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
        bResult = true;  // This IS (or could be) a valid credit card number.
      } else {
        bResult = false;  // This could NOT be a valid credit card number
      }
    }
  }
  
  // change alert to on-page display or other indication as needed.
  if(bResult) {
    //alert("This IS a valid Credit Card Number!");
  }
  if(!bResult){
    //alert("This is NOT a valid Credit Card Number!");
  }
  return bResult; // Return the results
}

/* Counts the length of an object, trims if too long, returns num of chars left if available */
function textCounter(fieldToCount, fieldToDisplay, maxLength) {
  if (fieldToCount.value.length > maxLength) {
    fieldToCount.value = fieldToCount.value.substring(0, maxLength);
  } else {
    fieldToDisplay.value = maxLength - fieldToCount.value.length;
  }
}

function getRadioValue(formName, fieldName) {
  numButtons = eval('document.' + formName + '.' + fieldName + '.length')
  
  for (var i=0; i < numButtons; i++) {
    if (eval('document.' + formName + '.' + fieldName + '[i].checked')) {
      return rad_val = eval('document.' + formName + '.' + fieldName + '[i].value');
    }
  }
  return "";
}

function isChecked(formName, fieldName) {
  numButtons = eval('document.' + formName + '.' + fieldName + '.length')

  if (numButtons > 1) {
    for (var i=0; i < numButtons; i++) {
      if (eval('document.' + formName + '.' + fieldName + '[i].checked')) {
        return true;
      }
    }
  }
  else {
    if (eval('document.' + formName + '.' + fieldName + '.checked')) {
      return true;
    }
    else {
      return false;
    }
  }
}

function getDisplay(obj) {
 return document.getElementById(obj).style.display 
}

function showBlanket(type, msg, blanketURL, confirmURL) {
  if (type == 'alert') {
    t_loadurl(blanketURL + '&msg='+ msg,'BlanketContainer','')
  }
  else if (type == 'confirm') {
    t_loadurl(blanketURL + '&msg='+ msg + '&confirmURL=' + confirmURL,'BlanketContainer','')
  }
  else {
    t_loadurl(blanketURL,'BlanketContainer','')
  }
}
function hideBlanket(type) {
  document.getElementById('BlanketContainer').innerHTML='';
}


/*
v1.03 Copyright (c) 2006 Stuart Colville
http://muffinresearch.co.uk/archives/2006/04/29/getelementsbyclassname-deluxe-edition/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial 
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
IN THE SOFTWARE.
*/
  
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;    
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();                              
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';   
  var arrClass = strClass.split(delim);    
  for (var i = 0, j = objColl.length; i < j; i++) {                         
    var arrObjClass = objColl[i].className.split(' ');   
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if ((delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]); 
          break comparisonLoop;
        }
      }
    }
  }
  return arr; 
}


// Get Mouse Coordinates
function getwindow() {
  var d = document, v = window, w, h, l, t;
  if(typeof v.innerWidth === 'number') {
    w = v.innerWidth;
    h = v.innerHeight;
    l = v.pageXOffset;
    t = v.pageYOffset;
  } else if((v = d.documentElement) &&
      typeof v.clientWidth === 'number' &&
      v.clientWidth !== 0 || (v = d.body)) {
    w = v.clientWidth;
    h = v.clientHeight;
    l = v.scrollLeft;
    t = v.scrollTop;
  }
  return {w: w, h: h, l: l, t: t};
}


var moux, mouy;
function getmouse(e) {
  e = e || window.event || {};
  var w = getwindow(),
    minx = w.l,
    miny = w.t,
    maxx = w.w + w.l,
    maxy = w.h + w.t;
  if(typeof e.pageX === 'number') {
    moux = e.pageX;
    mouy = e.pageY;
  } else {
    moux = e.x + w.l;
    mouy = e.y + w.t;
  }
//  document.forms.f.elements.t.value =
   'mouse x =\t' + moux + '\nmouse y =\t' + mouy;
}

if( window.captureEvents ) { window.captureEvents( Event.MOUSEMOVE ); }
window.onscroll = getmouse;
window.onresize = getmouse;
window.document.onmousemove = getmouse;



function toggleHelperLayer(layerId) {
  getDetailDiv = document.getElementById('help_' + layerId);
  var getDetailDivClass = getDetailDiv.className;

  if (getDetailDivClass.match('helperNone')) {
    var findOpenDetail = getElementsByClassName('helperBlock', 'div');
    if (findOpenDetail.length > 0) {
      for (var i = 0, j = findOpenDetail.length; i < j; i++) {
        var getOpenDetailById = document.getElementById(findOpenDetail[i].getAttribute('id'));
        getOpenDetailById.className = getOpenDetailById.className.replace('helperBlock', 'helperNone');
      }
    }

    moux -= '281';
    getDetailDiv.style.top = mouy + 'px';
    getDetailDiv.style.left= moux + 'px';
    getDetailDiv.className = getDetailDivClass.replace('helperNone', 'helperBlock');
  } else {
    getDetailDiv.className = getDetailDivClass.replace('helperBlock', 'helperNone');
  }
}
