// Draw Clockfunction menuAction(Action,SectionID){
	document.MenuForm.action = Action;
	document.MenuForm.SectionID.value = SectionID;
	document.MenuForm.submit();}
function trim(str){
   return str.replace(/^\s*|\s*$/g,"");
}function popUp(URL,WindowName,resizable,scrollbars,width,height){
	window.open (URL,WindowName,"tollbar=0,resizable="+resizable+",scrollbars="+scrollbars+",width="+width+",height="+height+",left="+(screen.width-width)/2+",top="+(screen.height-height)/2+"");}
function dialog(URL,WindowName,resizable,scrollbars,width,height){
	window.showModelessDialog(URL, WindowName, "dialogHeight: "+height+"px; dialogWidth: "+width+"px; dialogTop: "+(screen.height-height)/2+"px; dialogLeft: "+(screen.width-width)/2+"px; edge: Sunken; center: Yes; help: No; resizable: "+resizable+"; status: No;");	
}function show_full(pict, w, h, title) 
{
   var new_wind= window.open('','NewWind','scrollbars=1, height='+h+', width='+w+'');
   with(new_wind.document)
  { 
      open();
	  write("<html><head><title>"+title+"</title></head>");
	  write("<body bgcolor=ffffff leftmargin='0' topmargin='0' marginheight='0' marginwidth='0'>");
      write("<table align=center width=100%><tr><td>");
	  write("<A HREF='#' onClick='window.close(self)'><img src=");
	  write(pict);
	  write(" border=0></a>");
	  write("</td></tr></table>");
	  write("</body></html>");
	  close();    
   }
}
function selectAll(SelectAll,fields){
	if(fields!=null){
		var i=0;
		while(fields[i]!=null){
			fields[i].checked=SelectAll.checked;
			i++;
		}
		if(i==0)
			fields.checked=SelectAll.checked;
	}
}
function validateRequired(field,Msg){
	try{
		if(trim(field.value)==""){
			alert(Msg);
			field.focus();
			return false;
		}
	}catch(e){
		try{
			if(field.options.selectedIndex==0){
				alert(Msg);
				field.focus();
				return false;
			}
		}
		catch(ee){
			return false;
		}
	}
	return true;
}
function validateInt(field,Msg){
	if ( field.value!="" && (isNaN(field.value) || (field.value!=parseInt(field.value)) ) ){
		alert(Msg);
		field.focus();
		return false;
	}
	return true;
}
function validateNumeric(field,Msg){
	if(field.value!="" && isNaN(field.value)){
		alert(Msg);
		field.focus();
		return false;
	}
	return true;
}
function ValidateEmail(strEmail) {
	var blnValid;
	var goodEmail = strEmail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	if (!goodEmail)
		alert('Please enter a valid email address ['+strEmail+']');
	return goodEmail;
}

function validatePhone(obj,Msg){
	var p=obj.value
	p=p.replace("(","")
	p=p.replace(")","")
	p=p.replace("-","")
	p=p.replace("-","")
	if (p!="" && ( isNaN(p) || p.length!=10 )){
		alert(Msg);
		obj.focus();
		return false;
	}
	return true;
}


function PhoneEntry(Phone){
	var n=Phone.name;
	var p=Phone.value
	var p1=Phone;
	if(p.length==3){
		//d10=p.indexOf('(')
		pp=p;
		d4=p.indexOf('(')
		d5=p.indexOf(')')
		if(d4==-1){
			pp="("+pp;
		}
		if(d5==-1){
			pp=pp+")";
		}
		//pp="("+pp+")";
		Phone.value="";
		Phone.value=pp;
	}
	if(p.length>3){
		d1=p.indexOf('(')
		d2=p.indexOf(')')
		if (d2==-1){
			l30=p.length;
			p30=p.substring(0,4);
			//alert(p30);
			p30=p30+")"
			p31=p.substring(4,l30);
			pp=p30+p31;
			//alert(p31);
			Phone.value="";
			Phone.value=pp;
		}
		}
	if(p.length>5){
		p11=p.substring(d1+1,d2);
		if(p11.length>3){
		p12=p11;
		l12=p12.length;
		l15=p.length
		//l12=l12-3
		p13=p11.substring(0,3);
		p14=p11.substring(3,l12);
		p15=p.substring(d2+1,l15);
		Phone.value="";
		pp="("+p13+")"+p14+p15;
		Phone.value=pp;
		//obj1.value="";
		//obj1.value=pp;
		}
		l16=p.length;
		p16=p.substring(d2+1,l16);
		l17=p16.length;
		if(l17>3&&p16.indexOf('-')==-1){
			p17=p.substring(d2+1,d2+4);
			p18=p.substring(d2+4,l16);
			p19=p.substring(0,d2+1);
			//alert(p19);
		pp=p19+p17+"-"+p18;
		Phone.value="";
		Phone.value=pp;
		//obj1.value="";
		//obj1.value=pp;
		}
	}
}



function logOut(){
	document.login .submit ();
}

function Upload(ImagesPath,TableName,IDColumnName,IDColumnValue,ImageColumn){
	popUp(up+"admin/UploadImage.asp?ImagesPath="+ImagesPath+"&TableName="+TableName+"&IDColumnName="+IDColumnName+"&IDColumnValue="+IDColumnValue+"&ImageColumn="+ImageColumn,"_blank",0,0,250,40);
}

function rowColor(id,ON){
	if(ON)
		document.getElementById(id).style.backgroundColor ='#D6E1EB';
	else
		document.getElementById(id).style.backgroundColor ='';
}
function isAdded(combo,value){
	for(i=0;i<combo.length;i++){
		if(combo.options[i].value==value){
			return true;
			break;
		}
	}
	return false;
}
function setSelectedIDs(catlist,hiddenField){
	var cats="";
	for(i=0;i<catlist.length;i++){
		cats += catlist.options[i].value;
		if (i<catlist.length-1)
		cats += ","
	}
	hiddenField.value=cats;
}
