function browserVersion()
{
   g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
   if (g_fIsSP2)
   {
   //This browser is Internet Explorer in SP2. 
   }
   else
   {
   //This browser is not Internet Explorer in SP2.
   }
}
function DWSModalDialog(URL, height, width)
{
	var retval = "";
	
	p = document.getElementById('ExpirePage');
	if (p != null)
	{
		if (p.value > 0)
		{
			clearTimeout(p.value);
			p.value = '0';
		}
	}
	if (width == 0) width = 500;
	if (height == 0) height = 650;
	var maxWidth = .99 * screen.AvailWidth;
	var maxHeight = .90 * screen.AvailHeight;

	// Check of XP SP2 and elongate since it does not allow you to remove the status bar.
//	g_fIsSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
//	if (g_fIsSP2)
		height = height + 20;

	if (width > maxWidth)
		width = maxWidth;
	if (height > maxHeight)
		height = maxHeight;
	
	var args = "dialogHeight:" + height + "px; dialogWidth:" + width + "px; edge: Raised; scroll:no;  center: Yes; help: yes; resizable: no; status: yes;";

	if (URL.indexOf("?") >= 0)
		URL += "&"
	else
		URL += "?";
	URL = URL + "WindowHeight="+height+"&WindowWidth="+width;
	retval = window.showModalDialog(URL, this, args);
	if(retval!="" && retval!=null)
		location.reload();
	else
	if (p != null)
		startSessionTimer();
}
function IsMainDialog() {return true;}

function ShowDialog(URL, title, height, width)
{
	var retval = "";
	
	var maxWidth = .99 * screen.AvailWidth
	var maxHeight = .90 * screen.AvailHeight
	if (width > maxWidth)
		width = maxWidth;
	if (height > maxHeight)
		height = maxHeight;
		
	var args = "dialogHeight:" + height + "px; dialogWidth:" + width + "px; edge: scroll:no; Raised; center: Yes; help: no; resizable: no; status: no;";

	retval = window.showModalDialog("/admin/dialogFrame.aspx?dialog="+URL+"&Title="+title, this, args);
	if(retval!="" && retval!=null)
	{
		location.reload();
	}
}

function PassMarketingCode(address)
{
	var ss = location.search.toLowerCase();
	var i = ss.indexOf("msc=");
	qs = "";
	if (i > 0)
		qs = "&" + location.search.substr(i);
	location.href = address + qs;
}
function encodeemail(address)
{
	var temparray = address.split("@");
	var result = temparray.join("*DWS*");
	return result;
}

function decodeemail(address)
{
	var temparray = address.split("*DWS*");
	var result = temparray.join("@");
	return result;
}

function sendmail (address)
{
	var result = decodeemail(address);
	window.open ('mailto:'+result,'_blank');
}

function AddProductToCart(business, productname, productnumber, productamount)
{
	var addproduct = document.forms.addproduct;
	if (!addproduct) {
		var str= "<form id='addproduct' target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
//		str += "<input type="image" src="https://www.paypal.com//en_US/i/btn/sc-but-03.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
		str += "<input type='hidden' name='add' value='1'>";
		str += "<input type='hidden' name='cmd' value='_cart'>";
		str += "<input type='hidden' name='business' value='"+business+"'>";
		str += "<input type='hidden' name='item_name' value='"+productname+"'>";
		str += "<input type='hidden' name='item_number' value='"+productnumber+"'>";
		str += "<input type='hidden' name='amount' value='"+productamount+"'>";
		str += "<input type='hidden' name='no_note' value='1'>";
		str += "<input type='hidden' name='currency_code' value='USD'>";
		str += "<input type='hidden' name='lc' value='US'>";
		str += "</form>";
		document.body.insertAdjacentHTML("afterBegin",str);
	} else {
		document.forms.addproduct.business.value = business;
		document.forms.addproduct.item_name.value = productname;
		document.forms.addproduct.item_number.value = productnumber;
		document.forms.addproduct.amount.value = productamount;
	}
	document.forms.addproduct.submit();
}

function ViewCart(business)
{
	var viewcart = document.forms.viewcart;
	if (!viewcart) {
		var str = "<form id='viewcart' target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
		str += "<input type='hidden' name='cmd' value='_cart'>";
		str += "<input type='hidden' name='business' value='"+decodeemail(business)+"'>";
		str += "<input type='hidden' name='display' value='1'>";
		str += '</'+'form>';
		document.body.insertAdjacentHTML("afterBegin",str);
	}
	document.forms.viewcart.submit();
}

function SelectRow(td)
{
}