var b_is_mac_ie = false;
var b_js_but_no_html_edit = false;
var detect = navigator.userAgent.toLowerCase();
if ((-1 < detect.indexOf( "mac" )) && ((-1 < detect.indexOf( "msie" )) || (-1 < detect.indexOf( "internet explorer" )))) {
	b_js_but_no_html_edit = true;
	b_is_mac_ie = true;
	}
var tif_load_time_init_ms = (new Date()).getTime();

function tif_validate_as_local_user_id (this_obj, group) {
	// trim whitespace
	this_obj.value = this_obj.value.replace( / /g, '' );
	if (this_obj.value == '') this_obj.value = 0;
	var re_digit = new RegExp( "^\\d+$" );
	var re_local = new RegExp( "^" + group + "U\\d+$", "i" );
	var re_global = new RegExp( "^[A-Z][A-Z]U\\d+$", "i" );
	if (this_obj.value.match( re_digit )) {
		/* ok */
		}
	else if (this_obj.value.match( re_local )) {
		/* ok */
		this_obj.value = this_obj.value.toUpperCase();
		}
	else if (this_obj.value.match( re_global )) {
		alert( 'Error: user-ID "' + this_obj.value + '" maps to another server; this input requires a local account.' );
		}
	else {
		alert( 'Error: user-ID "' + this_obj.value + '" does not pattern-match to a valid account.' );
		}
	}



function tif_mi_show (x_big, y_big, obj) {
	var abs_div = object_by_id( 'tif_mi_top_abs' );
	if (abs_div == null) return;
	if (x_big == 0) {
		abs_div.innerHTML = '<br />';
		return;
		}
	var div2 = object_by_id( 'tif_mi_top_abs_container' );
	if (div2 == null) return;
	var pos_abs_div = Position.get( div2 );
	var pos = Position.get( obj );
	abs_div.innerHTML = "<img src=\"" + obj.src + "\" width=\"" + x_big + "\" height=\"" + y_big + "\" style=\"border:1px solid #000000\" />";
	abs_div.style.top = (pos.top - pos_abs_div.top - parseInt( 0.8 * y_big ) ) + 'px';
	abs_div.style.left = (1 - x_big - 10) + 'px';
	return;
	}




/* used on Folio Gallery Page photographer-facing edit interface */

function tif_fgp_set_sort_order (str_form_prefix, this_array) {
	for (var i = 0; i < this_array.length; i++) {
		var obj = object_by_id( str_form_prefix + "dww_sort_order_" + this_array[i] );
		if (obj != null) {
			obj.value = 3000;
			}
		}
	return false;
	}

function tif_fgp_set_radio (str_form_prefix, this_array, set_index) {
	for (var i = 0; i < this_array.length; i++) {
		for (var j = 0; j < 3; j++) {
			var obj = object_by_id( str_form_prefix + "dww_display_" + this_array[i] + "_" + j );
			if (obj != null) {
				obj.checked = (set_index == j);
				}
			}
		}
	return false;
	}


/* code for TIF-multi-select checkboxes (namespace tif_msc_*) */

var tif_msc_b_shift_down = false;
var tif_msc_last_id = null;

function tif_msc_onclick (o) {
	if (tif_msc_b_shift_down) {
		// yay
		}
	else {
		tif_msc_last_id = null;
		return;
		}

	if (tif_msc_last_id == null) {
		tif_msc_last_id = o.id;
		return
		}

	// scan through and toggle all

	var set_all_to = o.checked;

	/* get start and stop indexes: */
	var e1 = parseInt( tif_msc_last_id.substring( 8 ) );
	var e2 = parseInt( o.id.substring( 8 ) );

	var s = Math.min( e1, e2 );
	var e = Math.max( e1, e2 );

	for (var i = s; i <= e; i++) {
		var this_obj = object_by_id( "tif_ftr_" + i );
		if (this_obj == null) {
			break;
			}
		this_obj.checked = set_all_to;
		}

	}

// 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/)
function tif_msc_k_down (key) {
	if (!key) {
		key = event;
		key.which = key.keyCode;
		}
 	switch (key.which) {
 		case 16:
 			tif_msc_b_shift_down = true;
 			break;
		}
	}

function tif_msc_k_up (key) {
	if (!key) {
		key = event;
		key.which = key.keyCode;
		}
 	switch (key.which) {
 		case 16:
 			tif_msc_b_shift_down = false;
			tif_msc_last_id = null;
 			break;
		}
	}

function tif_msc_init () {
	tif_msc_b_shift_down = false;
	tif_msc_last_id = null;
	document.onkeydown = tif_msc_k_down;
	document.onkeyup = tif_msc_k_up;
	}

/* end tif_msc_* */






function sfpp_sff_item_show (int_id, b_show) {
	var min_id = int_id;
	var max_id = int_id;
	if (int_id == 0) {
		/* show or hide all */
		min_id = 1;
		max_id = 9999999;
		var o = object_by_id( 'tif_sfpp_sff1' );
		if (o == null) {
			}
		else {
			if (b_show) {
				// prompt to hide
				o.innerHTML = " (click to <a href=\"#\" onclick=\"return sfpp_sff_item_show(0,false)\">collapse all details</a>)";
				}
			else {
				// prompt to show
				o.innerHTML = " (click to <a href=\"#\" onclick=\"return sfpp_sff_item_show(0,true)\">show all details</a>)";
				}
			}
		}
	else {
		}
	for (var j = min_id; j <= max_id; j++) {
		var obj = object_by_id( 'sfpp_sff_item_' + j );
		if (obj == null) break;
		obj.style.height = b_show ? 'auto' : '2em';
		var o2 = object_by_id( 'sfpp_sff2_' + j );
		if (o2) {
			if (b_show) {
				o2.innerHTML = "<a href=\"#\" onclick=\"return sfpp_sff_item_show(" + j + ",false)\">hide details</a>";
				}
			else {
				o2.innerHTML = "<a href=\"#\" onclick=\"return sfpp_sff_item_show(" + j + ",true)\">show details</a>";
				}
			if (int_id == 0) {
				o2.style.display = b_show ? 'none' : 'block';
				}
			}
		}
	return false;
	}

function set_remind_on (new_index, target_id) {
	var o = obidff( target_id );
	o.selectedIndex = new_index;
	return false;
	}


var tif_currency_by_pp = new Array();
var tif_currency_WP = "GBP";
var tif_currency_GC = "GBP";
var tif_currency_SP = new Array('');

function tif_change_fsfid (o, pb_count, html_field_name, admin_url_he, maybe_partner_2) {
	
	var o_test_1 = document.getElementById( maybe_partner_2 + '_js1' );
	var o_test_2 = document.getElementById( maybe_partner_2 + '_js2' );
	var o_test_3 = document.getElementById( maybe_partner_2 + '_js3' );
	var o_test_4 = document.getElementById( maybe_partner_2 + '_js4' );

	
	if (o.selectedIndex == 0) {
		if (o_test_1 == null) {
			}
		else {
			o_test_3.style.visibility = 'hidden';
			o_test_4.style.visibility = 'visible';
			o_test_1.style.width = '1px';
			o_test_1.style.overflow = 'hidden';
			}
		
		
		}
	else if (o.selectedIndex <= pb_count) {
		if (o_test_1 == null) {
			}
		else {
			o_test_3.style.visibility = 'visible';
			o_test_4.style.visibility = 'hidden';
			o_test_1.style.width = '1px';
			o_test_1.style.overflow = 'hidden';
			}


		}
	else {
		if (o_test_1 == null) {
			}
		else {
			o_test_3.style.visibility = 'hidden';
			o_test_4.style.visibility = 'hidden';
			o_test_1.style.width = '';
			o_test_1.style.overflow = '';
			o_test_2.innerHTML = '';
			}
		
		
		}

	var pp_id = o[o.selectedIndex].value;
	var pp_currency = tif_currency_by_pp[pp_id];
	if (pp_currency == null) {
		//
		}
	else {
		var o_test = document.getElementById( maybe_partner_2 + '_pm1_expl' );
		if (tif_currency_WP == "333") {
			if (o_test == null) {
				}
			else if ((pp_currency == "EUR") || (pp_currency == "GBP") || (pp_currency == "USD")) {
				// yay
				o_test.title = "";
				o_test.style.textDecoration = "";
				}
			else {
				// warn
				o_test.title = "WorldPay accepts only EUR|GBP|USD but selected price plan accepts only " + pp_currency;
				o_test.style.textDecoration = "line-through";
				}
			}
		else {
			if (o_test == null) {
				}
			else if (pp_currency == tif_currency_WP) {
				// yay
				o_test.title = "";
				o_test.style.textDecoration = "";
				}
			else {
				// warn
				o_test.title = "WorldPay accepts only " + tif_currency_WP + " but selected price plan accepts only " + pp_currency;
				o_test.style.textDecoration = "line-through";
				}
			}

		o_test = document.getElementById( maybe_partner_2 + '_pm3_expl' );
		if (o_test == null) {
			}
		else if (pp_currency == tif_currency_GC) {
			// yay
			o_test.title = "";
			o_test.style.textDecoration = "";
			}
		else {
			// warn
			o_test.title = "Google Checkout accepts only " + tif_currency_GC + " but selected price plan accepts only " + pp_currency;
			o_test.style.textDecoration = "line-through";
			}


		o_test = document.getElementById( maybe_partner_2 + '_pm4_expl' );
		if (o_test == null) {
			}
		else {
			var b_sage_pay_ok = false;
			for (var i = 0; i < tif_currency_SP.length; i++) {
				if (tif_currency_SP[i] == pp_currency) {
					b_sage_pay_ok = true;
					break;
					}
				}
			if (b_sage_pay_ok) {
				// yay
				o_test.title = "";
				o_test.style.textDecoration = "";
				}
			else {
				// warn
				o_test.title = "Selected price plan accepts " + pp_currency + " but you have declared that your SagePay account does not support that currency";
				o_test.style.textDecoration = "line-through";
				}
			}


		}
	
	}


function dww_meta_status ( obj, write_back_id, max_chars ) {
	if (!obj) return;
	var o_write_back = object_by_id( write_back_id );
	if (!o_write_back) return;
	var curr_len = obj.value.length;
	var status = '(currently ' + curr_len + ')';
	if (curr_len > max_chars) {
		status = '<span style="color:#cc0000;background-color:#cccccc">' + status + '</span>';
		}
	o_write_back.innerHTML = status;
	}


/*

	called onchange for (input type=file) 

	i_error_handle:
		0: if error, alert() and log.  Always highlight_namespace
			return value "true" if passed validation, "false" if failed
		1: if error, return error-string.  Always highlight_namespace
		
		2: if error, alert() but do not log.  Highlight namespace.  Basically same as 0, but without logging

2006-09-08: map ".JPEG" to ".JPG" for validation purposes

*/

function validate_file_upload ( elem_obj, i_error_handle ) {
	var rv = '';
	for (;;) {
		if (!elem_obj) break;
		if (elem_obj.type != 'file') break;
		var this_filename = elem_obj.value;
		if (elem_obj.className == '') break;
		if (elem_obj.className.indexOf( 'vf_' ) != 0) break;
		var my_id = elem_obj.className.substr( 0, 8 );
		var b_is_error = true;
		var this_extension = 'NULL';
		var first_valid_extension = null;
		if (this_filename == '') {
			b_is_error = false;
			}
		else {
			var str_allowed_extensions = elem_obj.className.substr( 9, elem_obj.className.length ).toUpperCase();
			var a_allowed_extensions = str_allowed_extensions.split( '_' );
			this_filename = this_filename.toUpperCase();
			var flen = this_filename.length;
			if (this_filename.lastIndexOf( '.' ) != -1) {
				var test = this_filename.substring( this_filename.lastIndexOf( '.' ) + 1, flen );
				if (test.length < 8) {
					this_extension = test;
					}
				}
			/* 2006-09-08 forgiving mapping */
			if (this_extension == "JPEG") {
				this_extension = "JPG";
				}
			var o_so_pretty = '';/* returns "JPG" or "JPG or GIF" or "JPG, BMP, PNG or GIF" */
			for (var j = 0; j < a_allowed_extensions.length; j++) {
				o_so_pretty += a_allowed_extensions[j];
				if (first_valid_extension == null) {
					first_valid_extension = a_allowed_extensions[j].toLowerCase();
					}
				if (j < a_allowed_extensions.length - 2) {
					o_so_pretty += ', ';
					}
				else if (j == a_allowed_extensions.length - 2) {
					o_so_pretty += ' or ';
					}
				if (this_extension == a_allowed_extensions[j]) {
					b_is_error = false;
					break;
					}
				}
			}
		if (b_is_error) {
			if (this_extension == 'NULL') {
				rv = 'Error: cannot accept file ' + elem_obj.value + '.\n\nThat file has does not have a recognisable file extension.  This upload requires ' + o_so_pretty + ' files.  A file named, for example, "test.' + first_valid_extension + '" would be acceptable.\n\n';
				}
			else {
				rv = 'Error: cannot accept file ' + elem_obj.value + '.\n\nThat file has extension ' + this_extension + '.  This upload requires ' + o_so_pretty + ' files.\n\n';
				}
			}
		highlight_namespace( my_id, b_is_error );
		break;
		}
	if (i_error_handle == 0) {
		if (rv != '') {
			alert( rv );
			log_js_error( rv );
			return false;
			}
		else {
			return true;
			}
		}
	else if (i_error_handle == 2) {
		if (rv != '') {
			alert( rv );
			return false;
			}
		else {
			return true;
			}
		}
	else if (i_error_handle == 1) {
		return rv;
		}
	}

function set_fd_submit ( o ) {
	if (!o) return;
	var my_value = o.value;
	var forms = document.forms;
	for (var i = 0; i < forms.length; i++) {
		var inputs = document.forms[i].elements;
		for (var k = 0; k < inputs.length; k++) {
			if (inputs[k].name != 'fd_submit_udav') continue;
			inputs[k].value = my_value;
			break;
			}
		}
	}

var b_disable_on_submit = true;
var on_submit_xtra = function (obj) { return true }//redefine to add form-specific validators
function return_false(f) { return confirm( "This form has already been submitted once; are you sure you want to submit it again?"); }
//function return_false(f) { return false }
function on_submit(f) {
	if (!on_submit_xtra( f )) return false;
	var a_submit_elements = new Array();
	
	/* standard upload-file type validation */
	/* ie use {{ input type="file" class="vf_001_jpg_png_gif_bmp" }} */

	var str_display_error = '';

	var b_has_files = false;
	var b_has_submit = false;
	for (var i = 0; i < f.elements.length; i++) {
		var obj = f.elements[i];
		if (obj.name == 'fd_submit_udav') b_has_submit = true;
		if (obj.type == 'submit') {
			a_submit_elements.push( obj );
			}
		if (obj.type != 'file') continue;
		if (obj.value) b_has_files = true;
		str_display_error += validate_file_upload( obj, 1 );
		}
	if (str_display_error != '') {
		alert( str_display_error );
		log_js_error( str_display_error );
		return false;
		}
	
	/* end global file type validation */

	if (b_disable_on_submit) {

		for (var i = 0; i < a_submit_elements.length; i++) {
			var obj = a_submit_elements[i];
			if ((obj.name) && (!b_has_submit)) continue;
			if ((obj.className == 'submit sa') && (obj.value == 'Save All')) {
				obj.value = 'Saving...';
				}
			else if (b_has_files) {
				obj.value = 'Uploading - Please wait..';
				}
			if (obj.disabled) {
				// already disabled, do nothing
				}
			else {
//				obj.disabled = true;
				obj.style.cursor = 'default';
				}
			}
		on_submit = return_false;
		}
	
	return true;
	}


function rf_set_all_cb (name_contains, state_to_set) {
	set_all_checkboxes_named( name_contains, state_to_set );
	return false;
	}

function set_all_checkboxes_named ( name_contains, state_to_set ) {
	var forms = document.forms;
	for (var i = 0; i < forms.length; i++) {
		var inputs = document.forms[i].elements;
		for (var k = 0; k < inputs.length; k++) {
			if (inputs[k].type == "checkbox") {
				var name = inputs[k].name;
				if (name.indexOf( name_contains ) > -1) {
					var b_clicked = (inputs[k].checked != state_to_set);
				
					inputs[k].checked = state_to_set;
					if (name_contains == 'qua') {
						WMF_change_qua( inputs[k] );
						}
					if ((b_clicked) && (inputs[k].onclick) && (inputs[k].onclick != "undefined")) {
						inputs[k].onclick();
						}
					}
				}
			}
		}
	}

function set_all_radio_named ( name_contains, value_to_set ) {
	var forms = document.forms;
	for (var i = 0; i < forms.length; i++) {
		var inputs = document.forms[i].elements;
		for (var k = 0; k < inputs.length; k++) {
			if (inputs[k].type == "radio") {
				var name = inputs[k].name;
				var valu = inputs[k].value;
				if (name.indexOf( name_contains ) > -1) {
					inputs[k].checked = ( valu == value_to_set ) ? true : false;
					}
				}
			}
		}
	}

var g_cache_select_limit = null;
var g_cache_select = null;
function set_all_select_display_named ( name_contains, display_to_set ) {
	if (g_cache_select == null) {
		var count_select = 0;
		g_cache_select = new Array();
		var forms = document.forms;
		for (var i = 0; i < forms.length; i++) {
			var inputs = document.forms[i].elements;
			for (var k = 0; k < inputs.length; k++) {
				if (inputs[k].type == "select-one") {
					g_cache_select.push( inputs[k] );
					count_select++;
					if ((g_cache_select_limit != null) && (g_cache_select_limit <= count_select)) {
						break;
						}
//					inputs[k].style.visibility = display_to_set;
					}
				}
			if ((g_cache_select_limit != null) && (g_cache_select_limit <= count_select)) {
				break;
				}
			}
		}
	for (var i = 0; i < g_cache_select.length; i++) {
		var this_select_obj = g_cache_select[i];
		this_select_obj.style.visibility = display_to_set;
		}
	}

function highlight_namespace ( namespace, b_is_error ) {
	var color_back = "";
	var color_fore = "";
	if (b_is_error) {
		color_back = "#dddddd";
		color_fore = "#cc0000";
		}
	if (document.getElementById) {
		var i = 0;
		for (;;) {
			var cell = document.getElementById( namespace + "_" + i );
			if (cell == null) {
				break;
				}
			cell.style.backgroundColor = color_back;
			cell.style.color = color_fore;
			i++;
			}
		}
	}


/*

b_alert one of:

	0: do not alert() and do not log
	1: alert() to visitor, but do not log
	2: alert() to visitor and save to log

*/

function validate_by_schema ( form_object, schema, b_alert ) {
	var stub_errors = new Array();
	for (var i = 0; i < schema.length; i++) {
		var codename = schema[i][0];
		var value = get_form_value_by_name( form_object, codename );
		var stub = fd_validate( value, schema[i][1], schema[i][2], schema[i][3], schema[i][4], schema[i][5], schema[i][6] );
		var b_is_error = (stub != "");
		if (b_is_error) {
			stub_errors.push( stub );
			}
		highlight_namespace( codename, b_is_error );
		}

	if (stub_errors.length == 0) {
		return true;
		}
	var master = "";
	for (var i = 0; i < stub_errors.length; i++) {
		master += "Error: " + stub_errors[i] + ".\n\n";
		}
	if (b_alert > 0) {
		alert( master );
		}
	if (b_alert > 1) {
		log_js_error( master );
		}
	return false;
	}

function get_form_value_by_name ( form_object, name, b_no_recurse ) {
	var value = null;
	if (form_object == null) {
		alert( "Error: get_form_value_by_name was passed a null form object." );
		}
	else {
		for (var i = 0; i < form_object.length; i++) {
			var field_object = form_object[i];
			if (field_object.name != name) {
				continue;
				}
			var type = field_object.type;
			if ((type == "radio") || (type == "checkbox")) {
				if (!field_object.checked) continue;
				}
			if (field_object.type == "select") {
				value = field_object[field_object.selectedIndex].value;
				}
			else {
				value = field_object.value;
				}
			break; // no support for multi-name
			}
		if ((value == null) && (!b_no_recurse)) {
			value = get_form_value_by_name( form_object, name + "_udav", true );
			}
		}
	return value;
	}


function fd_validate ( value, type, min, max, b_allow_null, b_allow_blank, display_name, b_core_error_only ) {
	var error = "";
	var value_string = "" + value;
	for (;;) {

		if (value == null) {
			if (b_allow_null) break;
			error = "value cannot be null";
			break;
			}

		// from here on out, we are guaranteed that $value is defined

		if ((type == "int") || (type == "real")) {
			value_string = value_string.replace( "+", "" );
			}
		else if ((type == "httpurl") && (value_string.toLowerCase() == "http://")) {
			value_string = "";
			}

		var len = value_string.length;

		if (len == 0) {
			if (b_allow_blank) break;
			error = "value cannot be blank";
			break;
			}

		var sys_max_length = null;

		if (type == "email") {
			sys_max_length = 255;
			}
		else if (type == "hostname") {
			sys_max_length = 255;
			}
		else if (type == "regex") {
			sys_max_length = 65535;
			}
		else if (type == "file") {
			sys_max_length = 255;
			}
		else if (type == "folder") {
			sys_max_length = 255;
			}

		if (sys_max_length != null) {
			if (sys_max_length < len) {
				error = "value is " + len + " characters long but the maximum supported by this software is " + sys_max_length + " characters";
				break;
				}
			}

		var re;

		if ((type == "int") || (type == "real")) {
			if (type == "int") {
				re = new RegExp( "^-?\\d+$" );
				if (!value_string.match( re )) {
					error = "must match [-][number]";
					break;
					}
				}
			else {
				re = new RegExp( "^-?\\d*\\.?\\d*$" );
				if (!value_string.match( re )) {
					error = "must match [-][number][.number]";
					break;
					}
				}
			if (min != null) {
				if (value_string < min) {
					error = "minimum acceptable value is " + min;
					break;
					}
				}
			if (max != null) {
				if (value_string > max) {
					error = "maximum acceptable value is " + max;
					break;
					}
				}
			}
		else if (type == "string") {
			if (min != null) {
				if (len < min) {
					error = "string is " + len + " characters, but minimum acceptable length is " + min + " characters";
					break;
					}
				}
			if (max != null) {
				if (len > max) {
					error = "string is " + len + " characters, but maximum acceptable length is " + max + " characters";
					break;
					}
				}
			}
		else if (type == "stringplain") {
			var Forbid = new Array( "&", ">", "<", "\"" );
			for (var i = 0; i < Forbid.length; i++) {
				if (-1 == value_string.indexOf( Forbid[i] )) continue;
				error = "string cannot contain any of the following four characters: & > < \"";
				break;
				}
			if (error != "") break;
			error = fd_validate( value_string, "string", min, max, b_allow_null, b_allow_blank, display_name, true );
			if (error != "") break;
			}
		else if (type == "email") {
			re = new RegExp( "\\s" );
			if (value_string.match( re )) {
				error = "value cannot contain whitespace";
				break;
				}

			if (0 == value_string.indexOf( "." )) {
				error = 'email address cannot begin with a period "."';
				break;
				}
			if (-1 < value_string.indexOf( ".@" )) {
				error = 'email address cannot contain a period "." right before the at-sign "@"';
				break;
				}
			if (-1 < value_string.indexOf( ".." )) {
				error = 'email address cannot contain two periods ".." right next to each other';
				break;
				}


			// 2007-09-26 added:
			if (0 == value_string.indexOf( "'" )) {
				error = 'email address cannot begin with a single quote';
				break;
				}
			if (-1 < value_string.indexOf( "'@" )) {
				error = 'email address cannot contain a single quote right before the at-sign "@"';
				break;
				}
			if (-1 < value_string.indexOf( "''" )) {
				error = 'email address cannot contain two single quotes right next to each other';
				break;
				}
			re = new RegExp( "[^a-zA-Z0-9\\.\\-\\_\\'\\@]" );
			if (value_string.match( re )) {
				error = "username portion of email address may contain only alphanumerics, dot, underscore, hyphen, and single quote";
				break;
				}
			// end added


			re = new RegExp( "^(.+?)\\@(.+?)$" );
			if (!value_string.match( re )) {
				error = "must be of the format \"user\@host\"";
				break;
				}
			re = new RegExp( "\\.\\d+$" );
			if (value_string.match( re )) {
				error = "this system does not accept email addresses whose hostnames end with numbers";
				break;
				}
			var i = value_string.indexOf( "@" );
			var hostname = value_string.substring( i + 1 );
			error = fd_validate( hostname, "hostname", 1, 0, 0, 0, "", true );
			if (error != "") break;
			}
		else if (type == "hostname") {
			re = new RegExp( "[^a-zA-Z0-9\\.\\-]" );
			if (value_string.match( re )) {
				error = "value contains characters outside the allowed character set of A-Z, 0-9, . and -";
				break;
				}
			re = new RegExp( "(^-|--|-$)" );
			if (value_string.match( re )) {
				error = "hostname cannot begin with a hyphen, end with a hyphen, or have two hyphens next to each other";
				break;
				}
			re = new RegExp( "(^\\.|\\.\\.|\\.$)" );
			if (value_string.match( re )) {
				error = "hostname cannot begin with a period, end with a period, or have two periods next to each other";
				break;
				}
			re = new RegExp( "\\.\\d+$" );
			if (value_string.match( re )) {
				// okay -- is IP
				}
			else {
				var i = value_string.lastIndexOf( "." );
				var tld = value_string.substring( i + 1 );
				tld = tld.toLowerCase();
				var all_valid_tld = new Array("com","net","org","edu","gov","mil","aero","arpa","biz","coop","info","int","museum","name","pro","mobi","jobs","post","travel",				"ac","ad","ae","af","ag","ai","al","am","an","ao","aq","ar","as","at","au","aw","az","ax","ba","bb","bd","be","bf","bg","bh","bi","bj","bm","bn","bo","br","bs","bt","bv","bw","by","bz","ca","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","cr","cs","cu","cv","cx","cy","cz","de","dj","dk","dm","do","dz","ec","ee","eg","eh","er","es","et","eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","io","iq","ir","is","it","je","jm","jo","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mg","mh","mk","ml","mm","mn","mo","mp","mq","mr","ms","mt","mu","mv","mw","mx","my","mz","na","nc","ne","nf","ng","ni","nl","no","np","nr","nu","nz","om","pa","pe","pf","pg","ph","pk","pl","pm","pn","pr","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","st","sv","sy","sz","tc","td","tf","tg","th","tj","tk","tl","tm","tn","to","tp","tr","tt","tv","tw","tz","ua","ug","uk","um","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","ye","yt","yu","za","zm","zw");
				var b_match = false;
				for (var i = 0; i < all_valid_tld.length; i++) {
					if (tld == all_valid_tld[i]) {
						b_match = true;
						break;
						}
					}
				if (!b_match) {
					error = "unrecognized top-level domain \"" + tld + "\"";
					break;
					}
				}
			}
		else if (type == "bool") {
			if ((value_string != "0") && (value_string != "1")) {
				error = "value must be \"0\" or \"1\"";
				break;
				}
			}
		else if (type == "httpurl") {
			re = new RegExp( "^http://" );
			if (!value_string.match( re )) {
				error = "URL must start with \"http://\"";
				break;
				}
			}
		else if ((type == "regex") || (type == "file") || (type == "folder")) {
			// okay... no client-side validation defined
			}
		else {
			error = "unrecognized validation type \"" + type + "\"";
			break;
			}
		break;
		}
	if ((error) && (!b_core_error_only)) {
		var type_name = "value";
		if (display_name) {
			type_name = display_name;
			}
		else if (type == "int") {
			type_name = "integer value";
			}
		else if (type == "real") {
			type_name = "real number value";
			}
		else if (type == "string") {
			type_name = "string";
			}
		else if (type == "email") {
			type_name = "email address";
			}
		else if (type == "hostname") {
			type_name = "hostname value";
			}
		if (value_string.length > 0) {
			type_name += " \"" + value_string + "\"";
			}
		error = type_name + " failed validation; " + error;
		}
	return error;
	}








/*
Returns the DOM object for the given ID.  Should work on MSIE and Netscape.  Returns null if no matching object can be found.

*/

function object_by_id (id) {
	var obj = null;
	if (document) {
		if (document.getElementById) { // netscape + ie5
			obj = document.getElementById(id);
			}
		else if (document.all) { // ie4
			obj = document.all[id];
			}
		}
	return obj;
	}

function obidff ( id ) {
	var obj = object_by_id( id );
	if (obj == null) {
		var err = "Error: unable to get expected DOM object " + id + ".";
		Alert( err );
		log_js_error( err );
		}
	return obj;
	}

function log_js_error ( str ) {
	var src = "/?Action=Err&__is_js=1&msg=" + escape( str );
	var forms = document.forms;
	for (var i = 0; i < forms.length; i++) {
		var inputs = document.forms[i].elements;
		for (var k = 0; k < inputs.length; k++) {
			if (!inputs[k].name) continue;
			if (inputs[k].name == "_created") continue;
			if (inputs[k].name == "end_tag") continue;
			if (inputs[k].type == "select") continue;
			var valu = "";
			if (inputs[k].value) {
				valu = inputs[k].value;
				}
			var name = inputs[k].name;
			if ((name == "Action") || (name == "msg")) {
				name = "_" + name;
				}
			if (forms.length > 1) {
				name = k + "_" + name;
				}
			src += "&" + escape( name ) + "=" + escape( valu );
			}
		}
	if (src.length > 1024) {
		src = src.substring( 0, 1024 );
		}
	var Comm = new Image();
	Comm.src = src;
	}


function remove_event ( element, event_name, p_function ) {
	if (window.detachEvent) {
		element.detachEvent( 'on' + event_name, p_function );
		}
	else if (window.removeEventListener) {
		element.removeEventListener( event_name, p_function, false );
		}
	else {
		}
	}


function add_event ( element, event_name, p_function ) {
	if (window.attachEvent) {
		element.attachEvent( 'on' + event_name, p_function );
		}
	else if (window.addEventListener) {
		element.addEventListener( event_name, p_function, false );
		}
	else {
		}
	}


var none_for_images = function ( event_obj ) {
	//alert(1);
	var element = null;
	if (typeof( event ) != "undefined") {
		element = event.srcElement;
		}
	else {
		element = event_obj.target;
		}
	var rv = true;
	for (;;) {
		if (element == null) break;
		if (!element.className) break;
		if ((element.className != "thumb") && (element.className != "thumb noprint") && (element.className != "thumbmed") && (element.className != "thumbsmall") && (element.className != "sbs")) break;
		rv = false;
		break;
		}
	if (!rv) {
		//alert( 'break' );
		if (event_obj.preventDefault) {
			event_obj.preventDefault();//netscape
			}
		}
	return rv;
	};

var ga_onload = new Array();
function g_onload () {
	for (var i = 0; i < ga_onload.length; i++) {
		var this_function = ga_onload[i];
		this_function();
		}
	};

/* replaces the cp.writeDiv() function */

function cp_writeDivEx() {
	ga_onload.push( function() {
		var o_test = object_by_id( 'colorPickerDiv' );
		if (o_test == null) {
			var newdiv = document.createElement('div');
			newdiv.setAttribute('id', 'colorPickerDiv');
			newdiv.style.position = 'absolute';
			newdiv.style.visibility = 'hidden';
			newdiv.style.zIndex = 4;
			document.body.appendChild(newdiv);
			}
		} );
	}


if (-1 == location.href.indexOf( 'tif_privacy1=0' )) {
	add_event( document, 'contextmenu', none_for_images );
	}

if (-1 == location.href.indexOf( 'tif_privacy2=0' )) {
	add_event( document, 'dragstart', none_for_images );
	}

/* 2009-01-14 added mousedown to prevent drag-n-drop from Firefox 3 */

if (-1 == location.href.indexOf( 'tif_privacy3=0' )) {
	add_event( document, 'mousedown', none_for_images );
	}

if (-1 != location.href.indexOf( 'tif_privacy4=1' )) {
	add_event( document, 'touchstart', none_for_images );
	}

add_event( window, 'load', g_onload );


var tif_show_cache = new Array();
function tif_show(str,id) {
	var obj = object_by_id( 'tif_show_' + id );
	if (!obj) return;
	if (tif_show_cache[id] == null) {
		if (obj.innerHTML) {
			tif_show_cache[id] = obj.innerHTML;
			}
		else {
			return;
			}
		}
	if ((obj.innerHTML) && (tif_show_cache[id] != null)) {
		if (str == "") {
			str = tif_show_cache[id];
			}
		obj.innerHTML = str;
		}
	}


/* functions and variables for client-side table sorting */

function get_outer_html(id) {
	var html = null;
	var obj = object_by_id( id );
	if ((obj != null) && (obj.innerHTML)) {
		html = '<tr id="' + id + '">' + obj.innerHTML + '</tr>';
		}
	return html;
	}



var header_cache = null;
var footer_cache = null;
var outerHTML_cache = new Array();
var b_objects_read = false;
function read_objects(id_prefix,expected_count) {
	if (b_objects_read) {
		return true;
		}
	for (var i = 0; i < expected_count; i++) {
		var obj_key = id_prefix + i;
		var obj = object_by_id( obj_key );
		if (obj == null) {
			alert( "Error: could not load object " + obj_key );
			return false;
			}
		if (!obj.innerHTML) {
			alert( "Error: could not load .outerHTML property of object " + obj_key );
			return false;
			}
		html = obj.innerHTML;
		if (html == "undefined") {
			alert( "Error: .outerHTML property undefined for object " + obj_key );
			}
		outerHTML_cache[i] = '<tr id="' + obj_key + '">' + html + '</tr>';
		}
	b_objects_read = true;
	return true;
	}
var b_reverse = false;
var current_sort = -1;
var b_working = false;
function sortTable(id_prefix,a_sort_list) {
	if (b_working) {
		return;
		}



	b_working = true;

	var new_table_html = "";

	var sort_list = global_sort_by_id[ a_sort_list ];

	// last array element is 1 for forward-sorted and 0 for reverse-sorted
	if (a_sort_list == current_sort) {
		b_reverse = !b_reverse;
		}
	else {
		var final_array_elem = sort_list[ sort_list.length - 1 ];
		b_reverse = ( final_array_elem == 0 );
		}

	if (!read_objects( id_prefix, sort_list.length - 1 )) {
		return false;
		}

	for (var i = 0; i < ( sort_list.length - 1 ); i++) {
		var this_row = outerHTML_cache[ sort_list[ i ] ];
		if ("" + this_row == "undefined") {
			alert( "Error: outerHTML_cache returned 'undefined' on key " + sort_list[i] );
			return false;
			}
		if (b_reverse) {
			new_table_html = this_row + new_table_html;
			}
		else {
			new_table_html += this_row;
			}
		}
	var container_obj = object_by_id( id_prefix );
	if ((container_obj) && (container_obj.innerHTML)) {

		if (header_cache == null) {
			header_cache = "";
			var i = 0;
			while (true) {
				var this_key = id_prefix + "_header_" + i;
				i++;
				var this_html = get_outer_html( this_key );
				if (this_html == null) {
					break;
					}
				header_cache += this_html;
				}
			}
		if (footer_cache == null) {
			footer_cache = "";
			var i = 0;
			while (true) {
				var this_key = id_prefix + "_footer_" + i;
				i++;
				var this_html = get_outer_html( this_key );
				if (this_html == null) {
					break;
					}
				footer_cache += this_html;
				}
			}
		new_table_html = '<table border="1" cellpadding="4" cellspacing="0" style="width:100%">' + header_cache + new_table_html + footer_cache + '</table>';
		container_obj.innerHTML = new_table_html;
		}

	// update status
	var i = 0;
	while (true) {
		var key = id_prefix + '_ss_' + current_sort + '_' + i; i++;
		var obj = object_by_id( key );
		if (obj == null) {
			break;
			}
		obj.style.borderBottom = "2px solid #000000";
		}
	i = 0;
	while (true) {
		var key = id_prefix + '_ss_' + a_sort_list + '_' + i; i++;
		var obj = object_by_id( key );
		if (obj == null) {
			break;
			}
		if (b_reverse) {
			obj.style.borderBottom = "2px solid #ff4444";
			}
		else {
			obj.style.borderBottom = "2px solid #8888ff";
			}
		}
	current_sort = a_sort_list;
	b_working = false;
	}


/* write during load; used for JS progress bar while loading large tables */
function write_dl (id, str) {
	var o = object_by_id( id );
	if (o != null) {
		if (str == "") {
			o.style.display = 'none';
			}
		else {
			o.style.display = 'block';
			o.innerHTML = str;
			}
		}
	}


var g_sid = "";
var g_skin = "";
function set_persistent_fields (sid,skin) {
	g_sid = sid;
	g_skin = skin;
	}
function add_to_lightbox (file_id,o_caller) {
	if (o_caller != null) {
		var o = new Image();
		o.src = o_caller.href + "&mode=1"; // adds image in "quiet mode"
/*
		o_caller.href += "&mode=2"; // will now link to Lightboxes interactively
		o_caller.onclick = rtrue;
		o_caller.target = '';
		o_caller.innerHTML = '<img src="/images/cp/16/lightbox_in.gif" height="16" width="16" alt="view lightbox" border="0" style="margin-right:4px" />';
*/
		var i = 0;
		while (true) {//update all icons
			var o_test = object_by_id( "lbxi_" + file_id + "_" + i );
			i++;
			if (o_test == null) break;
			o_test.src = "/images/cp/16/lightbox_in.gif";
			}
		i = 0;
		while (true) {//update all links
			var key = "lbxa_" + file_id + "_" + i;
			var o_test = object_by_id( key );
			i++;
			if (o_test == null) break;
			o_test.href += "&mode=2";
			o_test.onclick = rtrue;
			o_test.target = '';
			}
		i = 0;
		while (true) {//update all test
			var o_test = object_by_id( "lbxt_" + file_id + "_" + i );
			i++;
			if (o_test == null) break;
			o_test.innerHTML = "view lightbox";
			}
		}
	return false;
	}
function rtrue() {
	return true;
	}


function html_encode(str) {
	var rv = "";
	str = str.toString();
	for (var i = 0; i < str.length; i++) {
		var ch = str.substr( i, 1 );
		if (ch == "<") {
			rv += "&lt;";
			}
		else if (ch == ">") {
			rv += "&gt;";
			}
		else if (ch == "&") {
			rv += "&amp;";
			}
		else if (ch == "\"") {
			rv += "&quot;";
			}
		else {
			rv += ch;
			}
		}
	return rv;
	}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;
	for (i=0; a && i < a.length &&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}


/* general workaround for kb912945 issues */
function tif_write (str) {
	document.write( str );
	}


var alert_count = 0;
function Alert ( str ) {
	if (alert_count > 3) {
		return;
		}
	alert_count++;
	alert( str );
	}

function supportsIeTrans (trans_name) {
	var detect = navigator.userAgent.toLowerCase();
	if (-1 < detect.indexOf("safari")) {
		return false;
		}
	var allowed_transitions = new Array(
		'Iris',
		'Blinds',
		'CheckerBoard',
		'RandomDissolve',
		'Barn',
		'Strips',
		'RandomBars'
		);
	var b_matched = false;
	for (var i = 0; i < allowed_transitions.length; i++) {
		if (allowed_transitions[i] == trans_name) {
			b_matched = true;
			break;
			}
		}
	if (!b_matched) {
		return false;
		}
	if ((typeof( document.body.filters ) == "object") && ("filters" in document.body) && (trans_name in document.body.filters))
		return true;
	else
		return false;
	}


/* http://www.dhtmlnirvana.com/program/archives/Opera-9-Object-Detection.html */
function opacityDetect() {


/* 2009-06-11 no longer blacklisting safari

	//2006-05-11 for now, disable transitions in safari
	var detect = navigator.userAgent.toLowerCase();
	if (-1 < detect.indexOf("safari")) {
		return false;
		}

*/



	if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7alpha+, Safari 1.2+)
		return true;
	else if ((typeof( document.body.filters ) == "object") && ("filters" in document.body) && ("alpha" in document.body.filters)) // Internet Exploder
		return true;
//	else if (typeof document.body.style.MozOpacity == 'string') // older Mozilla, Netscape 7.x
//		return true;
//	else if (typeof document.body.style.getPropertyValue("-khtml-opacity") == 'string') // Konqueror, older Safari
//		return true;
	else // opacity not supported
		return false;
	}

function pd_set_state ( form_prefix, pd_index, b_show, str_type ) {
	var key = form_prefix + 'pd' + pd_index;
	var o = obidff( key );
	if (b_show) {
		o.style.height = '';
		o.style.overflow = '';
		}
	else {
		o.style.height = '1px';
		o.style.overflow = 'hidden';
		}
	var o_e = obidff( key + 'e' );
	var o_c = obidff( key + 'c' );
	if (b_show) {
		o_e.style.display = 'block';
		o_c.style.display = 'none';
		}
	else {
		o_e.style.display = 'none';
		o_c.style.display = 'block';
		}
	if (str_type == 'meta') {
		var this_value = get_cookie( 'tif_pss_' + str_type );
		var this_num = b_show ? 'x1' : 'x0';
		var three_num = this_num + this_value;
		var expires = new Date((new Date()).getTime() + 365 * 24 * 60 * 60 * 1000);
		var c = "tif_pss_" + str_type + "=" + three_num.substr( 0, 6 ) +
			"; expires=" + expires.toGMTString() +
			"; path=/; domain=" + location.host;
		document.cookie = c;
		}
	}

function pd_set_defaults ( form_prefix, pd_index, b_show, str_type ) {
	var this_value = get_cookie( 'tif_pss_' + str_type );
	if (this_value == 'x1x1x1') {
		b_show = true;
		}
	pd_set_state( form_prefix, pd_index, b_show );
	}


function get_cookie ( c_name ) {
	var str_value = '';
	if (document.cookie.length > 0) {
		var c_start = document.cookie.indexOf( c_name + '=' );
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf( ';', c_start );
			if (c_end == -1) c_end = document.cookie.length;
			str_value = unescape( document.cookie.substring( c_start, c_end ) );
			}
		}
	return str_value;
	}


function ss2_expose ( url_url, i_type ) {
	var start_slideshow = object_by_id( 'start_slideshow' );
	if (i_type == 0) {
		if ((start_slideshow) && (start_slideshow.innerHTML)) {
			start_slideshow.href = unescape( url_url );
			}
		}
	else if (i_type == 1) {
		if (start_slideshow) {
			var test = object_by_id( 'slide_control' );
			if ((test) && (test.innerHTML)) {
				start_slideshow.href = unescape( url_url );
				}
			}
		}
	}

function ss3_navigate ( url_url_fragment ) {
	var this_url = "/ss/?" + unescape( url_url_fragment );
	location.href = this_url;
	return false;
	}













function sff_profit_calc ( obj, cost, echo_id, i_use_babel ) {
	if (obj == null) {
		return;
		}
	var new_price = obj.value;
	var min_price = ( i_use_babel == 1 ) ? 0 : cost;
	/* 2009-03-06 ignore tiered pricing */
	
	if (new_price.indexOf( "/" ) != -1) {
		return;
		}

	var stub = fd_validate( new_price, 'real', min_price, 9999.99, 0, 0, 'Price' );
	if (stub != '') {
		alert( "Error: " + stub + "." );
		return;
		}
	var profit = new_price - cost;
	var echo_obj = object_by_id( 'sff_profit_' + echo_id );
	if (echo_obj == null) {
		return;
		}
	echo_obj.innerHTML = profit.toFixed(2);
	}





/* Column Header Help */

var chh_event = null;
var chh_e_str = '';
var chh_e_obj = null;
var chh_e_bia = true;

var chh_width = 400;

function chh_init () {
	document.write('<script type="text/javascript" src="/images/cp/z_pos.js"></' + 'script>');
	document.write('<div id="chh_container" style="position:absolute;top:1px;left:1px;visibility:hidden;border:2px solid #000000!important;color:#000000!important;background-color:#ffffee!important;width:' + chh_width + 'px;padding:5px;z-index:9"><br /></' + 'div>');
	}


function chh_show ( str_ue_explanation, trigger_obj, b_bias_top ) {
	chh_e_str = str_ue_explanation;
	chh_e_obj = trigger_obj;
	chh_e_bia = b_bias_top;
	if (chh_event != null) {
		window.clearTimeout( chh_event );
		}
	chh_event = window.setTimeout( 'chh_show_actual()', 150 );
	}

function chh_show_actual () {
	var chh_o = object_by_id( 'chh_container' );
	if (chh_o == null) return;

	set_all_select_display_named( '', 'hidden' );

	var my_pos = Position.get( chh_e_obj );
	chh_o.innerHTML = unescape( chh_e_str );

	var he_pos = Position.get( chh_o );

	var set_left = my_pos.left + my_pos.width - chh_width - 15;
	set_left = Math.max( 30, set_left );

	var set_top = my_pos.top - he_pos.height - 6;
	if ((set_top < 30) || (!chh_e_bia)) {
		set_top = my_pos.top + my_pos.height + 6;
		}

	chh_o.style.top = set_top + "px";
	chh_o.style.left = set_left + "px";
	chh_o.style.visibility = 'visible';
	chh_e_obj.style.backgroundColor = '#ffffee';
	}


function chh_hide ( trigger_obj ) {
	if (chh_event != null) {
		window.clearTimeout( chh_event );
		}

	var chh_o = object_by_id( 'chh_container' );
	if (chh_o == null) return;

	chh_o.innerHTML = '';
	chh_o.style.visibility = 'hidden';
	trigger_obj.style.backgroundColor = '';
	set_all_select_display_named( '', 'visible' );
	}

function video_path (str_url) {
	var vpath = '/' + 'v';
	return vpath + vpath + str_url.substr( 8, 58 );
	}



function get_stylesheet_rules ( index ) {
	if (!document.styleSheets) return null;
	if (!document.styleSheets[index]) return null;
	if (document.styleSheets[index].cssRules) return document.styleSheets[index].cssRules;
	if (document.styleSheets[index].rules) return document.styleSheets[index].rules;
	return null;
	}


function set_js_styles () {
	var a_rules = get_stylesheet_rules( 0 );
	if (!a_rules) return;

	if ((a_rules[0]) && (a_rules[0].style)) {
		a_rules[0].style.visibility = 'visible';//.needs_javascript_visible { visibility:visible }
		}

	if (a_rules[1]) {
		a_rules[1].style.display = 'block';//.needs_javascript_block { display:block }
		}

	if (a_rules[2]) {
		a_rules[2].style.display = 'inline';//.needs_javascript_inline { display:inline }
		}

	if (a_rules[11]) {
		a_rules[11].style.display = 'none';
		}
		
	if (a_rules[12]) {
		a_rules[12].style.display = 'none';
		}

	if (a_rules[13]) {
		a_rules[13].style.visibility = 'hidden';
		}

	if (a_rules[14]) {
		a_rules[14].style.height = '2em';
		}

	var b_is_ie = false;
	var detect = navigator.userAgent.toLowerCase();
	if (((-1 < detect.indexOf( "internet explorer" )) || (-1 < detect.indexOf( "msie" ))) && (document.all)) {
		// IE
		b_is_ie = true;
		}

	if ((b_is_ie) && (false)) {

		// .table_header_public
		a_rules[3].style.filter = "progid:DXImageTransform.Microsoft.Gradient(startColorStr='#43a543', endColorStr='#87e987', gradientType='0')";

		// .table_header_client
		a_rules[4].style.filter = "progid:DXImageTransform.Microsoft.Gradient(startColorStr='#d33a30', endColorStr='#ff7f70', gradientType='0')";

		// .table_header_folios
		a_rules[5].style.filter = "progid:DXImageTransform.Microsoft.Gradient(startColorStr='#4a56c9', endColorStr='#8e9aff', gradientType='0')";

		// .table_header_default
		a_rules[6].style.filter = "progid:DXImageTransform.Microsoft.Gradient(startColorStr='#aaaaaa', endColorStr='#eeeeee', gradientType='0')";

		// .gradient_v_22222_ffffff
		a_rules[8].style.filter = "progid:DXImageTransform.Microsoft.Gradient(startColorStr='#222222', endColorStr='#ffffff', gradientType='0')";

		// .panel
		if (document.styleSheets.length == 1) {
			a_rules[9].style.filter = "progid:DXImageTransform.Microsoft.Gradient(startColorStr='#aaaaaa', endColorStr='#ffffff', gradientType='0')";
			}
		}
	}
set_js_styles();
