//watermarks for text boxes
function setWatermark(obj, val) {
	if(obj.value == "" && val != "") {
		obj.value = val;
		obj.style.color = "#AAAAAA";
	}
}

function clearWatermark(obj, val) {
	if(obj.value == val) {
		obj.value = "";
		obj.style.color = "#000000";
	}
}

function updatePopupBg() {

}

function updatePopupBg(evt) {
	var TheEventObject = evt || event;

	var popupBg = document.getElementById("ctl00_ContentPlaceHolder1_PopUpBackground");
	var x = 0;
	var y = 0;
			
	if(window.addEventListener) {
		x = window.pageXOffset;
		y = window.pageYOffset;
	}
	else if(document.addEventListener) {
		x = window.pageXOffset;
		y = window.pageYOffset;
    }
	else if(document.all && document.compatMode && document.compatMode == "CSS1Compat") {
		x = document.documentElement.scrollLeft ;
		y = document.documentElement.scrollTop ;
    };
    		
	popupBg.style.top = y + "px"; //document.body.clientHeight - popupBg.style.pixelHeight + y;
	popupBg.style.left = x + "px"; //x;
	
	//alert("popupBg.top:" + popupBg.style.top + "; popupBg.left:" + popupBg.style.left);
}


//fixes for the div bg
if(window.addEventListener) // Firefox 1+, Opera 9, Safari 3+, etc.
{
	window.addEventListener("scroll", updatePopupBg, false);
}
else if(document.addEventListener) // Opera 7, Opera 8
{
	document.addEventListener("scroll", updatePopupBg, false);
}
else if("onscroll" in self) // MSIE 6, 7 and MSIE 8
{
	self.onscroll = updatePopupBg;
};


function preloadProductImages() {
    var imgArray = new Array();
    imgArray[0] = "/images/WhoopiePie_WeCare.png";
    imgArray[1] = "/images/WhoopiePie_Wecare_Glow.png";
    imgArray[2] = "/images/WhoopiePie_Wecare_Fade.png";
    imgArray[3] = "/images/JellyBelly_WeCare.png";
    imgArray[4] = "/images/JellyBelly_WeCare_Glow.png";
    imgArray[5] = "/images/JellyBelly_WeCare_Fade.png";

    var imgLoad = new Image();
    for (var i = 0; i < 6; i++) {
        imgLoad.src = imgArray[i];
    }
}

function fadeIn(image) {
    //don't fade if the image is selected
    if (image.src.substring(image.src.length, image.src.length - 8) != "Glow.png") {
        if (image.id == "product_wp")
            image.src = "/images/WhoopiePie_Wecare.png";
        else if (image.id == "product_jb")
            image.src = "/images/JellyBelly_WeCare.png";
    }
}

function fadeOut(image) {
        //don't fade if the image is selected
    if (image.src.substring(image.src.length, image.src.length - 8) != "Glow.png") {
        if (image.id == "product_wp")
            image.src = "/images/WhoopiePie_WeCare_Fade.png";
        else if (image.id == "product_jb")
            image.src = "/images/JellyBelly_WeCare_Fade.png";
    }
}

function select(image) {
    if (image.id == "product_wp") {
        image.src = "/images/WhoopiePie_WeCare_Glow.png";
        document.getElementById("product_jb").src = "/images/JellyBelly_WeCare_Fade.png";
        document.getElementById("ctl00_AdditionalContent_SelectedProduct").value = "Whoopie Pies";
    }
    else if(image.id == "product_jb") {
        image.src = "/images/JellyBelly_WeCare_Glow.png";
        document.getElementById("product_wp").src = "/images/WhoopiePie_WeCare_Fade.png";
        document.getElementById("ctl00_AdditionalContent_SelectedProduct").value = "Jelly Beans";
    }
}