// initialize global variables
	var g_fade_background = ('');
	var g_fade_background_link = ('');
	var g_fade_element = ('');
	var g_fade_element_link = ('');
	var g_fade_item = (1);
	var g_fade_background_item = (2);
	var g_popup = (0);
	var g_scroll = (0);
	var g_timer = ('');

//# Body OnLoad
	function body_onload()
	{
	// verify that we need to fade
		if(g_fade)
		{
		// initialize fade
			document.getElementById('img_promotion1_fade').src = (g_fade_images[g_fade_background_item]);
			g_fade_background = document.getElementById('img_promotion1_fade');
			g_fade_background_link = document.getElementById('a_promotion1_fade');
			g_fade_element = document.getElementById('img_promotion1');
			g_fade_element_link = document.getElementById('a_promotion1');
			g_timer = setTimeout('fade(0, 100);', 8000);
		}
	}

//# Check
	function check(p_form, p_element, p_select)
	{
	// process form elements
		l_select = ("");
		for(l_object = 0; l_object < p_form.elements.length; l_object++)
		{
		// verify that the element is a check box
			l_element = (p_form.elements[l_object]);
			if((l_element.type == "checkbox") && (l_element.name.indexOf(p_element) >= 0)) l_element.checked = (p_select);
		}
	}

//# Country
	function country(p_state, p_country)
	{
	// check state
		l_st = (p_state.value);
		l_country = (p_country);
		if((l_st == "ACT") || (l_st == "NSW") || (l_st == "NT") || (l_st == "QLD") || (l_st == "SA") || (l_st == "TAS") || (l_st == "VIC") || (l_st == "AU-WA")) l_country.value = ("AU");
		else if((l_st == "AB") || (l_st == "BC") || (l_st == "MB") || (l_st == "NB") || (l_st == "NF") || (l_st == "NS") || (l_st == "NT") || (l_st == "ON") || (l_st == "PE") || (l_st == "QC") || (l_st == "SK") || (l_st == "YT")) l_country.value = ("CA");
		else if(l_st == "NZ") l_country.value = ("NZ");
		else if((l_st == "AS") || (l_st == "FM") || (l_st == "GU") || (l_st == "MH") || (l_st == "MP") || (l_st == "PW") || (l_st == "PR") || (l_st == "VI")) l_country.value = (l_st);
		else l_country.value = ("US");
	}

//# Currency
	function currency(amount)
	{
/*
		var delimiter = ","; // replace comma if desired
		var n = new String(amount);
		var a = [];
		while(n.length > 3)
		{
			var nn = n.substr(n.length-3);
			a.unshift(nn);
			n = n.substr(0,n.length-3);
		}
		if(n.length > 0) { a.unshift(n); }
		n = a.join(delimiter);
		return n;
*/
		var i = parseFloat(amount);
		if(isNaN(i)) { i = 0.00; }
		var minus = '';
		if(i < 0) { minus = '-'; }
		i = Math.abs(i);
		i = parseInt((i + .005) * 100);
		i = i / 100;
		s = new String(i);
		if(s.indexOf('.') < 0) { s += '.00'; }
		if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
		s = minus + s;
		return s;
	}

//# Date
	function date(p_date)
	{
	// initialize date
		l_format = (/^\d{2}\/\d{2}\/\d{4}$/);
		l_month = (p_date.split("/")[0]);
		l_day = (p_date.split("/")[1]);
		l_year = (p_date.split("/")[2]);
		l_date = new Date(l_year, (l_month - 1), l_day);
	// verify that this is a valid date format
		l_valid = (true);
		if(!l_format.test(p_date)) l_valid = (false);
	// verify that this is a valid date
		else if(((l_date.getMonth() + 1) != l_month) || (l_date.getDate() != l_day) || (l_date.getFullYear() != l_year)) l_valid = (false);
	// return result
		return(l_valid);
	}

//# Fade
	function fade(p_fade, p_opacity)
	{
	// verify that we need to clear the timer
		if((p_fade == 0) && (g_timer != '')) clearTimeout(g_timer);
	// update opacity
		if(p_fade > p_opacity) p_opacity += (10);
		else p_opacity -= (10);
	// modify the promo
		g_fade_element.style.opacity = (p_opacity / 100);
		g_fade_element.style.filter = ('alpha(opacity=' + p_opacity + ')');
	// verify that we need to continue the fade
		if(p_fade != p_opacity) g_timer = setTimeout(('fade(' + p_fade + ', ' + p_opacity + ');'), 1);
	// verify that we need to fade in
		else if(p_fade == 0)
		{
		// initialize fade
			g_fade_item++;
			if(g_fade_item == g_fade_images.length) g_fade_item = (1);
			g_fade_element_link.href = (g_fade_urls[g_fade_item]);
			g_fade_element.alt = (g_fade_titles[g_fade_item]);
			g_fade_element.src = (g_fade_images[g_fade_item]);
			g_fade_element.title = (g_fade_titles[g_fade_item]);
			g_timer = setTimeout('fade_initialize();', 1000);
		}
	// verify that we need to fade out
		else g_timer = setTimeout('fade(0, 100);', 8000);
	}

//# Fade Initialize
	function fade_initialize()
	{
	// initialize fade
		g_fade_element.style.opacity = (1.0);
		g_fade_element.style.filter = ('alpha(opacity=100)');
		g_fade_background_item++;
		if(g_fade_background_item == g_fade_images.length) g_fade_background_item = (1);
		g_fade_background_link.href = (g_fade_urls[g_fade_background_item]);
		g_fade_background.src = (g_fade_images[g_fade_background_item]);
		g_timer = setTimeout('fade(0, 100);', 8000);
	// hide menu
		if(g_primary_menu_resource != '') document.getElementById('td_primary_menu' + g_primary_menu_resource).className = ('td_primary_menu');
	// show menu
		g_primary_menu = (g_fade_item);
		g_primary_menu_resource = (g_fade_item);
		if(g_primary_menu != '') document.getElementById('td_primary_menu' + g_primary_menu).className = ('td_primary_menu_hover');
	}

//# Filters
	function filters(p_action, p_filter)
	{
	// verify that we need to modify page filters
		if(p_action == 'page')
		{
		// initialize filters
			document.form_filters.p_filters_page.value = (p_filter);
			for(l_element = 0; l_element < document.form_filters.elements.length; l_element++) if((document.form_filters.elements[l_element].name.indexOf("_filters") > 0) && (document.form_filters.elements[l_element].value == '')) document.form_filters.elements[l_element].value = ('~');
		}
	// verify that we need to reset filters
		else if(p_action == 'reset')
		{
		// initialize filters
			for(l_element = 0; l_element < document.form_filters.elements.length; l_element++) if(document.form_filters.elements[l_element].name.indexOf("_filters") > 0) document.form_filters.elements[l_element].value = ('~');
		}
	// verify that we need to modify sort filters
		else if(p_action == 'sort')
		{
		// initialize filters
			l_sort = (' ASC');
			if(document.form_filters.p_filters_sort.value == (p_filter + l_sort)) l_sort = (' DESC');
			document.form_filters.p_filters_sort.value = (p_filter + l_sort);
		}
	// update filters
		document.form_filters.submit();
	}

//# Numeric
	function numeric(p_value)
	{
	// verify that the value is numeric
		p_value = p_value.replace('$', '');
		p_value = p_value.replace(',', '');
		p_value = parseFloat(p_value);
		if(isNaN(p_value)) p_value = (-1);
	// return the result
		return(p_value);
	}

//# Phone
	function phone(p_phone)
	{
	// verify that the phone number is formatted correctly
		//p_phone = p_phone.replace(/^\s+|\s+$/g, ""); // strip leading and trailing spaces
		//p_phone = p_phone.replace(/\s+/g, " "); // replace multiple spaces by a single space
		p_phone = p_phone.replace(/\-/g, ""); // remove hyphens
		p_phone = p_phone.replace("(", ""); // remove parentheses
		p_phone = p_phone.replace(")", ""); // remove parentheses
		p_phone = p_phone.replace(/\+/g, ""); // remove plus
		p_phone = p_phone.replace(/\s+/g, ""); // remove spaces
		if(/(^[0-9\s\-\+]{10,})$/gi.test(p_phone)) return(true); // telephone number, only digits, space, hyphen and plus sign allowed. Minimum of 10 characters.
		else return(false);
	}

//# Display Popup
	function popup(p_popup, p_action, p_background, p_video)
	{
	// display popup
		l_action = ('inline');
		if(p_action == 'inline') l_action = ('none');
		if(p_video != '') document.getElementById(p_video).style.display = (l_action);
		if(p_background == 'yes') document.getElementById('table_popups').style.display = (p_action);
		if(p_background == 'yes') document.getElementById('div_popup_background').style.display = (p_action);
		document.getElementById(p_popup).style.display = (p_action);
	}

//# Scroll
	function scroll(p_element_id)
	{
	// scroll the content
		g_scroll += (1);
		document.getElementById(p_element_id).scrollTop = (g_scroll);
	// initialize timeout
		l_height = (document.getElementById(p_element_id).style.height);
		l_height = (document.getElementById(p_element_id).scrollHeight - l_height.substr(0, (l_height.length - 2)));
		l_height = (l_height + 50);
		if(g_scroll > l_height) g_scroll = (1);
	// set timeout for next scroll
		setTimeout('scroll("' + p_element_id + '")', 75);
	}

//# Trim
	function trim(p_value)
	{
	// return trimmed value
		return p_value.replace(/^\s*/, "").replace(/\s*$/, "");
	}

