document.domain = '34sp.com';
var FIRSTPASS = 0;
function checkRefreshTime() {
}
// generic js for 34sp.com site
// used to preload images in browser cache
function preload_images() {
	// give document a symbol
	var d = document;
	// array of registered images
	if (!d.IMGS && d.images) {
		d.IMGS = new Array();
	}
	
	// register images here
	var args = preload_images.arguments;
	
	// the length of the array
	var arrLength = d.IMGS.length;
	
	// iterate through each argument and load them
	for(n=0; n<args.length; n++) {
		// check the image name is ok
		if (args[n].indexOf("#")!=0) {
			// make a new image and add an image to it
			d.IMGS[arrLength] = new Image;
			d.IMGS[arrLength++].src = args[n];
		}
	}
}

// used to create rollover effect and rollout likewise
function switch_image(id, image) {
	if (id.src>'') {
		id.src = image;
	}	// its not passed as this
	// get the id
	id = document.getElementById(id);
	if (id) {
		id.src = image;
	}
}
// is going to apply various css affects
function apply_css(id, style, value) {
	// test the element exists
	var id = document.getElementById(id);
	
	if (id) {
		// detect css effect and deal
		if (style=='display') {
			// figure out what display to apply
			try {
				if (id.style.display=='table-row') {
					id.style.display = 'none'; // make it visible
				} else {
					id.style.display = 'table-row'; // make it hidden
				}
			} catch(exception) {
				if (id.className=='show_tr') {
					id.className = 'hide'; // make it visible
				} else {
					id.className = 'show_tr'; // make it hidden
				}
			}
		} else if (value>'') {
			eval("id.style."+style+" = '"+value+"';");
		}
	}
}

// this function forces prices to format 00.00
function price_format(price) {
	var regex_float_10_2 = /\.[0-9]$/;	// regex to see if last digit is missing a 0
	var regex_round_2 = /\./;	// see if it has a decimal place if not make it have one
	var no_dps = /\.$/;	// see if it has a decimal place if not make it have one
	var more_than_2dp = /\.[0-9]{3,}$/;	// see if it has a decimal place if not make it have one
	
	// check for 0. with no 00
	if (more_than_2dp.test(price)) {
		price = Math.round(price*100)/100;
	}
	
	// check first for the missing 0
	if (regex_float_10_2.test(price)) {
		return price.toString()+"0";
	}
	
	// check for no .00
	if (!regex_round_2.test(price)) {
		return price.toString()+".00";
	}
	
	// check for 0. with no 00
	if (no_dps.test(price)) {
		return price.toString()+"00";
	}
	
	// if not matched above return price
	return price;
}

window.onmousedown = function () {
	var helpdiv = document.getElementById("FORMhelptext");
	if (helpdiv) {
			helpdiv.style.display = 'none';
	}
}

// used to show the help text on the site
function help_text(id, text) {
	var helpdiv = document.getElementById("FORMhelptext");
	// move the help div to the given location
	if (helpdiv) {
		helpdiv.style.display = 'inline';
		var text = '<div class="helpbox" id="helpbox123"><img src="images/helpbox-top.png" /><div class="helpboxcontent"><p>'+text+'</p></div><img src="images/helpbox-bottom.png" /></div>';
	
		helpdiv.innerHTML = text;
	
		// get the coords for this element
		var coords = get_coords(id);
		
		helpdiv.style.left = (coords['x']+9)+"px";
		helpdiv.style.top = ((coords['y'])+10)+"px";
	}
}

// get the x and y from a given id
function get_coords(id) {
	// used to store the x and y positions
	var X = 0, Y = 0;

	// check the elements exist in the document object model
	if (id) {
		// get the x and y abs position of the domains button
		// clone the reference to the domain button
		var current_element = id;
		// iterate through all valid parents of this button that have a positional affect
		while(current_element) {
			// keep tally of the x and y values cumulatively
			X += current_element.offsetLeft;
			Y += current_element.offsetTop;
		
			// move the internal pointer to the direct parent of the current element
			current_element = current_element.offsetParent;
		}
		
		var coords = new Array();
		coords['x'] = X;
		coords['y'] = Y;
		
		return coords;
	}
}