window.onload = function(){
	if(document.getElementsByTagName('img')){
		var allImages = document.getElementsByTagName('img');
		for(var j=0;j<allImages.length;j++){
			if(!allImages[j].alt){
				allImages[j].setAttribute('alt','fleecebaby.com');
			}
			//alert(allImages[j].alt);
		}
	}
	//alert(document.getElementById('global-nav').getElementsByTagName('li')[0].className);
	if(document.getElementById('shop')){
		var products = new Array();
		for(var x = 0; x < document.getElementById('shop').children.length; x++){
			if(document.getElementById("product-"+x)){
				products.push(document.getElementById("product-"+x));
				var thumbsContainer = products[x].children[2].firstChild.children[1];
				var thumblinks = thumbsContainer.getElementsByTagName('a');
				var count = thumblinks.length;
				for(var i=0;i<count;i++){
					thumblinks[i].setAttribute('onclick','slideshow(this); return false');
				}
			}
		}
	}
}
function cookieJar(action,reaction){
	//alert("for every" + action);
}

function slideshow(el){
	var contentDivElements = document.getElementById('shop').getElementsByTagName('div');
	for(var x = 0; x < contentDivElements.length; x++){
		if(contentDivElements[x].className == "main-image"){
			contentDivElements[x].getElementsByTagName('img')[0].setAttribute('src',el);
		}
		//alert(document.getElementById('shop').children[2]);
	}
	//var lgImageContainer = document.getElementById('main-image');
	//var lgImage = lgImageContainer.getElementsByTagName('img')[0];
	//lgImage.setAttribute('src',el);
}

function validateForm(){
		var checkoutForm = document.getElementById('checkoutpage');
		var txtField =  checkoutForm.getElementsByTagName('input');
		var x;
		for(var i=0; i<txtField.length;i++){
			if(txtField[i].value != ""){
				document.forms[1].submit();	
			}
			if(txtField[i].value == ""){
				x =i;
				window.location = "https://www.fleecebaby.com/checkout?error=2";
			}
		}
		
		if(x>0){
			return false;
			window.location = "https://wwww.fleecebaby.com/checkout?error=2";
		}
}

function submitForm(el){
	//alert(el.value);
	document.cookie ="shipping="+el.value;
}

function resetTextBox(el){
	el.value = '';	
}

function redirect(str){
	var url = "http://www.fleecebaby.com/";
	url = url + str;
	document.cookie ="error=shipping";
	window.location = url;
}

function killCookie(cookieName){
	document.cookie =cookieName+"=";	
}