<!-- Begin

function getObj(name){
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
  }
  else if (document.all)
  {
	this.obj = document.all[name];
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
  }
  return this.obj;
}
function inF_(obj,little_help){
	obj.style.borderColor="#6C95C1";
	obj.style.backgroundColor="#E8EDF0";
	printHelp(little_help);
}

function inB_(obj){
	obj.style.borderColor="#666666";
	obj.style.backgroundColor="#f6f6f6";
	printHelp('');
}
function inG_(obj){
        obj.style.borderColor="#6CD162";
        obj.style.backgroundColor="#f6f6f6";
        printHelp('Format is Correct');
}

function inE_(obj,little_help){
	obj.style.borderColor="red";
	obj.style.backgroundColor="#f6f6f6";
	printHelp("<font color=red>"+little_help+"</font>");
}

function printHelp(message){
	getObj('HELP').innerHTML= ""+message+"&nbsp;";
	getObj('HELP').className= "helpt";
	window.status=message;
} 

function toggleLayer(whichLayer){
  var elem, vis;
  elem = getObj(whichLayer);
  vis = elem.style;

  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
   vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
 vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function checkField(obj,type){
// takes obl - html object and checks it in various ways
// type is the type of data it should be formated like
// Type:(ssn,phone,email);
    error = "0";
    switch(type){
	case "ssn":
	    if (!(/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/.test(obj.value))){
 		inE_(obj,"Format for SSN is XXX-XX-XXX");
		error = "1";	
	    }	
	    break;
	case "phone":
            if (!(/\d{3}-\d{3}-\d{4}$/.test(obj.value))){
        	inE_(obj,"Format for Phone Number is XXX-XXX-XXX");
        	error = "1";
            }
            break;
	case "email":
            if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.value))){
        	inE_(obj,"Format for Email is incorrect");
        	error = "1";
            }
            break;
        case "money":
            if (!(/\$\d{1,3}(,\d{3})*\.\d{2}/.test(obj.value))){
                inE_(obj,"Format for Email is incorrect");
                error = "1";
            }
            break;
        case "time":
            if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.value))){
                inE_(obj,"Format for Email is incorrect");
                error = "1";
            }
            break;
        case "notnull":
            if (obj.value == ""){
                inE_(obj,"You cannot leave this field blank");
                error = "1";
            }
            break;

	default:
	break;
    }//end swtich
    if(error != "1"){inG_(obj);}
}// End checkField

function checkDates(obj,obj2){
	var d1_array = obj.value.split("-");
	var d2_array = obj2.value.split("-");
	var d1 = new Date();
	var d2 = new Date();
	d1.setFullYear(d1_array[2],d1_array[0],d1_array[1]);
	d2.setFullYear(d2_array[2],d2_array[0],d2_array[1]);
	error = "0";
	if (obj.value == ""){
		inE_(obj,"You cannot leave this field blank");
		error = "1";
	}else{
		if (d1 < d2){
			inE_(obj2,"");
			inE_(obj,"This end date must be later than the start date.");
			error = "1";	
		}	
	}

    if(error != "1"){inG_(obj);}
}// End checkField



function DelRow(loc){
	if(confirm('Are you sure you want to delete this')){location.replace(""+loc+"");}
}

function sortBox(v_id,subtype){
	window.open("sort.php?v_id="+v_id+"&subtype="+subtype, 'Sort', config='height=400,width=300,location=no,status=no,locationbar=no,resizable=no,toolbar=no,menubar=no,scrollbars=yes,title=no,left=50,top=75')
}
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function suggestions(objname,rowname,tablename){
	Xleft = findPosX(getObj(objname));
	Ytop = findPosY(getObj(objname))+20;
if(getObj('helpdeck').innerHTML == ""){
		getObj('helpdeck').innerHTML= "<IFRAME NAME=\"iframe\" ID=\"iframe\" STYLE=\"width:220px;height:140px; position:absolute;top:"+Ytop+"px;left:"+Xleft+";filter:Alpha(opacity=95);-moz-opacity:0.95;border-style: solid;border-width: 1px;border-color: #999999;\" SRC=\"suggestions.php?tn="+tablename+"&rn="+rowname+"&t="+objname+"&q="+getObj(objname).value+"\" frameborder=0 border=0 scrolling=auto></IFRAME>";
	} else {
		getObj('helpdeck').innerHTML = "";
	}
}


//  End -->

