function setChangeFlag(val){
	campadmin.changeflag.value = val;
}

function setChangeProviderFlag(val){
	provideradmin.changeflag.value = val;
}

function setChangeCategoryFlag(val){
	categoryadmin.changeflag.value = val;
}

function setChangeMessageFlag(val){
	messageadmin.changeflag.value = val;
}

function setStateId(val){
	campadmin.stateid.value = val;
}

function isValidEmail(obj) {
	var str = obj.value;
	//Validates that the email entered has the right format
 	if((str.indexOf(".") < 2) || (str.indexOf("@") < 1)){
		alert("invalid email address: " + obj.value);
		obj.value = "";
	}
}

function isPhone(obj){ 
	//Validates the phone number for proper format
	var strPhone = obj.value;
	var message = "";
	if(strPhone.length > 0){
		if(strPhone.substr(0,1) != "("){ // Is the First character a ( 
			message += "\n-invalid phone format: missing left parenthesis";
		} 
		if(strPhone.substr(4,1) != ")"){ // Is Forth character a ) 
			message += "\n-invalid phone format: missing right parenthesis";
		}  
		if(strPhone.substr(8,1) != "-"){ // Is Forth character a ) 
			message += "\n-invalid phone format: missing dash";
		} 
		for(var i = 0 ; i < strPhone.length ; i++){
			if((i != 0) && (i != 4) && (i != 8)){
				if(strPhone.charAt(i) > '9' || strPhone.charAt(i) < '0'){
 					message += "\n-invalid phone format: an letter was entered";
					break;
				}
			}
		}
		if(message.length > 0){
			message = "Incorrect phone number:" + message;
			alert(message);
			obj.value = "";
		}
	}
}

function setCategoryId(val){
	categoryadmin.categoryid.value = val;
}

function setMessageId(val){
	messageadmin.messageid.value = val;
}

function setProviderId(val){
	provideradmin.providerid.value = val;
}

function setTopicId(val){
	provideradmin.topicid.value = val;
}

function checkValidity(name){
	if(campadmin.changeflag.value.length == 0 && name != "new"){
		alert("Please select a camp and click the " + name + " button again");
		return false;
	}
	if(name == "delete"){
		if(confirm("Click 'Ok' to delete the record, or 'Cancel' to abort.")){
			campadmin.actionitem.value = name;
			campadmin.action = "camp_process_form.php";
			campadmin.submit(); 
		}
	} else {
		campadmin.actionitem.value = name;
		campadmin.action = "camp_entry_form.php";
		campadmin.submit(); 
	}	
}

function checkCatAction(name){
	if(categoryadmin.changeflag.value.length == 0 && name != "new"){
		alert("Please select a category and click the " + name + " button again");
		return false;
	}
	if(name == "delete"){
		if(confirm("Click 'Ok' to delete the record, or 'Cancel' to abort.")){
			categoryadmin.actionitem.value = name;
			categoryadmin.action = "provider_category_process_form.php";
			categoryadmin.submit(); 
		}
	} else {
		categoryadmin.actionitem.value = name;
		categoryadmin.action = "provider_category_entry_form.php";
		categoryadmin.submit(); 
	}	
}

function checkMessageAction(name){
	if(messageadmin.changeflag.value.length == 0 && name != "new"){
		alert("Please select a message and click the " + name + " button again");
		return false;
	}
	if(name == "delete"){
		if(confirm("Click 'Ok' to delete the record, or 'Cancel' to abort.")){
			messageadmin.actionitem.value = name;
			messageadmin.action = "message_process_form.php";
			messageadmin.submit(); 
		}
	} else {
		messageadmin.actionitem.value = name;
		messageadmin.action = "message_entry_form.php";
		messageadmin.submit(); 
	}	
}

function checkAction(name){
	if(provideradmin.changeflag.value.length == 0 && name != "new"){
		alert("Please select a provider and click the " + name + " button again");
		return false;
	}
	if(name == "delete"){
		if(confirm("Click 'Ok' to delete the record, or 'Cancel' to abort.")){
			provideradmin.actionitem.value = name;
			provideradmin.action = "provider_process_form.php";
			provideradmin.submit(); 
		}
	} else {
		provideradmin.actionitem.value = name;
		provideradmin.action = "provider_entry_form.php";
		provideradmin.submit(); 
	}	
}

function checkUserValidity(name){
	if(useradmin.changeflag.value.length == 0 && name != "new"){
		alert("Please select a camp and click the " + name + " button again");
		return false;
	}
	if(name == "delete"){
		if(confirm("Click 'Ok' to delete the record, or 'Cancel' to abort.")){
			useradmin.actionitem.value = name;
			useradmin.action = "user_process_form.php";
			useradmin.submit(); 
		}
	}
}

function register(){
	campadmin.action="regform.php";
	campadmin.submit(); 
}

function gouseradmin(){
	provideradmin.action="users.php";
	provideradmin.submit(); 
}  

function useradmin(){
	campadmin.action="users.php";
	campadmin.submit(); 
}  

function ConvertSearchDate(formField) {
    if (formField.value != '') {
      var d = parseDate(formField.value);
      if(d==null) {
        alert('Date string doesn\'t match any recognized formats');
        formField.value = '';
      } else {
        formField.value=formatDate(d,'MM/dd/yyyy');
      }
    }
  }
  
  function gotopage(formname, pageloc){
  	alert("implement this")
  }
  
<!--
// contient divers fonctions  qui vont permettre l'affichage du calque qui va bouger tout au long de la page
var hauteur=0;
var temps=0;
var max=1000;
function position(right,top,width,height,contenu) {
hauteur=height;
if ((document.all)||(document.objt)) {
var Z="<DIV id='CalqueImage' style='position:absolute;right:"+right+";top:"+top+";width:"+width+";height:"+height+"'>"+contenu+"</DIV>";
} else {
var Z="<LAYER name='CalqueImage' right="+right+" top="+top+" width="+width+" height="+height+">"+contenu+"</LAYER>";
}
document.write(Z);
setTimeout("Start()",temps);
}
function Start() {
DeplacerImage("CalqueImage",Postionimage("CalqueImage"));
setTimeout("Start()",temps);
}
function DeplacerImage(nom,top) {
if (document.objt) { //IE5 et NS6
document.objt(nom).style.top=top;
}
if ((document.all)&&(!document.objt)) { //IE4
document.all[nom].style.top=top;
}
if (document.layers) { //NS4
document.layers[nom].top=top;
}
}
function Postionimage(nom) {
if (document.objt) { //IE5
var pos=parseInt(document.objt(nom).style.top);
var wintop=parseInt(document.body.scrollTop);
var dispo=document.body.clientHeight;
}
if ((document.all)&&(!document.objt)) { //IE4
var pos=parseInt(document.all[nom].style.top);
var wintop=parseInt(document.body.scrollTop);
var dispo=document.body.clientHeight;
}
if ((document.objt)&&(!document.all)) { //NS6
var pos=parseInt(document.objt(nom).style.top);
var wintop=parseInt(window.pageYOffset);
var dispo=window.innerHeight;
}
if (document.layers) { //NS4
var pos=parseInt(document.layers[nom].top);
var wintop=parseInt(window.pageYOffset);
var dispo=window.innerHeight;
}
var diff=Math.ceil((pos-(wintop+dispo-hauteur)));
if (diff>max) {diff=max;}
if (diff<-1*max) {diff=-1*max;}
var top=pos-diff;
return top;
}


<!--
function agrandirimage(image)
{
	image.height="200"
	image.width="250"
}
function reduireimage(image)
{
	image.height="100"
	image.width="150"
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=800,left = 276,top = 32');");
}
// End -->
  