//Global Variables
var requiredVersion = 7;
var useRedirect = false;
var flashPage   = "flash.htm"
var noFlashPage = "noflash.htm"
var upgradePage = "upgradeflash.htm"

// System Variables
var flash2Installed = false;
var flash3Installed = false;
var flash4Installed = false;
var flash5Installed = false;
var flash6Installed = false;
var flash7Installed = false;
var flash8Installed = false;
var flash9Installed = false;
var maxVersion = 9;
var actualVersion = 0;
var hasRightVersion = false;
var jsVersion = 1.0;

function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}

function BRT_swapImgRestore() { 
  var i,x,a=document.BRT_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function BRT_preloadImages() { 
  var d=document; if(d.images){ if(!d.BRT_p) d.BRT_p=new Array();
    var i,j=d.BRT_p.length,a=BRT_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.BRT_p[j]=new Image; d.BRT_p[j++].src=a[i];}}
	reloadPage(true);
}

function BRT_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=BRT_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function BRT_swapImage() { 
  var i,j=0,x,a=BRT_swapImage.arguments; document.BRT_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=BRT_findObj(a[i]))!=null){document.BRT_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getPageName() {
 var sPath = window.location.pathname;
 var sPage;
 if (sPath.indexOf('/C:') > 0 || sPath.indexOf('C:\\') > 0) {
  sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
 }
 else {
	 //online
  sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
 }
 //alert(sPage);
 return sPage;
}

function mkflashbanner1(pluginOK) {
 if(pluginOK) {
  document.write('<table width=\"100%\" border=0 cellspacing=0 cellpadding=0><tr><td>');
  document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"742\" height=\"76\" id=\"hst_banner1\" align=\"middle\">');
  document.write('<param name=\"allowScriptAccess\" value=\"sameDomain\" />');
  document.write('<param name=\"movie\" value=\"images/hst_banner1.swf\" />');
  document.write('<param name=\"FlashVars\" value=\"varPageID=' + getPageName() + '\" />');  
  document.write('<param name=\"loop\" value=\"false\" />');
  document.write('<param name=\"quality\" value=\"high\" />');
  document.write('<param name=\"bgcolor\" value=\"#FFF5EB\" />');
  document.write('<embed src=\"images/hst_banner1.swf\" FlashVars=\"varPageID=' + getPageName() + '\" loop=\"false\" quality=\"high\" bgcolor=\"#FFF5EB\" width=\"742\" height=\"76\" name=\"hst_banner1\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />');
  document.write('</object>');
  document.write('</td></tr></table>');    
 } else {
  document.write('<table width=100% border=0 cellspacing=5 cellpadding=0><tr><td>');
  document.write('<img src=\"images/spacer.gif\" width=30 height=1 alt=\"cleaning ladies\"><a href=\"index.htm\"><img src=\"images/logo.jpg\" alt=\"Home Services Toronto is a leading provider of domestic manpower\" width=343 height=66 border=0></a></td>');
  document.write('<td valign=\"bottom\" align=\"center\"><div class=\"div-contact\">call&nbsp;&nbsp;(416)&nbsp;780-0963</div><br>'); 
  document.write('</td></tr></table>');  
 }
}

function mkflashbanner2(pluginOK) {
 if(pluginOK) {
  document.write('<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"742\" height=\"163\" id=\"hst_banner2\" align=\"middle\">');
  document.write('<param name=\"allowScriptAccess\" value=\"sameDomain\" />');
  document.write('<param name=\"movie\" value=\"images/hst_banner2.swf\" />');
  document.write('<param name=\"FlashVars\" value=\"varPageID=' + getPageName() + '\" />');  
  document.write('<param name=\"loop\" value=\"false\" />');  
  document.write('<param name=\"quality\" value=\"high\" />');
  document.write('<param name=\"bgcolor\" value=\"#FFF5EB\" />');
  document.write('<embed src=\"images/hst_banner2.swf\" FlashVars=\"varPageID=' + getPageName() + '\" loop=\"false\" quality=\"high\" bgcolor=\"#FFF5EB\" width=\"742\" height=\"163\" name=\"hst_banner2\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />');
  document.write('</object>');
 } else {
  document.write('<table width=100% border=0 cellspacing=0 cellpadding=0>');
  document.write('<tr><td align=\"center\"><img src=\"images/banner1.jpg\" width=301 height=85 alt=cleaning><img src=\"images/banner2.jpg\" width=243 height=85 alt=\"home cleaning ladies\"><img src=\"images/banner5.jpg\" width=195 height=85 alt=cleaning></td></tr>'); 
  document.write('<tr><td align=\"center\"><img src=\"images/banner3.jpg\" width=301 height=78 alt=babysitting><img src=\"images/banner4.jpg\" width=243 height=78 alt=caregiving><img src=\"images/banner6.jpg\" width=195 height=78 alt=cleaning></td></tr>');
  document.write('</table>');  
 }
}

function detectFlash () {
 var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
 var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; // true if we're on windows

 jsVersion = 1.1;

if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n');
  document.write('<\/SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
 }	

 // Start Flash Detecting
 if (navigator.plugins) {
  if (navigator.plugins["Shockwave Flash 2.0"]
    || navigator.plugins["Shockwave Flash"]) {

    var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
    var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
    var flashVersion = parseInt(flashDescription.substring(16));

    flash2Installed = flashVersion == 2;    
    flash3Installed = flashVersion == 3;
    flash4Installed = flashVersion == 4;
    flash5Installed = flashVersion == 5;
    flash6Installed = flashVersion == 6;
    flash7Installed = flashVersion == 7;
    flash8Installed = flashVersion == 8;
    flash9Installed = flashVersion >= 9;
  }
 }

 for (var i = 2; i <= maxVersion; i++) {  
  if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  
 if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 4;  
 if (actualVersion >= requiredVersion) {
  if (useRedirect) {
   if(jsVersion > 1.0) {
     window.location.replace(flashPage);  
   } else {
     window.location = flashPage;
   }
  }

  hasRightVersion = true;                
  } else {  
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
      } else {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}

// Check email STARTS here
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}

function checkform(form) {
 if (form.name.value == "") {
  alert( "Please enter your name." );
  form.name.focus();
  return false ;
 }
 if (form.email.value == "") {
  alert( "Please enter your email address." );
  form.email.focus();
  return false ;
 }
 if (form.comments.value == "") {
  alert( "Please enter your message." );
  form.comments.focus();
  return false ;
 }
 
 return true ;
}

function checkEmploumentForm(form) {
 if (form.firstName.value == "") {
  alert( "Please enter your first name." );
  form.firstName.focus();
  return false ;
 }
 if (form.lastName.value == "") {
  alert( "Please enter your last name." );
  form.lastName.focus();
  return false ;
 }
 if (form.phone.value == "") {
  alert( "Please enter your contact phone number." );
  form.phone.focus();
  return false ;
 }
 if (form.email.value == "") {
  alert( "Please enter your email." );
  form.email.focus();
  return false ;
 }
 if (form.position.value == "Not selected") {
  alert( "Please select position you apply for." );
  form.position.focus();
  return false ;
 }
if (form.positionType.value == "Not selected") {
  alert( "Please select position type." );
  form.positionType.focus();
  return false ;
 }
 if (form.yearsExperience.value == "") {
  alert( "Please enter your years of experience." );
  form.yearsExperience.focus();
  return false ;
 }
// if (form.references.value == "") {
//  alert( "Please enter your references contact info." );
//  form.references.focus();
//  return false ;
// }
 if (form.languages.value == "") {
  alert( "Please enter your additional languages." );
  form.languages.focus();
  return false ;
 }
 if (form.englishLevel.value == "Not selected") {
  alert( "Please enter your speaking english level." );
  form.englishLevel.focus();
  return false ;
 }
 if (form.ethnicBG.value == "") {
  alert( "Please enter your ethnic background." );
  form.ethnicBG.focus();
  return false ;
 }
 if (form.ageBracket.value == "Not selected") {
  alert( "Please enter your age bracket." );
  form.ageBracket.focus();
  return false ;
 }
 if (form.jobPermission.value == "") {
  alert( "Please check if you have permission to work in Canada." );
  form.jobPermission.focus();
  return false ;
 }
// if (form.additionalNotes.value == "") {
//  alert( "Please enter your additional notes." );
//  form.additionalNotes.focus();
//  return false ;
// }

 return true ;
}

function mkemail(name) {
 document.write('<a class=\"cnt_url\" href=\"mai' + 'lto:' + name + '@Hom' + 'eServicesToronto.' + 'com\">' + name + '@Hom' + 'eServicesToronto.' + 'com</a>');
}

function mktext(str) {
 document.write(str);
}

function openItemFrame() {
 document.write('<table width=\"100%\" border=0 cellspacing=0 cellpadding=0><tr><td><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td width=5><img src=\"images/tab_1.gif\" width=5 height=21 alt=\"family\"></td><td width=100% style=\"background-image:    url(images/tab_2.gif);\">&nbsp;</td><td width=6 style=\"background-image:    url(images/tab_right_bottom.gif);\"><img src=\"images/tab_6.gif\" width=6 height=21 alt=\"housekeeper\"></td></tr></table></td><tr><td><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td width=5 style=\"background-image:    url(images/tab_left_bg.gif);\"><img src=\"images/tab_left_bg.gif\" width=5 height=3 alt=\"babysitter\"></td><td><table width=\"100%\" border=0 cellspacing=1 cellpadding=7 align=center><tr><td valign=\"top\" class=bright-title>');
}

function closeItemFrame() {
 document.write('</td></tr></table></td><td width=6 style=\"background-image:    url(images/tab_right_bg.gif);\"><img src=\"images/tab_right_bg.gif\" width=6 height=3 alt=\"\"></td></tr></table></td></tr><tr><td><table width=100% border=0 cellspacing=0 cellpadding=0><tr><td width=5><img src=\"images/tab_left_bottom.gif\" width=5 height=21 alt=\"\"></td><td width=100% style=\"background-image:    url(images/tab_bg_bottom.gif);\" valign=top><img src=\"images/tab_bg_bottom.gif\" width=5 height=21 alt=\"\"></td><td width=6 style=\"background-image:    url(images/tab_right_bottom.gif);\"><img src=\"images/tab_right_bottom.gif\" width=6 height=21 alt=\"\"></td></tr></table></td></tr></table>');
}

function goPayPal(service_name, service_paypal) {
 document.write('<table width=\"98%\" border=0 cellspacing=0 cellpadding=2><tr><td width=30% valign=\"top\" class=\"bright-title\">' + service_name + '</td><td><img src=\"https://www.paypal.com/en_US/i/btn/x-click-butcc.gif\"><br><br></td><td valign=\"top\" align=\"center\"><form name=\"_xclick\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"><input type=\"hidden\" name=\"cmd\" value=\"_xclick\"><input type=\"hidden\" name=\"business\" value=\"sales.hst@HomeServicesToronto.com\"><input type=\"hidden\" name=\"page_style\" value=\"Primary\"><input type=\"hidden\" name=\"return\" value=\"http://www.homeservicestoronto.com/services_success.htm\"><input type=\"hidden\" name=\"cancel_return\" value=\"http://www.homeservicestoronto.com/services_cancel.htm\"><input type=\"hidden\" name=\"currency_code\" value=\"CAD\"><input type=\"hidden\" name=\"lc\" value=\"CA\"><input type=\"hidden\" name=\"item_name\" value=\"' + service_paypal + '\"><input type=\"hidden\" name=\"amount\" value=\"\"><input name=\"submit\" type=\"image\" src=\"https://www.paypal.com/en_US/i/btn/x-click-but6.gif\" alt=\"Make payments with PayPal - it\'s fast, free and secure!\" align=\"top\" border=\"0\"></form></td><td valign=\"top\" class=\"td-paypal\">Purchase with ecommerce most-advanced encryption, and Buyer Protection Policies now</td></tr></table>');
}

function goPayPalLink(service_paypal) {
 document.write('<table width=\"100%\" border=0 cellspacing=0 cellpadding=0><tr><td valign=\"top\" align=\"right\"><form name=\"_xclick\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"><input type=\"hidden\" name=\"cmd\" value=\"_xclick\"><input type=\"hidden\" name=\"business\" value=\"sales.hst@HomeServicesToronto.com\"><input type=\"hidden\" name=\"page_style\" value=\"Primary\"><input type=\"hidden\" name=\"return\" value=\"http://www.homeservicestoronto.com/services_success.htm\"><input type=\"hidden\" name=\"cancel_return\" value=\"http://www.homeservicestoronto.com/services_cancel.htm\"><input type=\"hidden\" name=\"currency_code\" value=\"CAD\"><input type=\"hidden\" name=\"lc\" value=\"CA\"><input type=\"hidden\" name=\"item_name\" value=\"' + service_paypal + '\"><input type=\"hidden\" name=\"amount\" value=\"\"><input name=\"submit\" type=\"image\" src=\"http://www.paypal.com/en_US/i/btn/x-click-but06.gif\" alt=\"Make payments with PayPal - it\'s fast, free and secure!\" align=\"top\" border=\"0\"></form></td><td align=\"right\" width=\"15%\" valign=\"top\" class=\"td-paypal-link\">It\'s fast, free and secure!</td></tr></table>');
}

function goPayPal_Old(service_name, service_paypal) {
 document.write('<table width=\"98%\" border=0 cellspacing=0 cellpadding=0><tr><td valign=\"top\" class=\"bright-title\">' + service_name + '</td><td valign=\"top\" class=\"td-paypal\">Purchase with the industry\'s most-advanced encryption,<br>fraud prevention, and Buyer Protection Policies now</td><td valign=\"top\" align=\"center\"><form name=\"_xclick\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"><input type=\"hidden\" name=\"cmd\" value=\"_xclick\"><input type=\"hidden\" name=\"business\" value=\"sales.hst@HomeServicesToronto.com\"><input type=\"hidden\" name=\"page_style\" value=\"Primary\"><input type=\"hidden\" name=\"return\" value=\"http://www.homeservicestoronto.com/services_success.htm\"><input type=\"hidden\" name=\"cancel_return\" value=\"http://www.homeservicestoronto.com/services_cancel.htm\"><input type=\"hidden\" name=\"currency_code\" value=\"CAD\"><input type=\"hidden\" name=\"lc\" value=\"CA\"><input type=\"hidden\" name=\"item_name\" value=\"' + service_paypal + '\"><input type=\"hidden\" name=\"amount\" value=\"\"><input name=\"submit\" type=\"image\" src=\"http://www.paypal.com/en_US/i/btn/x-click-but01.gif\" alt=\"Make payments with PayPal - it\'s fast, free and secure!\" align=\"top\" border=\"0\"></form></td></tr></table>');
}
