
// www.BusinessSellCanada.com/sale/bsc_buy.js //

defaultStatus=" - - -  Buy a Profitable Canadian Business For Sale  - - -";
window.status="<<< Buy a Profitable Canadian Business For Sale >>>";
var nomail='This does not contact the Business Seller !\n\nPress the "OK" button here, then click on the "More Details" button of the desired Listing.\n';

function RestStat() { window.status=''; return true; }

function NewWin(varname){
var w=window.open('/'+varname+'.htm','ForSale',
'toolbar=no,directories=no,status=yes,menubar=no,scrollbars=yes,history=no,resizable=yes');
}

logoonn = new Image(460, 208);
logoonn.src = "/images/bsctop_w.jpg";
logooff = new Image(460, 208);
logooff.src = "/images/bsctop_g.jpg";

function logo_onn()  {
  document.images["logo"].src = logoonn.src;
}
function logo_off()  {
  document.images["logo"].src = logooff.src;
}

function checkListno() { // checks for valid Listing #
 var doc = document.gotoln;
 var msg = "";
 var tmp;
 lino = doc.listno.value;

 tmp = lino.replace(/o/gi, "0"); // tr o to 0
 lino = tmp;
 tmp = lino.replace(/l/gi, "1"); // tr l to 1
 lino = tmp;

 while (lino.substr(0, 1) == "#" || lino.substr(0, 1) == " ") {
  tmp = lino.substr(1);  // remove leading # or spc
  lino = tmp;
 }
 if (! lino) {
  msg = "Enter a Listing Number in the box.\n";
  doc.listno.value = '';
  doc.listno.focus();
  alert(msg);
  return false;
 }
 if (isNaN (lino)) {
  msg = "The Listing No. must be a number.\n" + msg;

  url='http://www.BusinessSellCanada.com/sale/buycate.htm';

  if(document.images) {
   top.location.replace(url);
  }
  else {
   top.location.href = url;
  }
  doc.listno.value = '';
  doc.listno.focus();
 }
 else {
  while (/^ /.test(lino)) { // ltrim
   tmp = lino.substr(1);
   lino = tmp;
  }
  tmp = parseInt(lino, 10); // make integer
  lino = tmp + ""; // to string

  tmp = lino.length;
  if (tmp == 7) {
   lino = '0' + lino;
  }
  if (lino < 2101001 || lino > 93231999 ||
   lino.substr(1,2) > 32 || lino.substr(1,2) < 1 ||
   lino.substr(3,2) > 31 || lino.substr(3,2) < 1 ||
   lino.substr(5,3) < 1) {
    msg = "This Listing Number is not correct.\n";
    doc.listno.focus();
  }
 }
 if (msg) {
  alert(msg);
  return false;
 }
 doc.listno.value = lino;
 return true;
}

function movewarning(str) { // warns if coming from outside search engine
  var notbsc = 0;
  var RegExpSupp = 0; // are regular expressions supported ?
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) {
      RegExpSupp = 1;
    }
  }
  if (RegExpSupp) {
    var r1 = new RegExp("^http:", "i");
    var r2 = new RegExp("BusinessS[ea]l[le]Canada", "i"); // sell or sale
    notbsc = r1.test(str) && !r2.test(str);
  }
  else {
    notbsc = (str.indexOf("http:") == 0) && !((str.indexOf("businesssellcanada") < 0) && (str.indexOf("businesssalecanada") < 0));
  }
  if (notbsc) {
    alert('The business ad that you\'re looking for may have been moved to a different web page on this same site.  These pages are re-built daily as listings change.  Search here by Listing No.');
  }
}

/**********************************************\
* Drop down menu w/ description                *
* © Dynamic Drive (www.dynamicdrive.com)       *
* This notice must stay intact for use         *
* http://www.dynamicdrive.com/ for source code *
\**********************************************/

//Customized Text Descriptions for Links
var say=new Array()
// say[3]=".";

function jumptolink(what, nam) {
 if (nam == 'pro') {
  var doc = document.prov.a969;
  var msg = "Select a Province or Region\nfor the Search.";
 }
 else {
  var doc = document.a294.a969;
  var msg = "Select a Category for the Search.";
 }
 var selectedopt = doc.options[what];

 if (selectedopt.value) { // ignore options with null "value" tag
  if (document.getElementById && selectedopt.getAttribute("target")=="newwin") {
   window.open(selectedopt.value);
  }
  else  {
   window.location = selectedopt.value;
  }
 }
 else {
  doc.options[0].selected = true; // re-select the top
  doc.focus();
  alert(msg);
 }
}

function displaydesc(which) {
 say[0]="Select a 'Category' &amp; click on 'Go' ...";
 if (document.all) {
  if (say[which]) { 
   descriptions.innerHTML=say[which];
  }
  else { // this one is IE for me
   descriptions.innerHTML=a294.a969.options[which].text;
  }
 }
 else {
  if (document.getElementById) {
   if (say[which]) {
    document.getElementById("descriptions").innerHTML=say[which];
   }
   else {
    document.getElementById("descriptions").innerHTML=a294.a969.options[which].text;
   }
  }
 }
}

function display_pro(which) {
 say[0]="Select a 'Province' &amp; click on 'Go' ...";
 if (document.all) {
  if (say[which]) { 
   descrip_pro.innerHTML=say[which];
  }
  else { // this one is IE for me
   descrip_pro.innerHTML=prov.a969.options[which].text;
  }
 }
 else {
  if (document.getElementById) {
   if (say[which]) {
    document.getElementById("descrip_pro").innerHTML=say[which];
   }
   else {
    document.getElementById("descrip_pro").innerHTML=prov.a969.options[which].text;
   }
  }
 }
}

