﻿// JScript File

function getCurrentYear(){
  var d = (new Date()).getYear()
  if( d < 1000 ) d = 2000+ d % 100;
  return d;
}

function DateAdd(ItemType, DateToWorkOn, ValueToBeAdded) {
    switch (ItemType) {
        //date portion         
        case 'd': //add days
            DateToWorkOn.setDate(DateToWorkOn.getDate() + ValueToBeAdded)
            break;
        case 'm': //add months
            DateToWorkOn.setMonth(DateToWorkOn.getMonth() + ValueToBeAdded)
            break;
        case 'y': //add years
            DateToWorkOn.setYear(DateToWorkOn.getFullYear() + ValueToBeAdded)
            break;
        //time portion         
        case 'h': //add days
            DateToWorkOn.setHours(DateToWorkOn.getHours() + ValueToBeAdded)
            break;
        case 'n': //add minutes
            DateToWorkOn.setMinutes(DateToWorkOn.getMinutes() + ValueToBeAdded)
            break;
        case 's': //add seconds
            DateToWorkOn.setSeconds(DateToWorkOn.getSeconds() + ValueToBeAdded)
            break;
    }
    return DateToWorkOn;
}

function contact_dialog() {
    alert("Please contact us at 1-800-679-2640 for a quote. ");
    return false;
}

function PopWin(name, Lnk, value_width, value_height){
		//var Lnk = 'pop_notice_attachments.aspx?UsefulItemId=' + IdValue
		var str = "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,left=100,top=50,"
		str = str + "resizable=yes,width=" + value_width + ",height=" + value_height;
		var dwin = window.open (Lnk, name, str);
		dwin.focus();
}

function isDate(year, month, day) {
    var checkDate = new Date(Date.parse(month + '/' + day + '/' + year));
         
    if ((checkDate.getDate() == day) && (checkDate.getMonth() + 1 == month) && (checkDate.getUTCFullYear() == year)){
        return true;
    }else{
        return false;
    }
}

// Class LicenseDate

function LicenseDate(licenseClass,licenseDate) {
  this.CurrentLicenseClass=licenseClass;
  this.CurrentLicenseDate=licenseDate;
}

function OldStyle() {
  var myDate=new Date();
  if ((this.CurrentLicenseClass >= "A" && this.CurrentLicenseClass <= "G") || (this.CurrentLicenseClass >= "AZ" && this.CurrentLicenseClass <= "FZ") || this.CurrentLicenseClass == "G2" || this.CurrentLicenseClass == "G1" ||
      this.CurrentLicenseClass == "M" || this.CurrentLicenseClass == "M2" || this.CurrentLicenseClass == "M1") {
    myDate.setFullYear(1994,3,1);
  } else {
    myDate.setFullYear(myDate.getFullYear()-10,myDate.getMonth(),myDate.getDay());
  }
  return this.CurrentLicenseDate < (myDate.getTime() - myDate.getTime() % (24 * 60 * 60 * 1000));
}
LicenseDate.prototype.OldStyle=OldStyle;

function ShowG1() {
  if (this.OldStyle() == false) {
    if ((this.CurrentLicenseClass >= "A" && this.CurrentLicenseClass <= "G") || (this.CurrentLicenseClass >= "AZ" && this.CurrentLicenseClass <= "FZ") || this.CurrentLicenseClass == "G2" || this.CurrentLicenseClass == "M" || this.CurrentLicenseClass == "M2" || this.CurrentLicenseClass == "1" || this.CurrentLicenseClass == "2" 
        || this.CurrentLicenseClass == "3" || this.CurrentLicenseClass == "4" || this.CurrentLicenseClass == "5" || this.CurrentLicenseClass == "6")
       return true;
    else
       return false;
  } else {
    return false;
  }
}
LicenseDate.prototype.ShowG1=ShowG1;

function ShowG2() {
  if (this.OldStyle() == false) {
    if ((this.CurrentLicenseClass >= "A" && this.CurrentLicenseClass <= "G") || (this.CurrentLicenseClass >= "AZ" && this.CurrentLicenseClass <= "FZ") || this.CurrentLicenseClass == "M")
       return true;
    else
       return false;
  } else {
    return false;
  }
}
LicenseDate.prototype.ShowG2=ShowG2;

function getXMLHttp() {  
  var xmlhttp=false;
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.
  try {
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (E) {
    xmlhttp = false;
   }
  }
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
  }
  if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
  }
  return xmlhttp;
}
function trim(s)
{
return s.replace(/^\s+|\s+$/g, "");
}

function toggleReadmore(infoID, areaID) {
    document.getElementById(infoID).style.display = 'none';
    document.getElementById(areaID).style.display = '';
}

function GetParentNode(node) {
    return node.parentNode;
}

function GetDisplay(node) {
    if (node == null) return true;
    if (typeof(node.style) != "undefined" && node.style.display == "none") return false;
    if (typeof (node.parentNode) == "undefined") return true;
    return GetDisplay(node.parentNode);
}

/* rpagedata manipulating functions */

function AcquireDetail(val, detailID) {
    if (document.getElementById(val).checked)
        document.getElementById(detailID).style.display = '';
    else
        document.getElementById(detailID).style.display = 'none';
}

