var add_to_cart = new Image();
add_to_cart.src = "images/buttons/add_to_cart.gif";
var add_to_cart_active = new Image();
add_to_cart_active.src = "images/buttons/add_to_cart_active.gif";
var add_to_cart_pressed = new Image();
add_to_cart_pressed.src = "images/buttons/add_to_cart_pressed.gif";
var register = new Image();
register.src = "images/buttons/register.gif";
var register_active = new Image();
register_active.src = "images/buttons/register_active.gif";
var register_pressed = new Image();
register_pressed.src = "images/buttons/register_pressed.gif";
var sign_in = new Image();
sign_in.src = "images/buttons/sign_in.gif";
var sign_in_active = new Image();
sign_in_active.src = "images/buttons/sign_in_active.gif";
var sign_in_pressed = new Image();
sign_in_pressed.src = "images/buttons/sign_in_pressed.gif";

/***************
 * rolloverForm
 *
 * this is to highlight the buttons used inside a form. the img attribute
 * of the input field doesn't get added to the document image array, so
 * we have to get the element and set its src attribute.
 */
function rolloverForm(buttonName, newButton) {
	var button=document.getElementById(buttonName);
	button.setAttribute("src", newButton.src);
}

/****************
 * swapButton
 *
 * the simple version of rollover effect. just swapping one image for anther
 */
function swapButton(buttonName, newButton) {
	document.images[buttonName].src = newButton.src;
}

function highlightButton(buttonName, buttonType) {
	document.images[buttonName].src="images/buttons/"+buttonType+"_active.gif";
}

function unhighlightButton(buttonName, buttonType) {
	document.images[buttonName].src="images/buttons/"+buttonType+".gif";
}

function pressButton(buttonName, buttonType) {
	document.images[buttonName].src="images/buttons/"+buttonType+"_pressed.gif";
}

function popWin(contentHtml, width, height) {
	window.open(contentHtml, "", "width="+width+"px, height="+height+"px, resizable");
}

function emailFriend() {
	window.open("emailFriend.html", "", "width=360px, height=532px, noresizable");
}

function createCookie(name,value,hours) {
	if (hours) {
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function createCookie(name,value,hours) {
	if (hours) {         
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	    createCookie(name,"",-1);
}

function loginCookies() {

	document.cookie = "loginType=login; path=/";	

}

function retailCookies() {


	document.cookie = "loginType=register; path=/";	
	document.cookie = "custType=retail; path=/";

}

function wholesaleCookies() {

	var rsn = document.wholesale.resalenum.value;

	document.cookie = "loginType=register; path=/";	
	document.cookie = "custType=wholesale; path=/";
	document.cookie = "rsn=" + rsn + "; path=/";
}

function validateRSN() {

	var rsn = document.wholesale.resalenum.value;

	if ((rsn == "") || (rsn == " ")) {
		alert("You must enter a Resale Number");
		return false;
	}

}
