
// THIS FILE IS COPYRIGHT BY BABYSOFT



// Print the footer of each screen
// Param1: The ID of the footer you want the footer to be place on.
// Param2: The color of the footer line (empty will bring in a non-color line)
// Return: Null
function printFooter(footer_id, linecolor){

    var line = '';
    if (footer_id == '' || document.getElementById(footer_id) == null){
	alert ("tools.js->printFooter: Footer ID: ("+footer_id+") not found, Please make sure the\n parameter you entered is correct.");	
	return;
    }
    if (linecolor === undefined || linecolor == ''){linecolor = null;}
    if (linecolor === null){line = '<hr class="colorLine" width=100% />';}
    else{line = '<table class="bkborder" width="100%" border="0" bgcolor="#'+linecolor+'"><tr height="2"><td></td></tr></table>';}
    document.getElementById(footer_id).innerHTML = '\
	<div align=left><font size="1" color="#A8A8A8">&nbsp;\
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\
	<a class="blackLink" href="http://www.voset.com">Home</a>\
	&nbsp;|&nbsp;\
	<a class="blackLink" href="http://www.babysoft.ca/contact.html" onclick="return popupScreen(\'http://www.babysoft.ca/contact.html\',860,500)">Contact</a>\
	&nbsp;|&nbsp;\
	<a class="blackLink" href="http://www.babysoft.ca/career.html" onclick="return popupScreen(\'http://www.babysoft.ca/career.html\',860,500)">Career</a>\
	&nbsp;|&nbsp;\
	<a class="blackLink" href="http://www.babysoft.ca/company.html" onclick="return popupScreen(\'http://www.babysoft.ca/company.html\',860,500)">Company</a>\
	&nbsp;|&nbsp;\
	<a class="blackLink" href="http://www.babysoft.ca" onclick="return popupScreen(\'http://www.babysoft.ca\',860,500)">Babysoft</a>\
	&nbsp;</font></div>'+line+'<span id="COPYRIGHT_ID"></span>';
    
    // Make sure the ID=COPYRIGHT_ID is in this function, otherwise, the 
    // copyright statement will not display
    printCopyright();

    return;
}



// print the copyright footer
function printCopyright(){
    var date=new Date();

    document.getElementById('COPYRIGHT_ID').innerHTML = '\
	<!--<center><hr width="100%" noshade></center>-->\
	<font size=1>\
	A <a class="babysoft" href=http://www.babysoft.ca/index.html onclick="return popupScreen(\'http://www.babysoft.ca/index.html\',860,500)">Babysoft</a> Project. All rights reserved. Copyright ' + date.getFullYear() + '\
	\
	SKSYS CORPORATION.<br>\
	\
	<a class="babysoft" href="http://www.babysoft.ca/termOfUse.html" onclick="return popupScreen(\'http://www.babysoft.ca/termOfUse.html\',860,500)">Terms of Use</a>, <a class="babysoft" href="http://www.babysoft.ca/privacyAgreement.html" onclick="return popupScreen(\'http://www.babysoft.ca/privacyAgreement.html\',860,500)">Privacy Agreement</a>.\
	</font>';
	

}


// print the contact-us box at the right of the page
function printCallNow(){
    var callNowArray = new Array();
    callNowArray[0] = "./images/callNow000.jpg";
    callNowArray[1] = "./images/callNow001.jpg";
    callNowArray[2] = "./images/callNow002.jpg";
    callNowArray[3] = "./images/callNow003.jpg";

    if (document.getElementById("callNow") === null){return false;}
    document.getElementById("callNow").innerHTML = '\
        <table width=188 cellspacing=0 cellpadding=0 border=0>\
        <tr>\
        <td align=left valign=top width=6 height=6><img src="./images/boxTopLeft_gray.jpg" border=0 /></td>\
        <td align=left valign=top height=6>\
        <Table border=0 cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" width=100%><TR bgcolor="#C2B1AA" height="1"><TD width=100%></TD></tr></TABLE>\
        </td>\
        <td align=left valign=top width=6 height=6><img src="./images/boxTopRight_gray.jpg" border=0 /></td>\
        </tr>\
        <Tr>\
        <td class="leftBorder">&nbsp;</td>\
        <td bgcolor="#FFFFFF" valign=center align=center><span id="BABYSOFT_RANDOM_IMAGE2"></span></td>\
        <td class="rightBorder">&nbsp;</td>\
        </tr>\
        <Tr>\
        <td class="leftBorder">&nbsp;</td>\
	<td bgcolor="#FFFFFF" valign=center align=center><font size=2 color="#000000"><span id="pointForm">Get Started or need help?</span></font></span></td>\
        <td class="rightBorder">&nbsp;</td>\
	</tr>\
        <Tr>\
        <td class="leftBorder">&nbsp;</td>\
        <td bgcolor="#C2B1AA" valign=center align=center><font size=2 color="#FFFFFF"><span id="pointForm"><B>CALL NOW ! 1.905.475.6900</b></span></font></span></td>\
        <td class="rightBorder">&nbsp;</td>\
        </tr>\
        <tr>\
        <td align=left valign=bottom width=6 height=6><img src="./images/boxBottomLeft_gray.jpg" border=0 /></td>\
        <td align=left valign=bottom height=6>\
        <Table border=0 cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" width=100%><TR bgcolor="#C2B1AA" height="1"><TD width=100%></TD></tr></TABLE>\
        </td>\
        <td align=left valign=bottom width=6 height=6><img src="./images/boxBottomRight_gray.jpg" border=0 /></td>\
        </tr>\
        </table>\
        ';

    randomImage(callNowArray,'BABYSOFT_RANDOM_IMAGE2');

}



// check to see is the input is number or not, if not, warning exist
// allow only number and dot
// if Input is number, return true, else return false
function isNumber(input){
    for (i=0; i<input.length; i++){
	if ( ! ((input.charCodeAt(i) <= 57) && (input.charCodeAt(i) >= 48) ||
	     (input.charCodeAt(i) == 46) ) ){
//	    input = input.substr(0,input.length - 1);
//	    document.getElementById(id).value = input;
//	    alert ("Invalid Character !!!");
	    return false;
	}
    }
    return true;
}



// print the current date and time
// NOTE the id has to called "date"
function printDate(){
    var date=new Date();	
    var month = date.getMonth();
    var day = date.getDay();
    var todayDate = date.getDate()
    var year = date.getFullYear();
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    var monthWord = new Array(12);
    var dayWord = new Array(7);

    // Make sure minute and second has 2 digits
    if (minute < 10){
	minute = '0' + minute;
    }
    if (second < 10){
	second = '0' + second;
    }

    // convert month into word format
    monthWord[0] = "January";
    monthWord[1] = "February";
    monthWord[2] = "March";
    monthWord[3] = "April";
    monthWord[4] = "May";
    monthWord[5] = "June";
    monthWord[6] = "July";
    monthWord[7] = "August";
    monthWord[8] = "September";
    monthWord[9] = "October";
    monthWord[10] = "November";
    monthWord[11] = "December";
    month = monthWord[month];

    // convert day into word format
    dayWord[0] = "Sunday";
    dayWord[1] = "Monday";
    dayWord[2] = "Tuesday";
    dayWord[3] = "Wednesday";
    dayWord[4] = "Thursday";
    dayWord[5] = "Friday";
    dayWord[6] = "Saturday";
    day = dayWord[day];
    
    document.getElementById('date').innerHTML = day + ", " + month + " " + todayDate + ', ' + year + " " + hour + ":" + minute + ":" + second;

    time = setTimeout('printDate()',500);

}


// get today date in human readable format (eg. July 18, 2006)
function today(){
    var date=new Date();	
    var month = date.getMonth();

    var monthWord = new Array(12);

    // convert month into word format
    monthWord[0] = "January";
    monthWord[1] = "February";
    monthWord[2] = "March";
    monthWord[3] = "April";
    monthWord[4] = "May";
    monthWord[5] = "June";
    monthWord[6] = "July";
    monthWord[7] = "August";
    monthWord[8] = "September";
    monthWord[9] = "October";
    monthWord[10] = "November";
    monthWord[11] = "December";
    month = monthWord[month];

    var today = month + ' ' + date.getDate() + ', ' + date.getFullYear();

    return today;


}



// Compare the date object (my date object)
// compare date1 to date2, if date1 > date2 
// return 1, if date1<date2 return -1, if
// they are equal, return 0
// FORMAT: DD/MM/YYYY
function dateCompare(date1, date2){
  var date1_array = date1.split('/');
  var date2_array = date2.split('/');
  var date1_day = parseInt(date1_array[0]); // try cast the string to integer
  var date1_month = parseInt(date1_array[1]); // try cast the string to integer 
  var date1_year = parseInt(date1_array[2]); // try cast the string to integer
  var date2_day = parseInt(date2_array[0]); // try cast the string to integer 
  var date2_month = parseInt(date2_array[1]); // try cast the string to integer 
  var date2_year = parseInt(date2_array[2]); // try cast the string to integer

  if (date1_year > date2_year){
    return 1;
  }
  if (date1_year < date2_year){
    return -1;
  }

  if (date1_year == date2_year){

    if (date1_month > date2_month){
      return 1;
    }
    if (date1_month < date2_month){
      return -1;
    }

    if (date1_month == date2_month){

      if (date1_day > date2_day){
	return 1;
      }
      if (date1_day < date2_day){
	return -1;
      }
      
      if (date1_day == date2_day){
	return 0;
      }
    }
  }
}


// Random Generate an image to display to the param2 ID, if param2 is empty
// the function will automatically use ID="BABYSOFT_RANDOM_IMAGE" "<SPAN ID>"
// Param1: an array contains all the file name (with the full qualify path
// Param2: the ID of the image "<SPAN ID>"
// Return: null
function randomImage(imgArray, id){
    var seed;
    var img = new Image();
    var html;

    if (id == '' || id == null){
	id = "BABYSOFT_RANDOM_IMAGE";
    }

    seed = Math.floor(Math.random() * imgArray.length);
    img.src = imgArray[seed];

    html = '<img border=0 src=' + img.src + '>';
    document.getElementById(id).innerHTML = html;
    return;

}


// Popup a new screen with no address and tool bar
// Param1: the url you wish to entered
// Param2: (Optional) the width of the screen
// Param3: (Optional) the height of the screen
// Return: false always
function popupScreen(url,width,height){
    if (url == ''){
	alert ("tools.js->popupScreen: Invalid URL: ('+url+'), Please verify.");
	return;
    }
    if (width == '' || width == 0){
	width = 640;	// Default Width
    }
    if (height == '' || height == 0){
	height = 480;	// Default Height
    }

    var win = window.open(url,"msg_window","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+width+",height="+height);
    win.focus();
    return false;
}


