function togleProd( prodIdx, show ) {

	//  Hide all product layers, before showing the need one.
	for( var i = 0; i < prods.length; i++ )
	document.getElementById( "product_" + prods[i] ).style.display = "none";

	//  Show the new one.
	if( prodIdx && show ) document.getElementById( "product_" + prodIdx ).style.display = "block";
}

function setBookmark( formName, mapIdx, prodIdx, notes ) {
	document.forms[ formName ].elements[ 'bookmark[map_idx]' ].value = mapIdx;
	document.forms[ formName ].elements[ 'bookmark[prod_idx]' ].value = prodIdx;
	document.forms[ formName ].elements[ 'bookmark[notes]' ].value = document.getElementById( 'bookmark_notes_' + mapIdx ).value
	document.forms[ formName ].submit();
}

function togleBookmarkInfo( bmIdx, state ) {
	var b = document.getElementById( "book_prod_" + bmIdx );
	if( state ) b.style.display = "block";
	if( !state ) b.style.display = "none";
}

function togleLarge( prodIdx ) {
	var i = document.getElementById( "lg_img_" + prodIdx );
	if( i.style.display == "none" || i.style.display == "" ) i.style.display = "block";
	else i.style.display = "none";
}

//  GIFT MESSAGE CHARACTER COUNTING, ETC...
function count_sticky_chars( id, form_name, field, total ) {

	//  Setup vars.
	var element = document.forms[ form_name + "_" + id ].elements[ field ];
	var cur_length = element.value.length;

	//  Get the length.
	card_msg_chars = total - cur_length;

	//  Put in the preview text.
	if( cur_length > 0 ) document.getElementById( 'chars_left_' + id ).innerHTML = card_msg_chars;

	//  Address messages that are too long.
	if( cur_length > total ) {
		element.value = element.value.substr( 0, total );
		document.getElementById( 'chars_left_' + id ).innerHTML = "0";
	}
}
