

// globals for hiding & showing mast image
var xDoc = window.document;
var xPath = [110,111,112,113,114,115,116,117,118,125,135,145,155,165,185,205,225,245,265,285,305,315,325,335,342,343,344,345,346,347,348,349,350];
var xDir = -1;
var xPos = xPath.length; 

// check cookie to see if mast should be open or closed

function mast_check(){

	// check cookie and then adjust mast height accordingly 
	if($.cookie("QS-Mast") == "hidden"){
		$('#mast').height(110);
		$('#hide-show-link').text('Show Picture');
		xDir = 1;
		xPos = 0;
	} else {
		$('#mast').height(350);
		$('#hide-show-link').text('Hide Picture');
		xDir = -1;
		xPos = xPath.length;
	}
}


// increase home page mast height - not used for 2011 updates

function home_mast_height(){

	// check to see if an ID has been set on BODY tag
	var qs_body_id = document.body.id ? document.body.id : null;

	// adjust mast height
	if(qs_body_id == "home"){
		$('#mast').height(350);
	}
}


// load appropriate mast image

function load_mast_img(){

	// check to see if an ID has been set on BODY tag
	var qs_body_id = document.body.id ? document.body.id : null;

	// load mast image dependent on qs_body_id
	
	if(qs_body_id){

		/*
		
		don't need this for 2011 updates as different mast images are being used in the Online Catalogue


		if(
		   qs_body_id == "jackets-vests"
		|| qs_body_id == "activewear"
		|| qs_body_id == "aprons-pinneys-blankets"
		|| qs_body_id == "athletic-performance"
		|| qs_body_id == "casual-shirts-denim"
		|| qs_body_id == "golf-bags-accessories"
		|| qs_body_id == "golf-shirts"
		|| qs_body_id == "jackets-vests"
		|| qs_body_id == "ladies-only"
		|| qs_body_id == "online-catalogue"
		|| qs_body_id == "portfolio-cases"
		|| qs_body_id == "sports-bags"
		|| qs_body_id == "search-results"
		|| qs_body_id == "order-form"
		){

			$('#mast').css('background', 'transparent url(lib/img/mast-img-online-catalogue.jpg) no-repeat' );	
		
		} else {
	
			$('#mast').css('background', 'transparent url(lib/img/mast-img-'+ qs_body_id +'.jpg) no-repeat' );	
	
		} 
		
		*/

		$('#mast').css('background', 'transparent url(lib/img/mast-img-'+ qs_body_id +'.jpg) no-repeat' );	
	
	}
}


// blow away mast image hide/show control link - not used for 2011 updates

function hide_show_img_control(){

	// check to see if an ID has been set on BODY tag
	var qs_body_id = document.body.id ? document.body.id : null;

	// load mast image dependent on qs_body_id
	if(qs_body_id != "home"){
		$('#hide-show-link').hide();
	}
}


// hide & show mast image

function move_it() {

	//alert("xPos = " + xPos + "   " + "xDir = " + xDir)

	if(typeof moveId == 'undefined') {
		moveId = setInterval('move_it()',18);
	} else if(xPos <= 0 || xPos >= xPath.length) {
		xDir *= -1;
		clearInterval(moveId);
		delete moveId;
		var h = $('#mast').height() + "px"; 
		
		//alert(h);
		
		if(h == '110px') {
			//alert("xDir = " + xDir);
			$('#hide-show-link').text('Show Picture');
			$.cookie("QS-Mast", "hidden", { path: '/' });			
		}
		if(h == '350px') {
		
			//alert("xDir = " + xDir);
			
			$('#hide-show-link').text('Hide Picture');
			$.cookie("QS-Mast", "shown", { path: '/' });			
		}
		return false;
	}
	xPos += xDir;
	
	//alert("xPos = " + xPos);
	
	var h = xPath[xPos];	
	if(h) {
		h = h + 'px';
		$('#mast').height(h);
	}
}


function verify_search_input(form) {

	var q = form.q;

	if(!q.value){
		q.focus();
		return false;
	}
	if(q.value == "Product/Style Search"){
		q.focus();
		return false;
	}
}


function insert_search_term(t) {

	$('#qs-search-box').attr('value', t); 

}


function change_main_view_img(img, ver, id, nm) {

	// this bit changes the text for the colour/version 'Shown'
	$('#colour-version-shown').text(ver);

	// this bit changes the image that's currently being viewed on the product details page
	var img_path = "../product-images/details-main-view/" + img;

	$('#main-view-img').attr('src', img_path);

	$('#main-view-img').attr('alt', id + ' - ' + nm + ' - ' + ver);

	// this bit creates the url for the pop-up window			
	var lrg_img_url = "lrg-img-popup.php?prod_id=" + id + "&prod_name=" + escape(nm) + "&prod_img_ver=" + escape(ver);

	$('#details-larger-view-link').attr('href', lrg_img_url);
	
}


// larger view pop-up

var larger_view_win = '';

var _POPUP_FEATURES = 'location=0,scrollbars=0,resizable=1,statusbar=0,toolbar=0,menubar=0,width=700,height=660';

function raw_popup(url, target, features) {

    // pops up a window containing url optionally named target, optionally having features    
    if (!features){
		features = _POPUP_FEATURES;
    }

    if (!target){
		target = '_blank';		
    }

    larger_view_win = window.open(url, target, features);

    larger_view_win.focus();

    return larger_view_win;
}


function link_popup(src, features) {
    // to be used in an html event handler as in: <a href="..." onclick="link_popup(this,...)" ...
    // pops up a window grabbing the url from the event source's href
    return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);    
}


function replace_nav_link_txt(category) {

	var img_lib_nav_txt = category.replace(/ & /, " &amp; ");

	var img_lib_nav_id = category.replace(/ & /, "-");

	img_lib_nav_id = img_lib_nav_id.replace(/, /, "-");
	
	img_lib_nav_id = img_lib_nav_id.replace(/ /, "-");
	
	img_lib_nav_id = img_lib_nav_id.toLowerCase();
	
	img_lib_nav_id = '#' + img_lib_nav_id;
	
	$(img_lib_nav_id).html('<b>' + img_lib_nav_txt + '</b>');

}


function login_check() {

	var is_valid = true;

	// alert(is_valid + " " + $('#qs-username').attr('value') + " " + $('#qs-password').attr('value'))

	if($('#qs-username').attr('value') == "" || $('#qs-username').attr('value') == "Email"){
		is_valid = false;
	}

	if($('#qs-password').attr('value') == "" || $('#qs-password').attr('value') == "Password"){
		is_valid = false;
	}	

	if(is_valid){
		
		$('#qs-login-button').bind('click', function(){			
			
			$('#login-spinner').show();
						
			$('#qs-login-form').submit();
			
			return false;
		})
	}
}


function setup_login_check() {

	$('#qs-username').bind('blur', function(){
		login_check();
	});
	$('#qs-password').bind('blur', function(){
		login_check();
	});
	$('#qs-username').bind('change', function(){
		login_check();
	});
	$('#qs-password').bind('change', function(){
		login_check();
	});
	$('#qs-login-button').bind('click', function(){
		$('#qs-login-button').blur();
		return false;
	});
	
	login_check();
}

				
function login_error() {
	$('#login-form').show();
	$('#login-spinner').fadeOut('fast');
	$('#qs-username').addClass('login-error');
	$('#qs-password').addClass('login-error');		
	$('#login-error-message').fadeIn('fast');
}


function init_product_count() {

	// width of product image wrap (column is 400 px wide)
	// alert($('#product-slide-wrap').width());
	// var slide_wrap_width = parseInt($('#product-slide-wrap').css('width').split("px")[0]);
	var slide_wrap_width = parseInt($('#product-slide-wrap').width());

	// width of a product image
	// alert($('#product-slide img').width());
	// var product_img_width = parseInt($('#product-slide img').css('width').split("px")[0]);
	var product_img_width = parseInt($('#product-slide img').width());

	// number of product images in the product container
	var num_product_imgs = $('#product-slide img').length;

	// total width of all the product images together
	var total_width = num_product_imgs * product_img_width;		

	if (total_width > slide_wrap_width){
		var num_showing = slide_wrap_width/product_img_width;
		$('#product-slide-nav span').html(num_showing + " of " + num_product_imgs);
		$('#product-slide-nav').show();		
	}
}


// product thumbnail slider

function product_slide(num) {

	// width of product image wrap (column is 400 px wide)
	// var slide_wrap_width = parseInt($('#product-slide-wrap').css('width').split("px")[0]);
	var slide_wrap_width = parseInt($('#product-slide-wrap').width());
	// alert(slide_wrap_width);

	// width of a product image
	// var product_img_width = parseInt($('#product-slide img').css('width').split("px")[0]);
	var product_img_width = parseInt($('#product-slide img').width());
	
	// number of product images in the product container
	var num_product_imgs = $('#product-slide img').length;

	// not sure what this is for
	var max_products = (num_product_imgs - 1);

	// total width of all the product images together
	var total_width = num_product_imgs * product_img_width;		

	// make the product slide div the total width of all the product images added together
	// $('#product-slide').css("width", total_width);
	$('#product-slide').width(total_width);

	// find out the current x position of the product slide div divided by the width of a product image
	var current_position = Math.abs(Math.ceil(parseInt($('#product-slide').css('left').split("px")[0]) / parseInt(product_img_width)));

	// find out how much of the slide is still being displayed to the right of the 0 axis point 
	var remains = total_width - (current_position * product_img_width);

	if(num > 0){
		// prev
		// move 1 product image at a time = var next_pos = 0 - ((product_img_width * (current_position -1)) * num);
		// move 4 product images at a time = var next_pos = 0 - ((product_img_width * (current_position -4)) * num);
		max_products += 1;
		var next_pos = 0 - ((product_img_width * (current_position - 4)) * num);
		var num_showing = current_position;
	} else {
		// next
		// move 1 product image at a time = var next_pos = (product_img_width * (current_position +1)) * num;
		// move 4 product images at a time = var next_pos = (product_img_width * (current_position +4)) * num;
		// test if at end of product slider wrapping div
		if(remains > slide_wrap_width){
			var next_pos = (product_img_width * (current_position + 4)) * num;
			var num_showing = 0; // currently working on this
		}			
	}

	if(current_position >= 0 && current_position < max_products && next_pos <= 0) {
		
		$('#product-slide').animate(
			{
				left: next_pos + "px"
			}, 300
		);

		// display number of products to browse
		$('#product-slide-nav span').html(num_showing + " of " + num_product_imgs);

	}

}


// order form 

var prod_num = 0;
var no_sizes = false;
var vldt_courier = false;

function write_selects_container(pn) {

	var last_cn = 0;
	
	if ( pn > 2 ){
	
		last_cn = pn - 1;
	
	} else {
	
		last_cn = 1;
	
	}
	
	var last_container = "#qs-prod-selects-" + last_cn;
	
	var new_container = "qs-prod-selects-" + pn;
	
	if ( pn <= 1) {
	
		$('<div id="' + new_container + '"></div>').insertAfter('#qs-prod-selects');
		
	} else {
	
		$('<div id="' + new_container + '"></div>').insertAfter(last_container);	
	
	}
	
	setup_prod_selects(new_container,pn)

}


function setup_prod_selects(nc,pn) {
	
	nc = "#" + nc;		
	
	$(nc).load('lib/inc/order-form-scripts.php?dtls_rqst=setup&prod_num=' + pn + '');
		
}


function setup_prod_selects_lstnr(pn) {

	$('#qs-product-id-' + pn).change(function() {

		selection_is_valid = true;
		
		$('.qs-product-err-' + pn).hide();
		$('.qs-colour-err-' + pn).hide();
		$('.qs-size-err-' + pn).hide();
		$('.qs-quantity-err-' + pn).hide();

		if($('#qs-product-id-' + pn).attr('value') == "" || $('#qs-product-id-' + pn).attr('value') == "Select Product") {
		
			selection_is_valid = false;
		
		}
		
		if(selection_is_valid) {

			// reset this for the size select
			no_sizes = false;
			
			var prod_id = $('#qs-product-id-' + pn).val();

			$('#qs-colour-' + pn).attr('disabled', '');			
			$('#qs-colour-' + pn).load('lib/inc/order-form-scripts.php?dtls_rqst=setup_colours&prod_id=' + prod_id + '&prod_num=' + pn);
			$('#qs-colour-' + pn).focus();

			$('#qs-size-' + pn).attr('disabled', '');
			$('#qs-size-' + pn).load('lib/inc/order-form-scripts.php?dtls_rqst=setup_sizes&prod_id=' + prod_id + '&prod_num=' + pn);			

			$('#qs-quantity-' + pn).attr('disabled', '');

		} else {

			$('#qs-product-id-' + pn).focus();			

			// for whatever reason, this could not be done easily with jquery - wtf!?
			xDoc.getElementById('qs-colour-' + pn).selectedIndex = 0;
			$('#qs-colour-' + pn).attr('disabled', 'disabled');

			xDoc.getElementById('qs-size-' + pn).selectedIndex = 0;
			$('#qs-size-' + pn).attr('disabled', 'disabled');

			$('#qs-quantity-' + pn).attr('value', '');
			$('#qs-quantity-' + pn).attr('disabled', 'disabled');
		}

	})

	$('#qs-colour-' + pn).change(function() { 

		if(!no_sizes) {

			$('.qs-colour-err-' + pn).hide();
			$('#qs-size-' + pn).focus();			
		
		} else {
		
			$('.qs-colour-err-' + pn).hide();
			$('#qs-quantity-' + pn).focus();

			no_sizes = true;
		
		}
	
	})

	$('#qs-size-' + pn).change(function() { 
		$('.qs-size-err-' + pn).hide();
		$('#qs-quantity-' + pn).focus();	
	})
		
}


function disable_size_select(pn) {

	xDoc.getElementById('qs-size-' + pn).selectedIndex = 0;
	$('#qs-size-' + pn).attr('disabled', 'disabled');

	no_sizes = true;

}


function en_dis_remove_last(pn) {
	if(pn > 1){
		$('#qs-remove-last').show();
		$('#qs-remove-last-dis').hide();		
	} else {
		$('#qs-remove-last').hide();
		$('#qs-remove-last-dis').show();	
	}
}


// form validation
function verifyInput(form)  {

var i = 0;
for (i = 1; i <= prod_num; i++) {

//alert(prod_num +" "+ i);

if (

v_prod		($('#qs-product-id-' + i).val()) || 
v_colour	($('#qs-colour-' + i).val()) || 
v_size		($('#qs-size-' + i).val()) ||
v_quantity	($('#qs-quantity-' + i).val())

){

// don't submit the form		
// display the required fields error notice by submit button
$('#qs-sbmt-err').show();
return false;

}

}

if (

// bill to
v_company			($('#qs-company-name').val()) ||
v_contact			($('#qs-contact').val()) ||
v_email				($('#qs-email').val()) ||
v_telephone			($('#qs-telephone').val()) ||
v_address			($('#qs-address').val()) ||
v_city				($('#qs-city').val()) ||
v_prov				($('#qs-prov').val()) ||
v_count				($('#qs-count').val()) ||
v_postal			($('#qs-postal').val()) ||
v_purch				($('#qs-purch').val()) ||

// ship to
v_contact_ship		($('#qs-contact-ship').val()) ||
v_telephone_ship	($('#qs-telephone-ship').val()) ||
v_address_ship		($('#qs-address-ship').val()) ||
v_city_ship			($('#qs-city-ship').val()) ||
v_prov_ship			($('#qs-prov-ship').val()) ||
v_count_ship		($('#qs-count-ship').val()) ||
v_postal_ship		($('#qs-postal-ship').val()) ||
v_via_ship			($('#qs-via-ship').val()) ||
v_courier_ship		($('#qs-courier-ship').val()) ||
v_courier_accnt_ship($('#qs-courier-accnt-ship').val())

){

// don't submit the form		
// display the required fields error notice by submit button
$('#qs-sbmt-err').show();
return false;

}

// submit the form mmkay?
return true;

	
function v_prod(val) {
	if (!val) {
		$('#qs-product-id-' + i).focus();
		$('.qs-product-err-' + i).show();
		return true;
	}
	return false;
}


function v_colour(val) {
	if (!val) {
		$('#qs-colour-' + i).focus();
		$('.qs-colour-err-' + i).show();
		return true;
	}
	return false;
}

function v_size(val) {
	if (!val) {
		
		if($('#qs-size-' + i).attr('disabled')){

			return false;

		} else {
		
			$('#qs-size-' + i).focus();
			$('.qs-size-err-' + i).show();		
			return true;		

		}

	}
	return false;
}

function v_quantity(val) {
	if (!val) {
		$('#qs-quantity-' + i).focus();
		$('.qs-quantity-err-' + i).show();
		return true;
	}
	return false;
}

// bill to
function v_company(val) {
	if (!val) {
		$('#qs-company-name').focus();
		$('.comp-name-err').show();
		return true;
	}
	return false;
}

function v_contact(val) {
	if (!val) {
		$('#qs-contact').focus();
		$('.contact-err').show();
		return true;
	}
	return false;
}

function v_email(val) {
	if (!val) {
		$('#qs-email').focus();
		$('.email-err').show();
		return true;
	}
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!re_mail.test(val)) {
		$('#qs-email').focus();
		$('.email-err').show();
		$('.email-err').html("requires a valid email address");		
		return true;
	}
	return false;
}

function v_telephone(val) {
	if (!val) {
		$('#qs-telephone').focus();
		$('.phone-err').show();
		return true;
	}
	return false;
}

function v_address(val) {
	if (!val) {
		$('#qs-address').focus();
		$('.address-err').show();
		return true;
	}
	return false;
}

function v_city(val) {
	if (!val) {
		$('#qs-city').focus();
		$('.city-err').show();
		return true;
	}
	return false;
}

function v_prov(val) {
	if (!val) {
		$('#qs-prov').focus();
		$('.prov-err').show();
		return true;
	}
	return false;
}

function v_count(val) {
	if (!val) {
		$('#qs-count').focus();
		$('.count-err').show();
		return true;
	}
	return false;
}

function v_postal(val) {
	if (!val) {
		$('#qs-postal').focus();
		$('.postal-err').show();
		return true;
	}
	return false;
}

function v_purch(val) {
	if (!val) {
		$('#qs-purch').focus();
		$('.purch-err').show();
		return true;
	}
	return false;
}

// ship to
function v_contact_ship(val) {
	if (!val) {
		$('#qs-contact-ship').focus();
		$('.contact-err-ship').show();
		return true;
	}
	return false;
}

function v_telephone_ship(val) {
	if (!val) {
		$('#qs-telephone-ship').focus();
		$('.telephone-err-ship').show();
		return true;
	}
	return false;
}

function v_address_ship(val) {
	if (!val) {
		$('#qs-address-ship').focus();
		$('.address-err-ship').show();
		return true;
	}
	return false;
}

function v_city_ship(val) {
	if (!val) {
		$('#qs-city-ship').focus();
		$('.city-err-ship').show();
		return true;
	}
	return false;
}

function v_prov_ship(val) {
	if (!val) {
		$('#qs-prov-ship').focus();
		$('.prov-err-ship').show();
		return true;
	}
	return false;
}

function v_count_ship(val) {
	if (!val) {
		$('#qs-count-ship').focus();
		$('.count-err-ship').show();
		return true;
	}
	return false;
}

function v_postal_ship(val) {
	if (!val) {
		$('#qs-postal-ship').focus();
		$('.postal-err-ship').show();
		return true;
	}
	return false;
}

function v_via_ship(val) {
	if (!val) {
		$('#qs-via-ship').focus();
		$('.via-err-ship').show();
		return true;
	}
	return false;
}

function v_courier_ship(val) {
	if(vldt_courier){
		if (!val) {
			$('#qs-courier-ship').focus();
			$('.courier-err-ship').show();
			return true;
		}
		return false;
	}
}

function v_courier_accnt_ship(val) {
	if(vldt_courier){
		if (!val) {
			$('#qs-courier-accnt-ship').focus();
			$('.courier-accnt-err-ship').show();
			return true;
		}
		return false;
	}
}

}


// initialize

function init() {

	// check cookie to see if the mast should be open or closed
	mast_check();

	// increase home page mast height - not needed for 2011 updates as we're using the deep mast images on every page
	// home_mast_height();

	// insert mast image into page
	load_mast_img();

	// blow away mast image hide/show control link - not needed for 2011 updates as we're using the deep mast images on every page
	// hide_show_img_control();

	
	// order form product details select elements
	prod_num = prod_num + 1;
	$('#qs-products-total').attr('value', prod_num);
	write_selects_container(prod_num);

	var qs_login_link_open = xDoc.getElementById('login-link-open');
	var qs_login_link_close = xDoc.getElementById('login-link-close');
	var qs_login_form = xDoc.getElementById('login-form');
	var qs_hide_show_link = xDoc.getElementById('hide-show-link');
	var qs_log_out_link = xDoc.getElementById('log-out-link');
	var qs_search_form = xDoc.getElementById('qs-search-form');

	if(qs_login_link_open) {
		$('#login-link-open').bind('click', function(){
			$('#login-spinner').hide();
			$('#login-link-open').blur();
			$('#login-form').show();
		});
	}

	if(qs_login_link_close) {
		$('#login-link-close').bind('click', function(){
			$('#login-link-close').blur();
			$('#login-form').hide();
		});
	}

	if(qs_login_form) {
		$('#qs-username').bind('focus', function(){
			if(this.value == "Email"){
				this.value = "";
			}
		});
		$('#qs-username').bind('blur', function(){
			if(this.value == ""){
				this.value = "Email";
			}
		});
		$('#qs-password').bind('focus', function(){
			if(this.value == "Password"){
				this.value = "";
			}
		});
		$('#qs-password').bind('blur', function(){
			if(this.value == ""){
				this.value = "Password";
			}
		});		
		
		// some login form validation etc.
		setup_login_check();		
	}

	if(qs_log_out_link) {
		$('#log-out-link').bind('click', function(){
			do_log_out();
		});
	}

	if(qs_hide_show_link) {
		$('#hide-show-link').bind('click', function(){
			$('#hide-show-link').blur();
			move_it();
		});
	}

	if(qs_search_form) {
		$('#qs-search-box').bind('focus', function(){
			if(this.value == "Product/Style Search"){
				this.value = "";
			}
		});
		$('#qs-search-box').bind('blur', function(){
			if(this.value == ""){
				this.value = "Product/Style Search";
			}
		});
	}
	
	$('#product-slide-nav a.product-slide-prev').bind('click', function(){
		$('#product-slide-nav a.product-slide-prev').blur();
		product_slide(1);
		return false;
	});

	$('#product-slide-nav a.product-slide-next').bind('click', function(){
		$('#product-slide-nav a.product-slide-next').blur();
		product_slide(-1);
		return false;
	});

	// order form fun
	$('#qs-add-more').bind('click', function(){
		$('#qs-add-more').blur();
		prod_num = prod_num + 1;
		$('#qs-products-total').attr('value', prod_num);
		write_selects_container(prod_num);
		en_dis_remove_last(prod_num);
	});

	$('#qs-remove-last').bind('click', function(){
		$('#qs-remove-last').blur();
		if(prod_num > 1){
			$('#qs-prod-selects-' + prod_num).remove();
			prod_num = prod_num - 1;
			$('#qs-products-total').attr('value', prod_num);
			if (prod_num == 1){
				en_dis_remove_last(prod_num);
			}
		}
	});

	// same as billing
	$('#qs-as-billing').bind('click', function(){
		$('#qs-company-name-ship').attr('value', $('#qs-company-name').val());
		$('#qs-contact-ship').attr('value', $('#qs-contact').val());
		$('#qs-email-ship').attr('value', $('#qs-email').val());
		$('#qs-telephone-ship').attr('value', $('#qs-telephone').val());
		$('#qs-fax-ship').attr('value', $('#qs-fax').val());
		$('#qs-address-ship').attr('value', $('#qs-address').val());
		$('#qs-city-ship').attr('value', $('#qs-city').val());
		$('#qs-prov-ship').attr('value', $('#qs-prov').val());
		$('#qs-count-ship').attr('value', $('#qs-count').val());
		$('#qs-postal-ship').attr('value', $('#qs-postal').val());
		$('#qs-as-billing').blur();
	});


	// test ship via select if "collect" has been selected, if so validate courier fields
	$('#qs-via-ship').change(function() { 
		if($('#qs-via-ship').val() == "Collect"){		
			$('.courier-astrix').show();
			vldt_courier = true;
		} else {
			$('.courier-astrix').hide();
			$('.courier-err-ship').hide();
			$('.courier-accnt-err-ship').hide();
			vldt_courier = false;
		}		
	});


	$("#qs-order-form").submit(function(){

		// reset all error notices

		// all quantity fields
		var i = 0;
		for (i = 1; i <= prod_num; i++) {
			$('.qs-quantity-err-' + i).hide();
		}		

		// bill to
		$('.comp-name-err').hide();
		$('.contact-err').hide();
		$('.email-err').hide();
		$('.phone-err').hide();
		$('.address-err').hide();
		$('.city-err').hide();
		$('.prov-err').hide();
		$('.count-err').hide();
		$('.postal-err').hide();
		$('.purch-err').hide();

		// ship to		
		$('.contact-err-ship').hide();
		$('.telephone-err-ship').hide();
		$('.address-err-ship').hide();
		$('.city-err-ship').hide();
		$('.prov-err-ship').hide();
		$('.count-err-ship').hide();
		$('.postal-err-ship').hide();
		$('.via-err-ship').hide();
		$('.courier-err-ship').hide();
		$('.courier-accnt-err-ship').hide();
		
		// required fields error notice
		$('#qs-sbmt-err').hide();
		
		return verifyInput(this)		
		return false;
	});
	
}


// call initialize function

$(document).ready(function() {
	init();
});
