function OpenSalesInfo()
{ 
	var strLocation = new String(document.location);
	var strTemp;
	strLocation = strLocation.toLowerCase();
	if (strLocation.indexOf("product", 50) > 0)
		strTemp = "../SalesInfo/index.asp";
	else
	{
		if (strLocation.indexOf("directory", 1) > 0)
			strTemp = "SalesInfo/index.asp";
		else
			strTemp = "BusDirectory/SalesInfo/index.asp"
	}	

	newWindow = window.open(strTemp, "SalesInformation","location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,width=625,height=560"); 
}

function OpenMainImage(ID)
{ newWindow = window.open("Product_MainImage.asp?ID="+ID, "MainImage","location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,width=425,height=500"); }

function OpenProfile(ID)
{ 
	var strLocation = new String(document.location);
	var strTemp;
	strLocation = strLocation.toLowerCase();
	if (strLocation.indexOf("product", 50) > 0)
		strTemp = "../Profile.asp?ID="+ID;
	else
	{	if (strLocation.indexOf("directory", 1) > 0)
			strTemp = "Profile.asp?ID="+ID;
		else
			strTemp = "BusDirectory/Profile.asp?ID="+ID;
	}
	newWindow = window.open(strTemp, "BusinessProfile","location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,width=600,height=550,top=10,left=30,screenX=30,screenY=10"); 
}

function OpenPrintWindow(ID)
{

newWindow = window.open("Print.asp?ID="+ID, "PrintBusinessProfile","location=no,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes,resizable=yes,width=625,height=425,top=10,left=30,screenX=30,screenY=10"); 

}

function btn_Email(ID)
{
	window.close();
	window.opener.location = "Email.asp?ID="+ID;

}

function btn_WebSite(URL)
{   window.close();
	window.opener.location.href = "http://"+URL;
}

function btn_Products(ID)
{   window.close();
	window.opener.location = "ProductCatalog/Products.asp?ID="+ID;
}

function btn_Coupons(ID)
{
	window.close();
	window.opener.location = "Coupons/ViewCoupon.asp?ID="+ID;

}

//--- Referral System Function ---

function Registration_Validation(frm)
{
	if(frm.Name.value.length < 2)
	{	alert("Your Name is required before you can register"); return; }
	if(frm.Address.value.length < 28)
	{	alert("Please include your COMPLETE mailing address: City, Province, & Postal Code\n\nCheques will ONLY be mailed to the registered address"); return; }
	if(frm.Phone.value.length < 12)
	{	alert("Please include your phone number including area code"); return; }
	frm.submit();
}

function Referral_Validation(frm)
{
	if(frm.ToCompany.value.length < 2)
	{	alert("Missing Company Information"); return; }
	
	if(frm.Delivery.value.length < 6)
	{	alert("Please include either a fax number or email address of the company you want to refer"); return; }
	else
	{	strEmail = frm.Delivery.value.toLowerCase();	
		if(strEmail.indexOf("@",0) == -1)
		{	if(frm.Delivery.value.length != 8)
			{ alert("Please use a phone number WITHOUT the area code.  Long Distance call will not be processed"); return; }
		}
	}
	
	frm.submit();

}

function Referral_Send(frm)
{	if(!frm.Agree.checked)
	{	alert("Unless you agree with the terms and conditions of this promotion you will not be able to send this message"); return; }
	else
	{	frm.submit();	}
}

function PrintListing(URL, id)
{
	var options="";
	options = "status=no,directories=no,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no";
	options = options + ",width=600,height=400,top=100,left=100,screenX=100,screenY=100";

	page= URL+"/BusDirectory/print.asp?id="+id

	window.open(page,"AdPrint", options);
}