var baseUrl = "http://www.fynd.com/";
var charMatch = /^[a-z0-9\-]+$/i;
var field;
var fieldDiv;
var source;
var account;

function initDiv()
{
	if (document.getElementById || document.all)
	{
		document.write(unescape("%3Cdiv id='drop' style='position: absolute;z-index: 1;visibility: hidden;left: 0px;top: -1000px;width: 1px;height: 1px;border: 1px solid #000000;background: #ffffff;'%3E%3Cdiv id='content' style='margin: 2px;font-family: arial,sans-serif;font-size: 10px;'%3E&nbsp;%3C/div%3E%3C/div%3E"));
	}
}

function focusNext(f)
{
	var img = document.getElementById(f);
	img.focus();
}

function getXmlData(url)
{
//	url = url + "&cacheControl=" + new Date().getTime();
	error = 0;

//	alert(url);

	if (window.XMLHttpRequest)
	{
		var client = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) 
	{
		var client = new ActiveXObject("Microsoft.XMLHTTP");
	}
	client.onreadystatechange = handler;
	client.open("GET",url,true);
	client.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	client.send(null);

	function handler()
	{
		if (this.readyState == 4 && this.status == 200)
		{
			if (this.responseXML != null && this.responseXML.getElementsByTagName('response')[0].hasChildNodes())
			{
				xmlResponseHandler(this.responseXML);
//				errorCheck(this.responseXML);
			}
		}
// else if (this.readyState == 4 && this.status != 200)
//		{
//			errorCheck(null);
//		}
	}

	function errorCheck(data)
	{
//	alert('Y');
		try{
//	alert('Z');
			if (data.getElementsByTagName('errorCode')[0].hasChildNodes())
			{
				error = data.getElementsByTagName('errorCode')[0].firstChild.data; 
				if (error == 0)
				{
					xmlResponseHandler(data);
				}
				else
				{
					closeList();
				}
			}
			else
			{
				closeList();
			}
		} catch (e){}
	}
	return;
}

function getListBox()
{
	if (document.getElementById)
		return document.getElementById('drop').style;
	else 
		if (document.all) 
			return document.all.drop.style;
}

function closeList()
{
	var listBox = new Object(getListBox());
	try{
		listBox.left = "-1000px";
		listBox.top = "-1000px";
		listBox.width = "1px";
		listBox.height = "1px";
		listBox.visibility = "hidden";
	}
	catch(e) {}
}

function getElementPosition(obj)
{
	var position = new Object();
	position.left = calcLeftPosition(obj);
	position.top = calcTopPosition(obj);
	return(position);
}

function calcLeftPosition(obj)
{
	var x = obj.offsetLeft;
	while(obj.offsetParent)
	{
		x += obj.offsetParent.offsetLeft;
		obj = obj.offsetParent;
	}
	return(x);
}

function calcTopPosition(obj)
{
	var y = 0;
	if (obj.offsetParent)
	{
		while (1)
		{
			y += obj.offsetTop;
			if (!obj.offsetParent)
			{
				break;
			}
			obj = obj.offsetParent;
		}
	}
	else 
	{
		if (obj.y)
		{
			y += obj.y;
		}
	}
	return(y);
}

function firstFocus(myForm)
{
	try {
		document.getElementById(myForm).elements[0].focus();
	} catch (e){}
}

function decPl(d,p)
{
	var j = 0;
	var j1 = 0;
	var d1 = (+d);
	var s1 = new String();
	var s2 = new String();
	var s3 = new String();
	var i = new String();
	var f = new String();
	if (d1 != 0)
	{
		if (p < 0)
		{
			p = 0;
		}
		for (j = 0;j < p;j++)
		{
			d1 *= 10;
		}
		if (d < 0)
		{
			d1 -= 0.5;
		}
		else
		{
			d1 += 0.5;
		}
		s3 = d1.toString();
//	alert(s3);
		j = 0;
		do
		{
			if (j >= s3.length)
			{
				break;
			}
			s2 = s3.substring(j, j + 1);
			if (s2 == ".")
			{
				break;
			}
			s1 = s1 + s2;
			j++;
		} while(true);
		d1 = s1.valueOf();
		for (j = 0; j < p; j++)
		{
			d1 *= 0.1;
		}
//	alert(d1);
	}

	s3 = d1.toString();
	j = 0;
	var flag = 0;
	do
	{
		if (j >= s3.length)
		{
			break;
		}
		s2 = s3.substring(j,(j + 1));
		if (flag == 0)
		{
			i = i + s2;
		}
		else
		{
			f = f + s2;
		}
		if (s2 == ".")
		{
			flag = 1;
		}
		j++;
	} while(true);
	if (flag == 0 && p > 0)
	{
		i = i + ".";
	}
	if (f.length < p)
	{
		for (j = 0;j < p;j++)
		{
			f = f + "0";
		}
	}
	s3 = i + f.substring(0,p);
	return s3;
}

function validDate(d,m,y)
{
	var day, month, year, ix;
	ix = d.selectedIndex;
	day = d.options[ix].value;
	ix = m.selectedIndex;
	month = m.options[ix].value;
	ix = y.selectedIndex;
	year = y.options[ix].value;
	if (day == '--' 
		&& (month != '--' || year != '----'))
	{
		return false;
	}
	if (month == '--' 
		&& (day != '--' || year != '----'))
	{
		return false;
	}
	if (year == '----' 
		&& (day != '--' || month != '--'))
	{
		return false;
	}
	if (month == 2)
	{
		if (year % 4 == 0 && year % 4 != 125)
		{
			if (day > 29)
			{
				return false;
			}
		}
		else
		{
			if (day > 28)
			{
				return false;
			}
		}
	}
	if (month == 4 || month == 6 || month == 9 || month == 11)
	{
		if (day > 30)
		{
			return false;
		}
	}
	return true;
}

function setContent(f,c)
{
	document.getElementById(f).innerHTML = unescape(c);
}

function setColor(f,c)
{
	document.getElementById(f).style.color = c;
}

