function Viewport() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		this.windowX = window.innerWidth;
		this.windowY = window.innerHeight;

	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		this.windowX = document.documentElement.clientWidth;
		this.windowY = document.documentElement.clientHeight;

	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		this.windowX = document.body.clientWidth;
		this.windowY = document.body.clientHeight;

	}

	//this.windowX = (document.documentElement && document.documentElement.clientWidth) || window.innerWidth || self.innerWidth || document.body.clientWidth;
	//this.windowY = (document.documentElement && document.documentElement.clientHeight) || window.innerHeight || self.innerHeight || document.body.clientHeight;

	this.scrollX = (document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft;
	this.scrollY = (document.documentElement && document.documentElement.scrollTop) || window.pageYOffset || self.pageYOffset || document.body.scrollTop;
	this.pageX = (document.documentElement && document.documentElement.scrollWidth) ? document.documentElement.scrollWidth : (document.body.scrollWidth > document.body.offsetWidth) ? document.body.scrollWidth : document.body.offsetWidth;
	this.pageY = (document.documentElement && document.documentElement.scrollHeight) ? document.documentElement.scrollHeight : (document.body.scrollHeight > document.body.offsetHeight) ? document.body.scrollHeight : document.body.offsetHeight;
}


function get_backgroundimage(el_id) {
	el = document.getElementById(el_id);

	if (document.defaultView != null) {
		var bg = document.defaultView.getComputedStyle(el,null).getPropertyValue('background-image');

	} else {
		var bg = el.currentStyle['backgroundImage'];

	}

	return bg;

}








function text_field_required(field) {
	$(field).val("required");
	$(field).css("color", "#8a1518");
	$(field).css("font-style", "italic");
}

function select_field_required(field) {
	$(field).append($("<option selected=\"selected\"></option>").attr("value", "required").text("required"));
	$(field).css("color", "#8a1518");
	$(field).css("font-style", "italic");
}

helper_values = [
	"required",
	"confirm email address",
	"unit / box number",
	"attention / additional address",
	"ie 2999.99",
	"ie 5.9",
	"City",
	"First and last name",
];


function text_field_focus(field) {
	if (($.inArray($(field).val(), helper_values)) > -1) {
		helper_value = $(field).val();

		if (helper_value !== "required") {
			$(field).attr("rel", helper_value);
		}

		$(field).val("");
		$(field).css("color", "#000000");
		$(field).css("font-style", "normal");
	}
}

function text_field_blur(field) {
	value = $(field).val();

	if (value.length==0) {
		helper_value = $(field).attr("rel");

		if (helper_value) {
			$(field).val(helper_value);
			$(field).css("color", "#999999");
			$(field).css("font-style", "italic");
		}
	}
}

function select_field_focus(field) {
	$(field).children().each(function() {
		if (($.inArray($(this).val(), helper_values)) > -1) {
			$(this).remove();

			$(field).css("color", "#000000");
			$(field).css("font-style", "normal");

		}

	});

}

function form_required_clear(form) {
	$(form + " .text_field").each(function() {
		if ($(this).val()=="required") {
			$(this).val("");
		}

	});

	$(form + " .msg").html("");

	$(form + " select").each(function() {
		$(this).children().each(function() {
			if ($(this).val()=="required") {
				$(this).remove();
			}

		});

	});

}

function form_helper_clear(form) {
	$(form + " .text_field").each(function() {
		if (($.inArray($(this).val(), helper_values)) > -1) {
			$(this).val("");
		}

	});
}


function check_email(email) {
	// from: http://www.white-hat-web-design.co.uk/articles/js-validation.php

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	return(reg.test(email));
}


function check_date(date) {
	// from: http://snipplr.com/view/7875/javascript-validate-date/

    // make sure it is in the expected format
    if (date.search(/^\d{1,2}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{4}/g) != 0)
        return false;

    // remove other separators that are not valid with the Date class
    date = date.replace(/[\-|\.|_]/g, "/");

    // convert it into a date instance
    var dt = new Date(Date.parse(date));

    // check the components of the date
    // since Date instance automatically rolls over each component
    var arrDateParts = date.split("/");
    return (
        dt.getMonth() == arrDateParts[0]-1 &&
        dt.getDate() == arrDateParts[1] &&
        dt.getFullYear() == arrDateParts[2]
    );
}




function Mod10(ccNumb) {  // v2.0
	ccNumb = ccNumb.split("-").join("");

	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
		}
	  }
	}

  return bResult; // Return the results
}
