// JavaScript Document


function showImage(image) {
	images = document.getElementsByClassName('image_section');
	for(i=0; i<images.length; i++) {
		images[i].style.display = 'none';
	}

	image.style.display = '';
}

function updateSizes() {
	var value = $('color').options[$('color').selectedIndex].value;
	sizeSelects = document.getElementsByClassName('sizeSelect', 'mainInner');
	
	for(i=0; i<sizeSelects.length; i++) {
		sizeSelects[i].style.display = 'none';
	}
	
	$('size'+value).style.display='';
		
	$('size').value = $('size'+value).options[$('size'+value).selectedIndex].value;		
}

function updateSizeInput(element) {
	$('size').value = element.options[element.selectedIndex].value;		
}

function removeCartItem(id) {
	if(id) {
		$('cartItem').value = id;
		$('cartAction').value = 'REMOVE';
		$('cartBtn').click();
	}
}

function updateCartItem(id) {
	if(id) {
		$('cartItem').value = id;
		$('cartAction').value = 'UPDATE';
		$('cartBtn').click();
	}
}

function iePNGFix() {
	var version = parseFloat(navigator.appVersion.split('MSIE')[1]);
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
		document.getElementsByClassName('ie-fix-opacity').each(function(poElement){
			var cBGImg = poElement.currentStyle.backgroundImage;
			var cImage = cBGImg.substring(cBGImg.indexOf('"') + 1, cBGImg.lastIndexOf('"'));
			poElement.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + cImage + "',sizingMethod='scale')";
			poElement.style.backgroundImage = "none";
		});
	}
}

function createBookmark() {
	/* Old variables
	title = "One Steal Every Day"; 
 	url = "http://www.dealadaygolf.com";
	*/
	
	// new variables
	// this is what we changed
	title = "Apple Deal of the Day";
	url = "http://www.appledod.com";

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
 }
}

function updateNewsletterEmail(isfocus) {
	var email = $('newsletter_email');
	if(isfocus && email.value == 'Email Address') {
		email.value = '';
		email.style.color = '#000';
	}
	
	else if(!isfocus && email.value == '') {
		email.value = 'Email Address';
		email.style.color = '#999';
	}
}

function toggleBilling(condition) {
if(condition)
	$('billingInfo').style.display='none';
else
	$('billingInfo').style.display='';
}

function setCheckoutMethod() {
	if($('guest').checked) {
		window.location='checkout.php?payment=cc&action=guest';
	} else {
		window.location='newaccount.php';
	}
}