function checkAll(theForm,subControl, supControl)
{
	for(var i=0;i<theForm.elements.length;i++)
	{
		var e= theForm.elements[i];
		if ((e.name==subControl) && (e.disabled==false)) e.checked= supControl.checked;
	}
}
function confirmDel(theForm,subControl)
{
	var count=0;
	for(var i=0;i<theForm.elements.length;i++) {
		var e= theForm.elements[i];
		if((e.name==subControl) &&(e.checked==true))count++;
	}

	if (count==0){
		alert("Please choose at least one item to delete");
		return false;
	} else {
		return confirm("Are you sure want to delete these item(s)?");
	}
}
function onDelete(){
	//implemented by pages
}
function onInsert(){
	//implemented by pages
}
function onUpdate(){
	//implemented by pages
}
function onCancel(){
	//implemented by pages
}
function onReturn(){
	//history.back();
	//implemented by pages
}
function checkFormat(control, format, required){
	/*if (control==null) return true;
	var value = control.value;
	if (value==null && required==true) return false;
	if (format=="date") return check_date();
	if (format=="integer+") return check_integer();
	if (format=="")*/
}
//------------------- validates -----------------------------
function checkRequire(obj){
		if(obj.value==""){
			obj.focus();
			return false;
		}
		return true;
	}
function checkCompare(obj1,obj2){
	if(obj1.value != obj2.value){
		obj1.focus();
		return false;
	}
	return true;
}

function checkIsNumber(obj){
		if(obj.value==""){
			obj.focus();
			return false;
		}
		else{
			if(isNaN(obj.value)==true){
				obj.focus;
				return false;
			}	
		}
		return true;
}

function checkIsPositiveNumber(obj){
		if(obj.value==""){
			obj.focus();
			return false;
		}
		else{
			if((isNaN(obj.value)==false) &&(obj.value > 0)) {
				obj.focus;
				return true;
			}
			else{return false;}
		}
		return true;
}


function ValidateRegular(source, reg){		
	var value = source.value;

	if (value=="") return true;
	var rx = new RegExp(reg);
	var matches = rx.exec(value);
    return (matches != null && value == matches[0]);
}


function checkIsEmail(source){
	if (!ValidateRegular(source, "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")){
		source.select();
		source.focus();
		return false;
	}
	return true;
}

function checkIsURL(source){
	if (!ValidateRegular(source, "(http://)?([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?")){
		source.select();
		source.focus();
		return false;
	}
	return true;
}

function removeAttachment(name){
	if (name!=null && name!=""){
		var hidden = document.getElementById(name + "_HIDDEN");
		if (hidden!=null){
			if (hidden.value){
				hidden.value = "";
			}
		}
		var remove = document.getElementById(name + "_REMOVE");
		if (remove!=null){
			if (remove.style){
				remove.style.display = "none";
			}
		}
		var attach = document.getElementById(name + "_ATTACH");
		if (attach!=null){
			if (attach.style){
				attach.style.display = "none";
			}
		}
	}

}


//-------------------- images --------------------------------

function showFullImage(URL) {
  fullSizeWin = window.open(URL, "_blank", 'location=no,titlebar=no,scrollbars=yes,status=no,width=500,height=300,resizable=yes,toolbar=no,menubar=no');
  fullSizeWin.focus();
}

//-------------------- site's utilities --------------------------------

function bookmarksite(title,url){
	if (window.sidebar){ // firefox
		window.sidebar.addPanel(title, url, "");
	}
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all){ // ie
		window.external.AddFavorite(url, title);
	}
}

function openBookmarkList(id){
	var el = GetObjectID(id);
	el.style.display='';
}

function hideBookmarkList(id){
	var el = GetObjectID(id);
	el.style.display='none';
}


function GetObjectID(id){
	var el = document.getElementById(id);
	return(el);
}