$(document).ready(function(){
						   
/* image width functions */

$(".jTip img").each(function(){
if ($(this).attr("width") >= 242 ) {
$(this).css("border","none");
$(this).parent("a").css("border", "1px solid #727171");
$(this).parent("a").css("border-bottom", "none");
}
});

/* Category Type Page Functions */
	split_current_category_ids_path = current_category_ids_path.split(",");
	current_category_ids_path_1 = split_current_category_ids_path[0];
	current_category_ids_path_2 = split_current_category_ids_path[1];
	current_category_ids_path_3 = split_current_category_ids_path[2];
	
	if (current_category_ids_path_1 > 0 && current_category_ids_path_2 == 0 && current_category_ids_path_3 == 0) {
	
		$(".category_banner h1").each(function(){
			the_new_cat_url = $(this).parent(".category_banner").parent(".category_description_wrapper").attr("id");
			the_new_cat_url = the_new_cat_url.split("_");
			the_new_cat_url = the_new_cat_url[1];
			the_new_cat_url = "id_link_" + the_new_cat_url;
			the_new_cat_url = $('a[@id$="' + the_new_cat_url + '"]').attr("href");
			h1_content = $(this).html();
			h1_content = "<a href='" + the_new_cat_url + "'>" + h1_content + "</a>";
			$(this).html(h1_content);
		});
		
		$(".category_banner .category_img").each(function(){
			the_new_cat_img_url = $(this).parent(".category_banner").parent(".category_description_wrapper").attr("id");
			the_new_cat_img_url = the_new_cat_url.split("_");
			the_new_cat_img_url = the_new_cat_url[1];
			the_new_cat_img_url = "id_link_" + the_new_cat_url;
			the_new_cat_img_url = $('a[@id$="' + the_new_cat_url + '"]').attr("href");
			starting_tag = "<a href='" + the_new_cat_url + "'>";
			$(this).wrap(starting_tag, "</a>");
			
		});
		
	} //if
/* End Category Type Page Functions */

/* Detailed Product Page Functions */
/* For Nav Tabs */

var total_tab_width = 0;
var num_of_tabs = 0;
var navtab_last_width = 0;
$(".navbar tr:eq(0) a").each(function(){
that_tab_width = $(this).width();
background_move = that_tab_width;
background_move = background_move + 30;
background_move = background_move + "px 1px";
$(this).css("background-position",background_move);
$(this).parent("td").attr("width",that_tab_width);



total_tab_width = total_tab_width + that_tab_width;
num_of_tabs++;
navtab_last_width = $(this).width();
} //function
); //each

// force last tab a to be correct width 
//$(".navtab_last a").width(navtab_last_width);

last_navtab_link = $(".navbar tr:eq(0) a:last");
$(last_navtab_link).width(navtab_last_width);

last_nanvtab_td = $(".navbar tr:eq(0) td:last");

// remove float: left from navbar a's 
$(".navbar tr:eq(0) a").css("float","none");
var the_tab_content_width;
if (typeof(new_bike_template) != 'undefined') {
	the_tab_content_width = 755;
} else {
	the_tab_content_width = 474;
}
var nav_tab_adjuster_width = the_tab_content_width - total_tab_width + navtab_last_width - (num_of_tabs * 40);
var nav_tab_adjuster_width_px = 5 + nav_tab_adjuster_width +"px";
/*
$(".navtab_last").css("width",nav_tab_adjuster_width_px);
$(".navtab_last").attr("width",nav_tab_adjuster_width + 2);
$(".navtab_last a").css("width",nav_tab_adjuster_width_px);
*/
$(last_nanvtab_td).css("width",nav_tab_adjuster_width_px);
$(last_nanvtab_td).attr("width",nav_tab_adjuster_width + 2);
$(last_navtab_link).css("width",nav_tab_adjuster_width_px);


$(".navtab_notselected").parent("td").css("background-image","url(images_templ/bg_tab_nav_s_l.gif)");

$(".navbar tr:eq(0) td a").click(function(){
$(".navbar tr:eq(0) td a").css("background-image","url(images_templ/bg_tab_nav_s_r.gif)");
$(".navbar tr:eq(0) td").css("background-image","url(images_templ/bg_tab_nav_s_l.gif)");
$(".navbar tr:eq(0) td a").css("color","#333");

$(this).parent("td").css("background-image","url(images_templ/bg_tab_nav_l.gif)");
$(this).css("background-image","url(images_templ/bg_tab_nav_r.gif)");
$(".navtab_selected").css("color","#fff");
} // function
); // click




/* end for nav tabs */

/*
 * jqBookmark - a jquery Bookmark script
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file license.txt.
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to calisza@gmail.com so we can send you a copy immediately.
 *
 */
$(document).ready(function(){
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){
			$("a.jqbookmark").attr("rel","sidebar");
		} 
	}

	$("a.jqbookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;
		
		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) { // Opera 7+
			return false; // do nothing
		} else { 
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}
	
	});
});

// for pricealert dialog

    $("#price_alert_dialog").dialog({       
        modal: true,
        title: "Request Price Alerts",
        autoOpen: false,
        height: "200px",
        width: "425px",
        overlay: {
            opacity: 0.65,
            background: "black"
        },
		position: ["center",100] 
		});

$("#price_alert").click(function(){
$("#price_alert_dialog").dialog('open');
    });
$("#price_alert_dialog").css("display","block");

// ajax form

// validate price alert form

    //validation implementation
    $("#dialog_newsletter_signup").validate({
        rules: {
            form_email: {
                required: true,
                email: true
            }
        },
        messages: {
            form_email: {
                required: "Please enter your email address"
            }
        }
    });



$("#submit_price_alert").click(function(){
valid_price_alert_form = $("#dialog_newsletter_signup").validate().form();
if (valid_price_alert_form == true) {

	/////////////////////////////////
	
	submit_success_callbacks = function(){
		$("#price_alert_dialog .dialog_message").hide();
		$("#price_alert_dialog .dialog_message").html("<span id='success_message'><strong>Your email address has been submitted.</strong><br>Price Alert notifications will be sent soon.</span><br><br><div><button id='close_price_alert'>Close</div>");
		$("#price_alert_dialog .dialog_message").fadeIn("slow");
		
		// for close button
		$("#close_price_alert").click(function(){
			$("#price_alert_dialog").dialog('close');
		}); // click
	} // function
	var options = {
		// target element(s) to be updated with server response 
		// beforeSubmit: pre_submit,
		success: submit_success_callbacks // post-submit callback 
	};
	
	// bind form using 'ajaxForm' 
	$('#dialog_newsletter_signup').ajaxSubmit(options);
	return false;
	////////////////////////////////

} // if
}); // click


// end price alert



// for price match

$("#price_match_dialog").dialog({       
        modal: true,
        title: "Request Price Match",
        autoOpen: false,
        height: "500px",
        width: "665px",
        overlay: {
            opacity: 0.65,
            background: "black"
        },
		position: ["center",100] 
		});

$("#price_match").click(function(){
$("#price_match_dialog").dialog('open');
    });
$("#price_match_dialog").css("display","block");

// ajax form

// validate price match form

 //custom validation rule - phone
 
jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}, "Please specify a valid phone number");


// custom validation rule - phoneINT

jQuery.validator.addMethod("phoneINT", function(phone_number, element) {
    phone_number = phone_number.replace(/[\(\)\.\-\ ]/g, '');
	if ( phone_number.length > 9 && phone_number.length < 30 && isNaN(phone_number) == false && isNaN(parseInt(phone_number)) == false ) {
	return true;
	} else {
	return false;
	}
	
}, "Please specify a valid phone number");

//custom validation rule - enter valid url

jQuery.validator.addMethod("url2", function(the_url2, element) {
	return the_url2.match(/^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|biz|info|COM|ORG|NET|MIL|EDU|BIZ|INFO)$/);
}, "Please specify a valid website");


//custom validation rule - choose something from a select box
    $.validator.addMethod("select_something",
    function(value, element) {
        if (value == "select") {
            return false;
        }
        else if (value != "select") {
            return true;
			
        } // if
    },
    "Please make a selection");

    //validation implementation
    $("#price_match_form").validate({
        rules: {
            email_pm: {
                required: true,
                email: true
            },
			 name_pm: {
                required: true
            },
			product_description_pm: {
                required: true
            },
			retail_price_pm: {
                required: true
            },
			sale_price_pm: {
                required: true
            },
			quantity_pm: {
                required: true,
                number: true
            },
			product_url_pm: {
                required: true,
                url2: true
            },
			phone_pm: {
                required: true,
				phoneUS: true
            }
        },
        messages: {
            email_pm: {
                required: "Please enter your email address"
            }
        }
    });



$("#submit_price_match").click(function(){
valid_price_match_form = $("#price_match_form").validate().form();
if (valid_price_match_form == true) {
$("#submit_price_match").attr("disabled","disabled");
	/////////////////////////////////
	
	submit_success_callbacks = function(){
		$("#price_match_dialog .dialog_message").hide();
		$("#price_match_dialog .dialog_message").html("<span id='success_message'>Thank you for your interest in our Price Match Service.<br>You have been emailed the details of this request and one of our Gas Bike consultants will contact you Monday - Friday  9:30am-5:30pm PST.</span><br><br><div><button id='close_price_match'>Close</div>");
		$("#price_match_dialog .dialog_message").fadeIn("slow");
		
		// for close button
		$("#close_price_match").click(function(){
			$("#price_match_dialog").dialog('close');
		}); // click
	} // function
	var options = {
		// target element(s) to be updated with server response 
		// beforeSubmit: pre_submit,
		success: submit_success_callbacks // post-submit callback 
	};
	
	// bind form using 'ajaxForm' 
	$('#price_match_form').ajaxSubmit(options);
	return false;
	////////////////////////////////

} // if
}); // click

$("#price_match_form input").click(function(){
	$("#referral").attr("value","sign waiver");
	$("#prd_name_fpm").attr("value",prd_name_fpm);
}
)
// end for price match

// for contact form

 $("#contact_form").validate({
        rules: {
            full_name_conact: {
                required: true
            },
			 email_contact: {
                required: true,
				email: true
            },
			cell_phone_contact: {
                required: true,
                phoneINT: true
            },
			home_phone_contact: {
				required: true,
                phoneINT: true
            },
			email_regarding_contact: {
				select_something: true
            },
			comments_contact: {
                required: true
            }
        },
        messages: {
            email_contact: {
                required: "Please enter your email address"
            }
        }
    });
 
 // for contact form

 $("#wholesale_inquiry_form").validate({
        rules: {
            first_name_wholesale: {
                required: true
            },
			 last_name_wholesale: {
                required: true
            },
			company_name_wholesale: {
                required: true
            },
			phone_number_wholesale: {
				required: true,
                phoneINT: true
            },
			email_address_wholesale: {
				required: true,
                email: true
            },
			city_wholesale: {
                required: true
            },
			state_wholesale: {
                required: true
            },
			website_wholesale: {
                required: true,
				url2: true
            },
			business_type_wholesale: {
				select_something: true
            },
			product_interests_wholesale: {
				select_something: true
            },
			quantities_wholesale: {
				select_something: true
			},
			comments_wholesale: {
                required: true
            },
			carb_reg_wholesale: {
                required: true
            }
        },
        messages: {
            email_contact: {
                required: "Please enter your email address"
            }
        }
    });
	
	$("#affiliate_form").validate({
        rules: {
            first_name_affiliate: {
                required: true
            },
			last_name_affiliate: {
                required: true
            },
			address_affiliate: {
                required: true
            },
			city_affiliate: {
                required: true
            },
			state_affiliate: {
                required: true
            },
			zip_affiliate: {
                required: true
            },
			country_affiliate: {
                required: true
            },
			main_website_topic_affiliate: {
                required: true
            },
			describe_website_affiliate: {
                required: true
            },
			eighteen_affiliate: {
                required: true
            },
			payment_min_affiliate: {
                required: true
            },
			payment_interval_affiliate: {
                required: true
            },
			accept_terms_affiliate: {
                required: true
            },
			phone_affiliate: {
                required: true
            },
			no_ca_sales_affiliate: {
				required: true
			},
			email_affiliate: {
                required: true,
				email: true
            },
			verify_email_affiliate: {
                required: true,
				email: true,
				equalTo: "#email_affiliate"
            
            }
        }
    });
 
	$("#contact_form input").click(function(){
	$("#referral").attr("value","sign waiver");
	test_referral = $("#referral").attr("value");
}
)

// for custom product

$("#custom_price_maker").change(function(){
var custom_product_price = $("#custom_price_maker").attr("value");
var custom_product_value = "Price: $<price>" + custom_product_price + "</price>";
var custom_product_html = "Price : " + custom_product_price;
$("#custom_price_taker").attr("value",custom_product_value);
$("#custom_price_taker").html(custom_product_html);
recalculate_product_price_total(this.form);
})

$("#custom_add_to_cart").click(function(){
if (typeof(f_add2cart_form_alias1) != 'undefined') { f_add2cart_form_alias1('64', '0', false, 'There is a missing required Option. Please select the Option.'); } else { f_add2cart_form('64'); } return false;
})

// hide custom product on searchbox and sitemap

$(".select_category option[value='8,0,0']").hide();
$(".select_category option[value='8,30,0']").hide();

$(".sitemap_categorytype .categorytype_link[alt='Custom Product']").parent("p").hide();
$(".sitemap_category .category_link[alt='Custom Product']").parent("p").hide();
$(".listitem_sitemap_products .product_link[alt='Custom Product']").parent("li").hide();

// sitemap functions - change order of ct's

function getAllBetween_bicycle_motors() {

	var firstElement = $("a[title='Bicycle Motors']").parent(".sitemap_categorytype");
	var lastElement = $("a[title='Motorized Bicycle Articles']").parent(".sitemap_categorytype");
	var lastElementClass = $(lastElement).attr("class");
    var collection = new Array(); // Collection of Elements
    collection.push(firstElement); // Add First Element to Collection
	$("#new_sitemap_holder").append("<div id='bicycle_motors_holder'></div>");
    $(firstElement).nextAll().each(function(){ // Traverse all siblings
        var siblingID  = $(this).attr("class"); // Get Sibling ID
        //console.log('siblingID: ' + siblingID + '  lastElementClass:' + lastElementClass);
        if (siblingID != lastElementClass) { // If Sib is not LastElement
				collection.push($(this)); 
				$(this).appendTo("#bicycle_motors_holder");
				// Add Sibling to Collection
        } else { // Else, if Sib is LastElement
                return false; // Break Loop
        }
    });         
   $("#bicycle_motors_holder").prepend(firstElement);
}

function getAllBetween_bike_motor_parts() {

	var firstElement = $("a[title='Bike Motor Parts']").parent(".sitemap_categorytype");
	var lastElement = $("a[title='Motorized Bicycle Articles']").parent(".sitemap_categorytype");
	var lastElementClass = $(lastElement).attr("class");
    var collection = new Array(); // Collection of Elements
    collection.push(firstElement); // Add First Element to Collection
	$("#new_sitemap_holder").append("<div id='bike_motor_parts_holder'></div>");
    $(firstElement).nextAll().each(function(){ // Traverse all siblings
        var siblingID  = $(this).attr("class"); // Get Sibling ID
        //console.log('siblingID: ' + siblingID + '  lastElementClass:' + lastElementClass);
        if (siblingID != lastElementClass) { // If Sib is not LastElement
				collection.push($(this)); 
				$(this).appendTo("#bike_motor_parts_holder");
				// Add Sibling to Collection
        } else { // Else, if Sib is LastElement
                return false; // Break Loop
        }
    });         
   $("#bike_motor_parts_holder").prepend(firstElement);
}

function getAllBetween_bicycle_motor_service() {

	var firstElement = $("a[title='Bicycle Motor Service']").parent(".sitemap_categorytype");
	var lastElement = (".sitemap_custompages");
	var lastElementClass = $(lastElement).attr("class");
    var collection = new Array(); // Collection of Elements
    collection.push(firstElement); // Add First Element to Collection
	$("#new_sitemap_holder").append("<div id='bicycle_motor_service_holder'></div>");
    $(firstElement).nextAll().each(function(){ // Traverse all siblings
        var siblingID  = $(this).attr("class"); // Get Sibling ID
        //console.log('siblingID: ' + siblingID + '  lastElementClass:' + lastElementClass);
        if (siblingID != lastElementClass) { // If Sib is not LastElement
				collection.push($(this)); 
				$(this).appendTo("#bicycle_motor_service_holder");
				// Add Sibling to Collection
        } else { // Else, if Sib is LastElement
                return false; // Break Loop
        }
    });         
   $("#bicycle_motor_service_holder").prepend(firstElement);
}
// move bikes
function getAllBetween_bicycle_motorized_bicycles() {

	var firstElement = $("a[title='Motorized Bicycles (DIY)']").parent(".sitemap_categorytype");
	var lastElement = $("a[title='Bicycle Motor Support']").parent(".sitemap_categorytype");
	var lastElementClass = $(lastElement).attr("class");
    var collection = new Array(); // Collection of Elements
    collection.push(firstElement); // Add First Element to Collection
	$("#new_sitemap_holder").append("<div id='motorized_bicycles_holder'></div>");
    $(firstElement).nextAll().each(function(){ // Traverse all siblings
        var siblingID  = $(this).attr("class"); // Get Sibling ID
        //console.log('siblingID: ' + siblingID + '  lastElementClass:' + lastElementClass);
        if (siblingID != lastElementClass) { // If Sib is not LastElement
				collection.push($(this)); 
				$(this).appendTo("#motorized_bicycles_holder");
				// Add Sibling to Collection
        } else { // Else, if Sib is LastElement
                return false; // Break Loop
        }
    });         
   $("#motorized_bicycles_holder").prepend(firstElement);
}

function removeAllBetween_wholesale_inquiries() {

	var firstElement = $("a[title='Wholesale Inquires']").parent(".sitemap_categorytype");
	var lastElement = $("a[title='Photo Galleries']").parent(".sitemap_categorytype");
	var lastElementClass = $(lastElement).attr("class");
    var collection = new Array(); // Collection of Elements
    collection.push(firstElement); // Add First Element to Collection
    $(firstElement).nextAll().each(function(){ // Traverse all siblings
        var siblingID  = $(this).attr("class"); // Get Sibling ID
        //console.log('siblingID: ' + siblingID + '  lastElementClass:' + lastElementClass);
        if (siblingID != lastElementClass) { // If Sib is not LastElement
				collection.push($(this)); 
				$(this).hide();
				$("a[title='Wholesale Inquires']").parent(".sitemap_categorytype").hide();
				// Add Sibling to Collection
        } else { // Else, if Sib is LastElement
                return false; // Break Loop
        }
    });         
}

function removeAllBetween_photo_galleries() {

	var firstElement = $("a[title='Photo Galleries']").parent(".sitemap_categorytype");
	var lastElement = $("a[title='Promotions']").parent(".sitemap_categorytype");
	var lastElementClass = $(lastElement).attr("class");
    var collection = new Array(); // Collection of Elements
    collection.push(firstElement); // Add First Element to Collection
    $(firstElement).nextAll().each(function(){ // Traverse all siblings
        var siblingID  = $(this).attr("class"); // Get Sibling ID
        //console.log('siblingID: ' + siblingID + '  lastElementClass:' + lastElementClass);
        if (siblingID != lastElementClass) { // If Sib is not LastElement
				collection.push($(this)); 
				$(this).hide();
				$("a[title='Photo Galleries']").parent(".sitemap_categorytype").hide();
				// Add Sibling to Collection
        } else { // Else, if Sib is LastElement
                return false; // Break Loop
        }
    });         
}

function removeAllBetween_company() {

	var firstElement = $("a[title='Company']").parent(".sitemap_categorytype");
	var lastElement = $("a[title='Motorized Bicycle Articles']").parent(".sitemap_categorytype");
	var lastElementClass = $(lastElement).attr("class");
    var collection = new Array(); // Collection of Elements
    collection.push(firstElement); // Add First Element to Collection
    $(firstElement).nextAll().each(function(){ // Traverse all siblings
        var siblingID  = $(this).attr("class"); // Get Sibling ID
        //console.log('siblingID: ' + siblingID + '  lastElementClass:' + lastElementClass);
        if (siblingID != lastElementClass) { // If Sib is not LastElement
				collection.push($(this)); 
				$(this).hide();
				$("a[title='Company']").parent(".sitemap_categorytype").hide();
				// Add Sibling to Collection
        } else { // Else, if Sib is LastElement
                return false; // Break Loop
        }
    });         
}

function removeAllBetween_promotions() {

	var firstElement = $("a[title='Promotions']").parent(".sitemap_categorytype");
	var lastElement = $("a[title='Motorized Bicycles']").parent(".sitemap_categorytype");
	var lastElementClass = $(lastElement).attr("class");
    var collection = new Array(); // Collection of Elements
    collection.push(firstElement); // Add First Element to Collection
    $(firstElement).nextAll().each(function(){ // Traverse all siblings
        var siblingID  = $(this).attr("class"); // Get Sibling ID
        //console.log('siblingID: ' + siblingID + '  lastElementClass:' + lastElementClass);
        if (siblingID != lastElementClass) { // If Sib is not LastElement
				collection.push($(this)); 
				$(this).hide();
				$("a[title='Promotions']").parent(".sitemap_categorytype").hide();
				// Add Sibling to Collection
        } else { // Else, if Sib is LastElement
                return false; // Break Loop
        }
    });         
}

$("#sitemap_wrapper").css("display","block");
getAllBetween_bicycle_motorized_bicycles();
getAllBetween_bicycle_motors();
getAllBetween_bike_motor_parts();
getAllBetween_bicycle_motor_service();

  // removeAllBetween_wholesale_inquiries();
  removeAllBetween_photo_galleries();
  removeAllBetween_company();
  // removeAllBetween_promotions();
$(".sitemap_categorytype").eq(0).hide();
// search page

$(".searcht_wrapper:odd").css("background-color", "#EBEAEA");

// for pdf download

$("#send_pdf_dialog").dialog({       
        modal: true,
        title: "Download PDF",
        autoOpen: false,
        height: "300px",
        width: "480px",
        overlay: {
            opacity: 0.65,
            background: "black"
        },
		position: ["center",100] 
		});

	$(".send_pdf").click(function(){

$("#send_pdf_dialog").dialog('open');

$("#send_pdf_dialog").load("send_pdf_form.htm",'',function(html){

$("#pdf_id").attr("value",pdf_to_download);

$("#send_pdf_dialog").css("display","block");

// send pdf validation
 $("#send_pdf").validate({
        rules: {
            pdf_email: {
                required: true,
                email: true
            },
			 pdf_first_name: {
                required: true
            },
			pdf_last_name: {
                required: true
            }
        }
    });

// validate send pdf
$("#submit_send_pdf").click(function(){
$("#submit_send_pdf").attr("disabled",false);
valid_send_pdf_form = $("#send_pdf").validate().form();
if (valid_send_pdf_form == true) {
	pre_submit = function (){
	$("#submit_send_pdf").attr("value","Processing");
	$("#submit_send_pdf").attr("disabled",true);
	}
	submit_success_callbacks = function(){
		$("#send_pdf_dialog .dialog_message").hide();
		$("#send_pdf_dialog .dialog_message").fadeIn("slow");
		
// for close button
		$("#close_pdf_form").click(function(){
			$("#send_pdf_dialog").dialog('close');
		}); // click
	} // function
	var options = {
		// target element(s) to be updated with server response 
		beforeSubmit: pre_submit,
		target: ".dialog_message",
		success: submit_success_callbacks // post-submit callback 
	};
	
	// bind form using 'ajaxForm' 
	$('#send_pdf').ajaxSubmit(options);
	return false;

} // if
}); // click

 });
 pdf_to_download = $(this).attr("id");
}); // click


// end send pdf

/* lightbox for new product template --*/

if (typeof(image_coll) != 'undefined') {

	for (var key in image_coll) {
		var image_str = image_coll[key];
	}
	
	var image_coll_arr = image_str.split(',');
	
	// render small images
	var a = 'images_templ/product_images/';
	var smi = '';
	
	xl_image_coll_arr = [];
	for (i = 0; i < image_coll_arr.length; i++) {
		if (image_coll_arr[i] != "") {
			// add extra large images to "xl_image_coll_arr" array
			xlim = image_coll_arr[i].split(".");
			xlim = xlim[0];
			xlim = xlim + "-xl.jpg";
			xl_image_coll_arr[i] = xlim;
			// create src attribute value for small image
			smim = image_coll_arr[i].split(".");
			smim = smim[0];
			smim = smim + "-sm.jpg";
			smi += '<img src="' + a + smim + '" id="' + i + '">';
			
		}
	}
	// divs to hold standard and small images
	$("#bt_img").append("<div id='sti'></div>");
	$("#bt_img").append("<div id='smi'></div>");
	// insert initial standard image
	var sti = "<a title='" + bt_product_name + "' class='st_img' href='" + a + xl_image_coll_arr[0] + "'><img src='" + a + image_coll_arr[0] + "'></a>";
	$("#sti").append(sti);
	// insert small images
	$("#smi").append(smi);
	
	// add onclick for small images
	$("#smi img").click(function(){
		$this = $(this);
		sti_img_src = a + image_coll_arr[$this.attr("id")];
		$("#sti img").attr("src", sti_img_src);
		$("#sti a").attr("href", a + xl_image_coll_arr[$this.attr("id")]);
		curr_xli = a + xl_image_coll_arr[$this.attr("id")];
		$(".st_img").colorbox();
	});
	$(".st_img").colorbox();
}//if

}); // ready
