var regExEmail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
var regExWebsite = /^(http:\/\/)?\w+([\.-]?\w+)*\w+([\.-]?\w+)*(\.\w+)+(\/)?(\w+)?$/;
var regExReq = /.+/;
var regExReq6 = /.{6}/;
var regExNum = /^[\d]+$/;

function Toggle(obj)
{
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
}

function AutoToggle(obj)
{
	var el = document.getElementById(obj);
	if (el.style.display == 'none') el.style.display = '';
}

function Show(obj)
{
	document.getElementById(obj).style.display = '';
}

function Hide(obj)
{
	document.getElementById(obj).style.display = 'none';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function ShowSwatch(obj, value, id)
{
	var target = document.getElementById('swatch_viewer');
	var coords = findPos(obj);
	if (coords[0] < 130) coords[0] = 130;
	if (coords[1] < 130) coords[1] = 130;
	//target.style.left = (coords[0] - 122) + "px";
	//target.style.top = (coords[1] - 122) + "px";
	target.style.left = (coords[0] + 18) + "px";
	target.style.top = (coords[1] + 18) + "px";
	if (id) target.innerHTML = "<img src='/images/swatches/" + id + ".jpg' />";
	if (value) target.style.backgroundColor=value;
	target.style.display="inline";
}

function HideSwatch()
{
	var obj = document.getElementById('swatch_viewer');
	obj.style.display="none"
	obj.innerHTML = " ";
	obj.style.backgroundColor="#fff"
}

function ShowPopup(file, width, height, scroll)
{
	if (scroll) mywindow = window.open (file, "mywindow","location=0,status=0,scrollbars=1,width=" + width + ",height=" + height);
	else mywindow = window.open (file, "mywindow","location=0,status=0,scrollbars=0,width=" + width + ",height=" + height);
	mywindow.moveTo(0,0);
}