/*
Main script for TalWare.
Developed by Microforum Inc. for TalMatch application.
Programmer Edmond Tong
All comments will be removed when in production.
*/
//Browser Detection Starts
var ns4 = (document.layers)? true:false;
var ns6 = (document.getElementById)? true:false;
var ie4 = (document.all)? true:false;
var ie5 = false;
//Buggy MAC Detection Starts
var ieMac = ie4 && navigator.platform.indexOf('Mac')>=0;
//Buggy MAC Detection Ended
if (ie4){
  if (navigator.userAgent.indexOf('MSIE 5')>0){
    ie5 = true;
  }
  if (ns6){
    ns6 = false;
  }
}
//Browser Detection Ended
//Confirm Submit Starts
function submitConfirm(message){
  var beforeSubmit = confirm(message);
  if (beforeSubmit){
    return true;
  }
  else
    return false;
}
//Confirm Submit Ended
//Resize Fix For Netscape Starts
window.onResize = resizeFix;
if (ns4){
  widthCheck = window.innerWidth;
  heightCheck = window.innerHeight;
}
function resizeFix(){
  if(ns4){
    if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
      document.location.href = document.location.href;
  }
}
//Resize Fix For Netscape Ended
//Move Object Starts
function moveTo(obj,xL,yL){
  if ( (ns4) || (ie4) ) {
    obj.left = xL;
    obj.top = yL;
    return true;
  }
  else if (ns6) {
    obj.style.left = xL;
    obj.style.top = yL;
    return true;
  }
}
//Move Object Ended
//Show Object Starts
function showObject(obj){
  if (ns4) obj.visibility = "show"
  else if (ie4) obj.visibility = "visible"
  else if (ns6) obj.style.display = "block"
}
//Show Object Ended
//Hide Object Starts
function hideObject(obj) {
  if (ns4) obj.visibility = "hide"
  else if (ie4) obj.visibility = "hidden"
  else if (ns6) obj.style.display = "none"
}
//Hide Object Ended
//Document Write Starts
with (document){
  write('<script language="JavaScript" src="jscript/bubbleHelpObj.js"></script>');
  write('<style type="text/css">');
  if (ns4) {
    write(".bubbleHelpStyle{position:absolute;layer-background-color:#94D5D5;background-color:#94D5D5;visibility:hidden;}");
  }
  if (ns6){
    write(".bubbleHelpStyle{position:absolute;display:none;layer-background-color:#94D5D5;background-color:#94D5D5;border:1px solid #000000;text-decoration:none;font-family:arial,helvetica;font-size:11px;padding-left:5px;padding-right:5px;z-index:5;}");
  }
  else {
    write(".bubbleHelpStyle{position:absolute;visibility:hidden;layer-background-color:#94D5D5;background-color:#94D5D5;border:1px solid #000000;text-decoration:none;font-family:arial,helvetica;font-size:11px;padding-left:5px;padding-right:5px;z-index:5;}");
  }
  write('</style>');
}
//Document Write Ended
//Cookie Functions Starts
function saveCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000))
    var expires = "; expires="+date.toGMTString();
  }
  else expires = ""
  document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i<ca.length;i++){
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
function deleteCookie(name) {
  saveCookie(name,"",-1);
}
//Cookie Functions Ended
//Form Submit Check Starts
function ontformsub(){
  var isSubmitted = false;
  if (isSubmitted) return false;
  isSubmitted = true;
  return true;
}
//Form Submit Check Ended


//function to check the editing status of a form
var formoldvalue = '';
var pagerefreshed = false;

function formvalue(thisfrm)
{
	var tmpvalue='';
	for(var i = 0; i<thisfrm.length-1; i++) {
		tmpvalue = tmpvalue + thisfrm.elements[i].value;
		if (thisfrm.elements[i].type=='checkbox' || thisfrm.elements[i].type=='radio')
		{
		tmpvalue = tmpvalue + thisfrm.elements[i].checked;
		}
	}
	return tmpvalue;
}

function checkformvalue(frmName, strAlert)
{
	if (document.forms[frmName])
	{
		if (formoldvalue != formvalue(document.forms[frmName]) || pagerefreshed) 
			return submitConfirm(strAlert); 
		else 
			return true;
	}
	return true;
}

function getformoldvalue(frmName)
{
	if (document.forms[frmName])
		formoldvalue=formvalue(document.forms[frmName])
		
	return;
}

